Skip to content

3.1.X and @next emitting declaration file with initializer in ambient context #28230

@southpolesteve

Description

@southpolesteve

TypeScript Version: [email protected]

Search Terms:
"ambient context", "ambient context initializer", "ambient context public static"

Code

export class Foo {
  public static readonly bar = 0;
  public baz = 0;
}

Expected behavior:

Typescript emits a definition file without initializers:

export declare class Foo {
    static readonly bar: number;
    baz: number;
}

This is the output created by [email protected]

Actual behavior:

Typescript emits a definition file with initializer:

export declare class Foo {
    static readonly bar = 0;
    baz: number;
}

Playground Link:
https://www.typescriptlang.org/play/#src=export%20declare%20class%20Foo%20%7B%0D%0A%20%20%20%20static%20readonly%20bar%20%3D%200%3B%0D%0A%20%20%20%20baz%3A%20number%3B%0D%0A%7D

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions