Skip to content

Commit 622c546

Browse files
committed
Minor tweaks
1 parent 852d016 commit 622c546

12 files changed

+100
-7
lines changed

.github/workflows/claude-code-review.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ jobs:
4040
4141
Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
4242
43+
Be succinct. Double-check everything.
44+
4345
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
4446
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
4547
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'

.github/workflows/main.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
- 22
2121
- 20
2222
steps:
23-
- uses: actions/checkout@v5
24-
- uses: actions/setup-node@v5
23+
- uses: actions/checkout@v6
24+
- uses: actions/setup-node@v6
2525
with:
2626
node-version: ${{ matrix.node-version }}
2727
- run: npm install
@@ -34,10 +34,11 @@ jobs:
3434
matrix:
3535
typescript-version:
3636
- 'latest'
37+
- '~6.0.0'
3738
- '~5.9.0'
3839
steps:
39-
- uses: actions/checkout@v5
40-
- uses: actions/setup-node@v5
40+
- uses: actions/checkout@v6
41+
- uses: actions/setup-node@v6
4142
with:
4243
node-version: 24
4344
- run: npm install

.github/workflows/ts-canary.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
- next
1616
- latest
1717
steps:
18-
- uses: actions/checkout@v5
19-
- uses: actions/setup-node@v5
18+
- uses: actions/checkout@v6
19+
- uses: actions/setup-node@v6
2020
with:
2121
node-version: lts/*
2222
- run: npm install

source/delimiter-case.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import type {DelimiterCase} from 'type-fest';
3838
3939
const someVariable: DelimiterCase<'fooBar', '#'> = 'foo#bar';
4040
const someVariableNoSplitOnNumbers: DelimiterCase<'p2pNetwork', '#', {splitOnNumbers: false}> = 'p2p#network';
41+
const someVariableWithPunctuation: DelimiterCase<'div.card::after', '#', {splitOnPunctuation: true}> = 'div#card#after';
4142
4243
// Advanced
4344

source/delimiter-cased-properties-deep.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ const splitOnNumbers: DelimiterCasedPropertiesDeep<{line1: {line2: [{line3: stri
5151
],
5252
},
5353
};
54+
55+
const splitOnPunctuation: DelimiterCasedPropertiesDeep<{'user@info': {'user::id': number; 'user::name': string}}, '-', {splitOnPunctuation: true}> = {
56+
'user-info': {
57+
'user-id': 1,
58+
'user-name': 'Tom',
59+
},
60+
};
5461
```
5562
5663
@category Change case

source/delimiter-cased-properties.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ const result: DelimiterCasedProperties<User, '-'> = {
2727
const splitOnNumbers: DelimiterCasedProperties<{line1: string}, '-', {splitOnNumbers: true}> = {
2828
'line-1': 'string',
2929
};
30+
31+
const splitOnPunctuation: DelimiterCasedProperties<{'foo::bar': string}, '-', {splitOnPunctuation: true}> = {
32+
'foo-bar': 'string',
33+
};
3034
```
3135
3236
@category Change case

source/screaming-snake-case.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {ScreamingSnakeCase} from 'type-fest';
1414
1515
const someVariable: ScreamingSnakeCase<'fooBar'> = 'FOO_BAR';
1616
const someVariableNoSplitOnNumbers: ScreamingSnakeCase<'p2pNetwork', {splitOnNumbers: false}> = 'P2P_NETWORK';
17+
const someVariableWithPunctuation: ScreamingSnakeCase<'div.card::after', {splitOnPunctuation: true}> = 'DIV_CARD_AFTER';
1718
1819
```
1920

source/words.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ type Words6 = Words<'hello:world', {splitOnPunctuation: true}>;
9797
type Words7 = Words<'hello:world', {splitOnPunctuation: false}>;
9898
//=> ['hello', ':world']
9999
100-
type Words8 = Words<'hello:world', {splitOnPunctuation: true}>;
100+
type Words8 = Words<'hello::world', {splitOnPunctuation: true}>;
101101
//=> ['hello', 'world']
102102
```
103103

test-d/delimiter-case.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,39 @@ expectType<`foo${string}`>(stringPart);
115115
declare const withPunctuation: DelimiterCase<'onDialog:close', '#'>;
116116
expectType<'on#dialog:close'>(withPunctuation);
117117

118+
declare const withPunctuationAndSplit: DelimiterCase<'onDialog:close', '#', {splitOnPunctuation: true}>;
119+
expectType<'on#dialog#close'>(withPunctuationAndSplit);
120+
118121
declare const withPunctuation2: DelimiterCase<'foo-bar>>baz', '#'>;
119122
expectType<'foo#bar>>baz'>(withPunctuation2);
120123

124+
declare const withPunctuationAndSplit2: DelimiterCase<'foo-bar>>baz', '#', {splitOnPunctuation: true}>;
125+
expectType<'foo#bar#baz'>(withPunctuationAndSplit2);
126+
121127
declare const withPunctuation3: DelimiterCase<'card::after', '#'>;
122128
expectType<'card::after'>(withPunctuation3);
123129

130+
declare const withPunctuationAndSplit3: DelimiterCase<'card::after', '#', {splitOnPunctuation: true}>;
131+
expectType<'card#after'>(withPunctuationAndSplit3);
132+
124133
declare const withPunctuation4: DelimiterCase<'div.card::after', '#'>;
125134
expectType<'div.card::after'>(withPunctuation4);
126135

136+
declare const withPunctuationAndSplit4: DelimiterCase<'div.card::after', '#', {splitOnPunctuation: true}>;
137+
expectType<'div#card#after'>(withPunctuationAndSplit4);
138+
127139
declare const withPunctuationAndNumber: DelimiterCase<'foo-bar::01', '#'>;
128140
expectType<'foo#bar::01'>(withPunctuationAndNumber);
129141

130142
declare const withPunctuationAndNumber2: DelimiterCase<'foo-bar::01', '#', {splitOnNumbers: true}>;
131143
expectType<'foo#bar::#01'>(withPunctuationAndNumber2);
132144

145+
declare const withPunctuationSplitAndNumber: DelimiterCase<'foo-bar::01', '#', {splitOnPunctuation: true}>;
146+
expectType<'foo#bar#01'>(withPunctuationSplitAndNumber);
147+
148+
declare const withPunctuationSplitAndNumberSplit: DelimiterCase<'foo-bar::01', '#', {splitOnPunctuation: true; splitOnNumbers: true}>;
149+
expectType<'foo#bar#01'>(withPunctuationSplitAndNumberSplit);
150+
133151
// Verifying example
134152
type OddCasedProperties<T> = {
135153
[K in keyof T as DelimiterCase<K, '#'>]: T[K];

test-d/delimiter-cased-properties-deep.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ expectType<Set<{'foo-bar': string}>>(bar);
1313
declare const withOptions: DelimiterCasedPropertiesDeep<Set<{helloWorld: {p2p: Array<{addressLine1: string}>}}>, '.', {splitOnNumbers: true}>;
1414
expectType<Set<{'hello.world': {'p.2.p': Array<{'address.line.1': string}>}}>>(withOptions);
1515

16+
declare const withPunctuation: DelimiterCasedPropertiesDeep<{'hello@World1': {'foo::Bar': string}}, '.'>;
17+
expectType<{'hello@.world1': {'foo::.bar': string}}>(withPunctuation);
18+
19+
declare const withPunctuationSplit: DelimiterCasedPropertiesDeep<{'hello@World1': {'foo::Bar': string}}, '.', {splitOnPunctuation: true}>;
20+
expectType<{'hello.world1': {'foo.bar': string}}>(withPunctuationSplit);
21+
22+
declare const withPunctuationSplitAndNumbers: DelimiterCasedPropertiesDeep<{'hello@World1': {'foo::Bar1': string}}, '.', {splitOnPunctuation: true; splitOnNumbers: true}>;
23+
expectType<{'hello.world.1': {'foo.bar.1': string}}>(withPunctuationSplitAndNumbers);
24+
1625
// Verify example
1726
type User = {
1827
userId: number;
@@ -26,6 +35,18 @@ type UserWithFriends = {
2635
userFriends: User[];
2736
};
2837

38+
type UserPunctuated = {
39+
'user::id': number;
40+
'user::name': string;
41+
date: Date;
42+
'reg::exp': RegExp;
43+
};
44+
45+
type UserWithFriendsPunctuated = {
46+
'user@info': UserPunctuated;
47+
'user#friends': UserPunctuated[];
48+
};
49+
2950
const result: DelimiterCasedPropertiesDeep<UserWithFriends, '-'> = {
3051
'user-info': {
3152
'user-id': 1,
@@ -49,6 +70,7 @@ const result: DelimiterCasedPropertiesDeep<UserWithFriends, '-'> = {
4970
],
5071
};
5172
expectType<DelimiterCasedPropertiesDeep<UserWithFriends, '-'>>(result);
73+
expectType<DelimiterCasedPropertiesDeep<UserWithFriendsPunctuated, '-', {splitOnPunctuation: true}>>(result);
5274

5375
// Test object key properties
5476
declare const key: DelimiterCasedPropertiesDeep<{readonly userId?: number}, '-'>;
@@ -89,3 +111,6 @@ expectType<{'foo_bar': {'bar_baz': unknown}; biz: unknown}>({} as DelimiterCased
89111

90112
expectType<{'foo-bar': any}>({} as DelimiterCasedPropertiesDeep<{fooBar: any}, '-'>);
91113
expectType<{'foo_bar': {'bar_baz': any}; biz: any}>({} as DelimiterCasedPropertiesDeep<{fooBar: {barBaz: any}; biz: any}, '_'>);
114+
115+
expectType<{'foo-bar': unknown}>({} as DelimiterCasedPropertiesDeep<{'foo::bar': unknown}, '-', {splitOnPunctuation: true}>);
116+
expectType<{'foo_bar': {'bar_baz': unknown}; biz: unknown}>({} as DelimiterCasedPropertiesDeep<{'foo::bar': {'bar@baz': unknown}; biz: unknown}, '_', {splitOnPunctuation: true}>);

0 commit comments

Comments
 (0)