Skip to content

Latest commit

 

History

History
87 lines (58 loc) · 3.18 KB

BUG_REPORT.md

File metadata and controls

87 lines (58 loc) · 3.18 KB

Bug Report

There has been a few issues in the past about TypeScript having problems generating correct results around CJS and default export. But those issues focus on certain aspect of the problem and I couldn't find one that clearly show how big an issue it is.

So I decided to give it a shot and it seems to be worse than I thought.

Here are a few TL;DRs:

When you use export default in your code:

  • The declaration for CJS is incorrect.

When you consume a package that uses export default and transpiled to CJS:

  • module: ES* or Node* does not produce correct code (runtime error)

When using moduleResolution: Node16 or NodeNext:

  • You cannot use allowSyntheticDefaultImports or esModuleInterop, which you must use in Node for packages with export =

Related issues:

microsoft/TypeScript#50501 microsoft/TypeScript#50152 microsoft/TypeScript#41898

🔎 Search Terms

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

Playground link with relevant code

💻 Code

// We can quickly address your report if:
//  - The code sample is short. Nearly all TypeScript bugs can be demonstrated in 20-30 lines of code!
//  - It doesn't use external libraries. These are often issues with the type definitions rather than TypeScript bugs.
//  - The incorrectness of the behavior is readily apparent from reading the sample.
// Reports are slower to investigate if:
//  - We have to pare too much extraneous code.
//  - We have to clone a large repo and validate that the problem isn't elsewhere.
//  - The sample is confusing or doesn't clearly demonstrate what's wrong.

🙁 Actual behavior

🙂 Expected behavior