与 "Handbook" 文档相比,TypeScript 有哪些更好的记录?
Where is TypeScript better documented than in the "Handbook" documentation?
我知道 TypeScript documentation 并不完全是最新的,因为没有提到 type
和 abstract
关键字。例如,以下是现在有效的 TypeScript:
interface A {
b: string;
}
// I can't see anywhere in documentation this is mentioned.
type C = A;
var d: C;
d.b = 'something';
除了解析源代码或阅读有关 GitHub 问题的所有最新更改之外,是否还有更好的获取最新文档的地方?
它被称为Type Aliases,使您的代码更具可读性,您可以这样使用它:
type PrimitiveArray = Array<string|number|boolean>;
type MyNumber = number;
type NgScope = ng.IScope;
type Callback = () => void;
编辑:docs中也提到了。
文档中没有,但是 here。
Type Aliases
You can now define an alias for a type using the type keyword:
type PrimitiveArray = Array<string|number|boolean>;
type MyNumber = number;
type NgScope = ng.IScope;
type Callback = () => void;
Type aliases are exactly the same as their original types; they are simply
alternative names. You can use these aliases to better document your
code and aid readability.
我知道 TypeScript documentation 并不完全是最新的,因为没有提到 type
和 abstract
关键字。例如,以下是现在有效的 TypeScript:
interface A {
b: string;
}
// I can't see anywhere in documentation this is mentioned.
type C = A;
var d: C;
d.b = 'something';
除了解析源代码或阅读有关 GitHub 问题的所有最新更改之外,是否还有更好的获取最新文档的地方?
它被称为Type Aliases,使您的代码更具可读性,您可以这样使用它:
type PrimitiveArray = Array<string|number|boolean>;
type MyNumber = number;
type NgScope = ng.IScope;
type Callback = () => void;
编辑:docs中也提到了。
文档中没有,但是 here。
Type Aliases
You can now define an alias for a type using the type keyword:
type PrimitiveArray = Array<string|number|boolean>; type MyNumber = number; type NgScope = ng.IScope; type Callback = () => void;
Type aliases are exactly the same as their original types; they are simply alternative names. You can use these aliases to better document your code and aid readability.