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

Having both a .ts and .js file with the same name breaks intellisense #41012

Closed
FlowIT-JIT opened this issue Oct 9, 2020 · 6 comments
Closed
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@FlowIT-JIT
Copy link

FlowIT-JIT commented Oct 9, 2020

Having e.g. test.js and test.ts in the same project partially breaks intellisense.

Expected behavior:

Since value might be undefined , I would expect an error - just like we get when there is no test.ts present.

image

Actual behavior:

Notice how test.ts is now present (it's just an empty file), and we no longer receive an error - but the intellisense partially works, as the tool tip reveals the type of value.

image

Notice how it no longer knows that value might be undefined. It's like the validation rules for .ts files are being used for .js files all of a sudden.

If we rename test.ts to test2.ts, then intellisense works again.

image

Content of jsconfig.json:

{
    "compilerOptions": {
        "target": "es5",
        "checkJs": true,
        "resolveJsonModule": true,
        "strictNullChecks": true,
        "noImplicitAny": true
    }
}

Tested with TypeScript 4.0.3 and TypeScript@Next (4.1.0-dev.20201009).

VSCode:

Version: 1.50.0
Commit: 93c2f0fbf16c5a4b10e4d5f89737d9c2c25488a3
Date: 2020-10-07T06:00:00.397Z (2 days ago)
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 17.7.0

@MartinJohns
Copy link
Contributor

Most likely the same issue as #40982.

@andrewbranch andrewbranch added the Working as Intended The behavior described is the intended behavior; this is not a bug label Oct 9, 2020
@typescript-bot
Copy link
Collaborator

This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@FlowIT-JIT
Copy link
Author

@andrewbranch , is this really the desired behaviour? I'm sure the code does what it's supposed to do. But the behaviour still makes no sense and can easily confuse developers.

@andrewbranch
Copy link
Member

andrewbranch commented Oct 12, 2020

If anything, we should probably give you a configuration error in this case. Since jsconfig.json has noEmit: false by default, the existence of a JS file and TS file by the same basename looks highly suspicious. The assumption made by the config parser is that the TypeScript file is the canonical source, and the JS can be ignored since it is assumed to be the emit output. But that assumption itself is pretty suspicious, since noEmit is false, and if it were true, JS files that don’t have a corresponding TS file by the same basename would be an error. So there’s really no way to interpret this situation that doesn’t look like a misconfiguration.

@andrewbranch
Copy link
Member

This is somewhat similar to #40195

@FlowIT-JIT
Copy link
Author

Okay, I see. That makes sense. I appreciate the elaboration - thank you :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

4 participants