microsoft / microsoft/TypeScript

Crash: when inferring from a tuple with middle rest elements and trailing variadic elements

Open
#63,005 1 comment 0 reactions 0 assignees View on GitHub
Bug Domain: Crashes Help Wanted
Dominant language
Go
Stars
111k
Forks
14.3k
PR merge metrics
PR metrics pending

Description

### 🔎 Search Terms

Internal Error: Debug Failure

Variadic tuple types crash

infer rest elements crash

tuple mapping crash

### 🕗 Version & Regression Information

Versions tested: 5.7.3, 5.8.3, 5.9.3, Nightly

### ⏯ Playground Link

https://www.typescriptlang.org/zh/play/?target=7&noEmit=true&ts=6.0.0-dev.20260117#code/PTAEAEGcBcCcEsDG0Bco4FcCmAoEEA7AewFEBbeVdWbPMWLAB1iNAGIBWARi4GYAOHNACejLKADKGAEYAVDIwBMAJSwwAggQAms2AEN4AG3gEA5gDU9CPVqSKAPLNBYAHtCzbIoDAQDWxAHcCAG0AXQA+UABeUCdXd09QYJxQVNAAOkyAChMAMyxYUABhAEowgBoUtMz0vILQACFnNw8tL2C9AmFyzu7EfUgAC1CcUNAq1IB+JKLymoaxidA0AiwANwKAbhwhUXEpOQUVNWhNHX0jEwsreBs7WRPoyRl5JVUNbV0DYzNLa1tEA5gjU9GgAAwVaRoLjlRBoRQRbZAA

### 💻 Code

```ts
// repro #51138
type SubTup2RestAndTrailingVariadic2 = T extends [
...(infer C)[],
...infer B extends [any,any,crash]
]
? [C,...B]
: never;

type SubTup2RestAndTrailingVariadic2Test = SubTup2RestAndTrailingVariadic2<[...a: 0[],b: 1,c: 2]>;

```

### 🙁 Actual behavior

```
.\ts-versions\nightly\node_modules\.bin\tsc.cmd .\inferTypesWithFixedTupleExtendsAtVariadicPosition_m.ts
D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:123178
throw e;
^

TypeError: Cannot read properties of undefined (reading 'aliasSymbol')
at inferFromTypes (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68512:18)
at inferFromObjectTypes (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68994:21)
at invokeOnce (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68704:9)
at inferFromTypes (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68666:11)
at inferTypes (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68500:5)
at getConditionalType (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:62537:11)
at getConditionalTypeInstantiation (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63526:305)
at instantiateTypeWorker (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63629:14)
at instantiateTypeWithAlias (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63566:20)
at getTypeAliasInstantiation (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:60132:52)

Node.js v22.19.0
```

### 🙂 Expected behavior

The compiler should report a syntax error and not crash.

### Additional information about the issue

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the Playground reproduction and the supplied tuple-inference example, then trace the compiler stack from inferFromTypes through inferFromObjectTypes and getConditionalType. Reproduce the crash with the listed TypeScript versions and identify the relevant compiler regression-test location. Done means this input reports a syntax error instead of throwing an internal TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.