I find one difference between the Chinese document and the origin document in the Generics section of Handbook which makes me confused.
In the origin document, it says:
function getProperty<T, K extends keyof T>(obj: T, key: K) {
return obj[key];
}
let x = { a: 1, b: 2, c: 3, d: 4 };
getProperty(x, "a"); // okay
getProperty(x, "m"); // error: Argument of type 'm' isn't assignable to 'a' | 'b' | 'c' | 'd'.
But in Chinese document, it says:
function getProperty(obj: T, key: K) {
return obj[key];
}
let x = { a: 1, b: 2, c: 3, d: 4 };
getProperty(x, "a"); // okay
getProperty(x, "m"); // error: Argument of type 'm' isn't assignable to 'a' | 'b' | 'c' | 'd'.
I would like to fix the document but I don't know how to contribute to the Chinese website.
This is either a bug in the html generation or some sort of user error in the CMS. If you look at the rendered output in browser devtools, the <T, K extends keyof T> is actually there as a dom element with tagName T, and attributes k, extends, keyof, t.
This is either a bug in the html generation or some sort of user error in the CMS. If you look at the rendered output in browser devtools, the
<T, K extends keyof T>is actually there as a dom element with tagNameT,and attributesk,extends,keyof,t.
hhhh, I find that.
We don't control tslang.cn
The site seems outdated for a long time...
If you wanna read the Chinese edition, see this https://legacy.gitbook.com/book/zhongsp/typescript-handbook/details
The site seems outdated for a long time...
If you wanna read the Chinese edition, see this https://legacy.gitbook.com/book/zhongsp/typescript-handbook/details
Great! Thanks!
The site seems outdated for a long time...
If you wanna read the Chinese edition, see this https://legacy.gitbook.com/book/zhongsp/typescript-handbook/details
Is this the latest version?