})"
`;
+exports[`SFC compile <script setup> with TypeScript runtime Enum in normal script 1`] = `
+"import { defineComponent as _defineComponent } from 'vue'
+enum Foo { A = 123 }
+
+ export enum D { D = \\"D\\" }
+ const enum C { C = \\"C\\" }
+ enum B { B = \\"B\\" }
+
+export default /*#__PURE__*/_defineComponent({
+ setup(__props, { expose }) {
+ expose()
+
+
+return { D, C, B, Foo }
+}
+
+})"
+`;
+
exports[`SFC compile <script setup> with TypeScript withDefaults (dynamic) 1`] = `
"import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from 'vue'
import { defaults } from './foo'
})
})
+ test('runtime Enum in normal script', () => {
+ const { content, bindings } = compile(
+ `<script lang="ts">
+ export enum D { D = "D" }
+ const enum C { C = "C" }
+ enum B { B = "B" }
+ </script>
+ <script setup lang="ts">
+ enum Foo { A = 123 }
+ </script>`
+ )
+ assertCode(content)
+ expect(bindings).toStrictEqual({
+ D: BindingTypes.SETUP_CONST,
+ C: BindingTypes.SETUP_CONST,
+ B: BindingTypes.SETUP_CONST,
+ Foo: BindingTypes.SETUP_CONST
+ })
+ })
+
test('const Enum', () => {
const { content, bindings } = compile(
`<script setup lang="ts">
} else if (
(node.type === 'VariableDeclaration' ||
node.type === 'FunctionDeclaration' ||
- node.type === 'ClassDeclaration') &&
+ node.type === 'ClassDeclaration' ||
+ node.type === 'TSEnumDeclaration') &&
!node.declare
) {
walkDeclaration(node, scriptBindings, userImportAlias)
}
}
} else if (
+ node.type === 'TSEnumDeclaration' ||
node.type === 'FunctionDeclaration' ||
node.type === 'ClassDeclaration'
) {