我正在使用.d.ts
个文件来声明interfaces
,这样我就不需要在其他文件中明确导入它们了
我的tsconfing.json
是
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"noImplicitAny": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"noEmitHelpers": false,
"plugins": [
{
"name": "tslint-language-service"
},
{
"name": "@angular/language-service"
}
],
"types": [
"node",
"bootstrap",
"jquery",
"typeahead"
],
"lib": [
"dom",
"es2016",
"es2017"
]
},
"exclude": [
"node_modules",
"src/main.aot.ts"
],
"compileOnSave": false,
"buildOnSave": false
}
我的示例.d.ts
是
interface SomeData{
field:string;
}
但我希望在此添加Observable
字段
interface SomeData{
field:string;
field2:Observable<string>;
}
为此我试图导入Observable
按import {Observable} from 'rxjs/Obsevable'
添加类型定义不会导致导入功能
并使用/// <reference >
添加类型定义无效
我尝试的东西是
/// <reference path="../../../../node_modules/rxjs/Rx.d.ts" />
/// <reference path="../../../../node_modules/rxjs/Observable.d.ts" />
@types
rxjs5
个包
有什么建议吗?
编辑:也试过了
/// <reference types="rxjs/Observable" />