fix(compiler-sfc): support TS runtime enum in <script setup>
This commit is contained in:
@@ -884,6 +884,21 @@ return { }
|
||||
})"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> with TypeScript runtime Enum 1`] = `
|
||||
"import { defineComponent as _defineComponent } from 'vue'
|
||||
enum Foo { A = 123 }
|
||||
|
||||
export default _defineComponent({
|
||||
setup(__props, { expose }) {
|
||||
expose()
|
||||
|
||||
|
||||
return { Foo }
|
||||
}
|
||||
|
||||
})"
|
||||
`;
|
||||
|
||||
exports[`SFC compile <script setup> with TypeScript withDefaults (dynamic) 1`] = `
|
||||
"import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from 'vue'
|
||||
import { defaults } from './foo'
|
||||
|
||||
@@ -824,6 +824,18 @@ const emit = defineEmits(['a', 'b'])
|
||||
expect(content).toMatch(`emit: ((e: 'foo' | 'bar') => void),`)
|
||||
expect(content).toMatch(`emits: ["foo", "bar"] as unknown as undefined`)
|
||||
})
|
||||
|
||||
test('runtime Enum', () => {
|
||||
const { content, bindings } = compile(
|
||||
`<script setup lang="ts">
|
||||
enum Foo { A = 123 }
|
||||
</script>`
|
||||
)
|
||||
assertCode(content)
|
||||
expect(bindings).toStrictEqual({
|
||||
Foo: BindingTypes.SETUP_CONST
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('async/await detection', () => {
|
||||
|
||||
Reference in New Issue
Block a user