-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts filesFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.4.1
Code
src/foo.ts:
const foo = { bar: 'hello' };
export { foo };src/index.ts:
import { foo } from './foo';
export { foo };
const { bar: baz } = foo;
export { baz };package.json:
{
"name": "ts-declaration",
"version": "1.0.0",
"private": true,
"main": "dist/index.js",
"scripts": {
"build": "tsc"
},
"devDependencies": {
"typescript": "^2.4.1"
}
}tsconfig.json:
{
"compilerOptions": {
"module": "es2015",
"moduleResolution": "node",
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"strictNullChecks": true,
"target": "es5",
"outDir": "dist/",
"declaration": true
},
"exclude": [
"node_modules"
]
}Run $ npm install && npm run build.
Expected behavior:
dist/foo.d.ts:
declare const foo: {
bar: string;
};
export { foo };dist/index.d.ts:
import { foo } from './foo';
export { foo };
declare const baz: string;
export { baz };Actual behavior:
dist/foo.d.ts:
declare const foo: {
bar: string;
};
export { foo };dist/index.d.ts:
import { foo } from './foo';
export { foo };
export { baz }; // ERROR: Cannot find name `'baz'`.Note:
This would fail, too:
const { bar } = foo;
export { bar };This works:
const baz = foo.bar;
export { baz };Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts filesFixedA PR has been merged for this issueA PR has been merged for this issue