【发布时间】:2016-12-28 06:44:04
【问题描述】:
我们正在将 TypeScript 项目从 1.0 版升级到 TypeScript 1.8。 我们现在还使用最新的 IgniteUI 定义文件 (v 16.1),该文件(在 Typescript 版本更改之后)不适用于我们现有的对象初始化(请参阅本文底部的错误)。
这是我们现有的使用 IgniteUI igTextEditor 的 TypeScript 代码:
$(this.textinput).igTextEditor({
maxLength: this.maxChars,
textMode: sTextMode,
listItems: [""],
buttonType: "dropdown",
dropDownListOpening: function (evt, ui) {
formBase.setActiveForm(self.formID);
self.buttonClicked();
return false;
},
// Validator Options
validatorOptions: {
onblur: true,
onchange: false,
required: this.required,
notificationOptions: {
direction: "right",
showIcon: "true",
mode: "popover"
},
custom: function (value, fieldOptions) {
if (self.showError) {
self.showError = false;
if (self.errorMessage.length > 0) {
$(this.element).igValidator("option", "errorMessage", self.errorMessage);
}
return false;
}
self.validate(value);
return true;
}
},
keyup: function (evt, ui) { if (evt.keyCode == 13) { $(evt.currentTarget).blur() } },
focus: function () { formBase.setActiveForm(self.formID) }
});
这是来自 igniteui.d.ts 的相关接口定义:
interface IgTextEditor {
textMode?: string;
maxLength?: number;
includeKeys?: string;
excludeKeys?: string;
toUpper?: boolean;
toLower?: boolean;
listMatchIgnoreCase?: boolean;
listMatchOnly?: boolean;
listMatchContains?: boolean;
listAutoComplete?: boolean;
}
interface JQuery {
igTextEditor(options: IgTextEditor): JQuery;
igTextEditor(optionLiteral: string, options: IgTextEditor): JQuery;
igTextEditor(optionLiteral: string, optionName: string, optionValue: any): JQuery;
igTextEditor(optionLiteral: string, optionName: string): any;
igTextEditor(methodName: string): any;
}
igniteui.d.ts 中这段代码的唯一变化来自:
igTextEditor(optionLiteral: string, optionName: any, optionValue: any): JQuery;
到:
igTextEditor(optionLiteral: string, optionName: string, optionValue: any): JQuery;
升级到 TypeScript 1.8 后,我们收到以下错误:
错误 TS2345:构建:类型参数 '{ [x: number]: undefined;最大长度:数字;文本模式:字符串;列表项:字符串[]; buttonType: s...' 不能分配给“string”类型的参数。
问题:考虑到 TypeScript 在 1.8 中对类型验证更加严格,并且不能选择强制转换为
【问题讨论】:
-
您使用的是哪个版本的 Ignite UI?
-
Ignite UI 16.1 版 - 现在也更新了问题。
标签: javascript typescript1.8 ignite-ui