Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable navigate to file from "Errors and Warnings" when errors occur in TypeScript. #1420

Closed
liandaoacc opened this issue Dec 17, 2015 · 10 comments
Assignees
Labels
info-needed Issue requires more information from poster typescript Typescript support issues verified Verification succeeded
Milestone

Comments

@liandaoacc
Copy link

I followed Transpiling TypeScript into JavaScript, and got an error Unable to open 'HelloWorld.ts': File not found (e:\SoftwareProgram\Test\E:\SoftwareProgram\Test\HelloWorld.ts) in step 4 when I clicked on the problem. I report this because I think it should open HelloWorld.ts. Am I right?
My version is 0.10.3, and my OS is windows 7.

@dbaeumer
Copy link
Member

@liandaoacc this works for me. Here is what I see:

capture

From the error message I think there is a setup issue telling the tsc compiler to produce errors with absolute paths. Which version of tsc are you using. And can you please run tsc from a command prompt and provide the output.

@dbaeumer dbaeumer added info-needed Issue requires more information from poster typescript Typescript support issues labels Dec 17, 2015
@dbaeumer dbaeumer self-assigned this Dec 17, 2015
@dbaeumer dbaeumer added this to the Backlog milestone Dec 17, 2015
@liandaoacc
Copy link
Author

@dbaeumer I changed the path of TEST and still got the error.

Error Unable to open 'HelloWorld.ts': File not found (f:\TEST\F:\TEST\HelloWorld.ts). Create File Cancel

(I failed to attach image. Github show: Something went really wrong, and we can't process that file.)

I installed tsc using npm install -g typescript, here is my tsc path and tsc version.
And I can run tsc from cmd to provide the output.

F:\TEST>npm list -g
C:\Users\liandaoacc\AppData\Roaming\npm
└── [email protected]

F:\TEST>tsc -V
Version 1.0.3.0

F:\TEST>tsc HelloWorld.ts

F:\TEST>tsc HelloWorld.ts
F:\TEST\HelloWorld.ts(3,17): error TS2094: The property 'logg' does not exist on
value of type 'Console'.

@egamma
Copy link
Member

egamma commented Dec 18, 2015

@aeschli is covered by the fix you did with Dirk yesterday for 0.10.5?

@aeschli
Copy link
Contributor

aeschli commented Dec 18, 2015

@egamma No, that fix was not related to paths.

@dbaeumer
Copy link
Member

dbaeumer commented Jan 4, 2016

@liandaoacc can you provide me with the workspace that shows the problem (e.g as a public git repository). I can't reproduce this on WIndows using VSCode 0.10.6 and tsc version 1.7.5

@liandaoacc
Copy link
Author

@dbaeumer I tried many times in VSCode 0.10.5 and then update to 0.10.6, and finally I found how I produced this problem in both version.

  • Workspace
    My workspace is very easy, the directory is
./HelloWorld  
./HelloWorld/.vscode  
./HelloWorld/.vscode/tasks.json  
./HelloWorld/HelloWorld.ts

and the codes in files are
./HelloWorld/.vscode/tasks.json

{
    "version": "0.1.0",
    "command": "tsc",
    "isShellCommand": true,
    "showOutput": "silent",
    "args": ["HelloWorld.ts"],
    "problemMatcher": "$tsc"
}

./HelloWorld/HelloWorld.ts

class Startup {
    public static main(): number {
        console.logg('Hello World');
        return 0;
    }
}
  • To produce the problem
    case 1: before compiler the HelloWorld.ts .
    case 2: after compiler the HelloWorld.ts, simply pressing Ctrl+Shift+B (Run Build Task).

After some tries, I noticed that the VSCode showed me error message in case 1. I did not notice this before. The error message is Property 'logg' does not exist on type 'Console'. And I could click on this problem to navigate to HelloWorld.ts.
After I pressed Ctrl+Shift+B(case 2), another message came. That is The property 'logg' does not exist on type 'Console'. Please pay attention to these two message. They are different(the word The). I could not click on this problem to navigate to HelloWorld.ts and the error Unable to open 'HelloWorld.ts': File not found (e:\SoftwareProgram\Test\javasrcipt\TypeScript\HelloWorld\E:\SoftwareProgram\Test\javasrcipt\TypeScript\HelloWorld\HelloWorld.ts). came.
Sometimes VSCode showed me two error message, Property 'logg' does not exist on type 'Console' and The property 'logg' does not exist on type 'Console' in case 2. But sometimes just The property 'logg' does not exist on type 'Console'.

Since I failed to attach image, so I will reply the email to send some error message images.

@liandaoacc
Copy link
Author

@dbaeumer Sorry, I found I can't reply the email directly. So if you need the image, please let me know.

@dbaeumer
Copy link
Member

dbaeumer commented Jan 5, 2016

@liandaoacc The different error message come from the fact that in case1 the message comes from the internal language service where the second comes from the external tsc compiler. However in both cases you should be able to navigate to the file containing the error.

The problem is actual a very old version of the tsc compiler that is install on your system. tsc -V reports Version 1.0.3.0 on your system (this version reports file names as absolute paths). It should be at least 1.6.x or higher (which report file names as relative paths). I guess that a long time ago you install the tsc compiler through Visual Studio as an executable which now has preference over the npm module. In a command prompt type where tsc to validate this. I am pretty sure it will not take tsc from AppData\Roaming\npm\tsc.

You can either uninstall the old version of tsc (recommended) or if you really want to use that version of the compiler tweak the tasks.json file to instruct VS Code to use absolute paths from the compiler.

{
    "version": "0.1.0",
    "command": "tsc",
    "isShellCommand": true,
    "showOutput": "silent",
    "args": ["HelloWorld.ts"],
    "problemMatcher": {
        "base": "$tsc",
        "fileLocation": "absolute"  
    }
}

@dbaeumer dbaeumer closed this as completed Jan 5, 2016
@felixfbecker
Copy link
Contributor

I have the exact same problem with eslint:

image

tasks.json:

{
  "version": "0.1.0",
  "command": "npm",
  "args": ["--loglevel", "silent", "run"],
  "isShellCommand": true,
  "showOutput": "silent",
  "tasks": [
    {
      "taskName": "lint",
      "problemMatcher": "$eslint-stylish"
    }
  ]
}

Setting the problem matcher with fileLocation: absolute works, but imo this should not be needed. I have the latest eslint version installed so $eslint-stylish should set this automatically.

@egamma
Copy link
Member

egamma commented Jan 23, 2016

@felixfbecker this looks like a different issue. I've extracted this into a separate issue #2202

@dbaeumer dbaeumer added the verified Verification succeeded label May 27, 2016
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster typescript Typescript support issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants