-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-exporting default
from a dependency in JavaScript produces an invalid declaration file
#55082
Comments
👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of the repro in the issue body running against the nightly TypeScript. Issue body code block by @esdmr 👍 Compiled Historical Information
|
Update on which Symbols:
version 5.1.6
By comparison, here is the tables for version 4.6. version 4.6.4
(script to run these test cases) Edit: version 5.1.6,
|
CJS from CJS | node | node16 | nodenext | bundler |
---|---|---|---|---|
AMD | B | B | B | - |
CommonJS | B | B | B | - |
ES2015 | B | B | B | B |
ES2020 | B | B | B | B |
ES2022 | B | B | B | B |
ESNext | B | B | B | B |
Node16 | B | B | B | - |
NodeNext | B | B | B | - |
System | B | B | B | - |
UMD | B | B | B | - |
CJS from ESM | node | node16 | nodenext | bundler |
---|---|---|---|---|
AMD | B | B | B | - |
CommonJS | B | B | B | - |
ES2015 | B | B | B | B |
ES2020 | B | B | B | B |
ES2022 | B | B | B | B |
ESNext | B | B | B | B |
Node16 | B | B | B | - |
NodeNext | B | B | B | - |
System | B | B | B | - |
UMD | B | B | B | - |
ESM from CJS | node | node16 | nodenext | bundler |
---|---|---|---|---|
AMD | B | - | - | - |
CommonJS | B | - | - | - |
ES2015 | B | - | - | B |
ES2020 | B | - | - | B |
ES2022 | B | - | - | B |
ESNext | B | - | - | B |
Node16 | B | - | - | - |
NodeNext | B | - | - | - |
System | B | - | - | - |
UMD | B | - | - | - |
ESM from ESM | node | node16 | nodenext | bundler |
---|---|---|---|---|
AMD | B | - | ||
CommonJS | B | - | ||
ES2015 | B | B | ||
ES2020 | B | B | ||
ES2022 | B | B | ||
ESNext | B | B | ||
Node16 | B | - | ||
NodeNext | B | - | ||
System | B | - | ||
UMD | B | - |
version 5.1.6, "allowSyntheticDefaultImports": false
CJS from CJS | node | node16 | nodenext | bundler |
---|---|---|---|---|
AMD | - | |||
CommonJS | - | |||
ES2015 | ||||
ES2020 | ||||
ES2022 | ||||
ESNext | ||||
Node16 | - | |||
NodeNext | - | |||
System | - | |||
UMD | - |
CJS from ESM | node | node16 | nodenext | bundler |
---|---|---|---|---|
AMD | B | B | - | |
CommonJS | B | B | - | |
ES2015 | B | B | ||
ES2020 | B | B | ||
ES2022 | B | B | ||
ESNext | B | B | ||
Node16 | B | B | - | |
NodeNext | B | B | - | |
System | B | B | - | |
UMD | B | B | - |
ESM from CJS | node | node16 | nodenext | bundler |
---|---|---|---|---|
AMD | - | - | - | |
CommonJS | - | - | - | |
ES2015 | - | - | ||
ES2020 | - | - | ||
ES2022 | - | - | ||
ESNext | - | - | ||
Node16 | - | - | - | |
NodeNext | - | - | - | |
System | - | - | - | |
UMD | - | - | - |
ESM from ESM | node | node16 | nodenext | bundler |
---|---|---|---|---|
AMD | - | |||
CommonJS | - | |||
ES2015 | ||||
ES2020 | ||||
ES2022 | ||||
ESNext | ||||
Node16 | - | |||
NodeNext | - | |||
System | - | |||
UMD | - |
version 5.1.6, "esModuleInterop": false
and "allowSyntheticDefaultImports"
unset
CJS from CJS | node | node16 | nodenext | bundler |
---|---|---|---|---|
AMD | - | |||
CommonJS | - | |||
ES2015 | B | |||
ES2020 | B | |||
ES2022 | B | |||
ESNext | B | |||
Node16 | - | |||
NodeNext | - | |||
System | B | B | B | - |
UMD | - |
CJS from ESM | node | node16 | nodenext | bundler |
---|---|---|---|---|
AMD | B | B | - | |
CommonJS | B | B | - | |
ES2015 | B | B | B | |
ES2020 | B | B | B | |
ES2022 | B | B | B | |
ESNext | B | B | B | |
Node16 | B | B | - | |
NodeNext | B | B | - | |
System | B | B | B | - |
UMD | B | B | - |
ESM from CJS | node | node16 | nodenext | bundler |
---|---|---|---|---|
AMD | - | - | - | |
CommonJS | - | - | - | |
ES2015 | - | - | B | |
ES2020 | - | - | B | |
ES2022 | - | - | B | |
ESNext | - | - | B | |
Node16 | - | - | - | |
NodeNext | - | - | - | |
System | B | - | - | - |
UMD | - | - | - |
ESM from ESM | node | node16 | nodenext | bundler |
---|---|---|---|---|
AMD | - | |||
CommonJS | - | |||
ES2015 | B | |||
ES2020 | B | |||
ES2022 | B | |||
ESNext | B | |||
Node16 | - | |||
NodeNext | - | |||
System | B | - | ||
UMD | - |
Bug Report
🔎 Search Terms
Re-export, default, declaration,
module.exports
, Identifier expected ts(1003), js, JavaScript.🕗 Version & Regression Information
Bundler
since version5.0
.Node16
/NodeNext
since version4.7
.System
since version3.7
.⏯ Playground Link
Workbench Repro
Switch to the “Debug” tab and look at
/index.d.ts
.@showEmittedFile
did not work.💻 Code
Other cases like this:
(Only the declaration file that re-exports a dependency will be invalid.)
index.js
:export {default} from 'a';
(Declaration file will have as default)
node_modules/a/index.d.ts
may be provided separately (e.g., by a@types/
package).🙁 Actual behavior
Generated
index.d.ts
is invalid because, instead of re-exportingdefault as mod
, it re-exports"/path/to/node_modules/a/index" as mod
. Firstly, there is no export ona/index.js
with that identifier. Secondly, TypeScript does not even support “arbitrary module namespace identifier names” (#40594), so the resulting declaration file cannot be subsequently parsed anyway. (ErrsIdentifier expected. ts(1003)
.)🙂 Expected behavior
Generated
index.d.ts
should simply re-exportdefault as mod
, just like the JavaScript file. Ifnode_modules/a
is ESM, it should err that there is no export nameddefault
.The text was updated successfully, but these errors were encountered: