typescript d.ts文件仅导入rxjs类型定义

时间:2017-10-31 10:04:36

标签: typescript

我正在使用.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" />

0 个答案:

没有答案