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
Expected behavior: file importing immer compiles cleanly
Observed behavior: file importing immer triggers compilation errors
Occurs when using Proxies (use setUseProxies(true))
Occurs in the ES5 implementation (use setUseProxies(false))
Context: I'm working on a TypeScript project where ES5 compatibility needs to be ensured and bundle size must be limited, so specifying lib: ["es2015"] is not an option (it would allow code that uses ES2015 classes to slip through) nor it is an option to polyfill everything just so es2015 features would work if accidentally introduced. I understand from the README that immer is also intended for ES5-only environments.
Currently, when lib: ["es5"] is in tsconfig.json, compiling a TypeScript file that contains nothing more than import produce from 'immer' results in the following errors (run yarn run tsc in the reproduction repository):
$ /tmp/repro/node_modules/.bin/tsc
node_modules/immer/dist/immer.d.ts:4:7 - error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
4 | Map<any, any>
~~~
node_modules/immer/dist/immer.d.ts:5:7 - error TS2583: Cannot find name 'WeakMap'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
5 | WeakMap<any, any>
~~~~~~~
node_modules/immer/dist/immer.d.ts:6:7 - error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
6 | Set<any>
~~~
node_modules/immer/dist/immer.d.ts:7:7 - error TS2583: Cannot find name 'WeakSet'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
7 | WeakSet<any>
~~~~~~~
Found 4 errors.
error Command failed with exit code 2.
A workaround I'm using is to place the following in my local declarations (rename typings.d.text to typings.d.ts in the reproduction repository):
This silences errors caused by importing immer, without letting one use those classes accidentally. If one types something like "const m = new Map()" one gets error TS2693: 'Map' only refers to a type, but is being used as a value here..
Thanks for immer, by the way, exceptional work!
The text was updated successfully, but these errors were encountered:
setUseProxies(true)
)setUseProxies(false)
)Context: I'm working on a TypeScript project where ES5 compatibility needs to be ensured and bundle size must be limited, so specifying
lib: ["es2015"]
is not an option (it would allow code that uses ES2015 classes to slip through) nor it is an option to polyfill everything just so es2015 features would work if accidentally introduced. I understand from the README that immer is also intended for ES5-only environments.Currently, when
lib: ["es5"]
is in tsconfig.json, compiling a TypeScript file that contains nothing more thanimport produce from 'immer'
results in the following errors (runyarn run tsc
in the reproduction repository):A workaround I'm using is to place the following in my local declarations (rename
typings.d.text
totypings.d.ts
in the reproduction repository):This silences errors caused by importing immer, without letting one use those classes accidentally. If one types something like "const m = new Map()" one gets
error TS2693: 'Map' only refers to a type, but is being used as a value here.
.Thanks for immer, by the way, exceptional work!
The text was updated successfully, but these errors were encountered: