14

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
    }
}

3 Answers 3

26

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\.

  1. Hold Windows Button and hit the PauseBreak key
  2. Advanced System Settings
  3. Environment Variables
  4. In the "System" panel (the bottom in Windows 10) select the Path variable and click Edit
  5. Find and highlight an old version like C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\ in the text, delete it. Press "OK" three times.
  6. Restart VS Code
Sign up to request clarification or add additional context in comments.

3 Comments

thanks; that fixed the problem. Can't believe people from MS didn't think about when they were writing the typescript document for vs code...
As Fabio Turati commented below, the solution is adding a new Variable pointing to your TypeScript version. e.g: C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\. I simply copied his suggestion here to make it more visible.
By now you can remove Visual Studio 2013 and use a newer version.
8

I got this error in vs code. Box [Windows 08, VS Code]

 error TS5007: Cannot resolve referenced file: '.'.
   error TS5023: Unknown option 'p'
   Use the '--help' flag to see options.

Solution

  1. Go to C:\Program Files (x86)\Microsoft SDKs\TypeScript
  2. If you have both 1.0 and 1.8 version then rename or delete 1.0. If you don't have 1.8 version then install new typescript version from official download page. I installed Visual Studio 2013

Then it worked.

Note: - this answer suggests to do same thing. I am writing this answer to explicitly show all the steps. Also, I think community discourages, while answering, to just link the article, since link can go dead.

1 Comment

As a general tip, do not refer to "the above answer". It's above yours now, because it has a higher score, but that could change. And others might post yet more answers, and then it could be difficult to understand which one you mean. The solution is to add a link to it.
0

I resolve this problem by simply delete all older version of typescript. In my case i move to installed location of typescript like

C:\Program Files (x86)\Microsoft SDKs\TypeScript , this is the location where all typescript version installed. after deleting file and reopen visual studio code and it works fine!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.