Skip to content

Commit 437f56c

Browse files
ky-isyyx990803
authored andcommitted
fix(typescript): tsconfig whitespace (vuejs#2046)
1 parent b20f624 commit 437f56c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@ test('tsconfig.json should be valid json', async () => {
110110
expect(() => {
111111
JSON.parse(files['tsconfig.json'])
112112
}).not.toThrow()
113+
expect(files['tsconfig.json']).not.toMatch('" ')
113114
})
114115

115116
test('compat with unit-mocha', async () => {
116-
const { pkg } = await generateWithPlugin([
117+
const { pkg, files } = await generateWithPlugin([
117118
{
118119
id: '@vue/cli-plugin-unit-mocha',
119120
apply: require('@vue/cli-plugin-unit-mocha/generator'),
@@ -131,10 +132,12 @@ test('compat with unit-mocha', async () => {
131132

132133
expect(pkg.devDependencies).toHaveProperty('@types/mocha')
133134
expect(pkg.devDependencies).toHaveProperty('@types/chai')
135+
136+
expect(files['tsconfig.json']).not.toMatch('" ')
134137
})
135138

136139
test('compat with unit-jest', async () => {
137-
const { pkg } = await generateWithPlugin([
140+
const { pkg, files } = await generateWithPlugin([
138141
{
139142
id: '@vue/cli-plugin-unit-jest',
140143
apply: require('@vue/cli-plugin-unit-jest/generator'),
@@ -151,4 +154,6 @@ test('compat with unit-jest', async () => {
151154
])
152155

153156
expect(pkg.devDependencies).toHaveProperty('@types/jest')
157+
158+
expect(files['tsconfig.json']).not.toMatch('" ')
154159
})

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
"sourceMap": true,
1515
"baseUrl": ".",
1616
"types": [
17-
"node"<%_ if (hasMocha) { _%>,
17+
"node"<% if (hasMocha || hasJest) { %>,<% } %>
18+
<%_ if (hasMocha) { _%>
1819
"mocha",
1920
"chai"
20-
<%_ } else if (hasJest) { _%>,
21+
<%_ } else if (hasJest) { _%>
2122
"jest"
2223
<%_ } _%>
2324
],

0 commit comments

Comments
 (0)