fix: should be able to parse decorators in script lang="ts" & jsx (#2088)

* fix: should be able to parse decorators in script lang="ts"

* fix: should also support parsing jsx

Added to `compileScript` instead of `babelParserDefaultPlugins` because
it's not needed for template expression parsing
This commit is contained in:
Haoqun Jiang
2020-09-15 09:51:15 +08:00
committed by GitHub
parent 0cddde6aa4
commit 273d19ad46
2 changed files with 18 additions and 2 deletions

View File

@@ -520,6 +520,22 @@ describe('SFC compile <script setup>', () => {
})
describe('SFC analyze <script> bindings', () => {
it('can parse decorators syntax in typescript block', () => {
const { scriptAst } = compile(`
<script lang="ts">
import { Options, Vue } from 'vue-class-component';
@Options({
components: {
HelloWorld,
},
props: ['foo', 'bar']
})
export default class Home extends Vue {}
</script>
`)
expect(scriptAst).toBeDefined()
})
it('recognizes props array declaration', () => {
const { bindings } = compile(`
<script>