@next-core/build-next-bricks 1.11.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/getTypeDeclaration.js +24 -1
- package/src/makeBrickManifest.js +23 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/build-next-bricks",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"description": "Build next bricks",
|
|
5
5
|
"homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/build-next-bricks",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"webpack": "^5.84.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@next-core/brick-manifest": "^0.4.
|
|
52
|
+
"@next-core/brick-manifest": "^0.4.1"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "cdd45da473b22e9f884bcbf2f956b4fc564ab2fd"
|
|
55
55
|
}
|
|
@@ -103,7 +103,7 @@ export function getTypeAnnotation(entryNode, source, usedReferences) {
|
|
|
103
103
|
|
|
104
104
|
case "TSTypeAnnotation":
|
|
105
105
|
// let a: MyType
|
|
106
|
-
//
|
|
106
|
+
// ^^^^^^^^
|
|
107
107
|
return get(node.typeAnnotation);
|
|
108
108
|
|
|
109
109
|
case "TSTypeReference":
|
|
@@ -322,6 +322,29 @@ export function getTypeAnnotation(entryNode, source, usedReferences) {
|
|
|
322
322
|
annotation: get(node.typeAnnotation),
|
|
323
323
|
};
|
|
324
324
|
|
|
325
|
+
case "TSParenthesizedType":
|
|
326
|
+
return {
|
|
327
|
+
type: "parenthesizedType",
|
|
328
|
+
annotation: get(node.typeAnnotation),
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
case "TSConditionalType":
|
|
332
|
+
return {
|
|
333
|
+
type: "conditionalType",
|
|
334
|
+
checkType: get(node.checkType),
|
|
335
|
+
extendsType: get(node.extendsType),
|
|
336
|
+
trueType: get(node.trueType),
|
|
337
|
+
falseType: get(node.falseType),
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
case "TSInferType":
|
|
341
|
+
return {
|
|
342
|
+
type: "inferType",
|
|
343
|
+
typeParameter:
|
|
344
|
+
/** @type {AnnotationTypeParameter | undefined} */
|
|
345
|
+
(get(node.typeParameter)),
|
|
346
|
+
};
|
|
347
|
+
|
|
325
348
|
case "StringLiteral":
|
|
326
349
|
case "NumericLiteral":
|
|
327
350
|
case "BooleanLiteral":
|
package/src/makeBrickManifest.js
CHANGED
|
@@ -254,6 +254,29 @@ function scanFields(manifest, nodes, source) {
|
|
|
254
254
|
annotation,
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
|
+
} else if (node.value) {
|
|
258
|
+
// Infer type annotation from the default value.
|
|
259
|
+
let inferType;
|
|
260
|
+
switch (node.value.type) {
|
|
261
|
+
case "BooleanLiteral":
|
|
262
|
+
inferType = "boolean";
|
|
263
|
+
break;
|
|
264
|
+
case "StringLiteral":
|
|
265
|
+
inferType = "string";
|
|
266
|
+
break;
|
|
267
|
+
case "NumericLiteral":
|
|
268
|
+
inferType = "number";
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
if (inferType) {
|
|
272
|
+
manifest.types.properties.push({
|
|
273
|
+
name: prop.name,
|
|
274
|
+
annotation: {
|
|
275
|
+
type: "keyword",
|
|
276
|
+
value: inferType,
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
}
|
|
257
280
|
}
|
|
258
281
|
if (node.value && !prop.default) {
|
|
259
282
|
prop.default = source.substring(
|