Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting full inferred type with TypeScript 3.0?

Tags:

typescript

In TS 2.9, I could get the full inferred type of an identifier by hovering over it, and waiting for the tooltip to pop up.

It appears that the behaviour changed in TS 3.0, and it's affecting my productivity; it only shows part of the inferred type and truncates the rest with ellipsis.

Is there any way I can get back the TS 2.9 behaviour of showing the full type without any truncation whatsoever?

Maybe a tsconfig.json flag of some sort.


In TS 2.9,

    /*snip*/
    __canAccept: {
        page?: string | number | null | undefined;
        itemsPerPage?: string | number | null | undefined;
    };
}

In TS 3.0,

    /*snip*/
    __canAccept: {
        ...;
    };
}
like image 528
Justin AnyhowStep Avatar asked Sep 16 '25 06:09

Justin AnyhowStep


1 Answers

It seems like the solution is to set noErrorTruncation to true, and then restart VS code (or your editor of choice)

I don't know why I didn't try this sooner.

I also don't know why this works because the inferred types in the tooltip aren't "errors" at all.


[EDIT]

This actually doesn't work.

This affects tooltips and declaration emits.

The only solution I can see is to just wait till this is fixed in a future version of TS.

like image 172
Justin AnyhowStep Avatar answered Sep 19 '25 14:09

Justin AnyhowStep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!