fix: *.vue with `lang='tsx'` is not formatted (#3763)

master
wonderful-panda 2018-01-18 11:20:55 +09:00 committed by Lucas Duailibe
parent 114895a8a2
commit 3f788d4fb6
4 changed files with 71 additions and 1 deletions

View File

@ -28,7 +28,7 @@ function embed(path, print, textToDoc, options) {
const langAttr = node.attrs.find(attr => attr.name === "lang");
if (!langAttr) {
parser = "babylon";
} else if (langAttr.value === "ts") {
} else if (langAttr.value === "ts" || langAttr.value === "tsx") {
parser = "typescript";
}
}

View File

@ -1,5 +1,58 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`lang-ts.vue 1`] = `
<template>
<div>{{foo}}</div>
</template>
<script lang="ts">
export default {
computed: { foo( ): string { return "foo"; }, },
}
</script>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<template>
<div>{{foo}}</div>
</template>
<script lang="ts">
export default {
computed: {
foo(): string {
return "foo";
}
}
};
</script>
`;
exports[`lang-tsx.vue 1`] = `
<script lang="tsx">
import {VNode} from "vue"
export default {
computed: { foo( ):string { return "foo" }, },
render(h):VNode { return <div>{ this.foo }</div> },
}
</script>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<script lang="tsx">
import { VNode } from "vue";
export default {
computed: {
foo(): string {
return "foo";
}
},
render(h): VNode {
return <div>{this.foo}</div>;
}
};
</script>
`;
exports[`template-bind.vue 1`] = `
<template>
<div v-bind:id=" 'list-' + id "></div>

View File

@ -0,0 +1,10 @@
<template>
<div>{{foo}}</div>
</template>
<script lang="ts">
export default {
computed: { foo( ): string { return "foo"; }, },
}
</script>

View File

@ -0,0 +1,7 @@
<script lang="tsx">
import {VNode} from "vue"
export default {
computed: { foo( ):string { return "foo" }, },
render(h):VNode { return <div>{ this.foo }</div> },
}
</script>