Skip to content
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

alias for build-in type methods #8

Open
gasolin opened this issue Feb 10, 2019 · 2 comments
Open

alias for build-in type methods #8

gasolin opened this issue Feb 10, 2019 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@gasolin
Copy link
Owner

gasolin commented Feb 10, 2019

["a", "b", "c"].length can be written as ["a", "b", "c"].长度

Should work In Example:

EN:

let strLength2: number = (someValue2 as string).length;

CN:

变量 strLength2: 数字 = (someValue2 转为 文字).长度;
@gasolin gasolin added help wanted Extra attention is needed enhancement New feature or request labels Feb 10, 2019
@gasolin gasolin changed the title alias for for build-in type methods alias for build-in type methods Feb 10, 2019
@gasolin
Copy link
Owner Author

gasolin commented Feb 19, 2019

check if its possible with the .d.ts file

@gasolin
Copy link
Owner Author

gasolin commented Feb 20, 2019

https://stackoverflow.com/questions/47647709/method-alias-with-typescript shows its possible to define

interface Console {
  log(message?: any, ...optionalParams: any[]): void;
  紀錄: typeof Console.prototype.log;
}

in typescript/lib/lib.dom.d.ts, but console.紀錄 is not transpiled to console.log.
May introduce aliasof instead of typeof to provide similar usage but could transpile console.紀錄 as console.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant