CodinGame / monaco-vscode-api

VSCode public API plugged on the monaco editor
MIT License
214 stars 29 forks source link

registerExtension/IExtensionManifest Object literal may only specify known properties #313

Closed dkattan closed 6 months ago

dkattan commented 6 months ago

When attempting to call registerExtension with the contents of an extension's package.json, certain Json elements do not exist on IExtensionManifest/IRelaxedExtensionManifest

Attempting to call registerExtension with the content from vscode-mock-debug's package.json we get the following errors:

ERROR(vue-tsc)  No overload matches this call.
  The last overload gave the following error.
    Object literal may only specify known properties, and 'type' does not exist in type '{ url: string; }'.
      Object literal may only specify known properties, and 'enablement' does not exist in type 'ICommand'.
        Object literal may only specify known properties, and 'enablement' does not exist in type 'ICommand'.
          Object literal may only specify known properties, and 'languages' does not exist in type 'IDebugger'.
 FILE  C:/Users/dkattan/source/repos/immybot-ref/frontend/src/views/ScriptEditorV2/src/features/debugger.ts:767:9

    765 |       private: true,
    766 |       repository: {
  > 767 |         type: "git",
        |         ^^^^
    768 |         url: "https://github.com/Microsoft/vscode-mock-debug.git",
    769 |       },
    770 |       bugs: {

 ERROR(vue-tsc)  No overload matches this call.
  The last overload gave the following error.
    Object literal may only specify known properties, and 'type' does not exist in type '{ url: string; }'.
      Object literal may only specify known properties, and 'enablement' does not exist in type 'ICommand'.
        Object literal may only specify known properties, and 'enablement' does not exist in type 'ICommand'.
          Object literal may only specify known properties, and 'languages' does not exist in type 'IDebugger'.
 FILE  C:/Users/dkattan/source/repos/immybot-ref/frontend/src/views/ScriptEditorV2/src/features/debugger.ts:860:13

    858 |             title: "Debug File",
    859 |             category: "Mock Debug",
  > 860 |             enablement: "!inDebugMode",
        |             ^^^^^^^^^^
    861 |             icon: "$(debug-alt)",
    862 |           },
    863 |           {

 ERROR(vue-tsc)  No overload matches this call.
  The last overload gave the following error.
    Object literal may only specify known properties, and 'type' does not exist in type '{ url: string; }'.
      Object literal may only specify known properties, and 'enablement' does not exist in type 'ICommand'.
        Object literal may only specify known properties, and 'enablement' does not exist in type 'ICommand'.
          Object literal may only specify known properties, and 'languages' does not exist in type 'IDebugger'.
 FILE  C:/Users/dkattan/source/repos/immybot-ref/frontend/src/views/ScriptEditorV2/src/features/debugger.ts:867:13

    865 |             title: "Run File",
    866 |             category: "Mock Debug",
  > 867 |             enablement: "!inDebugMode",
        |             ^^^^^^^^^^
    868 |             icon: "$(play)",
    869 |           },
    870 |           {

I was able to track down command.enablement in the vscode source: https://github.com/microsoft/vscode/blob/2434b7da03ff51e5a56c4f4a4674167e49470419/src/vs/workbench/services/actions/common/menusExtensionPoint.ts#L577-L584

But I'm not sure how we'd be able to include these types since they are nested in IExtensionManifest which appears to be coming directly from vscode.

I suppose I can work around it by suppressing the error messages or doing JSON.parse(JSON.stringify()) similar to what you are doing in rollup-vsix-plugin.ts

Thoughts?

CGNonofr commented 6 months ago

I've already encountered that issue as well, the IExtensionManifest is missing of lot of properties. I don't have any good solution for it.

What is done in the demo is:

const extensionManifest = {
...
}
registerExtension(extensionManifest)

and typescript is happy with it

The only good solution is maybe to fix the type in VSCode itself

CGNonofr commented 6 months ago

good news :)

dkattan commented 6 months ago

good news :)

I just want you to know how much I appreciate the work you are doing here. I have been using Monaco Language Client since before you took it over and subsequently relinquished back to TypeFox. I'm in the process of adopting the rest of the functionality that this library enables so I am learning a lot.

I develop on Windows and our App uses Vue so I made a lot of (potentially unnecessary) changes to get the demo app working. I'm not a frontend guy so I've been hesitant to put in issues or PRs but I'd like to contribute these changes to make it easier for other people using Vue or other frameworks that work in a similar way, so I'll open up issues for the individual items so we can determine whether they are valid or I'm an idiot :D