Skip to content

Improve recursion identity for direct type instantiations#3445

Open
ahejlsberg wants to merge 3 commits intomainfrom
fix-3426
Open

Improve recursion identity for direct type instantiations#3445
ahejlsberg wants to merge 3 commits intomainfrom
fix-3426

Conversation

@ahejlsberg
Copy link
Copy Markdown
Member

@ahejlsberg ahejlsberg commented Apr 20, 2026

With this PR, we exclude type references that originate directly from resolution of AST type nodes from using their symbol as their recursion identity in isDeeplyNestedType. Infinite recursion in type relationships is ultimately fuelled by types produced by instantiateType, and we know that type references that originate directly from resolution of AST type nodes have not been subject to such instantiation. Therefore, it is safe to use themselves as their recursion identity.

Previously, code such as the following would not error because isDeeplyNestedType would see three nested instantiations of Array<T> with increasing type IDs and mistake that for generative recursion. The example now errors because the array instantiations all originate direcly in resolution of AST type nodes.

namespace A {
    export interface Outer {
        inners: Inner[];
    }
    export interface Inner {
        mids: Mid[];
    }
    export interface Mid {
        leaves: Leaf[];
    }
    export interface Leaf {
        id: string;
    }
}

namespace B {
    export interface Outer {
        inners: Inner[];
    }
    export interface Inner {
        mids: Mid[];
    }
    export interface Mid {
        leaves: Leaf[];
    }
    export interface Leaf {
        id: number;
    }
}

function test(a: A.Outer, b: B.Outer) {
    a = b;  // Now errors, previously didn't
}

Fixes #3426.

Copilot AI review requested due to automatic review settings April 20, 2026 15:27
@ahejlsberg
Copy link
Copy Markdown
Member Author

@typescript-bot test it

@typescript-bot
Copy link
Copy Markdown

typescript-bot commented Apr 20, 2026

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started
perf test this faster ✅ Started 👀 Results

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refines recursion identity selection in the checker so that type references produced directly from resolving AST type nodes don’t use their symbol as the recursion identity in isDeeplyNestedType, preventing false “generative recursion” detection that can mask real assignability errors (fixes #3426).

Changes:

  • Introduces ObjectFlagsFromTypeNode to mark type references created directly from AST type node resolution.
  • Updates getRecursionIdentity to avoid using t.symbol as the recursion identity when ObjectFlagsFromTypeNode is set.
  • Routes array/class/interface type-node resolution through a new createTypeReferenceEx(..., ObjectFlagsFromTypeNode) helper.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
internal/checker/types.go Adds a new ObjectFlagsFromTypeNode bit to tag type references originating from AST type nodes.
internal/checker/relater.go Excludes FromTypeNode references from using symbol recursion identity in getRecursionIdentity.
internal/checker/checker.go Creates createTypeReferenceEx and uses it in type-node resolution to apply ObjectFlagsFromTypeNode.

Comment on lines 24634 to +24639
id := getTypeListKey(typeArguments)
intf := target.AsInterfaceType()
if t, ok := intf.instantiations[id]; ok {
return t
}
t := c.newObjectType(ObjectFlagsReference, target.symbol)
t.objectFlags |= c.getPropagatingFlagsOfTypes(typeArguments, TypeFlagsNone)
t := c.newObjectType(ObjectFlagsReference|objectFlags|c.getPropagatingFlagsOfTypes(typeArguments, TypeFlagsNone), target.symbol)
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

createTypeReferenceEx caches instantiations only by typeArguments (getTypeListKey). That ignores the objectFlags parameter, so a previously-cached instantiation without ObjectFlagsFromTypeNode can be returned to callers that request it (and vice versa). This makes the new recursion-identity behavior depend on call order and can cause both missed recursion detection and missed errors. Consider including the relevant objectFlags bits (at least ObjectFlagsFromTypeNode) in the cache key and/or maintaining a separate instantiation cache for FromTypeNode references so the flag is applied deterministically only where intended.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

@ahejlsberg ahejlsberg Apr 20, 2026

Choose a reason for hiding this comment

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

This is a good observation and indeed something that was considered. The issue with tracking the flag in the cache key is that it creates distinct object identities for effectively identical types, which we then have to reconcile in multiple places elsewhere, for example in order to avoid strange types like number[] | number[] (two types that differ only by the flag). The flag is only used by a heuristic that ultimately also depends on type IDs (which similarly depend on declaration order), so it is a reasonable compromise to just record it in the first type instantiation.

Comment on lines +842 to +846
if t.symbol != nil && !(t.objectFlags&ObjectFlagsAnonymous != 0 && t.symbol.Flags&ast.SymbolFlagsClass != 0) && t.objectFlags&ObjectFlagsFromTypeNode == 0 {
// We track object types that have a symbol by that symbol (representing the origin of the type), but
// exclude the static side of a class since it shares its symbol with the instance side.
// exclude the static sides of classes (since they share their symbols with the instance sides) and type
// references that originate in resolution of AST type nodes (since such type nodes cannot be the source
// of generative recursion without first being instantiated).
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

This change adjusts recursion identity handling to fix a checker soundness gap, but the PR doesn't add a regression test for #3426 (nested arrays from distinct namespaces should now produce TS2322). Please add a minimal compiler test case under testdata/tests/cases/compiler/ that fails before this change and passes after, so we don’t regress this behavior again.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Now fixed.

@typescript-bot
Copy link
Copy Markdown

@ahejlsberg
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - native
Errors 4 4 ~ ~ ~ p=1.000 n=6
Symbols 81,793 (± 0.05%) 81,803 (± 0.02%) ~ 81,773 81,823 p=1.000 n=6
Types 98,821 98,821 ~ ~ ~ p=1.000 n=6
Memory Used 175,181k (± 0.06%) 175,172k (± 0.07%) ~ 174,984k 175,283k p=0.936 n=6
Memory Allocs 1,771,653 (± 0.01%) 1,771,580 (± 0.01%) ~ 1,771,353 1,771,955 p=0.336 n=6
Config Time 0.000s (±244.70%) 0.000s ~ ~ ~ p=0.405 n=6
Parse Time 0.063s (± 9.41%) 0.065s (± 7.53%) ~ 0.059s 0.071s p=0.521 n=6
Bind Time 0s 0s ~ ~ ~ p=1.000 n=6
Check Time 0s 0s ~ ~ ~ p=1.000 n=6
Emit Time 0.877s (± 0.83%) 0.864s (± 1.09%) -0.012s (- 1.43%) 0.851s 0.874s p=0.037 n=6
Total Time 0.940s (± 1.02%) 0.930s (± 0.95%) ~ 0.919s 0.945s p=0.127 n=6
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=6
Symbols 885,382 (± 0.02%) 885,125 (± 0.03%) ~ 884,691 885,326 p=0.093 n=6
Types 263,959 (± 0.00%) 263,959 (± 0.00%) ~ 263,958 263,960 p=0.934 n=6
Memory Used 829,462k (± 0.07%) 828,761k (± 0.05%) -701k (- 0.08%) 828,139k 829,180k p=0.031 n=6
Memory Allocs 6,727,077 (± 0.48%) 6,706,138 (± 0.18%) ~ 6,690,014 6,723,729 p=0.173 n=6
Config Time 0.028s (± 2.70%) 0.029s (±10.02%) ~ 0.027s 0.035s p=0.437 n=6
Parse Time 0.235s (± 3.24%) 0.233s (± 6.79%) ~ 0.212s 0.254s p=0.688 n=6
Bind Time 0s 0s ~ ~ ~ p=1.000 n=6
Check Time 0s 0s ~ ~ ~ p=1.000 n=6
Emit Time 1.905s (± 1.26%) 1.905s (± 0.57%) ~ 1.895s 1.924s p=0.748 n=6
Total Time 2.170s (± 1.13%) 2.169s (± 1.10%) ~ 2.141s 2.200s p=0.810 n=6
mui-docs - native
Errors 3 3 ~ ~ ~ p=1.000 n=6
Symbols 4,314,063 4,314,063 ~ ~ ~ p=1.000 n=6
Types 1,555,354 1,555,354 ~ ~ ~ p=1.000 n=6
Memory Used 5,459,516k (± 0.03%) 5,457,063k (± 0.08%) ~ 5,452,486k 5,462,795k p=0.230 n=6
Memory Allocs 89,153,512 (±15.56%) 115,261,657 (±13.91%) 🔻+26,108,145 (+29.28%) 90,503,098 133,839,028 p=0.031 n=6
Config Time 0.022s (± 3.44%) 0.022s (± 3.76%) ~ 0.021s 0.023s p=0.729 n=6
Parse Time 0.973s (±23.42%) 1.387s (±16.16%) 🔻+0.414s (+42.59%) 1.081s 1.641s p=0.020 n=6
Bind Time 0.002s 0.002s ~ ~ ~ p=1.000 n=6
Check Time 17.308s (± 0.35%) 17.180s (± 0.28%) -0.128s (- 0.74%) 17.146s 17.273s p=0.008 n=6
Emit Time 0.439s (± 4.70%) 0.431s (± 4.69%) ~ 0.415s 0.458s p=0.570 n=6
Total Time 19.213s (± 1.86%) 19.469s (± 0.95%) ~ 19.252s 19.705s p=0.230 n=6
self-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,396,661 1,396,711 +50 (+ 0.00%) ~ ~ p=0.001 n=6
Types 442,174 442,174 ~ ~ ~ p=1.000 n=6
Memory Used 1,644,406k (± 0.17%) 1,646,219k (± 0.26%) ~ 1,638,953k 1,651,381k p=0.378 n=6
Memory Allocs 57,210,816 (± 0.09%) 57,240,722 (± 0.09%) ~ 57,179,438 57,321,441 p=0.471 n=6
Config Time 0.014s (±50.00%) 0.016s (±52.53%) ~ 0.005s 0.030s p=0.936 n=6
Parse Time 0.282s (± 2.60%) 0.282s (± 4.00%) ~ 0.267s 0.295s p=1.000 n=6
Bind Time 0.000s (±244.70%) 0.001s (±210.14%) ~ 0.000s 0.007s p=0.599 n=6
Check Time 2.313s (± 0.54%) 2.303s (± 0.68%) ~ 2.280s 2.323s p=0.298 n=6
Emit Time 0.220s (± 7.43%) 0.216s (± 5.59%) ~ 0.207s 0.240s p=0.810 n=6
Total Time 29.761s (± 0.71%) 29.657s (± 0.91%) ~ 29.348s 30.123s p=0.575 n=6
self-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 338,176 338,176 ~ ~ ~ p=1.000 n=6
Types 199,525 199,525 ~ ~ ~ p=1.000 n=6
Memory Used 331,860k (± 0.04%) 331,840k (± 0.01%) ~ 331,809k 331,893k p=0.574 n=6
Memory Allocs 2,551,252 (± 0.02%) 2,551,249 (± 0.04%) ~ 2,550,065 2,552,506 p=0.936 n=6
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=6
Parse Time 0.135s (± 4.24%) 0.135s (± 5.84%) ~ 0.121s 0.145s p=0.872 n=6
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=6
Check Time 1.406s (± 1.08%) 1.386s (± 1.48%) ~ 1.363s 1.420s p=0.092 n=6
Emit Time 0.082s (± 1.00%) 0.089s (±13.53%) ~ 0.079s 0.108s p=0.360 n=6
Total Time 1.680s (± 0.88%) 1.663s (± 1.58%) ~ 1.625s 1.688s p=0.173 n=6
ts-pre-modules - native
Errors 3 3 ~ ~ ~ p=1.000 n=6
Symbols 752 752 ~ ~ ~ p=1.000 n=6
Types 356 356 ~ ~ ~ p=1.000 n=6
Memory Used 104,617k (± 0.02%) 104,591k (± 0.03%) ~ 104,541k 104,620k p=0.173 n=6
Memory Allocs 110,890 (± 0.23%) 110,908 (± 0.21%) ~ 110,639 111,200 p=1.000 n=6
Config Time 0.001s (±48.94%) 0.001s (±48.94%) ~ 0.000s 0.001s p=1.000 n=6
Parse Time 0.117s (± 2.74%) 0.116s (± 4.29%) ~ 0.110s 0.123s p=0.748 n=6
Bind Time 0s 0s ~ ~ ~ p=1.000 n=6
Check Time 0s 0s ~ ~ ~ p=1.000 n=6
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=6
Total Time 0.117s (± 2.88%) 0.117s (± 4.25%) ~ 0.111s 0.124s p=0.810 n=6
vscode - native
Errors 193 193 ~ ~ ~ p=1.000 n=6
Symbols 6,119,585 6,119,871 +286 (+ 0.00%) ~ ~ p=0.001 n=6
Types 2,319,533 2,319,610 +77 (+ 0.00%) ~ ~ p=0.001 n=6
Memory Used 4,169,752k (± 0.02%) 4,170,019k (± 0.02%) ~ 4,168,841k 4,171,236k p=0.810 n=6
Memory Allocs 30,323,420 (± 0.03%) 30,331,670 (± 0.03%) ~ 30,325,174 30,342,456 p=0.128 n=6
Config Time 0.123s (± 4.57%) 0.129s (± 7.11%) ~ 0.114s 0.138s p=0.148 n=6
Parse Time 0.691s (± 6.36%) 0.708s (± 5.02%) ~ 0.664s 0.755s p=0.471 n=6
Bind Time 0.157s (±31.99%) 0.131s (±26.25%) ~ 0.109s 0.196s p=0.471 n=6
Check Time 8.204s (± 0.48%) 8.183s (± 0.62%) ~ 8.129s 8.249s p=0.378 n=6
Emit Time 1.850s (±10.76%) 1.897s (±10.78%) ~ 1.641s 2.124s p=0.810 n=6
Total Time 11.060s (± 1.43%) 11.077s (± 1.39%) ~ 10.879s 11.260s p=0.936 n=6
webpack - native
Errors 944 944 ~ ~ ~ p=1.000 n=6
Symbols 695,186 695,188 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Types 332,898 332,898 ~ ~ ~ p=1.000 n=6
Memory Used 547,453k (± 0.02%) 547,342k (± 0.01%) ~ 547,263k 547,470k p=0.173 n=6
Memory Allocs 4,150,378 (± 0.10%) 4,148,823 (± 0.09%) ~ 4,144,003 4,154,990 p=0.471 n=6
Config Time 0.012s (±29.72%) 0.014s (±16.34%) ~ 0.011s 0.018s p=0.252 n=6
Parse Time 0.138s (± 2.82%) 0.143s (± 4.03%) ~ 0.135s 0.149s p=0.108 n=6
Bind Time 0.038s (±27.60%) 0.030s (±29.58%) ~ 0.023s 0.043s p=0.198 n=6
Check Time 1.094s (± 1.36%) 1.097s (± 1.16%) ~ 1.078s 1.111s p=0.688 n=6
Emit Time 0.001s 0.001s ~ ~ ~ p=1.000 n=6
Total Time 1.300s (± 1.07%) 1.303s (± 0.55%) ~ 1.292s 1.309s p=0.936 n=6
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 991,654 991,654 ~ ~ ~ p=1.000 n=6
Types 350,842 350,842 ~ ~ ~ p=1.000 n=6
Memory Used 603,383k (± 0.01%) 603,368k (± 0.02%) ~ 603,191k 603,554k p=0.689 n=6
Memory Allocs 4,944,554 (± 0.14%) 4,952,101 (± 0.27%) ~ 4,936,384 4,975,420 p=0.378 n=6
Config Time 0.006s (±33.30%) 0.007s (±27.08%) ~ 0.005s 0.009s p=0.315 n=6
Parse Time 0.133s (± 5.18%) 0.139s (± 5.53%) ~ 0.126s 0.148s p=0.296 n=6
Bind Time 0.037s (±24.62%) 0.034s (±26.91%) ~ 0.024s 0.046s p=0.517 n=6
Check Time 1.127s (± 0.96%) 1.126s (± 1.38%) ~ 1.111s 1.147s p=0.872 n=6
Emit Time 0.001s 0.001s ~ ~ ~ p=1.000 n=6
Total Time 1.308s (± 0.78%) 1.310s (± 0.78%) ~ 1.294s 1.322s p=1.000 n=6
System info unknown
Hosts
  • native
Scenarios
  • Compiler-Unions - native
  • angular-1 - native
  • mui-docs - native
  • self-build-src - native
  • self-compiler - native
  • ts-pre-modules - native
  • vscode - native
  • webpack - native
  • xstate-main - native
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Copy Markdown

@ahejlsberg Here are the results of running the user tests with tsc comparing main and refs/pull/3445/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Git clone failed"

Otherwise...

Everything looks good!

@jakebailey
Copy link
Copy Markdown
Member

Looks like this causes 30% more allocs in mui.

@typescript-bot
Copy link
Copy Markdown

@ahejlsberg Here are the results of running the top 400 repos with tsc comparing main and refs/pull/3445/merge:

Everything looks good!

@ahejlsberg
Copy link
Copy Markdown
Member Author

Looks like this causes 30% more allocs in mui.

There's something really odd about that test run. Check time (which is the only thing that would be affected) is slightly down, but parse time is way up by 42%.

@ahejlsberg
Copy link
Copy Markdown
Member Author

@typescript-bot perf test this faster

@typescript-bot
Copy link
Copy Markdown

typescript-bot commented Apr 20, 2026

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Copy Markdown

@ahejlsberg
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - native
Errors 4 4 ~ ~ ~ p=1.000 n=6
Symbols 81,805 (± 0.02%) 81,803 (± 0.02%) ~ 81,777 81,829 p=0.873 n=6
Types 98,821 98,821 ~ ~ ~ p=1.000 n=6
Memory Used 174,994k (± 0.03%) 175,063k (± 0.09%) ~ 174,868k 175,271k p=0.471 n=6
Memory Allocs 1,771,528 (± 0.01%) 1,771,653 (± 0.01%) ~ 1,771,284 1,771,900 p=0.066 n=6
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=6
Parse Time 0.056s (± 6.49%) 0.058s (± 5.03%) ~ 0.055s 0.062s p=0.294 n=6
Bind Time 0s 0s ~ ~ ~ p=1.000 n=6
Check Time 0s 0s ~ ~ ~ p=1.000 n=6
Emit Time 0.863s (± 1.01%) 0.856s (± 0.78%) ~ 0.849s 0.865s p=0.145 n=6
Total Time 0.919s (± 1.21%) 0.914s (± 0.99%) ~ 0.904s 0.927s p=0.572 n=6
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=6
Symbols 885,004 (± 0.10%) 884,737 (± 0.08%) ~ 883,646 885,584 p=0.471 n=6
Types 263,959 (± 0.00%) 263,959 (± 0.00%) ~ 263,957 263,962 p=0.807 n=6
Memory Used 829,290k (± 0.06%) 829,283k (± 0.05%) ~ 828,795k 829,781k p=1.000 n=6
Memory Allocs 6,722,677 (± 0.23%) 6,722,142 (± 0.31%) ~ 6,702,032 6,759,101 p=0.810 n=6
Config Time 0.028s (± 3.53%) 0.029s (± 7.84%) ~ 0.027s 0.033s p=0.673 n=6
Parse Time 0.244s (± 3.07%) 0.244s (± 4.26%) ~ 0.227s 0.256s p=1.000 n=6
Bind Time 0s 0s ~ ~ ~ p=1.000 n=6
Check Time 0s 0s ~ ~ ~ p=1.000 n=6
Emit Time 1.919s (± 0.84%) 1.928s (± 1.29%) ~ 1.895s 1.962s p=0.521 n=6
Total Time 2.193s (± 0.72%) 2.202s (± 1.35%) ~ 2.164s 2.244s p=0.689 n=6
mui-docs - native
Errors 3 3 ~ ~ ~ p=1.000 n=6
Symbols 4,314,063 4,314,063 ~ ~ ~ p=1.000 n=6
Types 1,555,354 1,555,354 ~ ~ ~ p=1.000 n=6
Memory Used 5,459,471k (± 0.05%) 5,457,471k (± 0.04%) ~ 5,454,968k 5,461,770k p=0.173 n=6
Memory Allocs 86,531,521 (±14.99%) 87,378,275 (± 8.97%) ~ 79,558,448 97,183,109 p=0.810 n=6
Config Time 0.022s (± 5.44%) 0.023s (± 8.67%) ~ 0.021s 0.026s p=0.933 n=6
Parse Time 0.906s (±22.84%) 0.928s (±13.41%) ~ 0.785s 1.077s p=0.471 n=6
Bind Time 0.002s (±18.82%) 0.002s ~ ~ ~ p=0.405 n=6
Check Time 17.325s (± 0.49%) 17.155s (± 0.26%) -0.171s (- 0.99%) 17.105s 17.223s p=0.005 n=6
Emit Time 0.452s (± 3.15%) 0.452s (± 3.87%) ~ 0.416s 0.460s p=0.460 n=6
Total Time 19.131s (± 0.88%) 18.940s (± 0.96%) ~ 18.744s 19.186s p=0.173 n=6
self-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,396,661 1,396,711 +50 (+ 0.00%) ~ ~ p=0.001 n=6
Types 442,174 442,174 ~ ~ ~ p=1.000 n=6
Memory Used 1,648,628k (± 0.26%) 1,645,565k (± 0.17%) ~ 1,642,130k 1,648,718k p=0.173 n=6
Memory Allocs 57,267,915 (± 0.11%) 57,262,869 (± 0.06%) ~ 57,217,524 57,295,391 p=0.810 n=6
Config Time 0.014s (±50.78%) 0.016s (±38.98%) ~ 0.007s 0.023s p=0.520 n=6
Parse Time 0.274s (± 2.85%) 0.279s (± 5.03%) ~ 0.261s 0.300s p=0.575 n=6
Bind Time 0.001s (±181.47%) 0.000s (±244.70%) ~ 0.000s 0.001s p=0.527 n=6
Check Time 2.324s (± 1.17%) 2.331s (± 0.64%) ~ 2.313s 2.356s p=0.810 n=6
Emit Time 0.217s (± 3.72%) 0.214s (± 3.26%) ~ 0.206s 0.224s p=0.630 n=6
Total Time 29.644s (± 0.83%) 29.618s (± 0.49%) ~ 29.406s 29.786s p=0.936 n=6
self-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 338,176 338,176 ~ ~ ~ p=1.000 n=6
Types 199,525 199,525 ~ ~ ~ p=1.000 n=6
Memory Used 331,819k (± 0.03%) 331,908k (± 0.04%) ~ 331,760k 332,149k p=0.230 n=6
Memory Allocs 2,551,411 (± 0.03%) 2,551,455 (± 0.01%) ~ 2,551,011 2,551,864 p=1.000 n=6
Config Time 0.001s 0.001s (±34.96%) ~ 0.001s 0.002s p=0.405 n=6
Parse Time 0.135s (± 5.83%) 0.133s (± 3.19%) ~ 0.128s 0.137s p=0.572 n=6
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=6
Check Time 1.390s (± 0.71%) 1.389s (± 1.34%) ~ 1.372s 1.416s p=0.810 n=6
Emit Time 0.086s (± 7.80%) 0.085s (±12.62%) ~ 0.080s 0.107s p=0.683 n=6
Total Time 1.665s (± 1.02%) 1.660s (± 1.34%) ~ 1.637s 1.689s p=0.689 n=6
ts-pre-modules - native
Errors 3 3 ~ ~ ~ p=1.000 n=6
Symbols 752 752 ~ ~ ~ p=1.000 n=6
Types 356 356 ~ ~ ~ p=1.000 n=6
Memory Used 104,596k (± 0.04%) 104,597k (± 0.04%) ~ 104,539k 104,646k p=0.810 n=6
Memory Allocs 110,837 (± 0.37%) 110,752 (± 0.32%) ~ 110,335 111,289 p=0.810 n=6
Config Time 0.001s (±48.94%) 0.001s (±48.94%) ~ 0.000s 0.001s p=1.000 n=6
Parse Time 0.118s (± 5.14%) 0.116s (± 4.59%) ~ 0.112s 0.127s p=0.466 n=6
Bind Time 0s 0s ~ ~ ~ p=1.000 n=6
Check Time 0s 0s ~ ~ ~ p=1.000 n=6
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=6
Total Time 0.119s (± 5.37%) 0.118s (± 4.47%) ~ 0.113s 0.128s p=0.520 n=6
vscode - native
Errors 193 193 ~ ~ ~ p=1.000 n=6
Symbols 6,120,408 6,120,545 +137 (+ 0.00%) ~ ~ p=0.001 n=6
Types 2,319,319 2,319,421 +102 (+ 0.00%) ~ ~ p=0.001 n=6
Memory Used 4,170,653k (± 0.03%) 4,170,244k (± 0.02%) ~ 4,169,219k 4,171,808k p=0.575 n=6
Memory Allocs 30,343,527 (± 0.06%) 30,334,548 (± 0.09%) ~ 30,307,903 30,369,524 p=0.810 n=6
Config Time 0.121s (± 4.09%) 0.119s (± 6.51%) ~ 0.106s 0.128s p=0.872 n=6
Parse Time 0.713s (± 4.57%) 0.720s (± 4.65%) ~ 0.690s 0.768s p=0.689 n=6
Bind Time 0.131s (±36.31%) 0.112s (± 3.16%) ~ 0.109s 0.118s p=0.629 n=6
Check Time 8.277s (± 0.83%) 8.265s (± 0.76%) ~ 8.220s 8.386s p=0.575 n=6
Emit Time 1.943s (±13.17%) 1.995s (± 8.66%) ~ 1.651s 2.119s p=0.810 n=6
Total Time 11.208s (± 1.70%) 11.235s (± 0.97%) ~ 11.043s 11.381s p=0.936 n=6
webpack - native
Errors 944 944 ~ ~ ~ p=1.000 n=6
Symbols 695,186 695,188 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Types 332,898 332,898 ~ ~ ~ p=1.000 n=6
Memory Used 547,213k (± 0.01%) 547,291k (± 0.02%) ~ 547,170k 547,471k p=0.199 n=6
Memory Allocs 4,148,432 (± 0.13%) 4,151,657 (± 0.19%) ~ 4,145,244 4,162,876 p=0.378 n=6
Config Time 0.013s (±22.27%) 0.014s (±16.27%) ~ 0.010s 0.016s p=0.517 n=6
Parse Time 0.146s (± 4.88%) 0.145s (± 7.61%) ~ 0.131s 0.156s p=1.000 n=6
Bind Time 0.032s (±19.21%) 0.034s (±34.81%) ~ 0.025s 0.050s p=1.000 n=6
Check Time 1.095s (± 1.39%) 1.098s (± 1.23%) ~ 1.083s 1.115s p=0.630 n=6
Emit Time 0.001s (±34.96%) 0.001s (±34.96%) ~ 0.001s 0.002s p=1.000 n=6
Total Time 1.305s (± 0.99%) 1.309s (± 0.77%) ~ 1.298s 1.327s p=0.809 n=6
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 991,654 991,654 ~ ~ ~ p=1.000 n=6
Types 350,842 350,842 ~ ~ ~ p=1.000 n=6
Memory Used 603,439k (± 0.02%) 603,376k (± 0.01%) ~ 603,268k 603,447k p=0.575 n=6
Memory Allocs 4,950,290 (± 0.19%) 4,953,357 (± 0.24%) ~ 4,938,483 4,969,896 p=0.810 n=6
Config Time 0.007s (±25.36%) 0.007s (±25.36%) ~ 0.005s 0.009s p=1.000 n=6
Parse Time 0.137s (± 3.18%) 0.142s (± 4.92%) ~ 0.135s 0.155s p=0.260 n=6
Bind Time 0.031s (±25.99%) 0.034s (±27.88%) ~ 0.024s 0.049s p=0.630 n=6
Check Time 1.131s (± 0.75%) 1.129s (± 1.41%) ~ 1.104s 1.150s p=0.936 n=6
Emit Time 0.001s 0.001s ~ ~ ~ p=1.000 n=6
Total Time 1.311s (± 0.42%) 1.317s (± 1.34%) ~ 1.294s 1.347s p=0.469 n=6
System info unknown
Hosts
  • native
Scenarios
  • Compiler-Unions - native
  • angular-1 - native
  • mui-docs - native
  • self-build-src - native
  • self-compiler - native
  • ts-pre-modules - native
  • vscode - native
  • webpack - native
  • xstate-main - native
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@ahejlsberg
Copy link
Copy Markdown
Member Author

microsoft/TypeScript#63415 implements this same change in the Strada code base. Interestingly, there is one failure in top 400 repos in Strada. It appears to be caused by relating almost identical copies of Plugin from two copies of the vite package in the same compilation. It seems Corsa is smarter about eliminating this duplication.

}
links.resolvedType = c.createNormalizedTypeReference(target, elementTypes)
if target.objectFlags&ObjectFlagsTuple != 0 {
links.resolvedType = c.createNormalizedTupleType(target, elementTypes)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this also accept and propagate ObjectFlagsFromTypeNode? FWIW, while testing this PR locally I ended up implementing this: https://github.com/microsoft/typescript-go/compare/fix-3426...Andarist:fix/deeply-nested-tuples-from-type-nodes?expand=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsc produces error, tsgo doesn't with sufficiently nested type

5 participants