-
-
Notifications
You must be signed in to change notification settings - Fork 841
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile error for TypeScript projects that transpile to ES5 #718
Comments
I'd recommend to set I think your global declaration should might work as well if you put it as |
|
@Bnaya I have confirmed that the codesandbox release eliminates the compile error. Thank you very much for fixing it so quickly! |
The TypeScript compiler has good justification for choosing this default. If code fails to compile, it means compilation must rely on incomplete or incorrect type information when analyzing the project files. In many cases the it probably won't break anything, but "probably won't break anything" is not the bar for professional software development at work, particularly for a component as fundamental as the compiler. 馃檪
We use thousands of other NPM packages in our TypeScript repos -- none of them have compile errors. |
Since there have been no additional reports of this issue in two years, and Proxy supporting browsers are nowadays quite the norm, won't fix this issue. skipLibCheck or a global ProxyHandlerDeclare, or patch-package can be used as workaround. |
馃悰 Bug Report
Some background: We are trying to adopt
@reduxjs/toolkit@1.4.0
, which depends onimmer
. Our projects target ES5 because we need to support devices with ancient JavaScript runtimes. Our applications have lots of components split across many teams and projects. So for performance reasons, we've agreed upon a standard set of polyfills that everyone uses. The polyfills are loaded manually, and transpilation is performed by the TypeScript compiler instead of Babel.Our build configuration does not support the Proxy polyfill. (It's not a commonly needed API, and that particular polyfill provides only partial functionality anyway.)
This causes a compile error for the
immer
typings:Immer currently seems to have a hard dependency on
ES2015.Proxy
in tsconfig.json.To Reproduce
npm install
npm run build
Suggested fix
The error is caused by this definition:
immer/dist/core/proxy.d.ts
If that one line is commented out, then the project builds successfully.
I tried fixing it by defining something like this in our application, however this seems to augment the global declarations only for our project's scope; immer's proxy.d.ts still fails to compile:
But here's a couple possible fixes that would work:
objectTraps
into a separate "opt-in" entry point. Thus this declaration would only be compiled by projects that import an Immer API that uses it.objectTraps
where it is, but modify its type declaration to avoid depending on the systemProxyHandler
definition. For example, if you simply paste the compiler'sProxyHandler
interface declaration into immer/dist/core/proxy.d.ts, then everything works whether or notES2015.Proxy
is added to tsconfig.json.Environment
We only accept bug reports against the latest Immer version.
setUseProxies(true)
setUseProxies(false)
(ES5 only) 馃憠 irrelevant, since this is a compile-time errorCC @victor-wm @bartvandenende-wm
The text was updated successfully, but these errors were encountered: