GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Template literal types for template literal expressions by ahejlsberg · Pull Request #41891 · microsoft/TypeScript

Conversation

@ahejlsberg

@ahejlsberg Anders Hejlsberg (ahejlsberg) commented Dec 9, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

With this PR we infer template literal types for template literal expressions. The PR adheres to the same principles as those of literal types in #10676 and widening vs. non-widening literal types in #11126. For example:

const n: number = 123;
const s1 = `${n}px`;  // `${number}px`
const s2: `${number}px` = s1;
const s3: `${number}pt` = s1;  // Error
let v1 = s1;  // string (because of widening)

As it is generally a breaking change for us to more strongly type anything, I'm marking this as a breaking change. In practice, the breaks appear to be rare and easy to fix.

Fixes #41631.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

NN---, KisaragiEffective, ExE-Boss, emmiep, forrest-lee, Hental, 0f-0b, 0kku, fvilante, jaskp, and 5 more reacted with thumbs up emoji AlCalzone, harrysolovay, ExE-Boss, fvilante, and VitorLuizC reacted with hooray emoji
All reactions
  • 👍 15 reactions
  • 🎉 5 reactions
Anders Hejlsberg (ahejlsberg) added 7 commits December 8, 2020 12:36
@ahejlsberg
Infer template literal types for template literal expressions
eda291d
@ahejlsberg
Update test
4acf495
@ahejlsberg
Update another test
537fd37
@ahejlsberg
Accept new baselines
e88ceca
@ahejlsberg
Minor fixes
e35c42e
@ahejlsberg
Add tests
dfd760d
@ahejlsberg
Accept new baselines
54c3be9
@typescript-bot TypeScript Bot (typescript-bot) assigned Anders Hejlsberg (ahejlsberg) Dec 9, 2020
@typescript-bot TypeScript Bot (typescript-bot) added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Dec 9, 2020
@ahejlsberg
Anders Hejlsberg (ahejlsberg) requested review from Daniel Rosenwasser (DanielRosenwasser), Ryan Cavanaugh (RyanCavanaugh) and Wesley Wigham (weswigham) December 9, 2020 04:00
This was referenced Dec 9, 2020
Try to preserve template-ness of string literal types where possible #41631
Closed
Template Literal Type - Does not evaluate interpolated template strings against type definition #41732
Closed
DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) requested changes Dec 9, 2020
View reviewed changes

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation looks good apart from the API stuff.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/compiler/types.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/compiler/types.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/baselines/reference/emitExponentiationOperatorInTempalteString4.types Resolved

Uh oh!

There was an error while loading. Please reload this page.

Anders Hejlsberg (ahejlsberg) added 2 commits December 9, 2020 06:20
@ahejlsberg
Make new TypeFlags internal
afcfd9c
@ahejlsberg
Accept new API baselines
96885c3
@ahejlsberg

Anders Hejlsberg (ahejlsberg) commented Dec 9, 2020

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) test this
TypeScript Bot (@typescript-bot) user test this
TypeScript Bot (@typescript-bot) run dt
TypeScript Bot (@typescript-bot) perf test this

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 9, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 96885c3. You can monitor the build here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 9, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the perf test suite on this PR at 96885c3. You can monitor the build here.

Update: The results are in!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 9, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at 96885c3. You can monitor the build here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 9, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized community code test suite on this PR at 96885c3. You can monitor the build here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot TypeScript Bot (typescript-bot) mentioned this pull request Dec 9, 2020
🤖 User test baselines have changed for fix41631 typescript-bot/TypeScript#112
Open
@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 9, 2020

Copy link
Copy Markdown
Contributor

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 9, 2020

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg)
The results of the perf run you requested are in!

Here they are:

Comparison Report - master..41891

Metric master 41891 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 344,449k (± 0.02%) 345,034k (± 0.02%) +584k (+ 0.17%) 344,903k 345,188k
Parse Time 1.99s (± 0.73%) 1.98s (± 0.53%) -0.01s (- 0.25%) 1.96s 2.01s
Bind Time 0.83s (± 0.41%) 0.83s (± 0.81%) 0.00s ( 0.00%) 0.82s 0.85s
Check Time 4.95s (± 0.50%) 4.97s (± 0.43%) +0.02s (+ 0.44%) 4.94s 5.02s
Emit Time 5.32s (± 0.51%) 5.34s (± 0.56%) +0.02s (+ 0.39%) 5.28s 5.43s
Total Time 13.08s (± 0.33%) 13.12s (± 0.40%) +0.04s (+ 0.31%) 13.04s 13.26s
Compiler-Unions - node (v10.16.3, x64)
Memory used 205,378k (± 0.02%) 205,380k (± 0.07%) +1k (+ 0.00%) 204,860k 205,516k
Parse Time 0.79s (± 0.92%) 0.79s (± 0.74%) -0.00s (- 0.63%) 0.78s 0.80s
Bind Time 0.50s (± 1.17%) 0.50s (± 1.17%) 0.00s ( 0.00%) 0.49s 0.51s
Check Time 11.87s (± 0.43%) 12.00s (± 0.62%) +0.13s (+ 1.05%) 11.79s 12.15s
Emit Time 2.33s (± 1.05%) 2.36s (± 1.19%) +0.03s (+ 1.38%) 2.30s 2.44s
Total Time 15.49s (± 0.42%) 15.64s (± 0.59%) +0.15s (+ 0.97%) 15.38s 15.84s
Monaco - node (v10.16.3, x64)
Memory used 354,918k (± 0.02%) 354,811k (± 0.02%) -108k (- 0.03%) 354,579k 354,965k
Parse Time 1.60s (± 0.51%) 1.60s (± 0.63%) -0.01s (- 0.44%) 1.57s 1.61s
Bind Time 0.72s (± 0.83%) 0.73s (± 0.84%) +0.01s (+ 0.83%) 0.72s 0.74s
Check Time 5.09s (± 0.28%) 5.12s (± 0.49%) +0.04s (+ 0.73%) 5.07s 5.16s
Emit Time 2.80s (± 0.67%) 2.80s (± 0.55%) 0.00s ( 0.00%) 2.78s 2.84s
Total Time 10.22s (± 0.25%) 10.25s (± 0.37%) +0.04s (+ 0.35%) 10.15s 10.33s
TFS - node (v10.16.3, x64)
Memory used 307,937k (± 0.03%) 307,862k (± 0.02%) -75k (- 0.02%) 307,714k 308,015k
Parse Time 1.24s (± 0.59%) 1.24s (± 0.48%) -0.00s (- 0.24%) 1.22s 1.25s
Bind Time 0.67s (± 1.23%) 0.68s (± 0.85%) +0.01s (+ 0.89%) 0.67s 0.69s
Check Time 4.58s (± 0.54%) 4.59s (± 0.27%) +0.00s (+ 0.07%) 4.56s 4.62s
Emit Time 2.93s (± 0.96%) 2.95s (± 0.63%) +0.02s (+ 0.65%) 2.92s 3.01s
Total Time 9.43s (± 0.32%) 9.45s (± 0.28%) +0.02s (+ 0.25%) 9.41s 9.54s
material-ui - node (v10.16.3, x64)
Memory used 489,542k (± 0.01%) 489,806k (± 0.02%) +264k (+ 0.05%) 489,643k 489,947k
Parse Time 2.06s (± 0.63%) 2.05s (± 0.54%) -0.00s (- 0.10%) 2.03s 2.08s
Bind Time 0.65s (± 0.99%) 0.65s (± 1.03%) -0.01s (- 0.77%) 0.63s 0.66s
Check Time 13.56s (± 0.51%) 13.54s (± 0.47%) -0.02s (- 0.17%) 13.43s 13.73s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.26s (± 0.43%) 16.23s (± 0.40%) -0.03s (- 0.18%) 16.12s 16.43s
Angular - node (v12.1.0, x64)
Memory used 322,311k (± 0.02%) 322,786k (± 0.04%) +475k (+ 0.15%) 322,385k 323,011k
Parse Time 1.96s (± 0.48%) 1.96s (± 0.70%) +0.01s (+ 0.31%) 1.94s 2.01s
Bind Time 0.81s (± 0.69%) 0.81s (± 1.23%) +0.01s (+ 0.62%) 0.79s 0.84s
Check Time 4.87s (± 0.36%) 4.92s (± 1.02%) +0.05s (+ 1.03%) 4.84s 5.10s
Emit Time 5.48s (± 0.76%) 5.47s (± 0.44%) -0.01s (- 0.09%) 5.44s 5.54s
Total Time 13.11s (± 0.39%) 13.17s (± 0.51%) +0.06s (+ 0.42%) 13.07s 13.40s
Compiler-Unions - node (v12.1.0, x64)
Memory used 191,517k (± 0.05%) 191,391k (± 0.10%) -126k (- 0.07%) 190,988k 191,625k
Parse Time 0.77s (± 0.52%) 0.77s (± 0.62%) +0.00s (+ 0.52%) 0.76s 0.78s
Bind Time 0.49s (± 1.01%) 0.50s (± 0.60%) +0.00s (+ 0.61%) 0.49s 0.50s
Check Time 10.63s (± 0.81%) 10.68s (± 0.69%) +0.05s (+ 0.47%) 10.54s 10.85s
Emit Time 2.35s (± 0.41%) 2.35s (± 1.16%) +0.00s (+ 0.13%) 2.30s 2.41s
Total Time 14.25s (± 0.57%) 14.30s (± 0.51%) +0.06s (+ 0.40%) 14.18s 14.51s
Monaco - node (v12.1.0, x64)
Memory used 336,986k (± 0.02%) 336,973k (± 0.02%) -12k (- 0.00%) 336,809k 337,146k
Parse Time 1.57s (± 0.79%) 1.58s (± 0.73%) +0.01s (+ 0.45%) 1.56s 1.62s
Bind Time 0.71s (± 0.91%) 0.71s (± 0.87%) +0.00s (+ 0.14%) 0.70s 0.72s
Check Time 4.90s (± 0.41%) 4.90s (± 0.35%) +0.01s (+ 0.16%) 4.86s 4.95s
Emit Time 2.86s (± 0.62%) 2.86s (± 0.87%) -0.00s (- 0.07%) 2.83s 2.94s
Total Time 10.04s (± 0.34%) 10.05s (± 0.38%) +0.01s (+ 0.14%) 9.96s 10.13s
TFS - node (v12.1.0, x64)
Memory used 292,164k (± 0.02%) 292,154k (± 0.01%) -10k (- 0.00%) 292,081k 292,264k
Parse Time 1.24s (± 0.45%) 1.25s (± 0.53%) +0.01s (+ 0.64%) 1.24s 1.27s
Bind Time 0.65s (± 0.91%) 0.65s (± 1.26%) 0.00s ( 0.00%) 0.64s 0.68s
Check Time 4.49s (± 0.77%) 4.51s (± 0.54%) +0.01s (+ 0.31%) 4.46s 4.57s
Emit Time 2.96s (± 0.64%) 2.98s (± 0.62%) +0.02s (+ 0.68%) 2.92s 3.00s
Total Time 9.34s (± 0.57%) 9.39s (± 0.42%) +0.05s (+ 0.49%) 9.31s 9.46s
material-ui - node (v12.1.0, x64)
Memory used 467,478k (± 0.05%) 467,354k (± 0.09%) -124k (- 0.03%) 466,592k 467,968k
Parse Time 2.07s (± 0.39%) 2.07s (± 0.42%) -0.00s (- 0.10%) 2.05s 2.09s
Bind Time 0.64s (± 0.73%) 0.65s (± 0.90%) +0.01s (+ 1.09%) 0.63s 0.66s
Check Time 11.97s (± 0.42%) 12.25s (± 1.43%) +0.28s (+ 2.36%) 11.89s 12.62s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 14.68s (± 0.35%) 14.97s (± 1.21%) +0.29s (+ 1.95%) 14.61s 15.33s
Angular - node (v8.9.0, x64)
Memory used 347,151k (± 0.02%) 347,682k (± 0.01%) +531k (+ 0.15%) 347,601k 347,787k
Parse Time 2.51s (± 0.34%) 2.51s (± 0.53%) +0.00s (+ 0.16%) 2.49s 2.55s
Bind Time 0.86s (± 0.67%) 0.86s (± 0.81%) +0.00s (+ 0.12%) 0.84s 0.87s
Check Time 5.60s (± 0.58%) 5.61s (± 0.34%) +0.01s (+ 0.25%) 5.55s 5.64s
Emit Time 6.29s (± 1.68%) 6.36s (± 0.69%) +0.07s (+ 1.13%) 6.26s 6.45s
Total Time 15.26s (± 0.84%) 15.35s (± 0.37%) +0.09s (+ 0.59%) 15.22s 15.47s
Compiler-Unions - node (v8.9.0, x64)
Memory used 213,067k (± 0.02%) 213,162k (± 0.02%) +94k (+ 0.04%) 213,041k 213,329k
Parse Time 0.95s (± 0.78%) 0.95s (± 0.23%) +0.00s (+ 0.11%) 0.95s 0.96s
Bind Time 0.57s (± 1.17%) 0.57s (± 1.27%) +0.00s (+ 0.35%) 0.56s 0.59s
Check Time 14.51s (± 0.91%) 14.57s (± 0.73%) +0.06s (+ 0.43%) 14.33s 14.74s
Emit Time 2.75s (± 1.87%) 2.72s (± 2.02%) -0.03s (- 0.95%) 2.59s 2.78s
Total Time 18.77s (± 0.88%) 18.82s (± 0.76%) +0.04s (+ 0.22%) 18.55s 19.00s
Monaco - node (v8.9.0, x64)
Memory used 358,757k (± 0.01%) 358,739k (± 0.01%) -18k (- 0.01%) 358,628k 358,845k
Parse Time 1.93s (± 0.40%) 1.93s (± 0.39%) -0.00s (- 0.16%) 1.91s 1.95s
Bind Time 0.91s (± 0.68%) 0.91s (± 0.57%) 0.00s ( 0.00%) 0.89s 0.92s
Check Time 5.63s (± 0.51%) 5.61s (± 0.47%) -0.02s (- 0.32%) 5.56s 5.70s
Emit Time 3.42s (± 0.69%) 3.40s (± 0.59%) -0.02s (- 0.53%) 3.35s 3.45s
Total Time 11.89s (± 0.34%) 11.86s (± 0.30%) -0.04s (- 0.33%) 11.79s 11.95s
TFS - node (v8.9.0, x64)
Memory used 310,532k (± 0.02%) 310,485k (± 0.01%) -47k (- 0.02%) 310,423k 310,582k
Parse Time 1.57s (± 0.49%) 1.56s (± 0.31%) -0.01s (- 0.45%) 1.56s 1.58s
Bind Time 0.69s (± 0.58%) 0.68s (± 0.54%) -0.00s (- 0.58%) 0.68s 0.69s
Check Time 5.33s (± 0.67%) 5.30s (± 0.63%) -0.03s (- 0.49%) 5.25s 5.42s
Emit Time 2.98s (± 0.88%) 2.96s (± 1.05%) -0.02s (- 0.54%) 2.88s 3.01s
Total Time 10.56s (± 0.50%) 10.51s (± 0.56%) -0.05s (- 0.50%) 10.40s 10.68s
material-ui - node (v8.9.0, x64)
Memory used 496,643k (± 0.01%) 496,986k (± 0.01%) +343k (+ 0.07%) 496,907k 497,068k
Parse Time 2.48s (± 0.40%) 2.48s (± 0.38%) +0.00s (+ 0.12%) 2.46s 2.50s
Bind Time 0.80s (± 0.83%) 0.81s (± 1.32%) +0.01s (+ 0.75%) 0.79s 0.84s
Check Time 18.10s (± 0.60%) 18.21s (± 0.56%) +0.11s (+ 0.59%) 18.01s 18.46s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 21.38s (± 0.56%) 21.50s (± 0.52%) +0.12s (+ 0.55%) 21.28s 21.77s
Angular - node (v8.9.0, x86)
Memory used 199,086k (± 0.02%) 199,390k (± 0.02%) +304k (+ 0.15%) 199,313k 199,468k
Parse Time 2.42s (± 0.51%) 2.43s (± 0.65%) +0.01s (+ 0.41%) 2.39s 2.46s
Bind Time 1.02s (± 0.91%) 1.01s (± 0.47%) -0.01s (- 0.49%) 1.00s 1.02s
Check Time 5.04s (± 0.38%) 5.06s (± 0.50%) +0.02s (+ 0.36%) 5.02s 5.12s
Emit Time 6.11s (± 0.91%) 6.10s (± 0.56%) -0.01s (- 0.15%) 6.05s 6.18s
Total Time 14.59s (± 0.39%) 14.60s (± 0.37%) +0.01s (+ 0.10%) 14.51s 14.71s
Compiler-Unions - node (v8.9.0, x86)
Memory used 128,101k (± 0.04%) 128,182k (± 0.03%) +82k (+ 0.06%) 128,084k 128,279k
Parse Time 0.97s (± 0.97%) 0.96s (± 0.86%) -0.00s (- 0.31%) 0.95s 0.99s
Bind Time 0.49s (± 1.26%) 0.49s (± 1.36%) +0.00s (+ 0.41%) 0.48s 0.51s
Check Time 13.70s (± 0.45%) 13.67s (± 0.46%) -0.02s (- 0.17%) 13.47s 13.77s
Emit Time 2.61s (± 0.83%) 2.62s (± 0.50%) +0.01s (+ 0.19%) 2.58s 2.64s
Total Time 17.77s (± 0.38%) 17.75s (± 0.37%) -0.02s (- 0.12%) 17.57s 17.87s
Monaco - node (v8.9.0, x86)
Memory used 203,246k (± 0.03%) 203,238k (± 0.02%) -8k (- 0.00%) 203,123k 203,318k
Parse Time 1.98s (± 1.09%) 1.96s (± 0.33%) -0.02s (- 0.91%) 1.95s 1.98s
Bind Time 0.72s (± 0.51%) 0.71s (± 0.69%) -0.00s (- 0.28%) 0.71s 0.73s
Check Time 5.74s (± 1.55%) 5.76s (± 0.84%) +0.02s (+ 0.38%) 5.67s 5.88s
Emit Time 2.81s (± 3.31%) 2.78s (± 1.67%) -0.03s (- 1.03%) 2.71s 2.92s
Total Time 11.24s (± 0.43%) 11.22s (± 0.38%) -0.02s (- 0.21%) 11.14s 11.32s
TFS - node (v8.9.0, x86)
Memory used 177,603k (± 0.02%) 177,597k (± 0.02%) -6k (- 0.00%) 177,513k 177,705k
Parse Time 1.60s (± 0.51%) 1.61s (± 0.54%) +0.01s (+ 0.50%) 1.59s 1.62s
Bind Time 0.65s (± 0.85%) 0.65s (± 1.14%) -0.00s (- 0.31%) 0.64s 0.67s
Check Time 4.84s (± 0.41%) 4.86s (± 0.42%) +0.02s (+ 0.37%) 4.82s 4.90s
Emit Time 2.85s (± 1.14%) 2.83s (± 1.04%) -0.01s (- 0.42%) 2.74s 2.89s
Total Time 9.94s (± 0.41%) 9.95s (± 0.28%) +0.01s (+ 0.11%) 9.87s 10.00s
material-ui - node (v8.9.0, x86)
Memory used 279,649k (± 0.03%) 279,852k (± 0.02%) +202k (+ 0.07%) 279,741k 279,936k
Parse Time 2.55s (± 0.80%) 2.54s (± 0.49%) -0.00s (- 0.16%) 2.52s 2.57s
Bind Time 0.73s (± 6.22%) 0.77s (± 7.04%) +0.04s (+ 5.34%) 0.69s 0.88s
Check Time 16.38s (± 0.68%) 16.44s (± 0.46%) +0.06s (+ 0.38%) 16.24s 16.59s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 19.66s (± 0.41%) 19.76s (± 0.28%) +0.10s (+ 0.50%) 19.64s 19.89s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-197-generic
Architecturex64
Available Memory16 GB
Available Memory11 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v8.9.0, x64)
  • node (v8.9.0, x86)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v8.9.0, x64)
  • Angular - node (v8.9.0, x86)
  • Compiler-Unions - node (v10.16.3, x64)
  • Compiler-Unions - node (v12.1.0, x64)
  • Compiler-Unions - node (v8.9.0, x64)
  • Compiler-Unions - node (v8.9.0, x86)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v8.9.0, x64)
  • Monaco - node (v8.9.0, x86)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v8.9.0, x64)
  • TFS - node (v8.9.0, x86)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v8.9.0, x64)
  • material-ui - node (v8.9.0, x86)
Benchmark Name Iterations
Current 41891 10
Baseline master 10

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Anders Hejlsberg (ahejlsberg) added 2 commits December 9, 2020 10:55
@ahejlsberg
Ensure template literals assignable to String, Object, {}, etc.
b3cdbf3
@ahejlsberg
Add tests
5cf670b
@ahejlsberg

Anders Hejlsberg (ahejlsberg) commented Dec 9, 2020

Copy link
Copy Markdown
Member Author

Test suites revealed that template literal types didn't consistently have a string constraint and therefore weren't assignable to String, Object, {}, and so on. Latest commits fix that.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ahejlsberg

Anders Hejlsberg (ahejlsberg) commented Dec 9, 2020

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) test this
TypeScript Bot (@typescript-bot) user test this

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 9, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized community code test suite on this PR at 5cf670b. You can monitor the build here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 9, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at 5cf670b. You can monitor the build here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

weswigham
Wesley Wigham (weswigham) approved these changes Dec 9, 2020
View reviewed changes
@ahejlsberg

Anders Hejlsberg (ahejlsberg) commented Dec 9, 2020

Copy link
Copy Markdown
Member Author

DT run is clean. Performance looks fine. Latest RWC run shows a few errors that shouldn't have been errors disappearing.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) mentioned this pull request Dec 10, 2020
Design Meeting Notes, 12/9/2020 #41907
Closed
@ahejlsberg

Anders Hejlsberg (ahejlsberg) commented Dec 10, 2020

Copy link
Copy Markdown
Member Author

Three user test suites have new errors.

office-ui-fabric

We are now (correctly) reporting an error that was previously silenced because they're compiling with strictFunctionTypes off. Simplified example:

declare const someStringArray: string[];
someStringArray.map(key => !!true ? `foo${key}` : null).filter((s: string) => s);

We now report an error neither `foo${string` | null or string are assignable to each other. Previously it (unsoundly) succeeded because string is assignable to string | null.

We're also reporting an error on something similar to this:

declare const someStringArray: string[];
someStringArray.map(key => `foo${key}`).concat(someStringArray);  // string[] not assignable to `foo${string}`[]

Ideally this wouldn't be an error. The core issue is that concat types the array and the argument using the same type variable. It really should be T and U with the result typed as (T | U)[].

fp-ts

One new error that looks to be correct and simply a result of the stronger typing.

webpack

One new error on something similar to this:

declare const someArray: unknown[];
someArray.map(item => `foo${item}`).unshift("someString");  // Type "someString" not assignable to type `foo${string}`

Not much we can do about this. The array is now of type `foo${string}`[] instead of just string[], so it is an error to insert a value of type "someString".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ahejlsberg Anders Hejlsberg (ahejlsberg) added the Breaking Change Would introduce errors in existing code label Dec 10, 2020
@ahejlsberg

Anders Hejlsberg (ahejlsberg) commented Dec 10, 2020

Copy link
Copy Markdown
Member Author

I'm going to mark this as a breaking change given what we're seeing in the user test suites.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ahejlsberg
Anders Hejlsberg (ahejlsberg) merged commit ee1f262 into master Dec 12, 2020
@ahejlsberg
Anders Hejlsberg (ahejlsberg) deleted the fix41631 branch December 12, 2020 01:07
@weswigham

Wesley Wigham (weswigham) commented Dec 12, 2020

Copy link
Copy Markdown
Member

Oof, apparently breaky enough to break our own build post-LKG. Namely, we have

                    const internal = jsDocStyle ? `/**@internal*/` : `/*@internal*/`;
                    // ...
                    appendText(fs, sources[Project.second][Source.ts][Part.one], `
class normalC {
    ${internal} constructor() { }
    ${internal} prop: string;
    ${internal} method() { }
    ${internal} get c() { return 10; }
    ${internal} set c(val: number) { }
}
namespace normalN {
    ${internal} export class C { }
    ${internal} export function foo() {}
    ${internal} export namespace someNamespace { export class C {} }
    ${internal} export namespace someOther.something { export class someClass {} }
    ${internal} export import someImport = someNamespace.C;
    ${internal} export type internalType = internalC;
    ${internal} export const internalConst = 10;
    ${internal} export enum internalEnum { a, b, c }
}
${internal} class internalC {}
${internal} function internalfoo() {}
${internal} namespace internalNamespace { export class someClass {} }
${internal} namespace internalOther.something { export class someClass {} }
${internal} import internalImport = internalNamespace.someClass;
${internal} type internalType = internalC;
${internal} const internalConst = 10;
${internal} enum internalEnum { a, b, c }`);

in our test harness.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@weswigham Wesley Wigham (weswigham) mentioned this pull request Dec 12, 2020
Simplify expression type to fix build break #41942
Merged
@weswigham

Wesley Wigham (weswigham) commented Dec 12, 2020

Copy link
Copy Markdown
Member

#41942 is up with a fix to the build break, assuming we don't want to do anything with this change,

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sandersn Nathan Shively-Sanders (sandersn) mentioned this pull request Jan 7, 2021
linkifyjs: Fix tests for TS 4.2 template literals DefinitelyTyped/DefinitelyTyped#50467
Merged
@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) added this to the TypeScript 4.2.0 milestone Jan 12, 2021
@justinfagnani Justin Fagnani (justinfagnani) mentioned this pull request Jan 13, 2021
Type safety with TemplateStringsArray and tag functions #33304
Open
5 tasks done
@jcalz Joe Calzaretta (jcalz) mentioned this pull request Feb 8, 2021
Revert changes for template literal types, keeping tests. #42588
Merged
@jcalz

Joe Calzaretta (jcalz) commented Feb 8, 2021

Copy link
Copy Markdown
Contributor

So #42588 undoes #41891, right? Just cross-linking them.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pedrodurek

Pedro Durek (pedrodurek) commented Feb 19, 2021

Copy link
Copy Markdown

Hey Daniel Rosenwasser (@DanielRosenwasser), considering that changes here were rolled back, do we have a new issue opened for this? Or you'll reopen this one #41631?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Mar 24, 2021
Cannot define a matching template literal type to a defined template literal #43143
Closed
Template literal types for contextually typed template literal expressions #43376
Merged
@pedrodurek Pedro Durek (pedrodurek) mentioned this pull request May 17, 2021
Type error on template literal with expression on Typescript 4.2 i18next/react-i18next#1319
Closed
@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) mentioned this pull request Aug 21, 2023
Evaluate simple template expressions #53907
Merged
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) DanielRosenwasser requested changes
@weswigham Wesley Wigham (weswigham) weswigham approved these changes
@RyanCavanaugh Ryan Cavanaugh (RyanCavanaugh) Awaiting requested review from RyanCavanaugh

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@ahejlsberg Anders Hejlsberg (ahejlsberg)

Labels

Author: Team Breaking Change Would introduce errors in existing code For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Milestone

TypeScript 4.2.0

Development

Successfully merging this pull request may close these issues.

Try to preserve template-ness of string literal types where possible

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@ahejlsberg @typescript-bot @weswigham @jcalz @pedrodurek @DanielRosenwasser
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.