最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

typescript - How to enable JavaScript IntelliSense for custom file extensions in VS Code? - Stack Overflow

programmeradmin1浏览0评论

The question title says it all. My organization uses a non-standard file extension on source code written using JavaScript. Changing the file extension to ".js" seems to activate IntelliSense.

However, I was wondering if the IntelliSense could be activated using the non-standard file extension.

The question title says it all. My organization uses a non-standard file extension on source code written using JavaScript. Changing the file extension to ".js" seems to activate IntelliSense.

However, I was wondering if the IntelliSense could be activated using the non-standard file extension.

Share Improve this question edited Jul 11, 2019 at 7:56 RBT 26k24 gold badges175 silver badges260 bronze badges asked Aug 16, 2018 at 18:24 Rich PRich P 512 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 5

Click the bottom right of the window where it says "Plain Text" or the name of the detected language. This will bring up a menu at the top that lets you change it for the current session and also configure that specific extension to always be interpreted as JS.

Use the files.associations setting:

"files.associations": {
  "*.customExtension": "javascript"
}

From this issue (found in a web search), it sounds like the TypeScript language service does not support non-standard extensions, so you won't be able to get semantic features like type-based pletions (which I assumed was what you meant by IntelliSense). The techniques described in the other answers may give you basic syntax highlighting.

Those who needs this functionality for a plugin can use the following contribution in their package.json files:

"contributes": {
  "languages": [
    {
      "id": "javascript",
      "extensions": [
        ".myext"
      ]
    }
  ],
}

This defines a file extension call myext that will be treated as javascript which es very handy for adding intellisense to virtual files.

https://code.visualstudio./api/references/contribution-points#contributes.languages https://code.visualstudio./api/extension-guides/virtual-documents

发布评论

评论列表(0)

  1. 暂无评论