Skip to content

[BUG] In the generated description file, the class type does not check the implemented interface. #26555

@ZSkycat

Description

@ZSkycat

TypeScript Version: 3.1.0-dev.20180818

Search Terms: description file class type interface implements

Code

export type LibObjectType = 'Circle' | 'Square';

export interface LibObject {
    readonly type: LibObjectType;
    readonly id: number;
}

export class LibCircle implements LibObject {
    readonly type = 'Circle';
    readonly id: number = Date.now();
}

export class LibSquare implements LibObject {
    readonly type = 'Square';
    readonly id: number = Date.now();
}

Expected behavior:

// index.d.ts
export declare class LibCircle implements LibObject {
    readonly type: 'Circle';
    readonly id: number;
}

image

Actual behavior:

// index.d.ts
export declare class LibCircle implements LibObject {
    readonly type: string;
    readonly id: number;
}

image

Playground Link:
https://github.com/ZSkycat/issue-typescript-20180821-1

Related Issues:

Metadata

Metadata

Assignees

Labels

DuplicateAn existing issue was already created

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions