mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add an extra test case for mapped type relationships (#53232)
This commit is contained in:
@@ -372,4 +372,21 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS
|
||||
function f<T extends { x: {} }>(): Partial<T> {
|
||||
return undefined! as T;
|
||||
}
|
||||
|
||||
|
||||
// #32365
|
||||
interface SettingsTypes {
|
||||
audio: {
|
||||
volume: string;
|
||||
};
|
||||
video: {
|
||||
resolution: string;
|
||||
};
|
||||
}
|
||||
interface Settings<Params extends { [K in keyof Params]?: string }> {
|
||||
config: Params;
|
||||
}
|
||||
type ConcreteSettingsResult1 = Settings<SettingsTypes["audio"]>;
|
||||
type ConcreteSettingsResult2 = Settings<SettingsTypes["audio" | "video"]>;
|
||||
type GenericSettingsAccess<T extends keyof SettingsTypes> = Settings<SettingsTypes[T]>;
|
||||
type GenericSettingsResult1 = GenericSettingsAccess<"audio">;
|
||||
type GenericSettingsResult2 = GenericSettingsAccess<"audio" | "video">;
|
||||
@@ -190,7 +190,24 @@ function f90<T extends { x: number }>() {
|
||||
function f<T extends { x: {} }>(): Partial<T> {
|
||||
return undefined! as T;
|
||||
}
|
||||
|
||||
|
||||
// #32365
|
||||
interface SettingsTypes {
|
||||
audio: {
|
||||
volume: string;
|
||||
};
|
||||
video: {
|
||||
resolution: string;
|
||||
};
|
||||
}
|
||||
interface Settings<Params extends { [K in keyof Params]?: string }> {
|
||||
config: Params;
|
||||
}
|
||||
type ConcreteSettingsResult1 = Settings<SettingsTypes["audio"]>;
|
||||
type ConcreteSettingsResult2 = Settings<SettingsTypes["audio" | "video"]>;
|
||||
type GenericSettingsAccess<T extends keyof SettingsTypes> = Settings<SettingsTypes[T]>;
|
||||
type GenericSettingsResult1 = GenericSettingsAccess<"audio">;
|
||||
type GenericSettingsResult2 = GenericSettingsAccess<"audio" | "video">;
|
||||
|
||||
//// [mappedTypeRelationships.js]
|
||||
function f1(x, k) {
|
||||
@@ -418,3 +435,21 @@ declare function f90<T extends {
|
||||
declare function f<T extends {
|
||||
x: {};
|
||||
}>(): Partial<T>;
|
||||
interface SettingsTypes {
|
||||
audio: {
|
||||
volume: string;
|
||||
};
|
||||
video: {
|
||||
resolution: string;
|
||||
};
|
||||
}
|
||||
interface Settings<Params extends {
|
||||
[K in keyof Params]?: string;
|
||||
}> {
|
||||
config: Params;
|
||||
}
|
||||
type ConcreteSettingsResult1 = Settings<SettingsTypes["audio"]>;
|
||||
type ConcreteSettingsResult2 = Settings<SettingsTypes["audio" | "video"]>;
|
||||
type GenericSettingsAccess<T extends keyof SettingsTypes> = Settings<SettingsTypes[T]>;
|
||||
type GenericSettingsResult1 = GenericSettingsAccess<"audio">;
|
||||
type GenericSettingsResult2 = GenericSettingsAccess<"audio" | "video">;
|
||||
|
||||
@@ -836,3 +836,58 @@ function f<T extends { x: {} }>(): Partial<T> {
|
||||
>T : Symbol(T, Decl(mappedTypeRelationships.ts, 188, 11))
|
||||
}
|
||||
|
||||
// #32365
|
||||
interface SettingsTypes {
|
||||
>SettingsTypes : Symbol(SettingsTypes, Decl(mappedTypeRelationships.ts, 190, 1))
|
||||
|
||||
audio: {
|
||||
>audio : Symbol(SettingsTypes.audio, Decl(mappedTypeRelationships.ts, 193, 25))
|
||||
|
||||
volume: string;
|
||||
>volume : Symbol(volume, Decl(mappedTypeRelationships.ts, 194, 10))
|
||||
|
||||
};
|
||||
video: {
|
||||
>video : Symbol(SettingsTypes.video, Decl(mappedTypeRelationships.ts, 196, 4))
|
||||
|
||||
resolution: string;
|
||||
>resolution : Symbol(resolution, Decl(mappedTypeRelationships.ts, 197, 10))
|
||||
|
||||
};
|
||||
}
|
||||
interface Settings<Params extends { [K in keyof Params]?: string }> {
|
||||
>Settings : Symbol(Settings, Decl(mappedTypeRelationships.ts, 200, 1))
|
||||
>Params : Symbol(Params, Decl(mappedTypeRelationships.ts, 201, 19))
|
||||
>K : Symbol(K, Decl(mappedTypeRelationships.ts, 201, 37))
|
||||
>Params : Symbol(Params, Decl(mappedTypeRelationships.ts, 201, 19))
|
||||
|
||||
config: Params;
|
||||
>config : Symbol(Settings.config, Decl(mappedTypeRelationships.ts, 201, 69))
|
||||
>Params : Symbol(Params, Decl(mappedTypeRelationships.ts, 201, 19))
|
||||
}
|
||||
type ConcreteSettingsResult1 = Settings<SettingsTypes["audio"]>;
|
||||
>ConcreteSettingsResult1 : Symbol(ConcreteSettingsResult1, Decl(mappedTypeRelationships.ts, 203, 1))
|
||||
>Settings : Symbol(Settings, Decl(mappedTypeRelationships.ts, 200, 1))
|
||||
>SettingsTypes : Symbol(SettingsTypes, Decl(mappedTypeRelationships.ts, 190, 1))
|
||||
|
||||
type ConcreteSettingsResult2 = Settings<SettingsTypes["audio" | "video"]>;
|
||||
>ConcreteSettingsResult2 : Symbol(ConcreteSettingsResult2, Decl(mappedTypeRelationships.ts, 204, 64))
|
||||
>Settings : Symbol(Settings, Decl(mappedTypeRelationships.ts, 200, 1))
|
||||
>SettingsTypes : Symbol(SettingsTypes, Decl(mappedTypeRelationships.ts, 190, 1))
|
||||
|
||||
type GenericSettingsAccess<T extends keyof SettingsTypes> = Settings<SettingsTypes[T]>;
|
||||
>GenericSettingsAccess : Symbol(GenericSettingsAccess, Decl(mappedTypeRelationships.ts, 205, 74))
|
||||
>T : Symbol(T, Decl(mappedTypeRelationships.ts, 206, 27))
|
||||
>SettingsTypes : Symbol(SettingsTypes, Decl(mappedTypeRelationships.ts, 190, 1))
|
||||
>Settings : Symbol(Settings, Decl(mappedTypeRelationships.ts, 200, 1))
|
||||
>SettingsTypes : Symbol(SettingsTypes, Decl(mappedTypeRelationships.ts, 190, 1))
|
||||
>T : Symbol(T, Decl(mappedTypeRelationships.ts, 206, 27))
|
||||
|
||||
type GenericSettingsResult1 = GenericSettingsAccess<"audio">;
|
||||
>GenericSettingsResult1 : Symbol(GenericSettingsResult1, Decl(mappedTypeRelationships.ts, 206, 87))
|
||||
>GenericSettingsAccess : Symbol(GenericSettingsAccess, Decl(mappedTypeRelationships.ts, 205, 74))
|
||||
|
||||
type GenericSettingsResult2 = GenericSettingsAccess<"audio" | "video">;
|
||||
>GenericSettingsResult2 : Symbol(GenericSettingsResult2, Decl(mappedTypeRelationships.ts, 207, 61))
|
||||
>GenericSettingsAccess : Symbol(GenericSettingsAccess, Decl(mappedTypeRelationships.ts, 205, 74))
|
||||
|
||||
|
||||
@@ -678,3 +678,39 @@ function f<T extends { x: {} }>(): Partial<T> {
|
||||
>undefined : undefined
|
||||
}
|
||||
|
||||
// #32365
|
||||
interface SettingsTypes {
|
||||
audio: {
|
||||
>audio : { volume: string; }
|
||||
|
||||
volume: string;
|
||||
>volume : string
|
||||
|
||||
};
|
||||
video: {
|
||||
>video : { resolution: string; }
|
||||
|
||||
resolution: string;
|
||||
>resolution : string
|
||||
|
||||
};
|
||||
}
|
||||
interface Settings<Params extends { [K in keyof Params]?: string }> {
|
||||
config: Params;
|
||||
>config : Params
|
||||
}
|
||||
type ConcreteSettingsResult1 = Settings<SettingsTypes["audio"]>;
|
||||
>ConcreteSettingsResult1 : Settings<{ volume: string; }>
|
||||
|
||||
type ConcreteSettingsResult2 = Settings<SettingsTypes["audio" | "video"]>;
|
||||
>ConcreteSettingsResult2 : Settings<{ volume: string; } | { resolution: string; }>
|
||||
|
||||
type GenericSettingsAccess<T extends keyof SettingsTypes> = Settings<SettingsTypes[T]>;
|
||||
>GenericSettingsAccess : GenericSettingsAccess<T>
|
||||
|
||||
type GenericSettingsResult1 = GenericSettingsAccess<"audio">;
|
||||
>GenericSettingsResult1 : Settings<{ volume: string; }>
|
||||
|
||||
type GenericSettingsResult2 = GenericSettingsAccess<"audio" | "video">;
|
||||
>GenericSettingsResult2 : Settings<{ volume: string; } | { resolution: string; }>
|
||||
|
||||
|
||||
@@ -192,3 +192,21 @@ function f90<T extends { x: number }>() {
|
||||
function f<T extends { x: {} }>(): Partial<T> {
|
||||
return undefined! as T;
|
||||
}
|
||||
|
||||
// #32365
|
||||
interface SettingsTypes {
|
||||
audio: {
|
||||
volume: string;
|
||||
};
|
||||
video: {
|
||||
resolution: string;
|
||||
};
|
||||
}
|
||||
interface Settings<Params extends { [K in keyof Params]?: string }> {
|
||||
config: Params;
|
||||
}
|
||||
type ConcreteSettingsResult1 = Settings<SettingsTypes["audio"]>;
|
||||
type ConcreteSettingsResult2 = Settings<SettingsTypes["audio" | "video"]>;
|
||||
type GenericSettingsAccess<T extends keyof SettingsTypes> = Settings<SettingsTypes[T]>;
|
||||
type GenericSettingsResult1 = GenericSettingsAccess<"audio">;
|
||||
type GenericSettingsResult2 = GenericSettingsAccess<"audio" | "video">;
|
||||
Reference in New Issue
Block a user