question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting noErrorTruncation to false truncates inferred type of variables/functions; which are not errors

See original GitHub issue

TypeScript 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:open
  • Created 5 years ago
  • Reactions:49
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

125reactions
Hati-commented, Aug 11, 2020

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#L1993

For 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 change ts.defaultMaximumTruncationLength = 160 at around line 12797 to something higher like ts.defaultMaximumTruncationLength = 800.

23reactions
Cianticcommented, Feb 24, 2020

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.

image

// from https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/intro-to-tweet-json
let foo = {
  "text": "My added comments to this Tweet ---> https:\/\/t.co\/LinkToTweet",
  "user": {
    "screen_name": "TweetQuoter"
  },
  "quoted_status": {
    "text": "original message",
    "user": {
      "screen_name": "OriginalTweeter"
    },
    "place": {      
    },
    "entities": {      
    },
    "extended_entities": {      
    }
  },
  "place": {    
  },
    "entities": {
      "hashtags": [

      ],
      "urls": [
        {
          "url": "https://t.co/W1FqVrsjQk",
          "expanded_url": "https://twittercommunity.com/t/rt-with-comment-aka-quote-tweets-now-may-have-media-attached-across-twitter-apis/125539",
          "display_url": "twittercommunity.com/t/rt-with-comm…",
          "unwound": {
            "url": "https://twittercommunity.com/t/rt-with-comment-aka-quote-tweets-now-may-have-media-attached-across-twitter-apis/125539",
            "status": 200,
            "title": "RT with comment, aka Quote Tweets, now may have media attached across Twitter APIs",
            "description": "Today we’re announcing a new feature that allows userspeople on Twitter to add a GIF, video, or photo to their Retweet with comments, aka Quote Tweets. Developers will start to see additional media metadata included in the payload for Quote Tweets. Quote Tweets with media will be rendered very similarly to Tweets with media across our APIs. This rendering is an addition to the existing media field, so this should not be a breaking change for application owners, if they are already ingesting med..."
          },
          "indices": [
            162,
            185
          ]
        },
        {
          "url": "https://t.co/lXs26mCkIl",
          "expanded_url": "https://twitter.com/TwitterSupport/status/1125479034513645569",
          "display_url": "twitter.com/TwitterSupport…",
          "indices": [
            186,
            209
          ]
        }
      ],
      "user_mentions": [

      ],
      "symbols": [

      ],
      "media": [
        {
          "id": 1125490782532657153,
          "id_str": "1125490782532657153",
          "indices": [
            210,
            233
          ],
          "media_url": "http://pbs.twimg.com/tweet_video_thumb/D56L51LV4AEEC8-.jpg",
          "media_url_https": "https://pbs.twimg.com/tweet_video_thumb/D56L51LV4AEEC8-.jpg",
          "url": "https://t.co/T9MBCHZWcD",
          "display_url": "pic.twitter.com/T9MBCHZWcD",
          "expanded_url": "https://twitter.com/TwitterDev/status/1125490788736032770/photo/1",
          "type": "animated_gif",
          "video_info": {
            "aspect_ratio": [
              101,
              165
            ],
            "variants": [
              {
                "bitrate": 0,
                "content_type": "video/mp4",
                "url": "https://video.twimg.com/tweet_video/D56L51LV4AEEC8-.mp4"
              }
            ]
          },
          "sizes": {
            "thumb": {
              "w": 150,
              "h": 150,
              "resize": "crop"
            },
            "small": {
              "w": 202,
              "h": 330,
              "resize": "fit"
            },
            "large": {
              "w": 202,
              "h": 330,
              "resize": "fit"
            },
            "medium": {
              "w": 202,
              "h": 330,
              "resize": "fit"
            }
          }
        }
      ]
    },
    "extended_entities": {
      "media": [
        {
          "id": 1125490782532657153,
          "id_str": "1125490782532657153",
          "indices": [
            210,
            233
          ],
          "media_url": "http://pbs.twimg.com/tweet_video_thumb/D56L51LV4AEEC8-.jpg",
          "media_url_https": "https://pbs.twimg.com/tweet_video_thumb/D56L51LV4AEEC8-.jpg",
          "url": "https://t.co/T9MBCHZWcD",
          "display_url": "pic.twitter.com/T9MBCHZWcD",
          "expanded_url": "https://twitter.com/TwitterDev/status/1125490788736032770/photo/1",
          "type": "animated_gif",
          "video_info": {
            "aspect_ratio": [
              101,
              165
            ],
            "variants": [
              {
                "bitrate": 0,
                "content_type": "video/mp4",
                "url": "https://video.twimg.com/tweet_video/D56L51LV4AEEC8-.mp4"
              }
            ]
          },
          "sizes": {
            "thumb": {
              "w": 150,
              "h": 150,
              "resize": "crop"
            },
            "small": {
              "w": 202,
              "h": 330,
              "resize": "fit"
            },
            "large": {
              "w": 202,
              "h": 330,
              "resize": "fit"
            },
            "medium": {
              "w": 202,
              "h": 330,
              "resize": "fit"
            }
          }
        }
      ]
    }
  };
Read more comments on GitHub >

github_iconTop Results From Across the Web

TSConfig Option: noErrorTruncation - TypeScript
TSConfig. noErrorTruncation ... How TypeScript infers types based on runtime behavior. Variable Declarations ... All the configuration options for a project.
Read more >
How to get compiler error messages with complete imports in ...
You can add the option to not truncate in your tsconfig.json : "noErrorTruncation": true. The compiler options page does not offer a lot...
Read more >
https://raw.githubusercontent.com/Microsoft/TypeSc...
In general cancelling is *not* safe for the type checker. ... serializedTypes?.set(key, { node: result, truncating: context.truncating, ...
Read more >
TypeScript errors and how to fix them
A list of common TypeScript errors and how to fix them.
Read more >
Compiler Options - TypeScript - JavaScript that scales.
Option Type Default ‑‑allowJs boolean false ‑‑allowSyntheticDefaultImports boolean module === "system" or ‑‑esModuleInterop ‑‑allowUmdGlobalAccess boolean false
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found