-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript warning/errors #138
Comments
协变, 逆变
|
microsoft/TypeScript#283 (comment) (JSDoc) Workaround / for future reference: use manual cast // cloneNode produces Node, @see https://github.com/Microsoft/TypeScript/issues/283
var a = document.cloneNode(true);
a.location; // Property 'location' does not exist on type 'Node'.
// workaround:
var b = /** @type {Document} */ (document.cloneNode(true));
b.location; // OK |
'this' type is available only in a non-static member of a class or interface.The wrong code: class Base {
hooks: {
// raise error here.
self: SyncHook<[this]>;
}
} The correct code: interface Hooks<C> {
self: SyncHook<[C]>;
}
class Base {
hooks: {
} & Hooks<this>;
} |
Get type of generic property.type Foo<T> = T extends { NodeC: infer U } ? { NodeC: U } : never;
class LinkedList {
private dummyNode: Foo<this>["NodeC"];
constructor() {
const NodeC = this.NodeC;
this.dummyNode = new NodeC();
}
private NodeC = class {
constructor() {
}
}
}
const list = new LinkedList();
console.log(list); |
microsoft/TypeScript#31661
The text was updated successfully, but these errors were encountered: