ERROR - Exports must be a statement at the top-level of a module when compiling es6 output from typescript compiler
See original GitHub issueTypescript output for an enum fails to compile with closure compiler because it assigns an export inside of a statement. For example
export enum Foo {}
transpiles to
var Foo;
(function (Foo) {
})(Foo = exports.Foo || (exports.Foo = {}));
as demonstrated here
When closure compiler is run on that code it results in the error ERROR - Exports must be a statement at the top-level of a module
I don’t believe that this should cause an error. Es6 supports this syntax. At the very least a there should be an option to make this into a warning or @suppress
it.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Documentation - ECMAScript Modules in Node.js - TypeScript
When a file is considered an ES module, a few different rules come into play compared to CommonJS: import / export statements and...
Read more >ES6 Modules · Issue #2242 · microsoft/TypeScript - GitHub
A top-level declaration that specifies an export modifier. An new ES6 export or import declaration of any form. An original TypeScript ...
Read more >Getting Unexpected Token Export - javascript - Stack Overflow
there is not enough information about your environment or configuration to offer any assistance. This error is suggesting that either webpack or babel...
Read more >Avoid these issues when using new ECMAScript modules in ...
Es6 modules now have full support in Node.js 12 and above so it's ... to compile in tsc because it is at the...
Read more >CommonJS modules | Node.js v19.2.0 Documentation
Assigning to exports will not modify module, must use module.exports module.exports ... to build native packages from Node.js modules without modification.
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
I don’t think that’s the right option, should be “angularCompilerOptions”: { “annotateForClosureCompiler”: true }
On Wed, Apr 12, 2017 at 1:35 PM Tyler Davis notifications@github.com wrote:
Oh, hi, you didn’t use the magic word. I remember that option now - it was from the early prototype of tsc_wrapped that you guys forked. Glad it’s fixed.