【发布时间】:2017-03-02 11:27:21
【问题描述】:
我正在开发一个 Ionic 2 rc.1 应用程序,我使用 idea intelliJ 2016.2.4。
项目运行良好,但 IDE 无法识别 Promise 的 typescript 定义,因为该类型似乎“未包含在 tsconfig.json 中”
检查错误为:Corresponding file is not included in tsconfig.json
我的 tsconfig.json 看起来像这样:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"target": "es5"
},
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
如果我从“排除”块中删除 node_modules,那么我的 IDE 检查没有问题,但项目运行 ionic serve 在 lint 阶段失败。
这是我的 package.json
{
"name": "ionic-hello-world",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"build": "ionic-app-scripts build",
"watch": "ionic-app-scripts watch",
"serve:before": "watch",
"emulate:before": "build",
"deploy:before": "build",
"build:before": "build",
"run:before": "build"
},
"dependencies": {
"@angular/common": "^2.0.0",
"@angular/compiler": "^2.0.0",
"@angular/compiler-cli": "0.6.2",
"@angular/core": "^2.0.0",
"@angular/forms": "^2.0.0",
"@angular/http": "^2.0.0",
"@angular/platform-browser": "^2.0.0",
"@angular/platform-browser-dynamic": "^2.0.0",
"@angular/platform-server": "^2.0.0",
"@ionic/storage": "^1.0.3",
"ionic-angular": "^2.0.0-rc.1",
"ionic-native": "^2.2.3",
"ionicons": "^3.0.0",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.21"
},
"devDependencies": {
"@ionic/app-scripts": "^0.0.36",
"typescript": "^2.0.3"
},
"cordovaPlugins": [
"cordova-plugin-device",
"cordova-plugin-console",
"cordova-plugin-whitelist",
"cordova-plugin-splashscreen",
"cordova-plugin-statusbar",
"ionic-plugin-keyboard"
],
"cordovaPlatforms": [
"ios@4.2.1",
"android@5.2.2"
]
}
有人知道如何解决这个问题吗?
谢谢
【问题讨论】:
-
您是否尝试过运行 typings install 命令?
-
嗨@DanielSuchý。 Ionic rc-1 中不再有 typings.json,现在它与
npm @types一起使用 -
安装一个promise
@types包,如es6-promise或core-js(假设Ionic 安装不这样做,您可以查看@types 文件夹以确保) .安装完成后,将typeRoots: [ "node_modules/@types"]添加到您的 tsconfig 文件中,让它获取类型定义
标签: intellij-idea typescript ionic2