Skip to content

[3.9] Complex types truncated in declaration files #38557

@ostrowr

Description

@ostrowr

TypeScript Version: 3.9.0+ (works in 3.8.x, broken in 3.9.x, 4.0.x)

Search Terms:
truncated, "...", declaration

Code

I'm still working on getting a scoped repro here, and will update this ticket when I have one. But – in TS 3.8 (and earlier), I have a complex type that produces the following code in a .d.ts file:

<-snip->
removed: (import("ts-json-validator/dist/json-schema").JsonValue[] & {
                [k: string]: unknown;
            }[]) | (import("ts-json-validator/dist/json-schema").JsonValue[] & {
                [k: string]: unknown;
            }[] & string) | (import("ts-json-validator/dist/json-schema").JsonValue[] & {
                [k: string]: unknown;
            }[] & number) | (import("ts-json-validator/dist/json-schema").JsonValue[] & {
                [k: string]: unknown;
            }[] & false) | (import("ts-json-validator/dist/json-schema").JsonValue[] & {
                [k: string]: unknown;
            }[] & true) | (import("ts-json-validator/dist/json-schema").JsonValue[] & {
                [k: string]: unknown;
            }[] & {
                [property: string]: import("ts-json-validator/dist/json-schema").JsonValue;
            }) | (import("ts-json-validator/dist/json-schema").JsonValue[] & {
                [k: string]: unknown;
            }[] & readonly import("ts-json-validator/dist/json-schema").JsonValue[]);
<-snip->

In 3.9+, this gets truncated as though we're in an editor environment:

removed: (import("ts-json-validator/dist/json-schema").JsonValue[] & {
                [k: string]: unknown;
            }[]) | (import("ts-json-validator/dist/json-schema").JsonValue[] & {
                ...;
            }[] & string) | ... 4 more ... | (import("ts-json-validator/dist/json-schema").JsonValue[] & ... 1 more ... & readonly import("ts-json-validator/dist/json-schema").JsonValue[]);

Expected behavior:
Types aren't truncated in .d.ts files

Actual behavior:
Types are truncated, producing syntactically invalid .d.ts files

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions