Skip to content

Get: Enhance Get type to support dot-separated keys#1373

Draft
Emiyaaaaa wants to merge 2 commits into
sindresorhus:mainfrom
Emiyaaaaa:fix/get
Draft

Get: Enhance Get type to support dot-separated keys#1373
Emiyaaaaa wants to merge 2 commits into
sindresorhus:mainfrom
Emiyaaaaa:fix/get

Conversation

@Emiyaaaaa

@Emiyaaaaa Emiyaaaaa commented Mar 2, 2026

Copy link
Copy Markdown
Collaborator

Closes #1372

@Emiyaaaaa Emiyaaaaa requested review from sindresorhus and som-sm and removed request for som-sm March 2, 2026 09:24
Comment thread test-d/get.ts
};

expectTypeOf<Get<Ambiguous, 'a.b', NonStrict>>().toBeNumber();
expectTypeOf<Get<Ambiguous, ['a.b'], NonStrict>>().toBeString();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
expectTypeOf<Get<Ambiguous, ['a.b'], NonStrict>>().toBeString();
expectTypeOf<Get<Ambiguous, ['a.b'], NonStrict>>().toBeString();
// Prefer the longest exact dotted key match when multiple dotted keys overlap
type OverlappingDotKeys = {
'a.b': string;
'a.b.c': number;
};
expectTypeOf<Get<OverlappingDotKeys, 'a.b.c', NonStrict>>().toBeNumber();
expectTypeOf<Get<OverlappingDotKeys, ['a.b.c'], NonStrict>>().toBeNumber();
// Longer exact dotted key should continue resolving the remaining path
type OverlappingDotKeysNested = {
'a.b': {
c: string;
};
'a.b.c': {
d: boolean;
};
};
expectTypeOf<Get<OverlappingDotKeysNested, 'a.b.c.d', NonStrict>>().toBeBoolean();
expectTypeOf<Get<OverlappingDotKeysNested, ['a.b.c', 'd'], NonStrict>>().toBeBoolean();

Repository owner deleted a comment from shahnoormujawar Mar 6, 2026
@Emiyaaaaa Emiyaaaaa marked this pull request as draft May 15, 2026 03:06
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.

Get incorrect behavior

2 participants