-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript 2.8 — initial support & updates #14
Changes from 1 commit
dd32b5c
803516b
0970ff4
8ff4824
229ea30
034e1b7
e0c4955
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
// TypeScript Version: 2.6 | ||
// TypeScript Version: 2.8 | ||
|
||
/** | ||
* Remove the variants of the second union of string literals from | ||
* the first. | ||
* | ||
* @see https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-307871458 | ||
* TypeScript Documentation suggests that as of 2.8 you should use the built-in "Exclude" instead. | ||
* | ||
* @see https://github.com/Microsoft/TypeScript-Handbook/blame/master/pages/release%20notes/TypeScript%202.8.md#L245 | ||
*/ | ||
export type Diff<T extends string, U extends string> = ( | ||
& { [P in T]: P } | ||
|
@@ -15,9 +17,9 @@ export type Diff<T extends string, U extends string> = ( | |
/** | ||
* Drop keys `K` from `T`. | ||
* | ||
* @see https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-307871458 | ||
* @see https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-377567046 | ||
*/ | ||
export type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>; | ||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | ||
|
||
/** | ||
* Find the overlapping variants between two string unions. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we replace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not familiar with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /**
* Extract from T those types that are assignable to U
*/
type Extract<T, U> = T extends U ? T : never;
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool! So what's the specific action you would like here? Sounds like the answer to your first question is "Yes", but do you want me to just delete the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So let's delete both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deleted! |
||
|
@@ -29,9 +31,11 @@ export type Overlap<T extends string, U extends string> = Diff<T, Diff<T, U>>; | |
* type from U only. | ||
* | ||
* @see https://github.com/pelotom/type-zoo/issues/2 | ||
* @see https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-307871458 | ||
* @see https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-377692897 | ||
*/ | ||
export type Overwrite<T, U> = Omit<T, Overlap<keyof T, keyof U>> & U; | ||
export type Overwrite<T, U> = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why this one needs to change except to use export type Overwrite<T, U> = Omit<T, Extract<keyof T, keyof U>> & U; |
||
[P in Exclude<keyof T, keyof U>]: T[P] | ||
} & U; | ||
|
||
/** | ||
* Use to prevent a usage of type `T` from being inferred in other generics. | ||
|
@@ -49,9 +53,8 @@ export type Overwrite<T, U> = Omit<T, Overlap<keyof T, keyof U>> & U; | |
export type NoInfer<T> = T & { [K in keyof T]: T[K] }; | ||
|
||
/** | ||
* `T` without the possibility of `undefined` or `null`. | ||
* | ||
* @see https://github.com/Microsoft/TypeScript/issues/15012#issuecomment-346499713 | ||
* Deprecated: available in TypeScript Core as of 2.8 | ||
* @see https://github.com/Microsoft/TypeScript-Handbook/blame/master/pages/release%20notes/TypeScript%202.8.md#L203 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's just take it out. |
||
*/ | ||
export type NonNullable<T> = T & {}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's either alias
Diff
toExclude
or just take it out; I think I'd be fine with the latter and bumping the major version since we're already making the breaking change of requiring TypeScript 2.8.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently making it an Alias, but happy to delete it instead, please advise!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's delete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted!