Skip to content

Commit ce8edcb

Browse files
betavsanlyyao
andauthored
fix(types): add definition for type TNode in common and miniprogram templates (#756)
* fix(types): add definition for type TNode in common and miniprogram templates * chore: update base.tpl * fix: fix cr --------- Co-authored-by: anlyyao <[email protected]>
1 parent 87590e9 commit ce8edcb

File tree

11 files changed

+104
-45
lines changed

11 files changed

+104
-45
lines changed

packages/products/tdesign-miniprogram/packages/components/common/common.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ export interface Styles {
66

77
export type ImageEvent = any;
88

9-
/**
10-
* 通用全局类型
11-
* */
129
export type PlainObject = { [key: string]: any };
1310

1411
export type OptionData = {
@@ -19,15 +16,18 @@ export type OptionData = {
1916
export type TreeOptionData<T = string | number> = {
2017
children?: Array<TreeOptionData<T>> | boolean;
2118
/** option label content */
22-
label?: string | TNode;
19+
label?: string;
2320
/** option search text */
2421
text?: string;
2522
/** option value */
2623
value?: T;
2724
/** option node content */
28-
content?: string | TNode;
25+
content?: string;
2926
} & PlainObject;
3027

28+
/**
29+
* 通用全局类型
30+
* */
3131
export type SizeEnum = 'small' | 'medium' | 'large';
3232

3333
export type ShapeEnum = 'circle' | 'round';

packages/products/tdesign-mobile-react/src/common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ export interface UploadDisplayDragEvents {
3636

3737
export type ImageEvent<T = any> = SyntheticEvent<T>;
3838

39-
/**
40-
* 通用全局类型
41-
* */
4239
export type PlainObject = { [key: string]: any };
4340

4441
export type OptionData = {
@@ -58,6 +55,9 @@ export type TreeOptionData<T = string | number> = {
5855
content?: string | TNode;
5956
} & PlainObject;
6057

58+
/**
59+
* 通用全局类型
60+
* */
6161
export type SizeEnum = 'small' | 'medium' | 'large';
6262

6363
export type ShapeEnum = 'circle' | 'round';

packages/products/tdesign-mobile-vue/src/common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ export interface UploadDisplayDragEvents {
4141

4242
export type ImageEvent = Event;
4343

44-
/**
45-
* 通用全局类型
46-
* */
4744
export type PlainObject = { [key: string]: any };
4845

4946
export type OptionData = {
@@ -63,6 +60,9 @@ export type TreeOptionData<T = string | number> = {
6360
content?: string | TNode;
6461
} & PlainObject;
6562

63+
/**
64+
* 通用全局类型
65+
* */
6666
export type SizeEnum = 'small' | 'medium' | 'large';
6767

6868
export type ShapeEnum = 'circle' | 'round';

packages/products/tdesign-react/packages/components/common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ export interface UploadDisplayDragEvents {
3636

3737
export type ImageEvent<T = any> = SyntheticEvent<T>;
3838

39-
/**
40-
* 通用全局类型
41-
* */
4239
export type PlainObject = { [key: string]: any };
4340

4441
export type OptionData = {
@@ -58,6 +55,9 @@ export type TreeOptionData<T = string | number> = {
5855
content?: string | TNode;
5956
} & PlainObject;
6057

58+
/**
59+
* 通用全局类型
60+
* */
6161
export type SizeEnum = 'small' | 'medium' | 'large';
6262

6363
export type ShapeEnum = 'circle' | 'round';

packages/products/tdesign-vue/src/common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ export interface UploadDisplayDragEvents {
3434

3535
export type ImageEvent = Event;
3636

37-
/**
38-
* 通用全局类型
39-
* */
4037
export type PlainObject = { [key: string]: any };
4138

4239
export type OptionData = {
@@ -56,6 +53,9 @@ export type TreeOptionData<T = string | number> = {
5653
content?: string | TNode;
5754
} & PlainObject;
5855

56+
/**
57+
* 通用全局类型
58+
* */
5959
export type SizeEnum = 'small' | 'medium' | 'large';
6060

6161
export type ShapeEnum = 'circle' | 'round';

packages/scripts/types/global/base.tpl

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,6 @@
22
/**
33
* 通用全局类型
44
* */
5-
export type PlainObject = { [key: string]: any };
6-
7-
export type OptionData = {
8-
label?: string;
9-
value?: string | number;
10-
} & PlainObject;
11-
12-
export type TreeOptionData<T = string | number> = {
13-
children?: Array<TreeOptionData<T>> | boolean;
14-
/** option label content */
15-
label?: string | TNode;
16-
/** option search text */
17-
text?: string;
18-
/** option value */
19-
value?: T;
20-
/** option node content */
21-
content?: string | TNode;
22-
} & PlainObject;
23-
245
export type SizeEnum = 'small' | 'medium' | 'large';
256

267
export type ShapeEnum = 'circle' | 'round';

packages/scripts/types/global/index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,22 @@ function combineGlobals(framework) {
1818
// 通用全局变量
1919
const baseGlobalData = fs.readFileSync(baseGlobalPath);
2020
// 框架特有全局变量
21-
const moreGlobalData = fs.readFileSync(path.resolve(__dirname, current.globalTplPath));
21+
const moreGlobalData = fs.readFileSync(
22+
path.resolve(__dirname, current.globalTplPath)
23+
);
2224
const outputPath = path.resolve(current.globalPath);
2325
let data = moreGlobalData.toString() + baseGlobalData.toString();
2426
if (['React(PC)', 'React(Mobile)'].includes(framework)) {
2527
data = formatType(data);
2628
}
27-
fs.writeFile(
28-
outputPath,
29-
data,
30-
(err) => {
31-
if (err) return console.error(err);
32-
console.log(chalk.green(`globals: ${outputPath} has been created successfully!`));
33-
},
34-
);
29+
const callback = (err) => {
30+
if (err) return console.error(err);
31+
// eslint-disable-next-line no-console
32+
console.log(
33+
chalk.green(`globals: ${outputPath} has been created successfully!`)
34+
);
35+
};
36+
fs.writeFile(outputPath, data, callback);
3537
}
3638

3739
module.exports = combineGlobals;

packages/scripts/types/global/miniprogram.tpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,22 @@ export interface Styles {
55
}
66

77
export type ImageEvent = any;
8+
9+
export type PlainObject = { [key: string]: any };
10+
11+
export type OptionData = {
12+
label?: string;
13+
value?: string | number;
14+
} & PlainObject;
15+
16+
export type TreeOptionData<T = string | number> = {
17+
children?: Array<TreeOptionData<T>> | boolean;
18+
/** option label content */
19+
label?: string;
20+
/** option search text */
21+
text?: string;
22+
/** option value */
23+
value?: T;
24+
/** option node content */
25+
content?: string;
26+
} & PlainObject;

packages/scripts/types/global/react.tpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,22 @@ export interface UploadDisplayDragEvents {
3535
}
3636

3737
export type ImageEvent<T = any> = SyntheticEvent<T>;
38+
39+
export type PlainObject = { [key: string]: any };
40+
41+
export type OptionData = {
42+
label?: string;
43+
value?: string | number;
44+
} & PlainObject;
45+
46+
export type TreeOptionData<T = string | number> = {
47+
children?: Array<TreeOptionData<T>> | boolean;
48+
/** option label content */
49+
label?: string | TNode;
50+
/** option search text */
51+
text?: string;
52+
/** option value */
53+
value?: T;
54+
/** option node content */
55+
content?: string | TNode;
56+
} & PlainObject;

packages/scripts/types/global/vue.tpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,22 @@ export interface UploadDisplayDragEvents {
3333
}
3434

3535
export type ImageEvent = Event;
36+
37+
export type PlainObject = { [key: string]: any };
38+
39+
export type OptionData = {
40+
label?: string;
41+
value?: string | number;
42+
} & PlainObject;
43+
44+
export type TreeOptionData<T = string | number> = {
45+
children?: Array<TreeOptionData<T>> | boolean;
46+
/** option label content */
47+
label?: string | TNode;
48+
/** option search text */
49+
text?: string;
50+
/** option value */
51+
value?: T;
52+
/** option node content */
53+
content?: string | TNode;
54+
} & PlainObject;

0 commit comments

Comments
 (0)