From: Evan You Date: Wed, 8 Jul 2020 13:45:01 +0000 (-0400) Subject: wip: move type declarations out of setup X-Git-Tag: v3.0.0-beta.21~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a44d53003e13ee1c98057da791ddb40a5b7c4329;p=thirdparty%2Fvuejs%2Fcore.git wip: move type declarations out of setup --- diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index d8d82f64bf..f766ab5363 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -344,10 +344,17 @@ export function compileScriptSetup( ) { const index = node.id.start! + startOffset s.overwrite(index, index + emitVar.length, '__emit__') - s.move(start, end, 0) emitType = `typeof __emit__` extractEmits(node, typeDeclaredEmits) } + + // move all type declarations to outer scope + if ( + node.type.startsWith('TS') || + (node.type === 'ExportNamedDeclaration' && node.exportKind === 'type') + ) { + s.move(start, end, 0) + } } // check default export to make sure it doesn't reference setup scope