Skip to content

Commit 5bbae44

Browse files
committed
chore: wip
1 parent f3fec05 commit 5bbae44

File tree

12 files changed

+187
-70
lines changed

12 files changed

+187
-70
lines changed

bun.lockb

-14 Bytes
Binary file not shown.

dts renamed to dtsx

File renamed without changes.

eslint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ export default stacks({
99
typescript: true,
1010
jsonc: true,
1111
yaml: true,
12+
ignores: [
13+
'fixtures/**'
14+
]
1215
})

fixtures/output/example-1.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Example of const declaration
3+
*/
4+
export const config: { [key: string]: string } = {
5+
apiUrl: 'https://api.example.com',
6+
timeout: '5000',
7+
}
8+
9+
/**
10+
* Example of interface declaration
11+
*/
12+
export interface User {
13+
id: number
14+
name: string
15+
email: string
16+
}
17+
18+
/**
19+
* Example of type declaration
20+
*/
21+
export interface ResponseData {
22+
success: boolean
23+
data: User[]
24+
}
25+
26+
/**
27+
* Example of function declaration
28+
*/
29+
export function fetchUsers(): Promise<ResponseData> {
30+
return fetch(config.apiUrl)
31+
.then(response => response.json()) as Promise<ResponseData>
32+
}

fixtures/output/example-2.d.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Example of another const declaration
3+
*/
4+
export const settings: { [key: string]: any } = {
5+
theme: 'dark',
6+
language: 'en',
7+
}
8+
9+
/**
10+
* Example of interface declaration
11+
*/
12+
export interface Product {
13+
id: number
14+
name: string
15+
price: number
16+
}
17+
18+
/**
19+
* Example of type declaration
20+
*/
21+
export interface ApiResponse<T> {
22+
status: number
23+
message: string
24+
data: T
25+
}
26+
27+
/**
28+
* Example of function declaration
29+
*/
30+
export function getProduct(id: number): Promise<ApiResponse<Product>> {
31+
return fetch(`${settings.apiUrl}/products/${id}`)
32+
.then(response => response.json()) as Promise<ApiResponse<Product>>
33+
}

fixtures/output/example-3.d.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Example of const declaration
3+
*/
4+
export const endpoints = {
5+
getUsers: '/users',
6+
getProducts: '/products',
7+
}
8+
9+
/**
10+
* Example of interface declaration
11+
*/
12+
export interface Order {
13+
orderId: number
14+
userId: number
15+
productIds: number[]
16+
}
17+
18+
/**
19+
* Example of type declaration
20+
*/
21+
export interface OrderResponse {
22+
success: boolean
23+
order: Order
24+
}
25+
26+
/**
27+
* Example of function declaration
28+
*/
29+
export async function createOrder(order: Order): Promise<OrderResponse> {
30+
return fetch(endpoints.getProducts, {
31+
method: 'POST',
32+
body: JSON.stringify(order),
33+
}).then(response => response.json()) as Promise<OrderResponse>
34+
}

fixtures/output/example-4.d.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Example of const declaration
3+
*/
4+
export const apiKeys = {
5+
google: 'GOOGLE_API_KEY',
6+
facebook: 'FACEBOOK_API_KEY',
7+
}
8+
9+
/**
10+
* Example of interface declaration
11+
*/
12+
export interface AuthResponse {
13+
token: string
14+
expiresIn: number
15+
}
16+
17+
/**
18+
* Example of type declaration
19+
*/
20+
export type AuthStatus = 'authenticated' | 'unauthenticated'
21+
22+
/**
23+
* Example of function declaration
24+
*/
25+
export function authenticate(user: string, password: string): Promise<AuthResponse> {
26+
return fetch('/auth/login', {
27+
method: 'POST',
28+
body: JSON.stringify({ user, password }),
29+
}).then(response => response.json()) as Promise<AuthResponse>
30+
}

fixtures/output/example-5.d.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Example of const declaration
3+
*/
4+
export const defaultHeaders = {
5+
'Content-Type': 'application/json',
6+
}
7+
8+
/**
9+
* Example of interface declaration
10+
*/
11+
export interface Comment {
12+
id: number
13+
postId: number
14+
body: string
15+
}
16+
17+
/**
18+
* Example of type declaration
19+
*/
20+
export interface CommentsResponse {
21+
comments: Comment[]
22+
}
23+
24+
/**
25+
* Example of function declaration
26+
*/
27+
export function fetchComments(postId: number): Promise<CommentsResponse> {
28+
return fetch(`/posts/${postId}/comments`)
29+
.then(response => response.json()) as Promise<CommentsResponse>
30+
}

fixtures/output/examples-1-5.d.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "dts-generation",
2+
"name": "dtsx",
33
"type": "module",
4-
"version": "0.1.0",
4+
"version": "0.0.0",
55
"description": "A modern, fast .d.ts generation tool, powered by Bun.",
66
"author": "Chris Breuer <chris@stacksjs.org>",
77
"license": "MIT",
@@ -16,8 +16,8 @@
1616
"keywords": [
1717
"dts",
1818
"generation",
19+
"isolated declarations",
1920
"development",
20-
"environment",
2121
"bun",
2222
"stacks",
2323
"typescript",

src/types.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
1+
/**
2+
* DtsGenerationConfig
3+
*
4+
* This is the configuration object for the DTS generation process.
5+
*/
16
export interface DtsGenerationConfig {
27
cwd: string
38
root: string
49
outdir: string
510
keepComments: boolean
611
clean: boolean
7-
tsconfigPath?: string
12+
tsconfigPath: string
813
}
914

15+
/**
16+
* DtsGenerationOption
17+
*
18+
* This is the configuration object for the DTS generation process.
19+
*/
1020
export type DtsGenerationOption = Partial<DtsGenerationConfig>
1121

22+
/**
23+
* DtsGenerationOptions
24+
*
25+
* This is the configuration object for the DTS generation process.
26+
*/
1227
export type DtsGenerationOptions = DtsGenerationOption | DtsGenerationOption[]

test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { generateDeclarationsFromFiles } from './src'
2-
// Example usage
3-
generateDeclarationsFromFiles('./src');
1+
import { generate } from './src'
42

3+
console.log('Generating declarations...')
4+
generate({
5+
root: './src',
6+
})
7+
console.log('Generated declarations')

0 commit comments

Comments
 (0)