microsoft/TypeScript

Can't find module with extension .es6

dbaeumer opened this issue · 9 comments

From @aikeru on July 6, 2016 19:0

  • VSCode Version: 1.2.1
  • OS Version: Windows 8.1

Some projects I work on use .es6 extension for JavaScript files that import/export using ES6 module syntax.

While webstorm and webpack seem to have no issues with this setup, VSCode gives a red squiggly saying [js] Cannot find module './filename.es6'.

Is there some way to get VS Code to find modules imported that do not have a .js extension? We would like to use .jsx in a similar fashion.

I have this for a .jsconfig:

    {
        "compilerOptions": {
            "target": "ES6",
            "module": "commonjs"
        },
        "files": [
            "**/*.jsx",
            "**/*.es6",
            "**/*.js"
        ]
    }

...and tried adding .es6 under user settings for VSCode, but suspect I did it wrong or that doesn't solve the issue.

Also opened StackOverflow here:
https://stackoverflow.com/questions/38046039/vs-code-es6-extensions-cant-find-module

Copied from original issue: microsoft/vscode#8816

@aikeru jsx is support but es6 to my knowledge not. Moving to TS team for further clarification.

TS team: for 2.0 I saw that you support arbitrary file extensions by use setting the kind on open. Would there be more we need to do to make this work.

es6 is not a supported extension. only js, jsx, ts, and tsx.

Wow, hang on a second ... The extension ".es6" is widely supported amongst the community. VSCode supports it for editing JavaScript out of the box as do competing tools like Webstorm.

".es6" might not be the best extension to use, but a lot of people have good/practical reasons for using an extension other than ".js". For codebases where this decision was already made some time ago, it's a hard sell to make that change just because VSCode doesn't support it.

I realize this is the TypeScript repo, but since my issue was moved here I assume VS Code depends on TypeScript internals to get its intellisense for JavaScript across modules.

Couldn't the extensions for what constitutes a "JavaScript" file be made configurable? That would be a great feature and enabling the use of VS Code in repositories like the ones I have to work in every day.

Please consider this.

@mhegazy I think the tsserver should consider supporting a configurable set of file extensions. Most editors support to map a file extension to a language mode. Not supporting this in the tsserver makes the story pretty incomplete for the editor/user since for example es6 file would get the right syntax coloring and snippets but not the correct JS smartness.

@mhegazy @dbaeumer thanks, guys! :) Will be hopefully watching this!

This issue is still not resolved with VS Code version 1.4.0.

There has been multiple requests around this area. I have files a new issue #10939 to track this change. Please move the conversion to the new issue.

That issue has now been closed in favor of #11158 which has to do with JSX, and doesn't address this use case or the problems it creates downstream.