You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: pages/Advanced Types.md
+6-7Lines changed: 6 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -834,7 +834,7 @@ type Partial<T> = { [P in keyof T]?: T[P] }
834
834
835
835
In these examples, the properties list is `keyofT` and the resulting type is some variant of `T[P]`.
836
836
This is a good template for any general use of mapped types.
837
-
That's because this kind of transformation is homomorphic, which means that the mapping applies to every property of `T` and no others.
837
+
That's because this kind of transformation is [homomorphic](https://en.wikipedia.org/wiki/Homomorphism), which means that the mapping applies only to properties of `T` and no others.
838
838
The compiler knows that it can copy all the existing property modifiers before adding any new ones.
839
839
For example, if `Person.name` were readonly, `Partial<Person>.name` would be readonly and optional.
These non-homomorphic types are essentially creating new properties (even though `Pick` uses `Person` as a source), so they don't copy property modifiers from anywhere; if `Person.name` were readonly, `Pick<Person, 'name'>.name` would not be readonly.
875
+
Non-homomorphic types are essentially creating new properties, so they can't copy property modifiers from anywhere.
877
876
878
877
## Inference from mapped types
879
878
@@ -892,5 +891,5 @@ function unproxify<T>(t: Proxify<T>): T {
892
891
let originalProps =unproxify(proxyProps);
893
892
```
894
893
895
-
Note that this unwrapping inference works best on homomorphic mapped types.
896
-
If the mapped type is not homomorphic you might have to explicitly give a type parameter to your unwrapping function.
894
+
Note that this unwrapping inference only works on homomorphic mapped types.
895
+
If the mapped type is not homomorphic you will have to explicitly give a type parameter to your unwrapping function.
0 commit comments