Skip to content

Commit 96d84f1

Browse files
authored
fix(typescript-build): set logger instance correctly (#580)
1 parent d95453e commit 96d84f1

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

packages/typescript-build/src/index.ts

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import path from 'path'
22
import { defu } from 'defu'
33
import consola from 'consola'
4-
import { Module } from '@nuxt/types'
5-
import { Options as TsLoaderOptions } from 'ts-loader'
6-
import { ForkTsCheckerWebpackPluginOptions as TsCheckerOptions } from 'fork-ts-checker-webpack-plugin/lib/ForkTsCheckerWebpackPluginOptions'
7-
import { RuleSetUseItem } from 'webpack'
4+
import type { Module } from '@nuxt/types'
5+
import type { Options as TsLoaderOptions } from 'ts-loader'
6+
import type { ForkTsCheckerWebpackPluginOptions as TsCheckerOptions } from 'fork-ts-checker-webpack-plugin/lib/ForkTsCheckerWebpackPluginOptions'
7+
import type TsCheckerLogger from 'fork-ts-checker-webpack-plugin/lib/logger/Logger'
8+
import type { RuleSetUseItem } from 'webpack'
89

910
export interface Options {
1011
ignoreNotFoundWarnings?: boolean
@@ -72,14 +73,23 @@ const tsModule: Module<Options> = function (moduleOptions) {
7273
if (options.typeCheck && isClient && !isModern) {
7374
// eslint-disable-next-line @typescript-eslint/no-var-requires
7475
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
76+
const logger = consola.withTag('nuxt:typescript')
77+
/* istanbul ignore next */
78+
const loggerInterface: TsCheckerLogger = {
79+
log (message) { logger.log(message) },
80+
info (message) { logger.info(message) },
81+
error (message) { logger.error(message) }
82+
}
7583
config.plugins!.push(new ForkTsCheckerWebpackPlugin(defu(options.typeCheck, {
7684
typescript: {
7785
configFile: path.resolve(this.options.rootDir!, 'tsconfig.json'),
7886
extensions: {
7987
vue: true
8088
}
8189
},
82-
logger: consola.withScope('nuxt:typescript')
90+
logger: {
91+
issues: loggerInterface
92+
}
8393
} as TsCheckerOptions)))
8494
}
8595
})

0 commit comments

Comments
 (0)