Closed
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 };