|
| 1 | +--- |
| 2 | +sidebar_position: 1 |
| 3 | +--- |
| 4 | + |
| 5 | +import Tabs from "@theme/Tabs"; |
| 6 | +import TabItem from "@theme/TabItem"; |
| 7 | +import CodeBlock from "@theme/CodeBlock"; |
| 8 | + |
| 9 | +# Change Parameter Object |
| 10 | + |
| 11 | +Modify the function argument to take an object. |
| 12 | + |
| 13 | +<Tabs> |
| 14 | + <TabItem value="js" label="before" default> |
| 15 | + <CodeBlock language="ts"> |
| 16 | + {`import { dummyFunction } from "foo"; |
| 17 | +dummyFunction("hello", "this is dashboard page");`} |
| 18 | + |
| 19 | +</CodeBlock> |
| 20 | + </TabItem> |
| 21 | + <TabItem value="ts" label="after"> |
| 22 | + <CodeBlock language="ts"> |
| 23 | + {`import { dummyFunction } from "foo"; |
| 24 | + |
| 25 | +dummyFunction({ |
| 26 | +"title": "hello", |
| 27 | +"description": "this is dashboard page" |
| 28 | +});`} |
| 29 | + |
| 30 | +</CodeBlock> |
| 31 | + </TabItem> |
| 32 | +</Tabs> |
| 33 | + |
| 34 | +## Options |
| 35 | + |
| 36 | +```typescript |
| 37 | +type Options = { |
| 38 | + functionSourceType?: "absolute" | "relative"; |
| 39 | + functionNameType?: "default" | "named"; |
| 40 | + functionSource: string; |
| 41 | + functionName: string; |
| 42 | + objectKeys: string[]; |
| 43 | +}; |
| 44 | +``` |
| 45 | + |
| 46 | +- functionSourceType: componentSource's type. you can choose absolute or relative |
| 47 | +- functionNameType: changed target specifier |
| 48 | +- functionSource: component source. you can choose package name or target path |
| 49 | +- functionName: props to add's component name |
| 50 | +- objectKeys: add props's name |
| 51 | + |
| 52 | +## Usage |
| 53 | + |
| 54 | +The usage method differs depending on the source type of the import statement to be converted. |
| 55 | + |
| 56 | +### absolute |
| 57 | + |
| 58 | +This is a situation where the source of the import module you want to change is an absolute path. |
| 59 | + |
| 60 | +```typescript title="option.ts" |
| 61 | +const option = { |
| 62 | + functionSourceType: "absolute", |
| 63 | + functionNameType: "named", |
| 64 | + functionSource: "foo", |
| 65 | + functionName: "dummyFunction", |
| 66 | + objectKeys: ["title", "description"], |
| 67 | +}; |
| 68 | +``` |
| 69 | + |
| 70 | +<Tabs> |
| 71 | + <TabItem value="js" label="before" default> |
| 72 | + <CodeBlock language="ts"> |
| 73 | + {`import { dummyFunction } from "foo"; |
| 74 | +dummyFunction("hello", "this is dashboard page");`} |
| 75 | + |
| 76 | +</CodeBlock> |
| 77 | + </TabItem> |
| 78 | + <TabItem value="ts" label="after"> |
| 79 | + <CodeBlock language="ts"> |
| 80 | + {`import { dummyFunction } from "foo"; |
| 81 | + |
| 82 | +dummyFunction({ |
| 83 | +"title": "hello", |
| 84 | +"description": "this is dashboard page" |
| 85 | +});`} |
| 86 | + |
| 87 | +</CodeBlock> |
| 88 | + </TabItem> |
| 89 | +</Tabs> |
| 90 | + |
| 91 | +### relative |
| 92 | + |
| 93 | +This is a situation where the source of the import module you want to change is an absolute path. |
| 94 | + |
| 95 | +```typescript title="option.ts" |
| 96 | +const option = { |
| 97 | + functionSourceType: "relative", |
| 98 | + functionNameType: "named", |
| 99 | + functionSource: path.join(process.cwd(), "../test/foo.ts"),, |
| 100 | + functionName: "dummyFunction", |
| 101 | + objectKeys: ["title", "description"], |
| 102 | +}; |
| 103 | +``` |
| 104 | + |
| 105 | +<Tabs> |
| 106 | + <TabItem value="js" label="before" default> |
| 107 | + <CodeBlock language="ts"> |
| 108 | + {`import { dummyFunction } from "../test/foo.ts"; |
| 109 | +dummyFunction("hello", "this is dashboard page");`} |
| 110 | + |
| 111 | +</CodeBlock> |
| 112 | + </TabItem> |
| 113 | + <TabItem value="ts" label="after"> |
| 114 | + <CodeBlock language="ts"> |
| 115 | + {`import { dummyFunction } from "../test/foo.ts"; |
| 116 | + |
| 117 | +dummyFunction({ |
| 118 | +"title": "hello", |
| 119 | +"description": "this is dashboard page" |
| 120 | +});`} |
| 121 | + |
| 122 | +</CodeBlock> |
| 123 | + </TabItem> |
| 124 | +</Tabs> |
0 commit comments