Reputation: 1863
I am maintaining an open-source project built with TypeScript. I didn't work on the project for a few weeks and I am back to fix a bug.
But executing the project through VScode makes it fail all of the sudden. The mentioned errors are all legit, and I need to fix them. But I can't wrap my head around, why they fail just now and only in VScode, and not through the command-line as well.
...project/node_modules/ts-node/src/index.ts:587
return new TSError(diagnosticText, diagnosticCodes);
^
TSError: ⨯ Unable to compile TypeScript:
...project/src/bar.ts(361,27): error TS2532: Object is possibly 'undefined'.
As said, it is indeed an error, but how can I make it work again temporarily?
Upvotes: 2
Views: 705
Reputation: 16127
As my comment, vscode will use build in typescript version to check the syntax of ts file or to run vscode launch(task). Sometimes your project ts version is different from build in version, it will take some confirmation.
This is the way to force vscode use your project ts version:
Open a ts file by your vscode and take a look at the bottom right you can see the Typescript version (I guess is 4.3.x). Let's click and change the setting to make sure that vscode use typescript in your node_modules
Upvotes: 4