我正在使用visual studio Angular2 mvc5模板,我改变了它的模型。我使用TypeLite生成了模型的打字稿版本。现在我必须引用打字稿,但即使在重建项目之后,打字稿系统也无法识别它们。当我在模型成员上按下F12时,它正在引用其他文件。
文件夹结构:
ProjectRoot/
app
some.component.ts
...
Scripts
...
TypeLite.Net4.tt
TypeLite.Net4.d.ts
typings (not included in project)
main (same)
ambient (same)
TypeLite (same)
index.d.ts (same)
typings.json
tsconfig.json
...
TypeLite.Net4.d.ts(代表更新的型号):
/// <reference path="Enums.ts" />
declare module Models {
interface BpmGraph {
Author: string;
BpmPoints: Models.BpmPoint[];
Id: number;
SongName: string;
Tags: string[];
TimedBy: string;
}
interface BpmPoint {
BpmMap: System.Collections.Generic.KeyValuePair<number, number>[];
BpmMap2: System.Tuple<number, number>[];
Bpms: number[];
GraphId: number;
Id: number;
Times: number[];
}
interface List {
Count: number;
CountEnded: number;
Id: number;
Name: string;
Tasks: Models.Task[];
}
interface Task {
Ended: boolean;
Id: number;
ListId: number;
Name: string;
}
}
declare module Models.ViewModel {
interface JSONReturnVM<T> {
element: T;
errormessage: string;
haserror: boolean;
}
}
declare module System {
interface Tuple<T1, T2> {
Item1: T1;
Item2: T2;
}
}
declare module System.Collections.Generic {
interface KeyValuePair<TKey, TValue> {
Key: TKey;
Value: TValue;
}
}
some.component.ts:
...
export class BpmHelperComponent {
constructor(private _appService: AppServiceTodoList)
{
}
get bpmGraph(): Models.List[]
{
return this._appService.todolist;
}
...
Index.d.ts(什么模型成员引用,未更新):
// Generated by typings
// Source: scripts/TypeLite.Net4.d.ts
declare module Models {
interface List {
Count: number;
CountEnded: number;
Id: number;
Name: string;
Tasks: Models.Task[];
}
interface Task {
Ended: boolean;
Id: number;
ListId: number;
Name: string;
}
}
declare module Models.ViewModel {
interface JSONReturnVM<T> {
element: T;
errormessage: string;
haserror: boolean;
}
}
typings.json:
{
"ambientDependencies": {
"bootstrap": "github:DefinitelyTyped/DefinitelyTyped/bootstrap/bootstrap.d.ts#56295f5058cac7ae458540423c50ac2dcf9fc711",
"core-js": "registry:dt/core-js#0.0.0+20160317120654",
"jquery": "github:DefinitelyTyped/DefinitelyTyped/jquery/jquery.d.ts#56295f5058cac7ae458540423c50ac2dcf9fc711",
"TypeLite": "file:Scripts/TypeLite.Net4.d.ts"
}
}
当我将some.component.ts的Models.List更改为Models.BpmGraph时,构建失败说&#34;构建:模块&#39;模型&#39;没有导出的成员&#39; BpmGraph&#34;
更新index.d.ts的正确方法是什么?它说&#39;由打字产生&#39;但我无法找到更新该文件的方法。
我尝试过打字安装,但除了消息
之外没有任何改变PM> typings install --global
[?25h
+-- debug
| `-- ms
`-- mocha (global)
答案 0 :(得分:0)
在更新打字(0.8.3到2.0.0)后重试的打字安装并成功。打字安装新文件夹&#39; global&#39;和some.component.ts正确引用。我认为这个问题的出现是因为打字&#39; ambient重命名为global。