plugin-typings icon indicating copy to clipboard operation
plugin-typings copied to clipboard

Unable to use available console functions with current interface

Open CITguy opened this issue 1 year ago • 2 comments

There are several useful console functions available that I'm unable to use when developing a plugin, because the TypeScript interface is too limited.

The current interface only declares a subset of available functions.

interface Console {
  log(message?: any, ...optionalParams: any[]): void
  error(message?: any, ...optionalParams: any[]): void
  assert(condition?: boolean, message?: string, ...data: any[]): void
  info(message?: any, ...optionalParams: any[]): void
  warn(message?: any, ...optionalParams: any[]): void
  clear(): void
}

FYI: I'm not familiar enough with TypeScript to know if there's a way around this.

CITguy avatar Oct 06 '24 18:10 CITguy

Ah, this is because we run plugin code in a javascript VM (here's a link to our blog post about it if you want to learn more!), so we have to overwrite console calls from inside the VM to actually print in the browser. We haven't overwritten these new methods, which is why you can't use them. I'll add this internally as a feature request. Thanks for the feedback!

Isaiah-Turner avatar Oct 11 '24 23:10 Isaiah-Turner

Ah, this is because we run plugin code in a javascript VM (here's a link to our blog post about it if you want to learn more!), so we have to overwrite console calls from inside the VM to actually print in the browser. We haven't overwritten these new methods, which is why you can't use them. I'll add this internally as a feature request. Thanks for the feedback!

Thanks for clarifying! I'm pretty new to plugin dev, so I was unaware of this. I wonder if it might help future noobs like myself if the interface were named something like VMConsole just to clarify that it's not an interface for the native console.

CITguy avatar Oct 13 '24 20:10 CITguy

Thanks for the thoughts here. We've got the feature request, so I'm going to close the issue.

jefflee-figma avatar Nov 22 '24 22:11 jefflee-figma