Skip to content

Commit db92cdd

Browse files
committed
chore: wip
chore: wip chore: wip chore: wip chore: wip chore: wip chore: wip
1 parent 161dc9a commit db92cdd

File tree

2 files changed

+459
-302
lines changed

2 files changed

+459
-302
lines changed

fixtures/output/example-0001.d.ts

Lines changed: 16 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,20 @@ import type { BunPlugin } from 'bun'
22
import type { DtsGenerationConfig, DtsGenerationOption } from '@stacksjs/dtsx'
33
import { generate } from '@stacksjs/dtsx'
44

5-
/**
6-
* Example of const declaration
7-
*/
8-
export const conf: { [key: string]: string } = {
9-
apiUrl: 'https://api.stacksjs.org',
10-
timeout: '5000', // as string
11-
}
5+
export declare const conf: { [key: string]: string };
126
export declare const someObject: {
137
someString: 'Stacks';
148
someNumber: 1000;
159
someBoolean: true;
1610
someFalse: false;
17-
someFunction: (...args: any[]) => void;
18-
anotherOne: (...args: any[]) => string;
11+
someFunction: (...args: any[]) => unknown;
12+
anotherOne: (...args: any[]) => unknown;
1913
someArray: Array<1 | 2 | 3>;
2014
someNestedArray: Array<Array<1 | 2 | 3> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10>>;
2115
someNestedArray2: Array<Array<1 | 2 | 3> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10> | 'dummy value'>;
2216
someNestedArray3: Array<Array<1 | 2 | 3> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10> | 'dummy value' | Array<11 | 12 | 13>>;
23-
someOtherNestedArray: Array<Array<'some text' | 2 | ((...args: any[]) => void) | ((...args: any[]) => void) | unknown> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10>>;
24-
someComplexArray: Array<Array<{ key: 'value' }> | Array<{ key2: 'value2' } | 'test' | 1000> | Array<'some string' | ((...args: any[]) => void) | unknown>>;
17+
someOtherNestedArray: Array<Array<'some text' | 2 | unknown | (...args: any[]) => unknown> | Array<4 | 5 | 6 | 7 | 8 | 9 | 10>>;
18+
someComplexArray: Array<Array<{ key: 'value' }> | Array<{ key2: 'value2' } | 'test' | 1000> | Array<'some string' | unknown>>;
2519
someObject: {
2620
key: 'value';
2721
};
@@ -30,79 +24,39 @@ export declare const someObject: {
3024
nestedKey: 'value';
3125
};
3226
otherKey: {
33-
nestedKey: (...args: any[]) => void;
27+
nestedKey: unknown;
28+
nestedKey2: (...args: any[]) => unknown;
3429
};
3530
};
36-
someNestedObjectArray: Array<{ key: 'value' } | { key2: 'value2' }>;
37-
someOtherObject: unknown;
38-
someInlineCall2: (...args: any[]) => void;
39-
someInlineCall3: (...args: any[]) => void;
4031
};
41-
/**
42-
* Example of interface declaration
43-
* with another comment in an extra line
44-
*/
45-
export interface User {
32+
export declare interface User {
4633
id: number
4734
name: string
4835
email: string
4936
}
50-
/**
51-
* Example of type declaration
52-
*
53-
* with multiple lines of comments, including an empty line
54-
*/
55-
export interface ResponseData {
37+
export declare interface ResponseData {
5638
success: boolean
5739
data: User[]
5840
}
59-
/**
60-
* Example of function declaration
61-
*
62-
*
63-
* with multiple empty lines, including an empty lines
64-
*/
65-
export function fetchUsers(): Promise<ResponseData> {
66-
return fetch(conf.apiUrl)
67-
.then(response => response.json()) as Promise<ResponseData>
68-
}
41+
export declare function fetchUsers(): Promise<ResponseData>;
6942
export declare interface ApiResponse<T> {
7043
status: number
7144
message: string
7245
data: T
7346
}
74-
/**
75-
* Example of another const declaration
76-
*
77-
* with multiple empty lines, including being poorly formatted
78-
*/
79-
const settings: { [key: string]: any } = {
80-
theme: 'dark',
81-
language: 'en',
82-
}
47+
declare const settings: { [key: string]: any };
8348
export declare interface Product {
8449
id: number
8550
name: string
8651
price: number
8752
}
88-
/**
89-
* Example of function declaration
90-
*/
91-
export function getProduct(id: number): Promise<ApiResponse<Product>> {
92-
return fetch(`${settings.apiUrl}/products/${id}`)
93-
.then(response => response.json()) as Promise<ApiResponse<Product>>
94-
}
53+
export declare function getProduct(id: number): Promise<ApiResponse<Product>>;
9554
export declare interface AuthResponse {
9655
token: string
9756
expiresIn: number
9857
}
99-
export declare type AuthStatus = 'authenticated' | 'unauthenticated'
100-
export function authenticate(user: string, password: string): Promise<AuthResponse> {
101-
return fetch('/auth/login', {
102-
method: 'POST',
103-
body: JSON.stringify({ user, password }),
104-
}).then(response => response.json()) as Promise<AuthResponse>
105-
}
58+
export declare type AuthStatus = 'authenticated' | 'unauthenticated';
59+
export declare function authenticate(user: string, password: string): Promise<AuthResponse>;
10660
export declare const defaultHeaders: {
10761
'Content-Type': 'application/json';
10862
};
@@ -112,20 +66,16 @@ declare interface Options<T> {
11266
cwd?: string
11367
defaultConfig: T
11468
}
115-
export declare function loadConfig<T extends Record<string, unknown>>(options: Options<T>): Promise<T>;
69+
export declare function loadConfig<T extends Record<string, unknown>(): void;
11670
declare const dtsConfig: DtsGenerationConfig;
117-
11871
export { generate, dtsConfig }
11972
export type { DtsGenerationOption }
120-
12173
export { config } from './config'
122-
12374
export * from './extract'
12475
export * from './generate'
125-
12676
export * from './types'
12777
export * from './utils'
128-
78+
// 1. Complex Generic Types
12979
export declare interface ComplexGeneric<T extends Record<string, unknown>, K extends keyof T> {
13080
data: T
13181
key: K
@@ -139,4 +89,3 @@ export declare type ComplexUnionIntersection =
13989
& {
14090
metadata: Record<string, unknown>
14191
}
142-
export default dts

0 commit comments

Comments
 (0)