We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents da0851e + 2f18bc1 commit 07d34abCopy full SHA for 07d34ab
docs/types/moving-types.md
@@ -42,13 +42,19 @@ bar = '789'; // ERROR: Type `string` is not `assignable` to type `number`
42
43
## Capturing the type of a class member
44
45
-Similar to capturing the type of a variable, you just declare a variable purely for type capturing purposes:
+You can traverse into any non-nullable object type to retrieve the type of a property:
46
47
```ts
48
class Foo {
49
foo: number; // some member whose type we want to capture
50
}
51
52
+let bar: Foo['foo']; // `bar` has type `number`
53
+```
54
+
55
+Alternatively, similar to capturing the type of a variable, you just declare a variable purely for type capturing purposes:
56
57
+```ts
58
// Purely to capture type
59
declare let _foo: Foo;
60
0 commit comments