microsoft/TypeScript

"Feature can only be used in a .ts file." when switching the language mode to TypeScript in a .js file

dbaeumer opened this issue · 2 comments

From @niieani on July 13, 2016 10:45

  • VSCode Version: all versions, tested also on latest: 1.4.0-insider 50a0945d8de129472b154fa514ba5328897d3be1
  • OS Version: OS X 10.11

Steps to Reproduce:

  1. Create a TypeScript file with a .js extension
  2. Change the language mode inside VSCode to "TypeScript" (defaults to JavaScript in files with a .js extension)
  3. Add some TypeScript specific code, e.g. interface ABC {}

Causes an error:

'interface declarations' can only be used in a .ts file.

Mentioned in the discussion here: #7926

Copied from original issue: microsoft/vscode#9199

This is a problem with the TSServer that infers the language mode from the extension. There are discussion to make the customizable.

Moving to TS team.

There has been multiple requests around this area. I have files a new issue to consolidate all the requests along with a proposal for a fix, see #10939. Let's use #10939 to track this change.
closing in favor of #10939.