From 0586e23815de6e6d7f7438d6b16fd97431e74a2c Mon Sep 17 00:00:00 2001 From: mrazauskas Date: Fri, 28 Aug 2026 09:47:36 +0300 Subject: [PATCH 1/3] Add `TupleTypeReference` interface Signed-off-by: mrazauskas --- packages/typescript/src/api/async/api.ts | 2 ++ packages/typescript/src/api/async/types.ts | 6 ++++++ packages/typescript/src/api/sync/api.ts | 2 ++ packages/typescript/src/api/sync/types.ts | 9 +++++++++ 4 files changed, 19 insertions(+) diff --git a/packages/typescript/src/api/async/api.ts b/packages/typescript/src/api/async/api.ts index ef6d7fb7ef10b..de9bf82fe65d3 100644 --- a/packages/typescript/src/api/async/api.ts +++ b/packages/typescript/src/api/async/api.ts @@ -125,6 +125,7 @@ import type { TemplateLiteralType, ThisTypePredicate, TupleType, + TupleTypeReference, Type, TypeParameter, TypePredicate, @@ -187,6 +188,7 @@ export type { TimingAccumulators, TimingInfo, TupleType, + TupleTypeReference, Type, TypeAcquisition, TypeParameter, diff --git a/packages/typescript/src/api/async/types.ts b/packages/typescript/src/api/async/types.ts index 79c392aed6b63..37d1e10f4463e 100644 --- a/packages/typescript/src/api/async/types.ts +++ b/packages/typescript/src/api/async/types.ts @@ -177,6 +177,12 @@ export interface TypeReference extends ObjectType { getTarget(): Promise; } +/** References to tuple types */ +export interface TupleTypeReference extends TypeReference { + /** Get the tuple type that describes this reference's shape */ + getTarget(): Promise; +} + /** Interface types — classes and interfaces (ObjectFlags.ClassOrInterface) */ export interface InterfaceType extends TypeReference { /** Get all type parameters (outer + local, excluding thisType) */ diff --git a/packages/typescript/src/api/sync/api.ts b/packages/typescript/src/api/sync/api.ts index b92a3fa26fb72..fc439a4424b61 100644 --- a/packages/typescript/src/api/sync/api.ts +++ b/packages/typescript/src/api/sync/api.ts @@ -142,6 +142,7 @@ import type { TemplateLiteralType, ThisTypePredicate, TupleType, + TupleTypeReference, Type, TypeParameter, TypePredicate, @@ -204,6 +205,7 @@ export type { TimingAccumulators, TimingInfo, TupleType, + TupleTypeReference, Type, TypeAcquisition, TypeParameter, diff --git a/packages/typescript/src/api/sync/types.ts b/packages/typescript/src/api/sync/types.ts index 43a650ef67621..bdb25aeb59b66 100644 --- a/packages/typescript/src/api/sync/types.ts +++ b/packages/typescript/src/api/sync/types.ts @@ -244,6 +244,15 @@ export interface TypeReference extends ObjectType { }; } +/** References to tuple types */ +export interface TupleTypeReference extends TypeReference { + /** Get the tuple type that describes this reference's shape */ + getTarget: { + (): TupleType; + gen(): Generator; + }; +} + /** Interface types — classes and interfaces (ObjectFlags.ClassOrInterface) */ export interface InterfaceType extends TypeReference { /** Get all type parameters (outer + local, excluding thisType) */ From f0cdcd7a08f103ce6f134af241df73cca32b26f3 Mon Sep 17 00:00:00 2001 From: mrazauskas Date: Fri, 28 Aug 2026 10:02:42 +0300 Subject: [PATCH 2/3] update test Signed-off-by: mrazauskas --- packages/typescript/test/async/api.test.ts | 5 ++++- packages/typescript/test/sync/api.test.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/typescript/test/async/api.test.ts b/packages/typescript/test/async/api.test.ts index b40091c90d6c9..8bf100117cbcd 100644 --- a/packages/typescript/test/async/api.test.ts +++ b/packages/typescript/test/async/api.test.ts @@ -75,6 +75,7 @@ import { type TypeParameter, TypePredicateKind, type TypeReference, + type TupleTypeReference, type UnionOrIntersectionType, } from "@typescript/typescript/unstable/async"; // @sync: } from "@typescript/typescript/unstable/sync"; import { createVirtualFileSystem } from "@typescript/typescript/unstable/fs"; @@ -2730,11 +2731,13 @@ export const tuple: readonly [number, string?, ...boolean[]] = [1]; const { type, api } = await getTypeAtName(spawnAPI(typeFiles), "tuple:"); try { assert.ok(type.flags & TypeFlags.Object); - const ref = type as TypeReference; + const ref = type as TupleTypeReference; assert.ok(ref.objectFlags & ObjectFlags.Reference); const target = await ref.getTarget(); assert.ok(target); assert.ok(target.flags & TypeFlags.Object); + assert.deepStrictEqual(target.elementFlags, [1, 2, 4]); + assert.equal(target.readonly, true); } finally { await api.close(); diff --git a/packages/typescript/test/sync/api.test.ts b/packages/typescript/test/sync/api.test.ts index d534bc20a6e4e..7007626925b27 100644 --- a/packages/typescript/test/sync/api.test.ts +++ b/packages/typescript/test/sync/api.test.ts @@ -80,6 +80,7 @@ import { SymbolFlags, type TemplateLiteralType, type TextEdit, + type TupleTypeReference, TypeFlags, TypeFormatFlags, type TypeParameter, @@ -2646,11 +2647,13 @@ export const tuple: readonly [number, string?, ...boolean[]] = [1]; const { type, api } = getTypeAtName(spawnAPI(typeFiles), "tuple:"); try { assert.ok(type.flags & TypeFlags.Object); - const ref = type as TypeReference; + const ref = type as TupleTypeReference; assert.ok(ref.objectFlags & ObjectFlags.Reference); const target = ref.getTarget(); assert.ok(target); assert.ok(target.flags & TypeFlags.Object); + assert.deepStrictEqual(target.elementFlags, [1, 2, 4]); + assert.equal(target.readonly, true); } finally { api.close(); From 9984da2a4749a0300a4039cfeb2ac41b11e1a34b Mon Sep 17 00:00:00 2001 From: mrazauskas Date: Fri, 28 Aug 2026 10:07:49 +0300 Subject: [PATCH 3/3] format Signed-off-by: mrazauskas --- packages/typescript/test/async/api.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typescript/test/async/api.test.ts b/packages/typescript/test/async/api.test.ts index 8bf100117cbcd..1622f40a694b0 100644 --- a/packages/typescript/test/async/api.test.ts +++ b/packages/typescript/test/async/api.test.ts @@ -70,12 +70,12 @@ import { SymbolFlags, type TemplateLiteralType, type TextEdit, + type TupleTypeReference, TypeFlags, TypeFormatFlags, type TypeParameter, TypePredicateKind, type TypeReference, - type TupleTypeReference, type UnionOrIntersectionType, } from "@typescript/typescript/unstable/async"; // @sync: } from "@typescript/typescript/unstable/sync"; import { createVirtualFileSystem } from "@typescript/typescript/unstable/fs";