Skip to content
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

fix(utils): remove the type that deleted the symbol which name is ObjectKeys. #215

Merged
merged 1 commit into from
Feb 22, 2023
Merged
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
18 changes: 18 additions & 0 deletions packages/common/utils/src/object/pick.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,22 @@ describe('pick', () => {
JP: 'JP',
});
});
it('should create an object composed of the given symbol keys', () => {
const FooSymbol = Symbol('foo');
const BarSymbol = Symbol('bar');

const symbols = {
[FooSymbol]: 'foo',
[BarSymbol]: 'bar',
} as const;

expect(pick(symbols, [FooSymbol])).toStrictEqual({
[FooSymbol]: 'foo',
});

expect(pick(symbols, [FooSymbol])).not.toStrictEqual({
[FooSymbol]: 'foo',
[BarSymbol]: 'bar',
});
});
});
3 changes: 1 addition & 2 deletions packages/common/utils/src/object/pick.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/** @tossdocs-ignore */
import { ObjectKeys } from '.';
import { ElementType } from './types';

export function pick<ObjectType extends Record<PropertyKey, unknown>, KeyTypes extends Array<ObjectKeys<ObjectType>>>(
export function pick<ObjectType extends Record<PropertyKey, unknown>, KeyTypes extends Array<keyof ObjectType>>(
obj: ObjectType,
keys: KeyTypes
) {
Expand Down