我使用IDB和类型记录,并试图定义EventTarget,这样我就可以从它得到结果和错误。
通常,对于操作,一个获得错误作为event.target.error和结果event.target.result。
var request = objectStore.add(data);
request.onerror = function(event) {
console.log(event.target.error)
}
request.onsuccess = function(event) {
callback(event.target.error,event.target.result);
};我试过像下面这样
interface EventTarget {
error?: any;
result: any;
}这就产生了很多无关的错误。我使用最新的开发分支(de583a588d7be350ac5108118a807715fcf83519)。
我能做些什么
Using tsc v1.0.0
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(11030,11): error TS2189: Interface 'SVGFEFloodElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(11100,11): error TS2189: Interface 'SVGFETileElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(11108,11): error TS2189: Interface 'SVGFEBlendElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(11139,11): error TS2189: Interface 'SVGFEMergeElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(11262,11): error TS2189: Interface 'SVGFEGaussianBlurElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(11339,11): error TS2189: Interface 'SVGFESpecularLightingElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(11442,11): error TS2189: Interface 'SVGFEMorphologyElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(11473,11): error TS2189: Interface 'SVGFEDisplacementMapElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(11614,11): error TS2189: Interface 'SVGFEConvolveMatrixElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(11664,11): error TS2189: Interface 'SVGFETurbulenceElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(11709,11): error TS2189: Interface 'SVGFEColorMatrixElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(11820,11): error TS2189: Interface 'SVGFEOffsetElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(12102,11): error TS2189: Interface 'SVGFEImageElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(12116,11): error TS2189: Interface 'SVGFECompositeElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(12206,11): error TS2189: Interface 'SVGFEComponentTransferElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
/usr/local/lib/node_modules/typescript/bin/lib.d.ts(12214,11): error TS2189: Interface 'SVGFEDiffuseLightingElement' cannot simultaneously extend types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes':
Named properties 'result' of types 'SVGElement' and 'SVGFilterPrimitiveStandardAttributes' are not identical.
>> Compilation failed编辑:
我可以看到目标在SVGAElement中使用(或者在事件中),
interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference {
target: SVGAnimatedString;
}我尝试的是用error和result扩展error。
我不知道EventTarget的这些循环扩展是如何工作的。我对打字本还不熟悉。
interface IDBRequest extends EventTarget {
onsuccess: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
interface Event {
....
target: EventTarget;
eventPhase: number;
....发布于 2014-03-22 05:37:29
result的类型必须与SVGElement和SVGFilterPrimitiveStandardAttributes完全相同。
如果一个接口接口实现了另一个接口,而子接口没有使用与父接口相同的类型,就会出现此错误:
interface FooEvent{
data: number;
}
interface BarEvent extends FooEvent{
data: string;
}https://stackoverflow.com/questions/22571707
复制相似问题