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
Apologies if this was submitted already, I could not find anything similar by searching.
TypeScript Version: 2.8.1
Search Terms: Existential types, undefined, Exclude, Required, NonNullable, in keyof
Code
typeOnlyPresentV1<T>={[PinkeyofT]: NonNullable<T[P]>};// should pass, and it doesconstTest_1: OnlyPresentV1<{test: string}>={test: "asd"};// should fail, and it doesconstTest_2: OnlyPresentV1<{test: string}>={test: undefined};// should pass, and it doesconstTest_3: OnlyPresentV1<{test: string|undefined}>={test: "asd"};// should fail, and it doesconstTest_4: OnlyPresentV1<{test: string|undefined}>={test: undefined};typeOnlyPresentV2<T>={[PinkeyofT]: T[P]extendsnull|undefined ? never : T[P]};// should pass, and it doesconstTest_5: OnlyPresentV2<{test: string}>={test: "asd"};// should fail, and it doesconstTest_6: OnlyPresentV2<{test: string}>={test: undefined};// should pass, and it doesconstTest_7: OnlyPresentV2<{test: string|undefined}>={test: "asd"};// should fail, but it doesn't!constTest_8: OnlyPresentV2<{test: string|undefined}>={test: undefined};
Expected behavior:
I noted down what my expectations are above each case.
I expected that inlining the definition of NonNullable would be the same as using the type.
Actual behavior:
Behavior is different, but definitions are essentially the same?
Playground Link:https://goo.gl/fWzwzA (shortend it because it was really long) Enabled all strictness checks I could
Related Issues: Could not find any
The text was updated successfully, but these errors were encountered:
Apologies if this was submitted already, I could not find anything similar by searching.
TypeScript Version: 2.8.1
Search Terms: Existential types, undefined, Exclude, Required, NonNullable, in keyof
Code
Expected behavior:
I noted down what my expectations are above each case.
I expected that inlining the definition of NonNullable would be the same as using the type.
Actual behavior:
Behavior is different, but definitions are essentially the same?
Playground Link: https://goo.gl/fWzwzA (shortend it because it was really long) Enabled all strictness checks I could
Related Issues: Could not find any
The text was updated successfully, but these errors were encountered: