Skip to content

Commit b274eaf

Browse files
committed
feat(typing): add declaration type
1 parent 88b108a commit b274eaf

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

packages/mock-addon/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"main": "dist/cjs/index.js",
2424
"module": "dist/esm/index.js",
25-
"types": "dist/ts/index.d.ts",
25+
"types": "typings.d.ts",
2626
"files": [
2727
"dist/**/*",
2828
"README.md",

packages/mock-addon/src/typings.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/mock-addon/typings.d.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
export type Method = 'GET' | 'PUT' | 'POST' | 'DELETE' | 'PATCH' | 'OPTIONS'
2+
3+
export type Request = {
4+
body: string | null
5+
method: Method
6+
signal: AbortSignal | null
7+
url: string
8+
searchParams?: string
9+
}
10+
11+
export type ResponseObj = string | object
12+
export type ResponseFn = (request: Request) => ResponseObj
13+
export type Response = ResponseObj | ResponseFn
14+
15+
export type StorybookAddonMockData = {
16+
url: string
17+
method: Method
18+
delay?: 0 | number
19+
status: number
20+
response: Response
21+
}
22+
23+
declare module '@storybook/csf' {
24+
interface Parameters {
25+
mockAddonConfigs?: {
26+
globalMockData?: StorybookAddonMockData[]
27+
ignoreQueryParams?: boolean
28+
refreshStoryOnUpdate?: boolean
29+
disableUsingOriginal?: boolean
30+
disable?: boolean
31+
}
32+
mockData?: StorybookAddonMockData[]
33+
}
34+
}

0 commit comments

Comments
 (0)