Closed sunlho closed 6 months ago
看一下定制化pont:https://github.com/alibaba/pont/blob/master/docs/customizedPont.md
试试覆盖这个方法?还有getInterfaceContent
我重写了getBaseClassInDeclaration,用正则进行了替换
const handleLoopType = (text: string, baseName: string, propName: string) => {
const reg = new RegExp(`defs\\..*\\.${baseName}`)
const arr = reg.exec(text)
if (arr?.length) {
const n = arr[0]
return text.replace(n, `Omit<${n}, '${propName}'>`)
}
return text
}
getBaseClassInDeclaration(base: BaseClass) {
//其他代码...
return `class ${base.name} {
${base.properties
.map((prop) => handleLoopType(prop.toPropertyCode(Surrounding.typeScript, true), base.name, prop.name))
.join('\n')}
}
`
}
当生成这种嵌套类型时,在一种循环处理的类型中会出现错误
这使我不得不手动处理类型
我想问的是我可不可以在生成时自动处理嵌套类型