fix: type generate for upload sfc tsx

This commit is contained in:
YunYouJun 2022-03-11 23:44:20 +08:00
parent 425e4a9f34
commit beeb9fb164
3 changed files with 5 additions and 2 deletions

View File

@ -68,9 +68,11 @@ export const generateTypesDefinitions = async () => {
if (script || scriptSetup) {
let content = ''
let isTS = false
let isTSX = false
if (script && script.content) {
content += script.content
if (script.lang === 'ts') isTS = true
else if (script.lang === 'tsx') isTSX = true
}
if (scriptSetup) {
const compiled = vueCompiler.compileScript(sfc.descriptor, {
@ -78,9 +80,11 @@ export const generateTypesDefinitions = async () => {
})
content += compiled.content
if (scriptSetup.lang === 'ts') isTS = true
else if (scriptSetup.lang === 'tsx') isTSX = true
}
const sourceFile = project.createSourceFile(
path.relative(process.cwd(), file) + (isTS ? '.ts' : '.js'),
path.relative(process.cwd(), file) +
(isTSX ? '.tsx' : isTS ? '.ts' : '.js'),
content
)
sourceFiles.push(sourceFile)

View File

@ -42,7 +42,6 @@ import {
onBeforeUnmount,
toRef,
shallowRef,
h,
defineComponent,
useSlots,
} from 'vue'