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.

"export class" does not compile with outfile=foo (module=none, es6)

See original GitHub issue

TypeScript Version: 3.8.3

Search Terms:

Code

{
   "$schema": "http://json.schemastore.org/tsconfig",
   "compilerOptions": {
      "module": "none",
      "target": "es6",
      "types": [],
      "outFile": "newFile.js" //   <- important
   },
   "files": [
      "main.ts"
   ]
}
// main.ts
declare module Common {
    abstract class absCom {
        constructor();
    }
}
export /* <- important */ class Com extends Common.absCom {
    constructor() {
        super();
    }
}

Expected behavior: This should compile without problems. Actual behavior: When I configure an outfile no file is generated (js and no .d.ts, .js.map). But we get no error message about this! This is the same with --verbose:

[13:11:21] Project 'foo/tsconfig.json' is out of date because output file 'foo/newFile.js' does not exist
[13:11:21] Building project 'foo/tsconfig.json'...
[13:11:23] Updating unchanged output timestamps of project 'foo/tsconfig.json'...

Test 1: Removing the outfile generates the following block in main.js:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Com extends Common.absCom {
    constructor() {
        super();
    }
}
exports.Com = Com;

Test 2: Removing export in main.ts we get in newFile.js:

class Com extends Common.absCom {
    constructor() {
        super();
    }
}

Thats why I think merging Object.defineProperty(exports, "__esModule", { value: true }); into one outfile causes the abort.

Playground Link: Not possible, as we need outfile to trigger the bug.

Related Issues: none found

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
HolgerJeromincommented, Apr 20, 2020

I always interpreted the docs as

The only module loader that can be used in conjunction with --outFile are “AMD” and “System”.

and not as

Only the values “AMD” and “System” can be used in conjunction with --outFile. Even “None” is not allowed.

Waiting for feedback from product owner.

1reaction
HolgerJeromincommented, Mar 26, 2020

Wow. We are using outFile with module=none for over five years without problems.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to properly export an ES6 class in Node 4?
in my case, the display function is not exported unless in the constructor I wrote this.display = display , any idea why? –...
Read more >
ES6 Modules and How to Use Import and Export in JavaScript
You can export members one by one. What's not exported won't be available directly outside the module: export const myNumbers = [ ...
Read more >
export - JavaScript - MDN Web Docs
The export declaration is used to export values from a JavaScript module. Exported values can then be imported into other programs with the ......
Read more >
Export and Import - The Modern JavaScript Tutorial
Please note that export before a class or a function does not make it a ... Modern build tools, such as webpack and...
Read more >
Module Compiler Option in TypeScript - tsmean
What does the module option in the TypeScript compiler options do exactly? Learn what CommonJS, AMD or ES6 actually do.
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