Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Oct 24, 2024
1 parent 524af20 commit 3a19f8b
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 194 deletions.
54 changes: 18 additions & 36 deletions fixtures/output/example-0001.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import type { BunPlugin } from 'bun'
import process from 'node:process'
import { generate, deepMerge } from '@stacksjs/dtsx'
import type { DtsGenerationConfig, DtsGenerationOption } from '@stacksjs/dtsx'
import { existsSync } from 'node:fs'
import { resolve } from 'node:path'

/**
* Example of const declaration
*/
export declare const conf: { [key: string]: string };

export declare const someObject: {
someString: 'Stacks';
someNumber: 1000;
Expand Down Expand Up @@ -32,7 +38,6 @@ export declare const someObject: {
someInlineCall2: (...args: any[]) => void;
someInlineCall3: (...args: any[]) => void;
};

/**
* Example of interface declaration
* with another comment in an extra line
Expand All @@ -42,7 +47,6 @@ export declare interface User {
name: string
email: string
}

/**
* Example of type declaration
*
Expand All @@ -52,91 +56,69 @@ export declare interface ResponseData {
success: boolean
data: User[]
}

/**
* Example of function declaration
*
*
* with multiple empty lines, including an empty lines
*/
export declare function fetchUsers(): Promise<ResponseData>;

export declare interface ApiResponse<T> {
status: number
message: string
data: T
}

/**
* Example of another const declaration
*
* with multiple empty lines, including being poorly formatted
*/
declare const settings: { [key: string]: any };

export declare interface Product {
id: number
name: string
price: number
}

/**
* Example of function declaration
*/
export declare function getProduct(id: number): Promise<ApiResponse<Product>>;

export declare interface AuthResponse {
token: string
expiresIn: number
}

export declare type AuthStatus = 'authenticated' | 'unauthenticated';

export declare function authenticate(user: string, password: string): Promise<AuthResponse>;

export declare const defaultHeaders: {
'Content-Type': 'application/json';
};

export declare function dts(options?: DtsGenerationOption): BunPlugin;

declare interface Options<T> {
name: string
cwd?: string
defaultConfig: T
}

export declare function loadConfig<T extends Record<string, unknown>>(options: Options<T>): Promise<T>;

export declare async function loadConfig<T extends Record<string, unknown>>(options: Options<T>): Promise<T>;
declare const dtsConfig: DtsGenerationConfig;

export { generate, dtsConfig }

export type { DtsGenerationOption };

export { config } from './config';

export type { DtsGenerationOption }
export { config } from './config'
export * from './extract'
export * from './generate'
export * from './types'
export * from './utils'
export declare interface ComplexGeneric<T extends Record<string, unknown>, K extends keyof T> {
data: T
key: K
value: T[K]
transform: (input: T[K]) => string
nested: Array<Partial<T>>
}

export declare type ComplexUnionIntersection =;

| (User & { role: 'admin' });

| (Product & { category: string });

export declare type ComplexUnionIntersection =
| (User & { role: 'admin' })
| (Product & { category: string })
& {
metadata: Record<string, unknown>
}

export default dts;

export * from './extract';
export * from './generate';
export * from './types';
export * from './utils';
export default dts
Loading

0 comments on commit 3a19f8b

Please sign in to comment.