]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: move type declarations out of setup
authorEvan You <yyx990803@gmail.com>
Wed, 8 Jul 2020 13:45:01 +0000 (09:45 -0400)
committerEvan You <yyx990803@gmail.com>
Thu, 9 Jul 2020 16:17:28 +0000 (12:17 -0400)
packages/compiler-sfc/src/compileScript.ts

index d8d82f64bf77f652925ee55011870e88aaa2226d..f766ab5363f739853a22d3dd3325507a85ae28c8 100644 (file)
@@ -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