8000 Simplify indexed access types applied to mapped types by ahejlsberg · Pull Request #28965 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content

Simplify indexed access types applied to mapped types #28965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update tests
  • Loading branch information
ahejlsberg committed Dec 11, 2018
commit 77d01ab332bce00322a0c76c5a94e77e45abf9db
4 changes: 2 additions & 2 deletions tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,10 @@ function onChangeGenericFunction<T>(handler: Handler<T & {preset: number}>) {
function updateIds<T extends Record<K, string>, K extends string>(
obj: T,
idFields: K[],
idMapping: { [oldId: string]: string }
idMapping: Partial<Record<T[K], T[K]>>
): Record<K, string> {
for (const idField of idFields) {
const newId = idMapping[obj[idField]];
const newId: T[K] | undefined = idMapping[obj[idField]];
if (newId) {
obj[idField] = newId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,6 @@ function f30<T, K extends keyof T>() {
let x: Partial<Record<keyof T, string>>[K] = "hello";
}

// We simplify indexed accesses applied to mapped types up to five levels deep

function f31<T, K extends keyof T>() {
let x: Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>[K] = "hello";
}

function f32<T, K extends keyof T>() {
let x: Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>[K] = "hello";
let x: Partial<Partial<Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>>>[K] = "hello";
}
0