question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Const enums and --isolatedModules

See original GitHub issue

I’m trying to use this library in a create-react-app with TypeScript. When I try to import it, I get the error

(...)/node_modules/@zxing/library/esm5/core/common/CharacterSetECI.d.ts
Type error: Ambient const enums are not allowed when the '--isolatedModules' flag is provided.  TS1209

CRA with TypeScript has this flag enabled by default and doesn’t let me turn it off. (To be honest, I don’t really understand what it does. Much less what the difference between enums and const enums is.)

Is there a way around this? I tried to remove all consts from enum declarations and all tests still pass.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
MidnightDesigncommented, Dec 14, 2018

Works like a charm now. Thank you so much for your help!

1reaction
odahcamcommented, Dec 11, 2018

Looks like I miserably failed at publishing it, hehe. I will try to publish it ASAP.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is `const enum` allowed with `isolatedModules`?
My understanding of --isolatedModules is that it tells the compiler to do extra checking to ensure that separate compilation (such as by using ......
Read more >
Cannot access ambient const enums when the ...
Set isolatedModules to true in tsconfig.json. npm run build. Get the following errors ...
Read more >
isolatedModules - TSConfig Option - TypeScript
transpileModule API which is used by some build tools. These limitations can cause runtime problems with some TypeScript features like const enum s...
Read more >
TypeScript: Don't Export const enums - ncjamieson
Exporting const enums from libraries will break some users. ... TypeScript has an isolatedModules compiler option that performs additional ...
Read more >
Cannot access ambient const enums (when using create react ...
I am trying to import an enum 'XRHandJoint', but I get a compilation error 'Cannot access ambient const enums when the '–isolatedModules' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found