javascript - vscode - replace typescript definitions with node_modules definitions - Stack Overflow

I am a big fan of vscode. Here's my question, let's say I have a code like this.const express

I am a big fan of vscode. Here's my question, let's say I have a code like this.

const express = require('express')
const app = express()
app.get('/', (req, res) => res.send('Hello World!'))

when I CMD+Click on express(inside require) or on get function, it's taking me to it's typescript definition which is cached in home folder. When I clear the cache, then it's taking me to definitions inside node_modules and the cache is getting build again. Whereas in webstorm, there are no typescript caching, it takes me into node_modules definition. Is it possible to disable typescript definitions and use node_modules definitions ??

as shown in the picture, when I click on express it takes me to tyepscript definition, not the node_modules one.

There is a built-in extension called TypeScript and JavaScript Language Features (vscode.typescript-language-features). Disabling that will work ?? I don't know but I am afraid that I lose javascript intellisense.

Anyone know ???

I am a big fan of vscode. Here's my question, let's say I have a code like this.

const express = require('express')
const app = express()
app.get('/', (req, res) => res.send('Hello World!'))

when I CMD+Click on express(inside require) or on get function, it's taking me to it's typescript definition which is cached in home folder. When I clear the cache, then it's taking me to definitions inside node_modules and the cache is getting build again. Whereas in webstorm, there are no typescript caching, it takes me into node_modules definition. Is it possible to disable typescript definitions and use node_modules definitions ??

as shown in the picture, when I click on express it takes me to tyepscript definition, not the node_modules one.

There is a built-in extension called TypeScript and JavaScript Language Features (vscode.typescript-language-features). Disabling that will work ?? I don't know but I am afraid that I lose javascript intellisense.

Anyone know ???

Share Improve this question edited Nov 16, 2018 at 10:31 Lokesh Sanapalli asked Nov 16, 2018 at 10:14 Lokesh SanapalliLokesh Sanapalli 1,0324 gold badges19 silver badges39 bronze badges 2
  • Possible duplicate of How can I view original javscript library source code in VS Code and not the typescript version? – Lokesh Sanapalli Commented Nov 17, 2018 at 9:46
  • Does this answer your question? Go to the TypeScript source file instead of the type definition file in VS Code – leonheess Commented May 6, 2022 at 22:13
Add a ment  | 

2 Answers 2

Reset to default 6

The "cache" is built by a feature called Automatic Type Acquisition. You can disable it by setting VS Code's typescript.disableAutomaticTypeAcquisition setting to true or creating a jsconfig.json file containing {"typeAcquisition": {"enable": false}}. You'll still have to manually remove previously downloaded type declarations in order for links to take you to the implementation JavaScript files. See this answer for some additional related information.

The cache is most probably generated by the mentioned extension. You should not use it to get Typescript Typings, because Typescript's intellisense works out of the box very well.

Do not forget to install typings for each JS package.

npm install @types/express -D

Also in Typescript you should use import, instead of require:

import * as express from 'express' 

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745388951a4625569.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信