【发布时间】:2017-03-20 06:17:51
【问题描述】:
尝试将描述性数组添加到我的数据和模型时出现以下错误。 错误 TS2322:类型'{“id”:字符串; “名称”:字符串; “能力”:字符串; “描述”:字符串[]; “年”:字符串; }[]' 不可分配给类型 'Competency[]'。 输入'{“id”:字符串; “名称”:字符串; “能力”:字符串; “描述”:字符串[]; “年”:字符串; }' 不可分配给类型“能力”。 属性“描述”的类型不兼容。 类型 'string[]' 不能分配给类型 'Descriptive[]'。 类型“字符串”不可分配给类型“描述性”。 app/app.routes.ts(9,36): 错误 TS2307: 找不到模块 './inventory/inventory.component'。
mocksCompetency.ts
import { Competency } from './competency';
export const COMPETENCY: Competency[] = [
{
"id": "EngLA001",
"name": "Oral Language",
"competency": "The teacher understands the importance of oral language, knows the development processes of oral language and provides the students with varied opportunities to develop listening and speaking skills.",
"descriptives": ["Something","More"],
"year": "2014",
}
];
能力.ts
export class Competency {
id: string;
name: string;
competency: string;
descriptives: Descriptive[];
year: string;
}
export class Descriptive {
description: string;
}
【问题讨论】:
标签: javascript angularjs typescript model