TypeStrong/fork-ts-checker-webpack-plugin

TypeError: config.logger.log is not a function

TrueXPixells opened this issue · 3 comments

Current behavior

i have a webpack react project trying to compile successfully

Expected behavior

but i get this;
D:\ProjectsN\JS\Source\Programs\discord\frontend\node_modules\fork-ts-checker-webpack-plugin\lib\hooks\tap-done-to-async-get-issues.js:67
config.logger.log(chalk_1.default.green('No errors found.'));
^

TypeError: config.logger.log is not a function
at D:\ProjectsN\JS\Source\Programs\discord\frontend\node_modules\fork-ts-checker-webpack-plugin\lib\hooks\tap-done-to-async-get-issues.js:67:27
at Generator.next ()
at fulfilled (D:\ProjectsN\JS\Source\Programs\discord\frontend\node_modules\fork-ts-checker-webpack-plugin\lib\hooks\tap-done-to-async-get-issues.js:5:58)

Node.js v20.3.0

Steps to reproduce the issue

Runs webpack serve --node-env development

Issue reproduction repository

config file;

            new ForkTsCheckerWebpackPlugin({
                typescript: {
                    configOverwrite: {
                        compilerOptions: {
                            sourceMap: isEnvDevelopment,
                            inlineSourceMap: false,
                            declarationMap: false,
                            noEmit: true,
                            incremental: true,
                            tsBuildInfoFile: "./node_modules/.cache/tsconfig.tsbuildinfo",
                        },
                    },
                    diagnosticOptions: {
                        syntactic: true,
                    },
                    mode: 'write-references',
                },
                issue: {
                    include: [
                        { file: '../**/src/**/*.{ts,tsx}' },
                        { file: '**/src/**/*.{ts,tsx}' },
                    ],
                    exclude: [
                        { file: '**/src/**/__tests__/**' },
                        { file: '**/src/**/?(*.){spec|test}.*' },
                        { file: '**/src/setupProxy.*' },
                        { file: '**/src/setupTests.*' },
                    ],
                },
                logger: {
                    infrastructure: 'silent',
                },
            }),
        ].filter(Boolean),

Environment

  • fork-ts-checker-webpack-plugin: 8.0.0
  • typescript: 5.1.3
  • eslint: 8.43.0
  • webpack: 5.87.0
  • os: Windows 11

Possible same as #814

Change:

logger: {
    infrastructure: 'silent',
},

to:

logger: {
    log: (message) => console.log(message),
    error: (message) => console.error(message),
},

Or for people that are are using create-react-app, create a fork-ts-checker.config.js in root folder and populate with:

module.exports = {
  logger: {
    log: (message) => console.log(message),
    error: (message) => console.error(message),
  },
};

You don't have to provide logger at all - it will use console object by default. It looks like an issue after upgrade, where we made a breaking change to logger config. You can see in README.md that now it can be either an object that implements log and error methods or 'webpack-infrastructure' string if you want to use webpack infrastructure logger instead :)