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.

Better display representation for intersection types

See original GitHub issue

I’m not sure if this has been discussed before, but join types are mostly unreadable. I think the type should be prettified somehow before being displayed to the user.

TypeScript Version:

1.8

Code

type T1 = {};
type T2 = {test: number};
type J = T1 & T2;

Expected behavior:

var x: J;
typeof x; // {test: number}

Actual behavior:

var x: J;
typeof x; // {} & {test: number}

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
louycommented, Apr 13, 2016

The second actually.

0reactions
RyanCavanaughcommented, May 9, 2016

Accepting PRs, with a big caveat. This is actually quite a bit trickier than it appears because of how the compiler handles anonymous self-referential types. A PR here should be accompanied by a large test suite of recursively self-referential types to ensure there aren’t any lingering runaway recursion bugs.

See also comments in #8228.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Discussion: Union and Intersection types #399 - GitHub
In my opinion, Union types will be more useful and hence should be looked into at ... for mapping between the structures and...
Read more >
Is it possible to display the full computed type of a typescript ...
Similarly, if you have an intersection of two types then sometimes it will just display it as Type1 & Type2 instead of displaying...
Read more >
[1911.01899] Non-idempotent intersection types in logical form
Abstract: Intersection types are an essential tool in the analysis of operational and denotational properties of lambda-terms and functional ...
Read more >
Pregrammars and Intersection Types - DROPS
A representation of intersection types in terms of pregrammars is presented. Pregrammar based rewriting relations, corresponding respectively to type ...
Read more >
Signalized Intersections Informational Guide, Second Edition
Provide bike lanes. Intersection-Wide. Treatments. (Chapter 9). • Modify stop line location. • Improve pedestrian signal display. • Modify pedestrian signal.
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