我可以安装打字稿定义没有WebStorm/PhpStorm
问题描述:
我发现我可以在此设置安装打字稿定义使用NPM或分型:我可以安装打字稿定义没有WebStorm/PhpStorm
,因为我并不需要使用的方便typings
或npm
来安装这些类型。
但是tsconfig.json
中的哪些设置会使WebStorm使用这些定义?在webstorm
下载的这些库实际上工作吗?
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"moduleResolution": "node",
"removeComments": true,
"allowSyntheticDefaultImports": true,
"noImplicitAny": false,
"sourceMap": true,
"outDir": "./src/",
"jsx": "react",
"experimentalDecorators": true,
"noLib": false,
"declaration": false,
"emitDecoratorMetadata": true
},
"exclude": [
"node_modules",
"src"
]
}
的package.json:
{
"name": "database",
"version": "0.0.1",
"private": true,
"dependencies": {
"axios": "^0.15.3",
"lodash": "^4.17.4",
"mobx": "^3.1.0",
"mobx-react": "^4.1.0",
"native-base": "^2.0.8",
"react": "15.4.2",
"react-native": "0.41.2",
"react-native-autocomplete-input": "^3.1.0",
"react-native-datepicker": "^1.4.4",
"react-native-extended-stylesheet": "^0.3.1",
"react-native-htmlview": "^0.5.0",
"react-native-mobx": "^0.3.1",
"react-native-modal-dropdown": "^0.4.1",
"react-native-orientation": "^1.17.0",
"react-native-pathjs-charts": "0.0.26",
"react-native-router-flux": "^3.37.0",
"react-native-sglistview": "^0.3.5",
"react-native-storage": "^0.1.5",
"react-native-view-shot": "^1.7.0",
"typescript": "^2.2.1"
},
"devDependencies": {
"babel-jest": "18.0.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-react-native": "1.9.1",
"babel-preset-react-native-stage-0": "^1.0.1",
"jest": "18.1.0",
"react-test-renderer": "15.4.2"
},
"jest": {
"preset": "react-native"
}
}
答
配置在Javascript| Libraries
中的库仅供PhpStorm本身用于代码完成/导航,但它们不适用于TypeScript编译器服务。 当您通过Settings | Languages & Frameworks | Javascript | Libraries
下载Typescript存根时,它们被放置在~/.PhpStorm*/config/javascript/extLibs/
中。这对于PhpStorm来说非常好,但是tsc编译器确实需要将d.ts
文件放置在项目目录中的某处。 因此,要获得下载的可用于Typescript编译器的存根,您需要将它们复制/移动到您的项目目录(并可能重命名为更具人性化的名称:))。然后,他们将可用于PhpStorm和编译器。 我们计划在未来的版本中提供一个选项,将文件直接下载到项目文件夹(而不是system/extLibs/
),请按照WEB-9237进行更新。相关功能要求:WEB-14413
所以,似乎使用npm
(npm install @types/
)是最好的解决方案,如果你需要的分型,以提供给打字稿编译