Skip to content

Commit c49eeb7

Browse files
elevatebartyyx990803
authored andcommitted
fix(typescript): fix invalid tsconfig.json (#1036)
1 parent d184638 commit c49eeb7

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

packages/@vue/cli-plugin-typescript/__tests__/tsGenerator.spec.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ test('classComponent', async () => {
3535

3636
expect(files['tsconfig.json']).toMatch(`"experimentalDecorators": true`)
3737
expect(files['tsconfig.json']).toMatch(`"emitDecoratorMetadata": true`)
38-
expect(files['src/App.vue']).toMatch(`export default class App extends Vue {`)
39-
expect(files['src/components/HelloWorld.vue']).toMatch(`export default class HelloWorld extends Vue {`)
38+
expect(files['src/App.vue']).toMatch(
39+
`export default class App extends Vue {`
40+
)
41+
expect(files['src/components/HelloWorld.vue']).toMatch(
42+
`export default class HelloWorld extends Vue {`
43+
)
4044
})
4145

4246
test('use with Babel', async () => {
@@ -96,6 +100,19 @@ test('lint with no lintOnSave', async () => {
96100
expect(pkg.vue).toEqual({ lintOnSave: false })
97101
})
98102

103+
test('tsconfig.json should be valid json', async () => {
104+
const { files } = await generateWithPlugin([
105+
{
106+
id: 'ts',
107+
apply: require('../generator'),
108+
options: {}
109+
}
110+
])
111+
expect(() => {
112+
JSON.parse(files['tsconfig.json'])
113+
}).not.toThrow()
114+
})
115+
99116
test('compat with unit-mocha', async () => {
100117
const { pkg } = await generateWithPlugin([
101118
{

packages/@vue/cli-plugin-typescript/generator/template/tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
"sourceMap": true,
1414
"baseUrl": ".",
1515
"types": [
16-
"node",
17-
<%_ if (hasMocha) { _%>
16+
"node"<%_ if (hasMocha) { _%>,
1817
"mocha",
1918
"chai"
20-
<%_ } else if (hasJest) { _%>
19+
<%_ } else if (hasJest) { _%>,
2120
"jest"
2221
<%_ } _%>
2322
],

0 commit comments

Comments
 (0)