由于您已经使用 安装了 javascript 库LibMan
,因此您也可以简单地重复使用LibMan
来安装定义:
libman install @types/jquery -p unpkg
libman install @types/bootstrap -p unpkg
默认路径为libs/@types
:</p>
lib/
@types/
bootstrap/
index.d.ts
...
jquery/
index.d.ts
...
我创建tsconfig.json
并配置路径映射以加载模块,如下所示:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"jquery": ["lib/@types/jquery"] ,
"bootstrap":["lib/@types/bootstrap"]
}
}
}
现在我们可以从打字稿中受益:

[更新]
对于 ASPNET-CORE 项目,默认路径为:wwwroot/lib/@types
,如果我们tsconfig.json
在项目目录下(项目文件旁边*.csproj
),我们需要将路径更改为:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"jquery": ["wwwroot/lib/@types/jquery"] ,
"bootstrap":["wwwroot/lib/@types/bootstrap"]
}
}
}
