File tree Expand file tree Collapse file tree 9 files changed +19
-133
lines changed Expand file tree Collapse file tree 9 files changed +19
-133
lines changed Original file line number Diff line number Diff line change @@ -6,18 +6,12 @@ export const settings: { [key: string]: any } = {
66 language : 'en' ,
77}
88
9- /**
10- * Example of interface declaration
11- */
129export interface Product {
1310 id : number
1411 name : string
1512 price : number
1613}
1714
18- /**
19- * Example of type declaration
20- */
2115export interface ApiResponse < T > {
2216 status : number
2317 message : string
Original file line number Diff line number Diff line change 1- /**
2- * Example of const declaration
3- */
41export const endpoints = {
52 getUsers : '/users' ,
63 getProducts : '/products' ,
74}
85
9- /**
10- * Example of interface declaration
11- */
126export interface Order {
137 orderId : number
148 userId : number
159 productIds : number [ ]
1610}
1711
18- /**
19- * Example of type declaration
20- */
2112export interface OrderResponse {
2213 success : boolean
2314 order : Order
Original file line number Diff line number Diff line change 1- /**
2- * Example of const declaration
3- */
41export const apiKeys = {
52 google : 'GOOGLE_API_KEY' ,
63 facebook : 'FACEBOOK_API_KEY' ,
74}
85
9- /**
10- * Example of interface declaration
11- */
126export interface AuthResponse {
137 token : string
148 expiresIn : number
159}
1610
17- /**
18- * Example of type declaration
19- */
2011export type AuthStatus = 'authenticated' | 'unauthenticated'
2112
22- /**
23- * Example of function declaration
24- */
2513export function authenticate ( user : string , password : string ) : Promise < AuthResponse > {
2614 return fetch ( '/auth/login' , {
2715 method : 'POST' ,
Original file line number Diff line number Diff line change 1- /**
2- * Example of const declaration
3- */
41export const defaultHeaders = {
52 'Content-Type' : 'application/json' ,
63}
7-
8- /**
9- * Example of interface declaration
10- */
114export interface Comment {
125 id : number
136 postId : number
147 body : string
158}
16-
17- /**
18- * Example of type declaration
19- */
209export interface CommentsResponse {
2110 comments : Comment [ ]
2211}
23-
24- /**
25- * Example of function declaration
26- */
2712export function fetchComments ( postId : number ) : Promise < CommentsResponse > {
2813 return fetch ( `/posts/${ postId } /comments` )
2914 . then ( response => response . json ( ) ) as Promise < CommentsResponse >
Original file line number Diff line number Diff line change 11/**
22 * Example of const declaration
33 */
4- export const config : { [ key : string ] : string } = {
5- apiUrl : 'https://api.example.com' ,
6- timeout : '5000' ,
7- }
4+ export declare const config : { [ key : string ] : string }
85
96/**
107 * Example of interface declaration
118 */
12- export interface User {
9+ export interface User {
1310 id : number
1411 name : string
1512 email : string
@@ -18,15 +15,12 @@ export interface User {
1815/**
1916 * Example of type declaration
2017 */
21- export interface ResponseData {
18+ export interface ResponseData {
2219 success : boolean
2320 data : User [ ]
2421}
2522
2623/**
2724 * Example of function declaration
2825 */
29- export function fetchUsers ( ) : Promise < ResponseData > {
30- return fetch ( config . apiUrl )
31- . then ( response => response . json ( ) ) as Promise < ResponseData >
32- }
26+ export declare function fetchUsers ( ) : Promise < ResponseData >
Original file line number Diff line number Diff line change 11/**
22 * Example of another const declaration
33 */
4- export const settings : { [ key : string ] : any } = {
5- theme : 'dark' ,
6- language : 'en' ,
7- }
4+ export declare const settings : { [ key : string ] : any }
85
9- /**
10- * Example of interface declaration
11- */
12- export interface Product {
6+ export interface Product {
137 id : number
148 name : string
159 price : number
1610}
1711
18- /**
19- * Example of type declaration
20- */
21- export interface ApiResponse < T > {
12+ export interface ApiResponse < T > {
2213 status : number
2314 message : string
2415 data : T
@@ -27,7 +18,4 @@ export interface ApiResponse<T> {
2718/**
2819 * Example of function declaration
2920 */
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- }
21+ export declare function getProduct ( id : number ) : Promise < ApiResponse < Product > >
Original file line number Diff line number Diff line change 1- /**
2- * Example of const declaration
3- */
4- export const endpoints = {
5- getUsers : '/users' ,
6- getProducts : '/products' ,
7- }
1+ export declare const endpoints
82
9- /**
10- * Example of interface declaration
11- */
12- export interface Order {
3+ export interface Order {
134 orderId : number
145 userId : number
156 productIds : number [ ]
167}
178
18- /**
19- * Example of type declaration
20- */
21- export interface OrderResponse {
9+ export interface OrderResponse {
2210 success : boolean
2311 order : Order
2412}
2513
2614/**
2715 * Example of function declaration
2816 */
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- }
17+ export declare function createOrder ( order : Order ) : Promise < OrderResponse >
Original file line number Diff line number Diff line change 1- /**
2- * Example of const declaration
3- */
4- export const apiKeys = {
5- google : 'GOOGLE_API_KEY' ,
6- facebook : 'FACEBOOK_API_KEY' ,
7- }
1+ export declare const apiKeys
82
9- /**
10- * Example of interface declaration
11- */
12- export interface AuthResponse {
3+ export interface AuthResponse {
134 token : string
145 expiresIn : number
156}
167
17- /**
18- * Example of type declaration
19- */
208export type AuthStatus = 'authenticated' | 'unauthenticated'
219
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- }
10+ export declare function authenticate ( user : string , password : string ) : Promise < AuthResponse >
Original file line number Diff line number Diff line change 1- /**
2- * Example of const declaration
3- */
4- export const defaultHeaders = {
5- 'Content-Type' : 'application/json' ,
6- }
1+ export declare const defaultHeaders
72
8- /**
9- * Example of interface declaration
10- */
11- export interface Comment {
3+ export interface Comment {
124 id : number
135 postId : number
146 body : string
157}
168
17- /**
18- * Example of type declaration
19- */
20- export interface CommentsResponse {
9+ export interface CommentsResponse {
2110 comments : Comment [ ]
2211}
2312
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- }
13+ export declare function fetchComments ( postId : number ) : Promise < CommentsResponse >
You can’t perform that action at this time.
0 commit comments