qjebbs / vscode-plantuml

Rich PlantUML support for Visual Studio Code.
MIT License
1.1k stars 159 forks source link

Compilation fails for localize calls #291

Open michael72 opened 4 years ago

michael72 commented 4 years ago

Hello @qjebbs! I find your plugin very helpful, so thank you for that! It makes writing plantuml and markdown code more fun than with other editors.

As plantuml is sometimes a bit tricky to get it to render larger diagrams without lines crossing I would like to try out some new feature - I was thinking about some keyboard shortcuts to swap lines (swap two lines, swap the content including the arrow from left to right, or swapping the arrow symbol).

Maybe I could also help fixing issues, but I cannot get the project to compile. I am also a TS newbie - so - maybe I did something wrong. But basically I installed npm, checked out your project, ran npm install and tried to debug your project in code - but the compilation fails (also when trying with an older version of both code and npm on virtual box with Linux)

So for instance line 25 in render.ts fails with

`\n<pre><code><code>${localize(53, null)}\n\n${diagram.content}</code></code></pre>`;
No overload matches this call.
  Overload 1 of 2, '(info: LocalizeInfo, message: string, ...args: any[]): string', gave the following error.
    Argument of type '53' is not assignable to parameter of type 'LocalizeInfo'.
  Overload 2 of 2, '(key: string, message: string, ...args: any[]): string', gave the following error.
    Argument of type '53' is not assignable to parameter of type 'string'.

I can see, that you access table content defined in a langs.nls.json file by the index - (btw wouldn't it be nicer to define an enum/constants for that). Doesn't seem to work though.

So my question is: does it fail for you too or is there some magic happening - some settings - some includes - somthing you do manually to get the project to compile?

Best Michael

qjebbs commented 4 years ago

node_modules/vscode-nls/lib/main.d.ts:

export interface LocalizeFunc {
    (info: LocalizeInfo, message: string, ...args: any[]): string;
    (key: string | number, message: string, ...args: any[]): string;
}
michael72 commented 4 years ago

OK - the problem seems to be that the LocalizeFunc definition has changed and number as key is no longer supported (for several years now) - see here

Looking at the output of npm list I see that the correct version of nls is used: -- vscode-nls@2.0.2

Downloading the tgz file and looking at the source: still no key: number contained.

How did you get it to compile?

michael72 commented 4 years ago

@qjebbs I manually edited the LocalizeFunc definition and also commented out a line in local.ts because killed does not exist. Then it compiled... Is it really intended like this?

qjebbs commented 4 years ago

https://nodejs.org/api/child_process.html#child_process_subprocess_killed

killed property is needed in the process management logic, but it is not defined in .d.ts file of node, I chose to add it. So is the LocalizeFunc definition.

If you have better way to do this, please tell me.

michael72 commented 4 years ago

@qjebbs

I got that - looked up the documentation. So basically you change your code locally to get it compiled, right? I mean this might look like a natural thing to do - but it is not normal to first fix the code base that you check out somewhere, right? So if you want any support, you might first want to look that your code base compiles and/or provide instructions about how to compile it.

So here is my proposal:

  1. get your plugin build with travis.ci
  2. fix the bugs in your code base or try to fix them on the other code bases and try to integrate those versions. In your case I would simply use any instead of the explicit (typescript) types. I know this is not probably the purpose of typescript - but changing the interface locally is not an option here.

I will try to do a pull request for doing just that.