Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed
@dsherret

Description

@dsherret
Issue body actions

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

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

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.