From 63be9e3d4abfea18c00436679efc787bed4dbba8 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 27 Oct 2024 15:22:37 +0100 Subject: [PATCH] chore: wip --- fixtures/input/example-0001.ts | 19 +++++++++++++++++++ fixtures/output/example-0001.d.ts | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/fixtures/input/example-0001.ts b/fixtures/input/example-0001.ts index c3b27ad..94ccde0 100644 --- a/fixtures/input/example-0001.ts +++ b/fixtures/input/example-0001.ts @@ -277,4 +277,23 @@ export function processData(data: unknown): unknown { return data } +// 5. Nested Object Types with Methods +export const complexObject = { + handlers: { + async onSuccess(data: T): Promise { + 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) + } + } +} + export default dts diff --git a/fixtures/output/example-0001.d.ts b/fixtures/output/example-0001.d.ts index 1e89460..6ff1528 100644 --- a/fixtures/output/example-0001.d.ts +++ b/fixtures/output/example-0001.d.ts @@ -120,6 +120,12 @@ export declare function processData(data: number): number; export declare function processData(data: boolean): boolean; export declare function processData(data: T): T; export declare function processData(data: unknown): unknown; +export declare const complexObject: { + handlers: { + 'async onSuccess(data': unknown; + 'onError(error': unknown; + }; +}; export { generate, dtsConfig } export type { DtsGenerationOption }