Closed
Description
π Search Terms
moduleDetection force legacy
π Version & Regression Information
- This changed in version 5.5-beta
β― Playground Link
No response
π» Code
package.json:
{
"name": "ts-test",
"version": "1.0.0",
"description": "",
"type": "commonjs",
"devDependencies": {
"typescript": "^5.5.0-beta"
}
}
tsconfig.json:
{
"include": ["src/index.ts"],
"compilerOptions": {
"module": "Preserve",
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"emitDeclarationOnly": true,
"declaration": true,
"declarationDir": "./dts"
}
}
src/index.ts:
export let a = 1;
π Actual behavior
src/index.ts:1:1 - error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled.
1 export let a = 1;
π Expected behavior
Given that I'm using "moduleDetection": "force"
, that file is an ES module (regardless of what package.json#type
says) and thus I shouldn't see that error. This was the behavior in 5.4.
Additional information about the issue
No response