Skip to content

Commit

Permalink
fix: any 타입을 unknown 타입으로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
2wndrhs committed Jan 9, 2024
1 parent 8c0f8f6 commit de2150f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion FrequencyCounter/areThereDuplicates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// 요소가 객체에 없다면 요소를 객체에 저장
// 정상적으로 배열을 순회했다면 false 반환

const areThereDuplicates = (...args: any[]): boolean => {
const areThereDuplicates = (...args: unknown[]): boolean => {
const map = new Map();

return args.some((value) => {
Expand Down
4 changes: 2 additions & 2 deletions Recursion/flatten.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ describe('flatten', () => {
});

it('빈 배열이 입력으로 들어올 경우 빈 배열 반환', () => {
const input: any[] = [];
const expectedOutput: any[] = [];
const input: unknown[] = [];
const expectedOutput: unknown[] = [];

expect(flatten(input)).toEqual(expectedOutput);
});
Expand Down
6 changes: 3 additions & 3 deletions Recursion/flatten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
// 원본 배열로 `helper` 함수를 호출
// `flattened` 배열 반환

const flatten = (input: any[]): any[] => {
const flattened: any[] = [];
const flatten = (input: unknown[]): unknown[] => {
const flattened: unknown[] = [];

const helper = (array: any[]): void => {
const helper = (array: unknown[]): void => {
if (array.length === 0) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions Recursion/someRecursive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// `array`의 첫 번째 요소를 인자로 콜백 함수를 호출한 결과가 `true`라면 `true` 반환
// `array`의 첫 번째 요소를 인자로 콜백 함수를 호출한 결과가 `false`라면 첫 번째 요소를 제외한 배열로 함수를 재귀호출한 결과를 반환

type CallbackFn = (element: any) => boolean;
type SomeRecursiveFn = (array: any[], callback: CallbackFn) => boolean;
type CallbackFn<T> = (element: T) => boolean;
type SomeRecursiveFn = <T>(array: T[], callback: CallbackFn<T>) => boolean;

const someRecursive: SomeRecursiveFn = (array, callback) => {
if (array.length === 0) {
Expand Down

0 comments on commit de2150f

Please sign in to comment.