From c49eeb732d81e651aa6057d2768a2767786eb092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20Ledoux?= Date: Wed, 25 Apr 2018 16:12:44 -0500 Subject: [PATCH] fix(typescript): fix invalid tsconfig.json (#1036) --- .../__tests__/tsGenerator.spec.js | 21 +++++++++++++++++-- .../generator/template/tsconfig.json | 5 ++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/@vue/cli-plugin-typescript/__tests__/tsGenerator.spec.js b/packages/@vue/cli-plugin-typescript/__tests__/tsGenerator.spec.js index 7b4e3b96dd..90cdb3c729 100644 --- a/packages/@vue/cli-plugin-typescript/__tests__/tsGenerator.spec.js +++ b/packages/@vue/cli-plugin-typescript/__tests__/tsGenerator.spec.js @@ -35,8 +35,12 @@ test('classComponent', async () => { expect(files['tsconfig.json']).toMatch(`"experimentalDecorators": true`) expect(files['tsconfig.json']).toMatch(`"emitDecoratorMetadata": true`) - expect(files['src/App.vue']).toMatch(`export default class App extends Vue {`) - expect(files['src/components/HelloWorld.vue']).toMatch(`export default class HelloWorld extends Vue {`) + expect(files['src/App.vue']).toMatch( + `export default class App extends Vue {` + ) + expect(files['src/components/HelloWorld.vue']).toMatch( + `export default class HelloWorld extends Vue {` + ) }) test('use with Babel', async () => { @@ -96,6 +100,19 @@ test('lint with no lintOnSave', async () => { expect(pkg.vue).toEqual({ lintOnSave: false }) }) +test('tsconfig.json should be valid json', async () => { + const { files } = await generateWithPlugin([ + { + id: 'ts', + apply: require('../generator'), + options: {} + } + ]) + expect(() => { + JSON.parse(files['tsconfig.json']) + }).not.toThrow() +}) + test('compat with unit-mocha', async () => { const { pkg } = await generateWithPlugin([ { diff --git a/packages/@vue/cli-plugin-typescript/generator/template/tsconfig.json b/packages/@vue/cli-plugin-typescript/generator/template/tsconfig.json index 89d9c4c210..a35c85a966 100644 --- a/packages/@vue/cli-plugin-typescript/generator/template/tsconfig.json +++ b/packages/@vue/cli-plugin-typescript/generator/template/tsconfig.json @@ -13,11 +13,10 @@ "sourceMap": true, "baseUrl": ".", "types": [ - "node", - <%_ if (hasMocha) { _%> + "node"<%_ if (hasMocha) { _%>, "mocha", "chai" - <%_ } else if (hasJest) { _%> + <%_ } else if (hasJest) { _%>, "jest" <%_ } _%> ],