Angular在d.ts中找不到自定义类型

时间:2020-09-23 15:23:24

标签: angular typescript

我已经创建了一个自定义d.ts文件,因此不必导入和导出我的类型,效果很好。但是,当我今天早上尝试为我的项目提供服务时,出现了以下错误:

src/app/feature/datrix-forms/main-form/main-form.component.ts:12:18 - error TS2304: Cannot find name 'parsedHelper'.

12  @Input() model: parsedHelper;

应该指出的是,我可以手动导入它,但是它可以正常工作,但这不破坏d.ts文件的目的吗?

即使在d.ts文件中声明了已解析的帮助程序,其文件结构也如下所示:

root
--src
----app
------feature
--------datrix-forms
----------main-form <--module throwing error
----types.d.ts <----types declared here
angular.json
tsconfig.app.json
tsconfig.json
tsconfig.spec.json
package.json

这是types.d.ts中错误类型的声明:

interface parsedHelper {
    age1: number;
    age2: number;
    income: number;
    maritalStatus: maritalStatusType;
    zip: string;
    majorCc: boolean;
}

tsconfig.app.json:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": []
  },
  "files": [
    "src/main.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ]
}

tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "module": "es2020",
    "lib": [
      "es2018",
      "dom"
    ]
  }
}

0 个答案:

没有答案