From 08f015aa8da938ffbce88f28daf4588f2eda9e77 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 17 Oct 2024 18:42:09 +0200 Subject: [PATCH] chore: wip --- fixtures/input/example-2.ts | 6 ------ fixtures/input/example-3.ts | 9 --------- fixtures/input/example-4.ts | 12 ------------ fixtures/input/example-5.ts | 15 --------------- fixtures/output/example-1.d.ts | 14 ++++---------- fixtures/output/example-2.d.ts | 20 ++++---------------- fixtures/output/example-3.d.ts | 25 ++++--------------------- fixtures/output/example-4.d.ts | 26 +++----------------------- fixtures/output/example-5.d.ts | 25 ++++--------------------- 9 files changed, 19 insertions(+), 133 deletions(-) diff --git a/fixtures/input/example-2.ts b/fixtures/input/example-2.ts index cd39dfe..b9f003c 100644 --- a/fixtures/input/example-2.ts +++ b/fixtures/input/example-2.ts @@ -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 { status: number message: string diff --git a/fixtures/input/example-3.ts b/fixtures/input/example-3.ts index d3ee491..471a937 100644 --- a/fixtures/input/example-3.ts +++ b/fixtures/input/example-3.ts @@ -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 diff --git a/fixtures/input/example-4.ts b/fixtures/input/example-4.ts index 1383251..e96847f 100644 --- a/fixtures/input/example-4.ts +++ b/fixtures/input/example-4.ts @@ -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 { return fetch('/auth/login', { method: 'POST', diff --git a/fixtures/input/example-5.ts b/fixtures/input/example-5.ts index b08740c..edeb0b9 100644 --- a/fixtures/input/example-5.ts +++ b/fixtures/input/example-5.ts @@ -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 { return fetch(`/posts/${postId}/comments`) .then(response => response.json()) as Promise diff --git a/fixtures/output/example-1.d.ts b/fixtures/output/example-1.d.ts index 2280d8c..3f4f655 100644 --- a/fixtures/output/example-1.d.ts +++ b/fixtures/output/example-1.d.ts @@ -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 @@ -18,7 +15,7 @@ export interface User { /** * Example of type declaration */ -export interface ResponseData { +export interface ResponseData { success: boolean data: User[] } @@ -26,7 +23,4 @@ export interface ResponseData { /** * Example of function declaration */ -export function fetchUsers(): Promise { - return fetch(config.apiUrl) - .then(response => response.json()) as Promise -} +export declare function fetchUsers(): Promise diff --git a/fixtures/output/example-2.d.ts b/fixtures/output/example-2.d.ts index cd39dfe..2ce5c79 100644 --- a/fixtures/output/example-2.d.ts +++ b/fixtures/output/example-2.d.ts @@ -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 { +export interface ApiResponse { status: number message: string data: T @@ -27,7 +18,4 @@ export interface ApiResponse { /** * Example of function declaration */ -export function getProduct(id: number): Promise> { - return fetch(`${settings.apiUrl}/products/${id}`) - .then(response => response.json()) as Promise> -} +export declare function getProduct(id: number): Promise> diff --git a/fixtures/output/example-3.d.ts b/fixtures/output/example-3.d.ts index d3ee491..f49e0af 100644 --- a/fixtures/output/example-3.d.ts +++ b/fixtures/output/example-3.d.ts @@ -1,24 +1,12 @@ -/** - * 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 } @@ -26,9 +14,4 @@ export interface OrderResponse { /** * Example of function declaration */ -export async function createOrder(order: Order): Promise { - return fetch(endpoints.getProducts, { - method: 'POST', - body: JSON.stringify(order), - }).then(response => response.json()) as Promise -} +export declare function createOrder(order: Order): Promise diff --git a/fixtures/output/example-4.d.ts b/fixtures/output/example-4.d.ts index 1383251..caf7682 100644 --- a/fixtures/output/example-4.d.ts +++ b/fixtures/output/example-4.d.ts @@ -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 { - return fetch('/auth/login', { - method: 'POST', - body: JSON.stringify({ user, password }), - }).then(response => response.json()) as Promise -} +export declare function authenticate(user: string, password: string): Promise diff --git a/fixtures/output/example-5.d.ts b/fixtures/output/example-5.d.ts index b08740c..4047898 100644 --- a/fixtures/output/example-5.d.ts +++ b/fixtures/output/example-5.d.ts @@ -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 { - return fetch(`/posts/${postId}/comments`) - .then(response => response.json()) as Promise -} +export declare function fetchComments(postId: number): Promise