diff --git a/packages/documentation/copy/en/handbook-v2/Everyday Types.md b/packages/documentation/copy/en/handbook-v2/Everyday Types.md index 4624f148c18a..358adbf70d78 100644 --- a/packages/documentation/copy/en/handbook-v2/Everyday Types.md +++ b/packages/documentation/copy/en/handbook-v2/Everyday Types.md @@ -34,7 +34,6 @@ We'll learn more about the syntax `T` when we cover _generics_. > Note that `[number]` is a different thing; refer to the section on [Tuples](/docs/handbook/2/objects.html#tuple-types). - ## `any` TypeScript also has a special type, `any`, that you can use whenever you don't want a particular value to cause typechecking errors. @@ -44,7 +43,7 @@ When a value is of type `any`, you can access any properties of it (which will i ```ts twoslash let obj: any = { x: 0 }; // None of the following lines of code will throw compiler errors. -// Using `any` disables all further type checking, and it is assumed +// Using `any` disables all further type checking, and it is assumed // you know the environment better than TypeScript. obj.foo(); obj(); @@ -132,6 +131,16 @@ Much like variable type annotations, you usually don't need a return type annota The type annotation in the above example doesn't change anything. Some codebases will explicitly specify a return type for documentation purposes, to prevent accidental changes, or just for personal preference. +#### Functions Which Return Promises + +If you want to annotate the return type of a function which returns a promise, you should use the `Promise` type: + +```ts twoslash +async function getFavoriteNumber(): Promise { + return 26; +} +``` + ### Anonymous Functions Anonymous functions are a little bit different from function declarations. @@ -501,7 +510,7 @@ If this happens, you can use two assertions, first to `any` (or `unknown`, which declare const expr: any; type T = { a: 1; b: 2; c: 3 }; // ---cut--- -const a = (expr as any) as T; +const a = expr as any as T; ``` ## Literal Types