Skip to content

Declaration emit widens literal types in readonly properties #15881

Description

@evmar

TypeScript Version: 2.3.1
Code

$ cat > foo.ts
export const FOO = 'FOO';
export class Bar { readonly type = FOO; }
$ tsc --declaration foo.ts
$ cat foo.d.ts
export declare const FOO = "FOO";
export declare class Bar {
    readonly type: string;
}

EDIT: added readonly to clarify bug report

Expected behavior:
Bar.type is of type "FOO"

Actual behavior:
The type falls back to string

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts files

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions