Skip to content

Cater for shapes where keys are not all strings in AddPrefixToKeys interface definition #6371

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion common/api-review/firestore-lite.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function addDoc<T>(reference: CollectionReference<T>, data: WithFieldValu

// @public
export type AddPrefixToKeys<Prefix extends string, T extends Record<string, unknown>> = {
[K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
[K in keyof T as K extends string ? `${Prefix}.${K}`: K]+?: T[K]
};

// @public
Expand Down
2 changes: 1 addition & 1 deletion common/api-review/firestore.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function addDoc<T>(reference: CollectionReference<T>, data: WithFieldValu

// @public
export type AddPrefixToKeys<Prefix extends string, T extends Record<string, unknown>> = {
[K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
[K in keyof T as K extends string ? `${Prefix}.${K}`: K]+?: T[K]
};

// @public
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/src/lite-api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export type AddPrefixToKeys<
T extends Record<string, unknown>
> =
// Remap K => Prefix.K. See https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#key-remapping-via-as
{ [K in keyof T & string as `${Prefix}.${K}`]+?: T[K] };
{ [K in keyof T as K extends string ? `${Prefix}.${K}`: K]+?: T[K] };

/**
* Given a union type `U = T1 | T2 | ...`, returns an intersected type
Expand Down