Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
- Loading branch information
1 parent
2f6aa0b
commit c043c25
Showing
28 changed files
with
687 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import {CamelCasedPropertiesDeep} from '../ts41/camel-cased-properties-deep'; | ||
import {expectType} from 'tsd'; | ||
|
||
declare const foo: CamelCasedPropertiesDeep<{A: {B: number; C: Array<{D: string}>}}>; | ||
|
||
expectType<{a: {b: number; c: Array<{d: string}>}}>(foo); | ||
|
||
declare const fooBar: CamelCasedPropertiesDeep<() => {a: string}>; | ||
expectType<() => {a: string}>(fooBar); | ||
|
||
declare const bar: CamelCasedPropertiesDeep<Set<{fooBar: string}>>; | ||
expectType<Set<{fooBar: string}>>(bar); | ||
|
||
// Verify example | ||
interface User { | ||
UserId: number; | ||
UserName: string; | ||
} | ||
|
||
interface UserWithFriends { | ||
UserInfo: User; | ||
UserFriends: User[]; | ||
} | ||
|
||
const result: CamelCasedPropertiesDeep<UserWithFriends> = { | ||
userInfo: { | ||
userId: 1, | ||
userName: 'Tom' | ||
}, | ||
userFriends: [ | ||
{ | ||
userId: 2, | ||
userName: 'Jerry' | ||
}, | ||
{ | ||
userId: 3, | ||
userName: 'Spike' | ||
} | ||
] | ||
}; | ||
expectType<CamelCasedPropertiesDeep<UserWithFriends>>(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {CamelCasedProperties} from '../ts41/camel-cased-properties'; | ||
import {expectType} from 'tsd'; | ||
|
||
declare const foo: CamelCasedProperties<{A: number; B: {C: string}}>; | ||
|
||
expectType<{a: number; b: {C: string}}>(foo); | ||
|
||
declare const bar: CamelCasedProperties<Array<{helloWorld: string}>>; | ||
expectType<Array<{helloWorld: string}>>(bar); | ||
|
||
declare const fooBar: CamelCasedProperties<() => {a: string}>; | ||
expectType<() => {a: string}>(fooBar); | ||
|
||
// Verify example | ||
interface User { | ||
UserId: number; | ||
UserName: string; | ||
} | ||
|
||
const result: CamelCasedProperties<User> = { | ||
userId: 1, | ||
userName: 'Tom' | ||
}; | ||
expectType<CamelCasedProperties<User>>(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import {expectType} from 'tsd'; | ||
import {DelimiterCasedPropertiesDeep} from '../ts41/delimiter-cased-properties-deep'; | ||
|
||
declare const foo: DelimiterCasedPropertiesDeep<{helloWorld: {fooBar: string}}, '/'>; | ||
expectType<{'hello/world': {'foo/bar': string}}>(foo); | ||
|
||
declare const fooBar: DelimiterCasedPropertiesDeep<() => {a: string}, '/'>; | ||
expectType<() => {a: string}>(fooBar); | ||
|
||
declare const bar: DelimiterCasedPropertiesDeep<Set<{fooBar: string}>, '-'>; | ||
expectType<Set<{'foo-bar': string}>>(bar); | ||
|
||
// Verify example | ||
interface User { | ||
userId: number; | ||
userName: string; | ||
} | ||
|
||
interface UserWithFriends { | ||
userInfo: User; | ||
userFriends: User[]; | ||
} | ||
|
||
const result: DelimiterCasedPropertiesDeep<UserWithFriends, '-'> = { | ||
'user-info': { | ||
'user-id': 1, | ||
'user-name': 'Tom' | ||
}, | ||
'user-friends': [ | ||
{ | ||
'user-id': 2, | ||
'user-name': 'Jerry' | ||
}, | ||
{ | ||
'user-id': 3, | ||
'user-name': 'Spike' | ||
} | ||
] | ||
}; | ||
expectType<DelimiterCasedPropertiesDeep<UserWithFriends, '-'>>(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {expectType} from 'tsd'; | ||
import {DelimiterCasedProperties} from '../ts41/delimiter-cased-properties'; | ||
|
||
declare const foo: DelimiterCasedProperties<{helloWorld: {fooBar: string}}, '/'>; | ||
expectType<{'hello/world': {fooBar: string}}>(foo); | ||
|
||
declare const bar: DelimiterCasedProperties<Array<{helloWorld: string}>, '-'>; | ||
expectType<Array<{helloWorld: string}>>(bar); | ||
|
||
declare const fooBar: DelimiterCasedProperties<() => {a: string}, '-'>; | ||
expectType<() => {a: string}>(fooBar); | ||
|
||
// Verify example | ||
interface User { | ||
userId: number; | ||
userName: string; | ||
} | ||
const result: DelimiterCasedProperties<User, '-'> = { | ||
'user-id': 1, | ||
'user-name': 'Tom' | ||
}; | ||
expectType<DelimiterCasedProperties<User, '-'>>(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {KebabCasedPropertiesDeep} from '../ts41/kebab-cased-properties-deep'; | ||
import {expectType} from 'tsd'; | ||
|
||
declare const foo: KebabCasedPropertiesDeep<{helloWorld: {fooBar: string}}>; | ||
expectType<{'hello-world': {'foo-bar': string}}>(foo); | ||
|
||
declare const bar: KebabCasedPropertiesDeep<Set<{fooBar: string}>>; | ||
expectType<Set<{'foo-bar': string}>>(bar); | ||
|
||
// Verify example | ||
interface User { | ||
userId: number; | ||
userName: string; | ||
} | ||
|
||
interface UserWithFriends { | ||
userInfo: User; | ||
userFriends: User[]; | ||
} | ||
|
||
const result: KebabCasedPropertiesDeep<UserWithFriends> = { | ||
'user-info': { | ||
'user-id': 1, | ||
'user-name': 'Tom' | ||
}, | ||
'user-friends': [ | ||
{ | ||
'user-id': 2, | ||
'user-name': 'Jerry' | ||
}, | ||
{ | ||
'user-id': 3, | ||
'user-name': 'Spike' | ||
} | ||
] | ||
}; | ||
expectType<KebabCasedPropertiesDeep<UserWithFriends>>(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {KebabCasedProperties} from '../ts41/kebab-cased-properties'; | ||
import {expectType} from 'tsd'; | ||
|
||
declare const foo: KebabCasedProperties<{helloWorld: {fooBar: string}}>; | ||
expectType<{'hello-world': {fooBar: string}}>(foo); | ||
|
||
// Verify example | ||
interface User { | ||
userId: number; | ||
userName: string; | ||
} | ||
const result: KebabCasedProperties<User> = { | ||
'user-id': 1, | ||
'user-name': 'Tom' | ||
}; | ||
expectType<KebabCasedProperties<User>>(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import {PascalCasedPropertiesDeep} from '../ts41/pascal-cased-properties-deep'; | ||
import {expectType} from 'tsd'; | ||
|
||
declare const foo: PascalCasedPropertiesDeep<{helloWorld: {fooBar: string}}>; | ||
expectType<{HelloWorld: {FooBar: string}}>(foo); | ||
|
||
declare const fooBar: PascalCasedPropertiesDeep<() => {a: string}>; | ||
expectType<() => {a: string}>(fooBar); | ||
|
||
declare const bar: PascalCasedPropertiesDeep<Set<{fooBar: string}>>; | ||
expectType<Set<{FooBar: string}>>(bar); | ||
|
||
// Verify example | ||
interface User { | ||
userId: number; | ||
userName: string; | ||
} | ||
|
||
interface UserWithFriends { | ||
userInfo: User; | ||
userFriends: User[]; | ||
} | ||
|
||
const result: PascalCasedPropertiesDeep<UserWithFriends> = { | ||
UserInfo: { | ||
UserId: 1, | ||
UserName: 'Tom' | ||
}, | ||
UserFriends: [ | ||
{ | ||
UserId: 2, | ||
UserName: 'Jerry' | ||
}, | ||
{ | ||
UserId: 3, | ||
UserName: 'Spike' | ||
} | ||
] | ||
}; | ||
expectType<PascalCasedPropertiesDeep<UserWithFriends>>(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {PascalCasedProperties} from '../ts41/pascal-cased-properties'; | ||
import {expectType} from 'tsd'; | ||
|
||
declare const foo: PascalCasedProperties<{helloWorld: {fooBar: string}}>; | ||
expectType<{HelloWorld: {fooBar: string}}>(foo); | ||
|
||
declare const bar: PascalCasedProperties<Array<{helloWorld: string}>>; | ||
expectType<Array<{helloWorld: string}>>(bar); | ||
|
||
declare const fooBar: PascalCasedProperties<() => {a: string}>; | ||
expectType<() => {a: string}>(fooBar); | ||
|
||
// Verify example | ||
interface User { | ||
userId: number; | ||
userName: string; | ||
} | ||
const result: PascalCasedProperties<User> = { | ||
UserId: 1, | ||
UserName: 'Tom' | ||
}; | ||
expectType<PascalCasedProperties<User>>(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {SnakeCasedPropertiesDeep} from '../ts41/snake-cased-properties-deep'; | ||
import {expectType} from 'tsd'; | ||
|
||
declare const foo: SnakeCasedPropertiesDeep<{helloWorld: {fooBar: string}}>; | ||
expectType<{hello_world: {foo_bar: string}}>(foo); | ||
|
||
declare const bar: SnakeCasedPropertiesDeep<Set<{fooBar: string}>>; | ||
expectType<Set<{foo_bar: string}>>(bar); | ||
|
||
// Verify example | ||
interface User { | ||
userId: number; | ||
userName: string; | ||
} | ||
|
||
interface UserWithFriends { | ||
userInfo: User; | ||
userFriends: User[]; | ||
} | ||
|
||
const result: SnakeCasedPropertiesDeep<UserWithFriends> = { | ||
user_info: { | ||
user_id: 1, | ||
user_name: 'Tom' | ||
}, | ||
user_friends: [ | ||
{ | ||
user_id: 2, | ||
user_name: 'Jerry' | ||
}, | ||
{ | ||
user_id: 3, | ||
user_name: 'Spike' | ||
} | ||
] | ||
}; | ||
expectType<SnakeCasedPropertiesDeep<UserWithFriends>>(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {SnakeCasedProperties} from '../ts41/snake-cased-properties'; | ||
import {expectType} from 'tsd'; | ||
|
||
declare const foo: SnakeCasedProperties<{helloWorld: {fooBar: string}}>; | ||
expectType<{hello_world: {fooBar: string}}>(foo); | ||
|
||
// Verify example | ||
interface User { | ||
userId: number; | ||
userName: string; | ||
} | ||
const result: SnakeCasedProperties<User> = { | ||
user_id: 1, | ||
user_name: 'Tom' | ||
}; | ||
expectType<SnakeCasedProperties<User>>(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.