我正在使用TypeLite从Web API项目中的一些C#POCO生成Typescript接口。这会生成一个文件,如:
// TypeLite.Net4.d.ts
declare namespace MyNamespace.Models {
interface InvoiceModel {
billingPeriodId: number;
createdDate: Date;
invoiceId: number;
invoiceNumber: number;
organizationId: number;
paidDate: Date;
total: number;
}
}
我想在我的Angular项目中使用这个文件,但我似乎无法找到如何做到的好解释。我尝试了我在网上找到的各种各样的东西,包括在tsconfig.json
,files
或include
部分添加到我的typeRoots
,但我还没有找到正确的方法。无论我做什么,我仍然得到错误TS2304: Cannot find name 'InvoiceModel'
。我该怎么做?
由于您尚未发布使用生成的打字稿声明文件的片段,并考虑了问题的部分内容
我尝试了我在网上找到的各种东西,包括在文件,include或typeRoots部分中将它添加到> my tsconfig.json“
我推断你在某种程度上缺少引用声明文件。这是与tripple-slash-directives完成的事情。
您需要做的就是将以下代码添加到您想要使用的位置作为第一行。
/// reference path=".../path/to/file" />