Skip to content
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

Missing exports in declarations, when destructing is used #17085

Closed
donaldpipowitch opened this issue Jul 11, 2017 · 0 comments
Closed

Missing exports in declarations, when destructing is used #17085

donaldpipowitch opened this issue Jul 11, 2017 · 0 comments
Assignees
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Fixed A PR has been merged for this issue

Comments

@donaldpipowitch
Copy link
Contributor

donaldpipowitch commented Jul 11, 2017

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 };
@donaldpipowitch donaldpipowitch changed the title Missing exports in declarations Missing exports in declarations, when destructing is used Jul 11, 2017
@mhegazy mhegazy added Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files labels Aug 23, 2017
@mhegazy mhegazy modified the milestone: TypeScript 2.6 Sep 1, 2017
@mhegazy mhegazy modified the milestones: TypeScript 2.6, TypeScript 2.7 Oct 9, 2017
weswigham added a commit to weswigham/TypeScript that referenced this issue Nov 17, 2017
weswigham added a commit to weswigham/TypeScript that referenced this issue Nov 17, 2017
weswigham added a commit that referenced this issue Nov 21, 2017
* Do visibility painting from collectLinkedAliases in checker to remove statefullness in declaration emit

* Fix #17085

* Add deeply destructured array to test

* Add test case for #18634

* Add PR feedback
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Nov 21, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants