Skip to content

Commit 9c05c88

Browse files
committed
chore: wip
chore: wip chore: wip chore: wip chore: wip chore: wip
1 parent b6d90c2 commit 9c05c88

File tree

3 files changed

+376
-250
lines changed

3 files changed

+376
-250
lines changed

fixtures/input/variable.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -134,24 +134,27 @@ export const complexArrays = {
134134
]
135135
}
136136

137-
// TODO: Nested Object Types with Methods
138-
// export const complexObject = {
139-
// handlers: {
140-
// async onSuccess<T>(data: T): Promise<void> {
141-
// console.log(data)
142-
// },
143-
// onError(error: Error & { code?: number }): never {
144-
// throw error
145-
// }
146-
// },
147-
// utils: {
148-
// formatters: {
149-
// date: (input: Date) => input.toISOString(),
150-
// currency: (amount: number, currency = 'USD') =>
151-
// new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(amount)
152-
// }
153-
// }
154-
// }
137+
// Nested Object Types with Methods
138+
export const complexObject = {
139+
handlers: {
140+
async onSuccess<T>(data: T): Promise<void> {
141+
console.log(data)
142+
},
143+
onError(error: Error & { code?: number }): never {
144+
throw error
145+
},
146+
someOtherMethod() {
147+
// some body
148+
}
149+
},
150+
utils: {
151+
formatters: {
152+
date: (input: Date) => input.toISOString(),
153+
currency: (amount: number, currency = 'USD') =>
154+
new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(amount)
155+
}
156+
}
157+
}
155158

156159
// TODO: Method Decorators and Metadata
157160
// export const methodDecorator = (

fixtures/output/variable.d.ts

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,35 @@ export declare const someObject: {
77
someNumber: 1000;
88
someBoolean: true;
99
someFalse: false;
10-
someFunction: ((...args: any[]) => unknown);
11-
anotherOne: ((...args: any[]) => unknown);
10+
someFunction: () => void;
11+
anotherOne: () => unknown;
1212
someArray: Array<1 | 2 | 3>;
1313
someNestedArray: Array<Array<1 | 2 | 3> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10>>;
1414
someNestedArray2: Array<Array<1 | 2 | 3> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10> | 'dummy value'>;
1515
someNestedArray3: Array<Array<1 | 2 | 3> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10> | 'dummy value' | Array<11 | 12 | 13>>;
16-
someOtherNestedArray: Array<Array<'some text' | 2 | unknown | ((...args: any[]) => unknown) | unknown> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10>>;
17-
someComplexArray: Array<Array<{ key: 'value' }> | Array<{ key2: 'value2' } | 'test' | 1000> | Array<'some string' | unknown | unknown>>;
16+
someOtherNestedArray: Array<Array<'some text' | 2 | unknown | (() => void) | unknown> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10>>;
17+
someComplexArray: Array<Array<{
18+
key: 'value'
19+
}> | Array<{
20+
key2: 'value2'
21+
} | 'test' | 1000> | Array<'some string' | unknown | unknown>>;
1822
someObject: {
19-
key: 'value'
20-
};
23+
key: 'value'
24+
};
2125
someNestedObject: {
22-
key: {
23-
nestedKey: 'value'
24-
};
25-
otherKey: {
26-
nestedKey: unknown;
27-
nestedKey2: ((...args: any[]) => unknown)
28-
}
29-
};
30-
someNestedObjectArray: Array<{ key: 'value' } | { key2: 'value2' }>;
26+
key: {
27+
nestedKey: 'value'
28+
};
29+
otherKey: {
30+
nestedKey: unknown;
31+
nestedKey2: () => void
32+
}
33+
};
34+
someNestedObjectArray: Array<{
35+
key: 'value'
36+
} | {
37+
key2: 'value2'
38+
}>;
3139
someOtherObject: unknown;
3240
someInlineCall2: unknown;
3341
someInlineCall3: unknown
@@ -42,3 +50,15 @@ export declare const complexArrays: {
4250
tuples: Array<readonly [1, 'string', true] | readonly ['literal', 42, false]>;
4351
mixedArrays: Array<unknown | unknown | ((...args: any[]) => unknown) | ((...args: any[]) => unknown)>
4452
};
53+
export declare const complexObject: {
54+
handlers: {
55+
onSuccess: <T> (data: T) => Promise<void>;
56+
onError: (error: Error & { code?: number }) => never
57+
};
58+
utils: {
59+
formatters: {
60+
date: (input: Date) => string;
61+
currency: (amount: number, currency: string) => string
62+
}
63+
}
64+
};

0 commit comments

Comments
 (0)