Skip to content

Commit

Permalink
Fix: Copy array/tuple-logic from DelimiterCasedPropertiesDeep to Came…
Browse files Browse the repository at this point in the history
…lCasedPropertiesDeep to fix changing tuple-type to array-type
  • Loading branch information
pmk1c committed Feb 21, 2024
1 parent e02f228 commit 7a66ce8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
27 changes: 21 additions & 6 deletions source/camel-cased-properties-deep.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,24 @@ const result: CamelCasedPropertiesDeep<UserWithFriends> = {
*/
export type CamelCasedPropertiesDeep<Value, Options extends CamelCaseOptions = {preserveConsecutiveUppercase: true}> = Value extends Function
? Value
: Value extends Array<infer U>
? Array<CamelCasedPropertiesDeep<U, Options>>
: Value extends Set<infer U>
? Set<CamelCasedPropertiesDeep<U, Options>> : {
[K in keyof Value as CamelCase<K, Options>]: CamelCasedPropertiesDeep<Value[K], Options>;
};
: Value extends []
? []

Check failure on line 50 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected indentation of 2 tabs but found 1.

Check failure on line 50 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected indentation of 2 tabs but found 1.

Check failure on line 50 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 16

Expected indentation of 2 tabs but found 1.
// Tailing spread array
: Value extends [infer U, ...infer V]

Check failure on line 52 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected indentation of 2 tabs but found 1.

Check failure on line 52 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected indentation of 2 tabs but found 1.

Check failure on line 52 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 16

Expected indentation of 2 tabs but found 1.
? [CamelCasedPropertiesDeep<U>, ...CamelCasedPropertiesDeep<V>]

Check failure on line 53 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected indentation of 3 tabs but found 2.

Check failure on line 53 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected indentation of 3 tabs but found 2.

Check failure on line 53 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 16

Expected indentation of 3 tabs but found 2.
: Value extends readonly [infer U, ...infer V]

Check failure on line 54 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected indentation of 3 tabs but found 2.

Check failure on line 54 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected indentation of 3 tabs but found 2.

Check failure on line 54 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 16

Expected indentation of 3 tabs but found 2.
? readonly [CamelCasedPropertiesDeep<U>, ...CamelCasedPropertiesDeep<V>]

Check failure on line 55 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected indentation of 4 tabs but found 3.

Check failure on line 55 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected indentation of 4 tabs but found 3.

Check failure on line 55 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 16

Expected indentation of 4 tabs but found 3.
// Leading spread array
: Value extends readonly [...infer U, infer V]

Check failure on line 57 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected indentation of 4 tabs but found 3.

Check failure on line 57 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected indentation of 4 tabs but found 3.

Check failure on line 57 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 16

Expected indentation of 4 tabs but found 3.
? [...CamelCasedPropertiesDeep<U>, CamelCasedPropertiesDeep<V>]

Check failure on line 58 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected indentation of 5 tabs but found 4.

Check failure on line 58 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected indentation of 5 tabs but found 4.

Check failure on line 58 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 16

Expected indentation of 5 tabs but found 4.
: Value extends readonly [...infer U, infer V]

Check failure on line 59 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected indentation of 5 tabs but found 4.

Check failure on line 59 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected indentation of 5 tabs but found 4.

Check failure on line 59 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 16

Expected indentation of 5 tabs but found 4.
? readonly [...CamelCasedPropertiesDeep<U>, CamelCasedPropertiesDeep<V>]

Check failure on line 60 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected indentation of 6 tabs but found 5.

Check failure on line 60 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected indentation of 6 tabs but found 5.

Check failure on line 60 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 16

Expected indentation of 6 tabs but found 5.
// Array
: Value extends Array<infer U>

Check failure on line 62 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected indentation of 6 tabs but found 5.

Check failure on line 62 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected indentation of 6 tabs but found 5.

Check failure on line 62 in source/camel-cased-properties-deep.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 16

Expected indentation of 6 tabs but found 5.
? Array<CamelCasedPropertiesDeep<U>>
: Value extends ReadonlyArray<infer U>
? ReadonlyArray<CamelCasedPropertiesDeep<U>>
: Value extends Set<infer U>
? Set<CamelCasedPropertiesDeep<U, Options>> : {
[K in keyof Value as CamelCase<K, Options>]: CamelCasedPropertiesDeep<Value[K], Options>;
};
3 changes: 3 additions & 0 deletions test-d/camel-cased-properties-deep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ expectType<{fooBAR: number; baz: {fooBAR: number; bARFoo: string}}>(baz);
declare const biz: CamelCasedPropertiesDeep<bazBizDeep, {preserveConsecutiveUppercase: false}>;
expectType<{fooBar: number; baz: {fooBar: number; barFoo: string}}>(biz);

declare const tuple: CamelCasedPropertiesDeep<{tuple: [number, string, {D: string}]}>;
expectType<{tuple: [number, string, {d: string}]}>(tuple);

// Verify example
type User = {
UserId: number;
Expand Down

0 comments on commit 7a66ce8

Please sign in to comment.