Skip to content

Conversation

ahejlsberg
Copy link
Member

@ahejlsberg ahejlsberg commented Oct 27, 2020

We currently remove template literals from intersections containing matching string literals. For example `foo${string}` & 'foox' is reduced to just 'foox'. We also need to perform the complementary reduction for union types, i.e. `foo${string}` | 'foox' should reduce to just `foo${string}`. This PR adds that functionality.

The following now produces no errors:

var x: '0';
var x: '0' & `${number}`;

var y: `${number}`;
var y: `${number}` | '0';  // Ok, previously was error

See also #40598.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 27, 2020
@ahejlsberg ahejlsberg added this to the TypeScript 4.1.1 milestone Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants