I just installed vs code v1 (the latest version) and typescript v1.8.10 (latest version). I followed the exact instruction from vs code website but can't get vs code to build the simplest typescript file though I can manually build it by running tsc command in git bash. The output from the vs code is:
error TS5007: Cannot resolve referenced file: '.'.
error TS5023: Unknown option 'p'
Use the '--help' flag to see options.
This is the my helloworld.ts file which really can't be simpler:
class Greet {
private _message : string;
constructor(message : string) {
this._message = message;
}
Say = () => console.log(this._message);
}
var g = new Greet('hello typescript!');
g.Say();
This is my tasks.json file:
{
// See http://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": ["-p", "."],
"showOutput": "silent",
"problemMatcher": "$tsc"
}
and tsconfig.json:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"sourceMap": true
}
}
Visual Studio Code includes TypeScript language support but does not include the TypeScript compiler, tsc . You will need to install the TypeScript compiler either globally or in your workspace to transpile TypeScript source code to JavaScript ( tsc HelloWorld. ts ). You can test your install by checking the version.
Using the workspace version of TypeScript# You can also trigger the TypeScript version selector with the TypeScript: Select TypeScript Version command. VS Code will automatically detect workspace versions of TypeScript that are installed under node_modules in the root of your workspace.
TypeScript supportBy default, Visual Studio 2022 provides language support for JavaScript and TypeScript files to power IntelliSense without any specific project configuration. For compiling TypeScript, Visual Studio gives you the flexibility to choose which version of TypeScript to use on a per-project basis.
Maybe it can help as mentioned at (VS Code, error, TS5023) Unknown compiler option 'p'
Open your environment settings and remove the old Typescript from your system PATH variable. Mine was C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\
.
Path
variable and click Edit
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\
in the text, delete it. Press "OK" three times.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With