为什么 vscode 从打字稿缓存中导入包 [英] Why vscode is importing packages from typescript cache

查看:57
本文介绍了为什么 vscode 从打字稿缓存中导入包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始了一个使用 cli 生成的 react-native 项目.该应用程序似乎工作得很好,但我注意到导入指向打字稿缓存而不是本地 node_modules.我什至没有使用打字稿.

IDE:vscode 1.19.3

import React, { Component } from 'react';

<块引用>

模块"/Users/MyMac/Library/Caches/typescript/2.6/node_modules/@types/react/index"

解决方案

这是 JavaScript 所期望的.这些 @types 文件为 react 等 npm 模块提供了 VS Code IntelliSense.react 模块本身仍然会从你本地的 node_modules

导入

有关自动类型获取的更多信息,请参阅我们的文档详情

I've started a react-native project generated using the cli. The app seems to be working just fine but i've notice that the import points to typescript cache instead of local node_modules. I'm not even using typescript.

IDE: vscode 1.19.3

import React, { Component } from 'react';

module "/Users/MyMac/Library/Caches/typescript/2.6/node_modules/@types/react/index"

解决方案

This is expected for JavaScript. These @types files power VS Code IntelliSense for npm modules such as react. The react module itself will still be imported from your local node_modules

See our documentation on Automatic type acquisition for more details

这篇关于为什么 vscode 从打字稿缓存中导入包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆