导入不使用typescript的自定义类型

时间:2017-05-24 13:18:54

标签: typescript import definitelytyped

所以我正在为我的应用程序编写自己的打字文件。我在根目录中有一个@types文件夹。 Everytinh工作得很好:我已经更新了tsconfig,让webpack和我的ide知道在哪里找到打字。

我在interace中定义的变量应该是一种外部库。但是当我将特定类型导入到typing文件中时,typing文件会被破坏或者其他东西,因为我的应用程序中找不到任何定义的接口了!

import {GraphQLError} from '../../node_modules/@types/graphql/error/GraphQLError';

interface IResponse{
  data?: {
    views: Array<IViewScheme>
  };
  errors?: Array<GraphQLError>;
  loading: boolean;
}

我也尝试过不同的路径,比如@ types / graphql等。但是所有路径都失败了。当我改变进口时,一切都很好......

我在这里做错了什么?

编辑:

tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "noEmit": true,
    "noEmitHelpers": true,
    "importHelpers": true,
    "strictNullChecks": false,
    "lib": [
      "dom",
      "es6"
    ],
    "typeRoots": [
      "node_modules/@types",
      "@types"
    ],
    "types": [
      "graphql",
      "hammerjs",
      "jasmine",
      "node",
      "source-map",
      "uglify-js",
      "webpack",
      "vizceral"
    ]
  },
  "exclude": [
    "node_modules",
    "dist"
  ],
  "awesomeTypescriptLoaderOptions": {
    "forkChecker": true,
    "useWebpackText": true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

0 个答案:

没有答案