Skip to content

Files with .es6 suffix are treated as TypeScript files #5046

Closed

Description

@jbutz
  • VSCode Version: 0.10.11
  • OS Version: OS X El Capitan v 10.11.4

Steps to Reproduce:

  1. Create a new file with the extension .es6 and the following code

    class Testing {
       constructor() {
           this.myValue = "Hello World";
       }
    
       test() {
           return this.myValue;
       }
    }
  2. The Language Mode is automatically set to "JavaScript", but on this.myValue you get Property 'myValue' does not exist on type 'Testing' errors.

  3. Close the file and rename it to use a .js extension

  4. Open the file and notice that the errors are gone

Activity

  1. changed the title [-]Errors in ES6 JavaScript files with the extension .es6[/-] [+]Files with .es6 suffix are treated as TypeScript files[/+] on Apr 7, 2016
  2. egamma commented on Apr 7, 2016

    @egamma
    Member

    What is happening is that VS Code registers .es6 files as JavaScript files and Code sends them over to the tsserver. Inside the tsserver .es6are not treated as JavaScript files but as TypeScript files. For this reason you get the additional errors.

    One work around is to disable the error diagnostics from the tsserver for js files in the settings: "javascript.validate.enable": false. When you do so you should really setup eslint to get javascript diagnostics https://github.com/Microsoft/vscode-docs/blob/vnext/release-notes/vFebruary.md#linters.

    Moving to TypeScript, there should be a way to configure that .es6 files need to be treated as JavaScript files. If VS Code doesn't send .es6 to the tsserver then the user doesn't get Intellisense and only coloring.

  3. egamma commented on Apr 7, 2016

    @egamma
    Member

    This issue was moved to microsoft/TypeScript#7926

  4. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions