Skip to content

TsConfig: flatten type errors. "Advanced Type" errors currently often unreadable. #35246

Closed
@SephReed

Description

@SephReed

Search Terms

"Type error read"
"type errors unreadable"

Suggestion

Type checking, and type definitions errors could me made significantly easier to debug by flattening/boiling down the type definitions to something more resembling what developers think of them as.

  1. This first example shows the kind of errors I run into in actual development. It's totally unreadable.

Screen Shot 2019-11-20 at 3 58 27 PM

  1. This second example shows the same effect

Screen Shot 2019-11-20 at 4 02 52 PM

Screen Shot 2019-11-20 at 4 01 34 PM

For this second example, it would be a lot more useful if instead it just showed what the type realistically is, and what it was missing. Ie:

Property "badProp" does not exist on type '{
  requestId: string;
  type: string;
  id?: string;
  createdAt?: Date;
  data?: string;
}'

This would be a really nice thing to add to tsconfig.

Use Cases

Almost 100% of the time one works with advanced types. Anything involving unions or (worst of all) utility types creates a wall of text.

Examples

// ts.config
{
  flattenTypesInMessaging: true
}

(I'll make a habit of posting all my most unreadable messages here)

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

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