mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 09:41:57 +00:00
refactor: material-parser
This commit is contained in:
parent
081a817aa9
commit
cc180b8cce
@ -11,6 +11,7 @@ export default function resolveTranspiledClass(path: any) {
|
||||
visitFunctionDeclaration(arg) {
|
||||
classPath = new NodePath(
|
||||
builders.functionDeclaration(
|
||||
// @ts-ignore
|
||||
arg.node.id || 'Default',
|
||||
[],
|
||||
builders.blockStatement([
|
||||
|
||||
@ -115,6 +115,7 @@ function handleTSTypeLiteral(path, typeParams) {
|
||||
value: getTSTypeWithRequirements(param.get('typeAnnotation'), typeParams),
|
||||
});
|
||||
} else if (t.TSCallSignatureDeclaration.check(param.node)) {
|
||||
// @ts-ignore
|
||||
type.signature.constructor = handleTSFunctionType(param, typeParams);
|
||||
} else if (t.TSIndexSignature.check(param.node)) {
|
||||
type.signature.properties.push({
|
||||
@ -195,12 +196,14 @@ function handleTSFunctionType(path, typeParams) {
|
||||
};
|
||||
|
||||
if (param.node.name === 'this') {
|
||||
// @ts-ignore
|
||||
type.signature.this = arg.type;
|
||||
return;
|
||||
}
|
||||
|
||||
if (param.node.type === 'RestElement') {
|
||||
arg.name = param.node.argument.name;
|
||||
// @ts-ignore
|
||||
arg.rest = true;
|
||||
}
|
||||
|
||||
@ -288,7 +291,7 @@ function handleTSIndexedAccessType(path, typeParams) {
|
||||
|
||||
let visitedTypes = {};
|
||||
|
||||
function getTSTypeWithResolvedTypes(path, typeParams) {
|
||||
function getTSTypeWithResolvedTypes(path, typeParams?) {
|
||||
if (t.TSTypeAnnotation.check(path.node)) {
|
||||
path = path.get('typeAnnotation');
|
||||
}
|
||||
@ -343,7 +346,7 @@ function getTSTypeWithResolvedTypes(path, typeParams) {
|
||||
*
|
||||
* If there is no match, "unknown" is returned.
|
||||
*/
|
||||
export default function getTSType(path, typeParamMap) {
|
||||
export default function getTSType(path, typeParamMap?) {
|
||||
// Empty visited types before an after run
|
||||
// Before: in case the detection threw and we rerun again
|
||||
// After: cleanup memory after we are done here
|
||||
@ -72,6 +72,7 @@ function getDocgenTypeHelper(
|
||||
}[] = symbolArr.map((prop) => {
|
||||
const propType = checker.getTypeOfSymbolAtLocation(
|
||||
prop,
|
||||
// @ts-ignore
|
||||
prop.valueDeclaration || (prop.declarations && prop.declarations[0]) || {},
|
||||
);
|
||||
return {
|
||||
|
||||
@ -4,7 +4,8 @@
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"rootDir": "src",
|
||||
"outDir": "lib"
|
||||
"outDir": "lib",
|
||||
"strict": false
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["schemas"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user