__createBinding assumes exports are readonly
See original GitHub issueUsing tslib 1.12.0, we are seeing the following error being thrown:
TypeError: Cannot set property foo of #<Object> which has only a getter
This is a result of this commit, which changes __exportStar
to use __createBinding
, which now uses Object.defineProperty
to create a readonly property on exports
.
The implication is that it’s no longer possible to do this in TypeScript:
# module1
export function foo() { /* do something */ }
# module2
export * from 'module1';
export function foo() { /* do another thing */ }
This differs from CommonJS behavior, where it is possible to overwrite previous exports.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:15
- Comments:12 (4 by maintainers)
Top Results From Across the Web
TypeError: "exports" is read-only => When exporting a ...
1) Is it possible to have module B import from module C and then export to module A, where the content of module...
Read more >TSConfig Option: esModuleInterop
This mis-match causes these two issues: the ES6 modules spec states that a namespace import ( import * as x ) can only...
Read more >MagicDraw UserManual.pdf - No Magic, Inc
Once exported, the package and its containing elements are read-only and the module name ... Use the Binding pattern when you want to...
Read more >https://unpkg.com/byots@4.3.0-dev.20210224.17.12/b...
Assumes both arrays are sorted * based on the provided comparer. ... export function stopTracing(typeCatalog?: readonly Type[]): void; export enum Phase ...
Read more >FactoryTalk Batch Recipe Editor User Guide
No patent liability is assumed by Rockwell Automation, Inc. with respect to use of information, ... Import and export restrictions for secured recipes....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Agree with @sramam this should be treated as a major version.
This issue, together with https://github.com/microsoft/tslib/issues/105 is painful to track down.
I also saw cases where users don’t even use typescript, but because of layers of dependencies, the issue rises up.
1.13.0 should be available for those impacted by the change. Users on TypeScript 3.9 should look into using tslib 2.0.0.