-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
Description
TypeScript Version: 3.7.0-dev.20191021
Search Terms:
- declaration
- modules
Code
https://github.com/andyfleming/typescript-module-declaration-mismatch-repro
Expected behavior:
A valid index.d.ts
file should be emitted.
Actual behavior:
The module is declared as "versions.static"
on line 1, but is imported below as "versions.static.js"
on line 10 (and not found).
Steps to reproduce
- Clone https://github.com/andyfleming/typescript-module-declaration-mismatch-repro
- Run
npm install
- Run
npm run generate-types
- Observe declared
"versions.static"
module and import attempt as"versions.static.js"
.
Code from Repo
package.json
{
"name": "@example-org/example-package",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"generate-types": "rm js/index.d.ts && tsc",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/andyfleming/typescript-module-declaration-mismatch-repro.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/andyfleming/typescript-module-declaration-mismatch-repro/issues"
},
"homepage": "https://github.com/andyfleming/typescript-module-declaration-mismatch-repro#readme",
"devDependencies": {
"typescript": "3.7.0-dev.20191021"
}
}
tsconfig.json
/* Generated with tsc --init via TypeScript 3.7.0-beta */
{
"compilerOptions": {
"module": "commonjs",
"allowJs": true,
"declaration": true,
"outFile": "./js/index.js",
"emitDeclarationOnly": true,
"strict": true,
"esModuleInterop": true
},
"include": [
"js/**/*"
]
}
js/index.js
import versions from './versions.static.js';
export {
versions
};
js/versions.static.js
export default {
"@a/b": "1.0.0",
"@a/c": "1.2.3"
};
js/index.d.ts (sample output)
declare module "versions.static" { // <-- declared one way here
var _default: {
"@a/b": string;
"@a/c": string;
};
export default _default;
}
declare module "index" {
export { versions };
import versions from "versions.static.js"; // <-- and different way here
}
Metadata
Metadata
Assignees
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone