Skip to content

Commit 14f8333

Browse files
committed
fix
Signed-off-by: sunrabbit123 <[email protected]>
1 parent 0f9418f commit 14f8333

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

src/bill/index.spec.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/constant/translatedVariableDictionary.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,11 @@ describe('translatedVariableDictionary', () => {
9494

9595
expectTypeOf(translatedVariableDictionary.생일구분코드).toEqualTypeOf<'birthdayDivisionCode'>();
9696
expect(translatedVariableDictionary.생일구분코드).toBe('birthdayDivisionCode');
97+
98+
expectTypeOf(translatedVariableDictionary.당선대수).toEqualTypeOf<'electionCongress'>();
99+
expect(translatedVariableDictionary.당선대수).toBe('electionCongress');
100+
101+
expectTypeOf(translatedVariableDictionary.위원회심사_처리일).toEqualTypeOf<'committeeReviewProcessDate'>();
102+
expect(translatedVariableDictionary.위원회심사_처리일).toBe('committeeReviewProcessDate');
97103
});
98104
});

src/constant/translatedVariableDictionary.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,30 @@ export type FirstLetterLowerCase<T extends string> = T extends `${infer First}${
1010
? `${Lowercase<First>}${Rest}`
1111
: T;
1212

13+
const isEmpty = (args?: string): args is '' | undefined => args === '' || args == null;
14+
1315
export const firstLetterLowerCase = <T extends string>(str: T) =>
1416
`${str.charAt(0).toLowerCase()}${str.slice(1)}` as FirstLetterLowerCase<T>;
1517

16-
export const variable = <T extends ReadonlyArray<string>>(_template: TemplateStringsArray, ...args: T) =>
17-
args.reduce((prev, cur, idx) => {
18-
return idx === 0 ? firstLetterLowerCase(cur) : `${prev}${cur}`;
19-
}, '') as T extends [infer First extends string, ...infer Rest extends ReadonlyArray<string>]
18+
export const variable = <T extends ReadonlyArray<string>>(_template: TemplateStringsArray, ...args: T) => {
19+
return (args.reduce((prev, cur, idx) => {
20+
if (idx !== 0) {
21+
return `${prev}${_template[idx]}${cur}`;
22+
}
23+
const prefix = _template[idx];
24+
25+
if (isEmpty(prefix)) {
26+
return `${prev}${firstLetterLowerCase(cur)}`;
27+
}
28+
29+
return `${prev}${firstLetterLowerCase(prefix)}${cur}`;
30+
}, '') + _template[args.length]) as T extends [
31+
infer First extends string,
32+
...infer Rest extends ReadonlyArray<string>,
33+
]
2034
? MergeString<[FirstLetterLowerCase<First>, ...Rest]>
2135
: MergeString<T>;
22-
36+
};
2337
/**
2438
* @description if you modify this properties, you should upgrade the minor version because it will be a break changes
2539
*/
@@ -51,6 +65,7 @@ const 처리결과 = `${처리}Result`;
5165
const 처리일 = `${처리}${일자}`;
5266
const 회부일 = `Submit${일자}`;
5367
const 상정일 = `Present${일자}`;
68+
5469
export const translatedVariableDictionary = {
5570
국회의원코드: variable`${국회의원}${코드}`,
5671
국회의원명: variable`${국회의원}${}`,

src/lawmaker/getLawmakerList.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { callOpenApi } from '../functional';
22
import { PaginationType } from '../types/callOpenApi';
3-
import { translatedVariableDictionary } from '../constant/index';
3+
import { translatedVariableDictionary } from '../constant';
44

55
interface Lawmaker {
66
NAAS_CD: string; // 국회의원코드

0 commit comments

Comments
 (0)