diff --git a/source/delimiter-cased-properties-deep.d.ts b/source/delimiter-cased-properties-deep.d.ts index ce7971024..06558fe1d 100644 --- a/source/delimiter-cased-properties-deep.d.ts +++ b/source/delimiter-cased-properties-deep.d.ts @@ -50,17 +50,15 @@ export type DelimiterCasedPropertiesDeep< Delimiter extends string, > = Value extends Function | Date | RegExp ? Value - : Value extends string - ? DelimiterCase - : Value extends UnknownArray - ? DelimiterCasedPropertiesArrayDeep - : Value extends Set - ? Set> : { - [K in keyof Value as DelimiterCase< - K, - Delimiter - >]: DelimiterCasedPropertiesDeep; - }; + : Value extends UnknownArray + ? DelimiterCasedPropertiesArrayDeep + : Value extends Set + ? Set> : { + [K in keyof Value as DelimiterCase< + K, + Delimiter + >]: DelimiterCasedPropertiesDeep; + }; type DelimiterCasedPropertiesArrayDeep = Value extends [] diff --git a/test-d/delimiter-cased-properties-deep.ts b/test-d/delimiter-cased-properties-deep.ts index a80488c0a..288a882cf 100644 --- a/test-d/delimiter-cased-properties-deep.ts +++ b/test-d/delimiter-cased-properties-deep.ts @@ -53,20 +53,30 @@ expectType<{readonly 'user-id'?: number}>(key); /** Test Array */ // Test for tuple -declare const tuple: DelimiterCasedPropertiesDeep<['userId', 'userName'], '-'>; -expectType<['user-id', 'user-name']>(tuple); -// Test for readonly -declare const readonlyTuple: DelimiterCasedPropertiesDeep; -expectType(readonlyTuple); +declare const tuple: DelimiterCasedPropertiesDeep<[User], '-'>; +expectType<[{'user-id': number;'user-name': string;date: Date;'reg-exp': RegExp}]>(tuple); +declare const tuple2: DelimiterCasedPropertiesDeep<['UserId', 'UserAge', string], '-'>; +expectType<['UserId', 'UserAge', string]>(tuple2); +// Test for readonly tuple +declare const readonlyTuple: DelimiterCasedPropertiesDeep; +expectType(readonlyTuple); // Test for array -declare const array: DelimiterCasedPropertiesDeep, '-'>; -expectType>(array); +declare const array: DelimiterCasedPropertiesDeep; +expectType>(array); // Test for readonly array -declare const readonlyArray: DelimiterCasedPropertiesDeep, '-'>; -expectType>(readonlyArray); +declare const readonlyArray: DelimiterCasedPropertiesDeep, '-'>; +expectType>(readonlyArray); // Test for tailing spread array -declare const tailingSpreadArray: DelimiterCasedPropertiesDeep<['userId', 'userName', ...Array<'userAge'>], '-'>; -expectType<['user-id', 'user-name', ...Array<'user-age'>]>(tailingSpreadArray); +declare const tailingSpreadArray: DelimiterCasedPropertiesDeep<[{userId: string}, {userName: number}, ...Array<{userAge: number}>], '-'>; +expectType<[{'user-id': string}, {'user-name': number}, ...Array<{'user-age': number}>]>(tailingSpreadArray); // Test for leading spread array -declare const leadingSpreadArray: DelimiterCasedPropertiesDeep<[...Array<'userId'>, 'userName', 'userAge'], '-'>; -expectType<[...Array<'user-id'>, 'user-name', 'user-age']>(leadingSpreadArray); +declare const leadingSpreadArray: DelimiterCasedPropertiesDeep<[...Array<{userId: string}>, {userName: number}, {userAge: number}], '-'>; +expectType<[...Array<{'user-id': string}>, {'user-name': number}, {'user-age': number}]>(leadingSpreadArray); +// Test for enum +enum UserType { + AdminUser = 'adminUser', + NormalUser = 'normalUser', +} +declare const enumTest: DelimiterCasedPropertiesDeep<{userType: UserType}, '-'>; +expectType<{['user-type']: UserType}>(enumTest); +enumTest['user-type'] = UserType.AdminUser;