Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Oct 17, 2024
1 parent c1dbbde commit 08f015a
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 133 deletions.
6 changes: 0 additions & 6 deletions fixtures/input/example-2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@ export const settings: { [key: string]: any } = {
language: 'en',
}

/**
* Example of interface declaration
*/
export interface Product {
id: number
name: string
price: number
}

/**
* Example of type declaration
*/
export interface ApiResponse<T> {
status: number
message: string
Expand Down
9 changes: 0 additions & 9 deletions fixtures/input/example-3.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
/**
* Example of const declaration
*/
export const endpoints = {
getUsers: '/users',
getProducts: '/products',
}

/**
* Example of interface declaration
*/
export interface Order {
orderId: number
userId: number
productIds: number[]
}

/**
* Example of type declaration
*/
export interface OrderResponse {
success: boolean
order: Order
Expand Down
12 changes: 0 additions & 12 deletions fixtures/input/example-4.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
/**
* Example of const declaration
*/
export const apiKeys = {
google: 'GOOGLE_API_KEY',
facebook: 'FACEBOOK_API_KEY',
}

/**
* Example of interface declaration
*/
export interface AuthResponse {
token: string
expiresIn: number
}

/**
* Example of type declaration
*/
export type AuthStatus = 'authenticated' | 'unauthenticated'

/**
* Example of function declaration
*/
export function authenticate(user: string, password: string): Promise<AuthResponse> {
return fetch('/auth/login', {
method: 'POST',
Expand Down
15 changes: 0 additions & 15 deletions fixtures/input/example-5.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
/**
* Example of const declaration
*/
export const defaultHeaders = {
'Content-Type': 'application/json',
}

/**
* Example of interface declaration
*/
export interface Comment {
id: number
postId: number
body: string
}

/**
* Example of type declaration
*/
export interface CommentsResponse {
comments: Comment[]
}

/**
* Example of function declaration
*/
export function fetchComments(postId: number): Promise<CommentsResponse> {
return fetch(`/posts/${postId}/comments`)
.then(response => response.json()) as Promise<CommentsResponse>
Expand Down
14 changes: 4 additions & 10 deletions fixtures/output/example-1.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
/**
* Example of const declaration
*/
export const config: { [key: string]: string } = {
apiUrl: 'https://api.example.com',
timeout: '5000',
}
export declare const config: { [key: string]: string }

/**
* Example of interface declaration
*/
export interface User {
export interface User {
id: number
name: string
email: string
Expand All @@ -18,15 +15,12 @@ export interface User {
/**
* Example of type declaration
*/
export interface ResponseData {
export interface ResponseData {
success: boolean
data: User[]
}

/**
* Example of function declaration
*/
export function fetchUsers(): Promise<ResponseData> {
return fetch(config.apiUrl)
.then(response => response.json()) as Promise<ResponseData>
}
export declare function fetchUsers(): Promise<ResponseData>
20 changes: 4 additions & 16 deletions fixtures/output/example-2.d.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
/**
* Example of another const declaration
*/
export const settings: { [key: string]: any } = {
theme: 'dark',
language: 'en',
}
export declare const settings: { [key: string]: any }

/**
* Example of interface declaration
*/
export interface Product {
export interface Product {
id: number
name: string
price: number
}

/**
* Example of type declaration
*/
export interface ApiResponse<T> {
export interface ApiResponse<T> {
status: number
message: string
data: T
Expand All @@ -27,7 +18,4 @@ export interface ApiResponse<T> {
/**
* Example of function declaration
*/
export function getProduct(id: number): Promise<ApiResponse<Product>> {
return fetch(`${settings.apiUrl}/products/${id}`)
.then(response => response.json()) as Promise<ApiResponse<Product>>
}
export declare function getProduct(id: number): Promise<ApiResponse<Product>>
25 changes: 4 additions & 21 deletions fixtures/output/example-3.d.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
/**
* Example of const declaration
*/
export const endpoints = {
getUsers: '/users',
getProducts: '/products',
}
export declare const endpoints

/**
* Example of interface declaration
*/
export interface Order {
export interface Order {
orderId: number
userId: number
productIds: number[]
}

/**
* Example of type declaration
*/
export interface OrderResponse {
export interface OrderResponse {
success: boolean
order: Order
}

/**
* Example of function declaration
*/
export async function createOrder(order: Order): Promise<OrderResponse> {
return fetch(endpoints.getProducts, {
method: 'POST',
body: JSON.stringify(order),
}).then(response => response.json()) as Promise<OrderResponse>
}
export declare function createOrder(order: Order): Promise<OrderResponse>
26 changes: 3 additions & 23 deletions fixtures/output/example-4.d.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
/**
* Example of const declaration
*/
export const apiKeys = {
google: 'GOOGLE_API_KEY',
facebook: 'FACEBOOK_API_KEY',
}
export declare const apiKeys

/**
* Example of interface declaration
*/
export interface AuthResponse {
export interface AuthResponse {
token: string
expiresIn: number
}

/**
* Example of type declaration
*/
export type AuthStatus = 'authenticated' | 'unauthenticated'

/**
* Example of function declaration
*/
export function authenticate(user: string, password: string): Promise<AuthResponse> {
return fetch('/auth/login', {
method: 'POST',
body: JSON.stringify({ user, password }),
}).then(response => response.json()) as Promise<AuthResponse>
}
export declare function authenticate(user: string, password: string): Promise<AuthResponse>
25 changes: 4 additions & 21 deletions fixtures/output/example-5.d.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
/**
* Example of const declaration
*/
export const defaultHeaders = {
'Content-Type': 'application/json',
}
export declare const defaultHeaders

/**
* Example of interface declaration
*/
export interface Comment {
export interface Comment {
id: number
postId: number
body: string
}

/**
* Example of type declaration
*/
export interface CommentsResponse {
export interface CommentsResponse {
comments: Comment[]
}

/**
* Example of function declaration
*/
export function fetchComments(postId: number): Promise<CommentsResponse> {
return fetch(`/posts/${postId}/comments`)
.then(response => response.json()) as Promise<CommentsResponse>
}
export declare function fetchComments(postId: number): Promise<CommentsResponse>

0 comments on commit 08f015a

Please sign in to comment.