fix(ts): fix default tsconfig.json (#4842)

[release]
This commit is contained in:
Kevin Marrec 2019-01-23 22:41:00 +01:00 committed by Pooya Parsa
parent 2184df4251
commit c39cf841a3
7 changed files with 21 additions and 30 deletions

View File

@ -1,7 +1,10 @@
{ {
"extends": "@nuxt/typescript-edge", "extends": "@nuxt/typescript-edge",
"compilerOptions": { "compilerOptions": {
"baseUrl": ".", "noImplicitAny": false,
"noImplicitAny": false "types": [
"@types/node",
"@nuxt/vue-app-edge"
]
} }
} }

View File

@ -1,6 +1,9 @@
{ {
"extends": "@nuxt/typescript-edge", "extends": "@nuxt/typescript-edge",
"compilerOptions": { "compilerOptions": {
"baseUrl": "." "types": [
} "@types/node",
"@nuxt/vue-app-edge"
]
},
} }

View File

@ -1,19 +1,3 @@
import { readJSON, writeJSON } from 'fs-extra'
export default { export default {
build: true, build: true
hooks: {
async 'build:done'(pkg) {
if (pkg.options.suffix && pkg.options.linkedDependencies) {
const tsconfig = await readJSON(pkg.resolvePath('tsconfig.json'))
tsconfig.compilerOptions.types = tsconfig.compilerOptions.types.map((type) => {
const suffix = pkg.options.linkedDependencies.includes(type) ? pkg.options.suffix : ''
return type + suffix
})
await writeJSON(pkg.resolvePath('tsconfig.json'), tsconfig, { spaces: 2 })
}
}
}
} }

View File

@ -22,7 +22,10 @@ export async function generateTsConfigIfMissing(rootDir) {
await writeJSON(tsConfigPath, { await writeJSON(tsConfigPath, {
extends: configToExtend, extends: configToExtend,
compilerOptions: { compilerOptions: {
baseUrl: '.' types: [
'@types/node',
'@nuxt/vue-app'
]
} }
}, { spaces: 2 }) }, { spaces: 2 })
consola.info(`Extending ${chalk.bold.blue(`node_modules/${configToExtend}/tsconfig.json`)}`) consola.info(`Extending ${chalk.bold.blue(`node_modules/${configToExtend}/tsconfig.json`)}`)

View File

@ -8,7 +8,6 @@
"dom" "dom"
], ],
"esModuleInterop": true, "esModuleInterop": true,
"resolveJsonModule": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"jsx": "preserve", "jsx": "preserve",
"sourceMap": true, "sourceMap": true,
@ -25,10 +24,6 @@
"@/*": [ "@/*": [
"./*" "./*"
] ]
}, }
"types": [
"@types/node",
"@nuxt/vue-app"
]
} }
} }

View File

@ -12,7 +12,7 @@ describe('typescript modern', () => {
await new Builder(nuxt, BundleBuilder).build() await new Builder(nuxt, BundleBuilder).build()
}) })
test('fork-ts-checker-webpack-plugin', () => { test('check types only once', () => {
expect(ForkTsCheckerWebpackPlugin).toHaveBeenCalledTimes(1) expect(ForkTsCheckerWebpackPlugin).toHaveBeenCalledTimes(1)
}) })

View File

@ -22,7 +22,10 @@ describe('typescript setup', () => {
expect(await readJSON(tsConfigPath)).toEqual({ expect(await readJSON(tsConfigPath)).toEqual({
extends: '@nuxt/typescript', extends: '@nuxt/typescript',
compilerOptions: { compilerOptions: {
baseUrl: '.' types: [
'@types/node',
'@nuxt/vue-app'
]
} }
}) })