Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
chore: wip

chore: wip

chore: wip

chore: wip

chore: wip
  • Loading branch information
chrisbbreuer committed Oct 31, 2024
1 parent b6d90c2 commit 9c05c88
Show file tree
Hide file tree
Showing 3 changed files with 376 additions and 250 deletions.
39 changes: 21 additions & 18 deletions fixtures/input/variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,27 @@ export const complexArrays = {
]
}

// TODO: Nested Object Types with Methods
// export const complexObject = {
// handlers: {
// async onSuccess<T>(data: T): Promise<void> {
// console.log(data)
// },
// onError(error: Error & { code?: number }): never {
// throw error
// }
// },
// utils: {
// formatters: {
// date: (input: Date) => input.toISOString(),
// currency: (amount: number, currency = 'USD') =>
// new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(amount)
// }
// }
// }
// Nested Object Types with Methods
export const complexObject = {
handlers: {
async onSuccess<T>(data: T): Promise<void> {
console.log(data)
},
onError(error: Error & { code?: number }): never {
throw error
},
someOtherMethod() {
// some body
}
},
utils: {
formatters: {
date: (input: Date) => input.toISOString(),
currency: (amount: number, currency = 'USD') =>
new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(amount)
}
}
}

// TODO: Method Decorators and Metadata
// export const methodDecorator = (
Expand Down
50 changes: 35 additions & 15 deletions fixtures/output/variable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,35 @@ export declare const someObject: {
someNumber: 1000;
someBoolean: true;
someFalse: false;
someFunction: ((...args: any[]) => unknown);
anotherOne: ((...args: any[]) => unknown);
someFunction: () => void;
anotherOne: () => unknown;
someArray: Array<1 | 2 | 3>;
someNestedArray: Array<Array<1 | 2 | 3> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10>>;
someNestedArray2: Array<Array<1 | 2 | 3> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10> | 'dummy value'>;
someNestedArray3: Array<Array<1 | 2 | 3> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10> | 'dummy value' | Array<11 | 12 | 13>>;
someOtherNestedArray: Array<Array<'some text' | 2 | unknown | ((...args: any[]) => unknown) | unknown> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10>>;
someComplexArray: Array<Array<{ key: 'value' }> | Array<{ key2: 'value2' } | 'test' | 1000> | Array<'some string' | unknown | unknown>>;
someOtherNestedArray: Array<Array<'some text' | 2 | unknown | (() => void) | unknown> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10>>;
someComplexArray: Array<Array<{
key: 'value'
}> | Array<{
key2: 'value2'
} | 'test' | 1000> | Array<'some string' | unknown | unknown>>;
someObject: {
key: 'value'
};
key: 'value'
};
someNestedObject: {
key: {
nestedKey: 'value'
};
otherKey: {
nestedKey: unknown;
nestedKey2: ((...args: any[]) => unknown)
}
};
someNestedObjectArray: Array<{ key: 'value' } | { key2: 'value2' }>;
key: {
nestedKey: 'value'
};
otherKey: {
nestedKey: unknown;
nestedKey2: () => void
}
};
someNestedObjectArray: Array<{
key: 'value'
} | {
key2: 'value2'
}>;
someOtherObject: unknown;
someInlineCall2: unknown;
someInlineCall3: unknown
Expand All @@ -42,3 +50,15 @@ export declare const complexArrays: {
tuples: Array<readonly [1, 'string', true] | readonly ['literal', 42, false]>;
mixedArrays: Array<unknown | unknown | ((...args: any[]) => unknown) | ((...args: any[]) => unknown)>
};
export declare const complexObject: {
handlers: {
onSuccess: <T> (data: T) => Promise<void>;
onError: (error: Error & { code?: number }) => never
};
utils: {
formatters: {
date: (input: Date) => string;
currency: (amount: number, currency: string) => string
}
}
};
Loading

0 comments on commit 9c05c88

Please sign in to comment.