|
1 | 1 | import path from 'path'
|
2 | 2 | import { defu } from 'defu'
|
3 | 3 | 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' |
8 | 9 |
|
9 | 10 | export interface Options {
|
10 | 11 | ignoreNotFoundWarnings?: boolean
|
@@ -72,14 +73,23 @@ const tsModule: Module<Options> = function (moduleOptions) {
|
72 | 73 | if (options.typeCheck && isClient && !isModern) {
|
73 | 74 | // eslint-disable-next-line @typescript-eslint/no-var-requires
|
74 | 75 | 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 | + } |
75 | 83 | config.plugins!.push(new ForkTsCheckerWebpackPlugin(defu(options.typeCheck, {
|
76 | 84 | typescript: {
|
77 | 85 | configFile: path.resolve(this.options.rootDir!, 'tsconfig.json'),
|
78 | 86 | extensions: {
|
79 | 87 | vue: true
|
80 | 88 | }
|
81 | 89 | },
|
82 |
| - logger: consola.withScope('nuxt:typescript') |
| 90 | + logger: { |
| 91 | + issues: loggerInterface |
| 92 | + } |
83 | 93 | } as TsCheckerOptions)))
|
84 | 94 | }
|
85 | 95 | })
|
|
0 commit comments