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 3.4.0 support #325
Conversation
We need a way to run TypeScript tests based on the installed version, since there are breaking changes between TypeScript 3.4 and 3.3. Here are the solutions I can think of:
Thoughts, @mweststrate? |
Oh, I forgot about But we'll still need to git-patch the tests, I think. |
This PR is dependent on prettier/prettier#5977 being fixed. |
It would be nice if we could only run the TypeScript tests when we know the typedefs have changed, but I don't think anyone has solved that yet. Otherwise, CI builds are slowed down by needing to install multiple versions of TypeScript to ensure safe upgrades / backward-compatible changes. |
I'm getting // old
// export type Draft<T> = T extends never[]
// ? T
// : T extends ReadonlyArray<any>
// ? T[number][] extends T
// ? DraftArray<T>
// : DraftTuple<T>
// : T extends AtomicObject
// ? T
// : T extends object
// ? { -readonly [P in keyof T]: Draft<T[P]> }
// : T
// new
export type Draft<T> = T extends AtomicObject
? T
: T extends object
? { -readonly [K in keyof T]: Draft<T[K]> }
: T Since 3.4 improves support for readonly arrays and tuples, this seems to work without breaking anything. |
Please release a new version with typescript 3.4 support, the latest stable vscode already comes with this version. I'm also getting Current workaround for usersReplace the export type Draft<T> = T You can replace it editing the node_modules file, using patch-package or maybe create a |
@brunolemos that is not a valid workaround. At a minimum, you need something like the following in order to correctly type the draft: export type Draft<T> = T extends AtomicObject
? T
: T extends object
? { -readonly [K in keyof T]: Draft<T[K]> }
: T The reason is if T has any readonly properties, they need to be erased |
I found some tricks to better handle the recursion in TS types, will investigate later whether this solves the open issues. |
Lol, it was already in there. Awesome test setup btw @aleclarson! |
closing in favor of #348 (which was based branched from this PR) |
Noticed an issue with the
Immutable<T>
type while testing outtypescript@3.4.0-dev.20190306
.This PR will also track other Immer-related issues with TypeScript 3.4.0 until 3.4.0 is officially released.