Skip to content

Incorrect namespace error when generating declarations #24632

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

Closed
WearyMonkey opened this issue Jun 3, 2018 · 1 comment
Closed

Incorrect namespace error when generating declarations #24632

WearyMonkey opened this issue Jun 3, 2018 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files

Comments

@WearyMonkey
Copy link

TypeScript Version: 3.0.0-dev.20180602

Search Terms:

Cannot find namespace, declaration, TS2503

Code

yarn add typescript@next
yarn tsc -- src/foo.ts --declaration
const Foo = {
  BANANA: 'banana' as 'banana',
}

export const Baa = {
  [Foo.BANANA]: 1
};

Expected behavior:

No error.

Actual behavior:

src/foo.ts:6:4 - error TS2503: Cannot find namespace 'Foo'.

6   [Foo.BANANA]: 1
     ~~~


error Command failed with exit code 2.

Omitting the --declaration option results in no error.
Ommiting the cast results in no error.

Playground Link:

Related Issues:

#24432

@WearyMonkey
Copy link
Author

WearyMonkey commented Jun 3, 2018

Casting the key expression back to a string also resolves the issue:

export const Baa = {
  [Foo.BANANA as string]: 1
};

@mhegazy mhegazy added the Bug A bug in TypeScript label Jun 4, 2018
@mhegazy mhegazy added this to the TypeScript 3.0 milestone Jun 4, 2018
@mhegazy mhegazy added the Domain: Declaration Emit The issue relates to the emission of d.ts files label Jun 4, 2018
@mhegazy mhegazy modified the milestones: TypeScript 3.0, TypeScript 3.1 Jul 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files
Projects
None yet
Development

No branches or pull requests

3 participants