@@ -2,26 +2,20 @@ import type { BunPlugin } from 'bun'
2
2
import type { DtsGenerationConfig , DtsGenerationOption } from '@stacksjs/dtsx'
3
3
import { generate } from '@stacksjs/dtsx'
4
4
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 } ;
12
6
export declare const someObject : {
13
7
someString : 'Stacks' ;
14
8
someNumber : 1000 ;
15
9
someBoolean : true ;
16
10
someFalse : false ;
17
- someFunction : ( ...args : any [ ] ) => void ;
18
- anotherOne : ( ...args : any [ ] ) => string ;
11
+ someFunction : ( ...args : any [ ] ) => unknown ;
12
+ anotherOne : ( ...args : any [ ] ) => unknown ;
19
13
someArray : Array < 1 | 2 | 3 > ;
20
14
someNestedArray : Array < Array < 1 | 2 | 3 > | Array < 4 | 5 | 6 | 7 | 8 | 9 | 10 > > ;
21
15
someNestedArray2 : Array < Array < 1 | 2 | 3 > | Array < 4 | 5 | 6 | 7 | 8 | 9 | 10 > | 'dummy value' > ;
22
16
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 > > ;
25
19
someObject : {
26
20
key : 'value' ;
27
21
} ;
@@ -30,79 +24,39 @@ export declare const someObject: {
30
24
nestedKey : 'value' ;
31
25
} ;
32
26
otherKey : {
33
- nestedKey : ( ...args : any [ ] ) => void ;
27
+ nestedKey : unknown ;
28
+ nestedKey2 : ( ...args : any [ ] ) => unknown ;
34
29
} ;
35
30
} ;
36
- someNestedObjectArray : Array < { key : 'value' } | { key2 : 'value2' } > ;
37
- someOtherObject : unknown ;
38
- someInlineCall2 : ( ...args : any [ ] ) => void ;
39
- someInlineCall3 : ( ...args : any [ ] ) => void ;
40
31
} ;
41
- /**
42
- * Example of interface declaration
43
- * with another comment in an extra line
44
- */
45
- export interface User {
32
+ export declare interface User {
46
33
id : number
47
34
name : string
48
35
email : string
49
36
}
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 {
56
38
success : boolean
57
39
data : User [ ]
58
40
}
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 > ;
69
42
export declare interface ApiResponse < T > {
70
43
status : number
71
44
message : string
72
45
data : T
73
46
}
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 } ;
83
48
export declare interface Product {
84
49
id : number
85
50
name : string
86
51
price : number
87
52
}
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 > > ;
95
54
export declare interface AuthResponse {
96
55
token : string
97
56
expiresIn : number
98
57
}
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 > ;
106
60
export declare const defaultHeaders : {
107
61
'Content-Type' : 'application/json' ;
108
62
} ;
@@ -112,20 +66,16 @@ declare interface Options<T> {
112
66
cwd ?: string
113
67
defaultConfig : T
114
68
}
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 ;
116
70
declare const dtsConfig : DtsGenerationConfig ;
117
-
118
71
export { generate , dtsConfig }
119
72
export type { DtsGenerationOption }
120
-
121
73
export { config } from './config'
122
-
123
74
export * from './extract'
124
75
export * from './generate'
125
-
126
76
export * from './types'
127
77
export * from './utils'
128
-
78
+ // 1. Complex Generic Types
129
79
export declare interface ComplexGeneric < T extends Record < string , unknown > , K extends keyof T > {
130
80
data : T
131
81
key : K
@@ -139,4 +89,3 @@ export declare type ComplexUnionIntersection =
139
89
& {
140
90
metadata : Record < string , unknown >
141
91
}
142
- export default dts
0 commit comments