typescript - 如何引用 Screeps 打字稿文件?
问题描述
我有一个 tsconfig.json:
{
"compilerOptions": {
//"noImplicitAny": "true",
//"removeComments": "true",
"target": "es5",
//"sourceMaps": true,
"outDir": "../compiledjs"
},
"files": ["./node_modules/screeps-typescript-declarations/dist/screeps.d.ts"],
}
我正在尝试使用 Screeps 特定的 Javascript 函数,如下所示:
Source.prototype.harvesters = function () {
var creeps = this.pos.findInRange(FIND_MY_CREEPS, 1);
return _(creeps).filter({ memory: { role: 'harvester' } }).value();
}
但我不断收到错误,因为 VS 代码无法识别Source
. 我在这里做错了什么?
解决方案
tsconfig.json 文件具有属性typeRoot
和types
特定类型信息。您的 tsconfig 有类型信息,files
而不是types
.
推荐阅读
- powershell - 工作流并行与不并行执行的时间相同
- python - 通过按下tkinter中的另一个定义来重置按钮中的定义?
- javascript - 如何在Angular 8中更新除当前索引之外的对象
- java - 图形上下文、Netbeans 和“曲线”线
- powershell - Powershell脚本退出差异
- scala - Spark INFO spark.MapOutputTrackerMasterEndpoint:被要求发送 shuffle 0 的地图输出位置永远慢
- c++ - 为什么在 for 循环中更改变量后变量不改变?
- sql - 给定月份 + 上个月的 SUM 值
- git - 如何在 docker 容器中设置 git?
- mysql - 选择子表中具有特定 id 的行的总和并将其与父表进行比较