Typescript: A bug in Chinese Typescript Document.

Created on 23 May 2019  路  6Comments  路  Source: microsoft/TypeScript

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.

External

All 6 comments

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 tagName T, and attributes k, extends, keyof, t.
hhhh, I find that.
image

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dlaberge picture dlaberge  路  3Comments

wmaurer picture wmaurer  路  3Comments

kyasbal-1994 picture kyasbal-1994  路  3Comments

CyrusNajmabadi picture CyrusNajmabadi  路  3Comments

jbondc picture jbondc  路  3Comments