Setting noErrorTruncation to false truncates inferred type of variables/functions; which are not errors
See original GitHub issueTypeScript Version: 3.0.1
Search Terms: noErrorTruncation
In TS 2.9, if noErrorTruncation
is unset, or set to false
, hovering the cursor over an identifier for type inference in VS code would bring up a tooltip with the inferred type.
In TS 3.0, if noErrorTruncation
is unset, or set to false
, the tooltip with the inferred type will be truncated with ellipsis.
Code
TS 2.9, with noErrorTruncation : false
/*snip*/
__canAccept: {
page?: string | number | null | undefined;
itemsPerPage?: string | number | null | undefined;
};
}
TS 3.0 with noErrorTruncation : false
/*snip*/
__canAccept: {
...;
};
}
Expected behavior:
noErrorTruncation
is about truncating errors.
The tooltips displaying inferred types aren’t errors, and should not be affected by this flag.
Actual behavior:
noErrorTruncation
affects tooltips displaying inferred types.
If anyone else is having this problem, just go to your tsconfig.json
, add the following line,
"noErrorTruncation": true,
and restart VS code (or your editor of choice)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:49
- Comments:19 (3 by maintainers)
Having this problem as well. Investigating and debugging this issue led me to find this being introduced in merge https://github.com/microsoft/TypeScript/pull/24258.
Typescript starts truncating the output when it reaches the default hard-limit of
160 * 10
characters to prevent the server from hanging too long, even with"noErrorTruncation": true
set. There’s currently no option for VS Code to disable it from the looks of it: https://github.com/microsoft/TypeScript/blob/57e2fe0462bb897e581aa489f1d6040db559d82b/src/services/utilities.ts#L1993For people using VS Code, a quick fix would be opening
<Microsoft VS Code install folder>/resources/app/extensions/node_modules/typescript/lib/tsserver.js
and changets.defaultMaximumTruncationLength = 160
at around line 12797 to something higher likets.defaultMaximumTruncationLength = 800
.It’s not just CI, it’s usability problem. I actually like browsing (and copying) the type from the hover tip in the VSCode, and when it gets truncated it’s pretty much useless.