【发布时间】:2026-02-08 20:25:02
【问题描述】:
我最近在使用带有 intelisense 的 Visual Studio 代码时遇到了这段文档:
“您还可以通过使用类型定义 .d.ts 文件来获取库的 IntelliSense。DefinitelyTyped 是所有主要 JavaScript 库和环境的类型文件存储库。使用 Typings 可以轻松管理类型, TypeScript 定义管理器。 例如 typings install --ambient node 安装内置 Node.js 模块的所有类型。 如果您的项目有 jsconfig.json 文件,请确保类型包含在由 jsconfig.json 文件位置定义的项目上下文中。"
(解释于https://code.visualstudio.com/Docs/languages/javascript)。
我的问题是我无法让它工作,我不确定我是否完全理解了以粗体标记的句子。粗体部分是否告诉我在与 jsconfig.json 相同的文件夹中创建名为 typings 或 typings.json 的文件夹,或者两者都需要。它是否告诉我以某种方式修改 jsconfig.json。
那么我如何让 intelisense 像开头所述那样使用我的凉亭包?
jsconfig.json
{
// See http://go.microsoft.com/fwlink/?LinkId=759670
// for the documentation about the jsconfig.json format
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules",
"bower_components",
"jspm_packages",
"tmp",
"temp"
],
"typings": "typings/"
}
我使用 node.js npm 来获取全局工具,我目前已将以下内容安装为全局:
- bower@1.7.9
- esling@2.9.0
- generator-aspnet@0.0.93
- less@2.6.1
- live-server@0.9.2
- typings@0.8.1
- yo@1.7.0
我用 bower 做客户端包
我目前的设置是用于开发 javascript 组件,而不是用于网站发布。 folder and file structure
【问题讨论】:
标签: javascript json typescript bower visual-studio-code