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

Enum member used in computed property name leads to compile error when using outputted .d.ts file #19704

Closed
dsherret opened this issue Nov 3, 2017 · 1 comment
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

@dsherret
Copy link
Contributor

dsherret commented Nov 3, 2017

TypeScript Version: 2.7.0-dev.20171102

Code

// test.ts
import * as ts from "typescript";

export const someVar = {
    [ts.SyntaxKind.SourceFile]: ""
};

Compile with: tsc test.ts --declaration --module commonjs

Expected behavior:

Expect the declaration file to export as it did in TS 2.5.3:

export declare const someVar: {
    [key: number]: string;
};

...or at least throw a compile error when compiling with --declaration.

Actual behavior:

export declare const someVar: {
    [ts.SyntaxKind.SourceFile]: string;
};

No compile error.

Another example

Here's another example that doesn't error with --declaration, even though I'm using a private name:

// test.ts
enum MyEnum {
    member = 0
}

export const someVar = {
    [MyEnum.member]: ""
};

// output: test.d.ts (and no compile error)
export const someVar = {
    [MyEnum.member]: string
};
@dsherret dsherret changed the title Enum used in computed property leads to compile error when using outputted .d.ts file Enum member used in computed property leads to compile error when using outputted .d.ts file Nov 3, 2017
@dsherret dsherret changed the title Enum member used in computed property leads to compile error when using outputted .d.ts file Enum member used in computed property name leads to compile error when using outputted .d.ts file Nov 3, 2017
@mhegazy mhegazy added Domain: Declaration Emit The issue relates to the emission of d.ts files Bug A bug in TypeScript labels Nov 3, 2017
@mhegazy mhegazy added this to the TypeScript 2.7 milestone Nov 3, 2017
@weswigham weswigham added this to In Review in Rolling Work Tracking Nov 13, 2017
@weswigham
Copy link
Member

This should be fixed in master, now that #15473 is merged.

@weswigham weswigham added the Fixed A PR has been merged for this issue label Nov 20, 2017
@weswigham weswigham removed this from In Review in Rolling Work Tracking Dec 15, 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