From 2e23003b6b87f520b0d72f616f12f62d585b3f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20My=C5=9Bliwiec?= Date: Wed, 6 Nov 2024 10:57:52 +0100 Subject: [PATCH] fix: show type check warning only when builder is not swc #2791 --- actions/build.action.ts | 18 ++++++++++++++++-- commands/build.command.ts | 8 +------- commands/start.command.ts | 8 +------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/actions/build.action.ts b/actions/build.action.ts index bfb4eb600..45b1ce76a 100644 --- a/actions/build.action.ts +++ b/actions/build.action.ts @@ -3,6 +3,7 @@ import { join } from 'path'; import * as ts from 'typescript'; import { Input } from '../commands'; import { AssetsManager } from '../lib/compiler/assets-manager'; +import { deleteOutDirIfEnabled } from '../lib/compiler/helpers/delete-out-dir'; import { getBuilder } from '../lib/compiler/helpers/get-builder'; import { getTscConfigPath } from '../lib/compiler/helpers/get-tsc-config.path'; import { getValueOrDefault } from '../lib/compiler/helpers/get-value-or-default'; @@ -10,7 +11,6 @@ import { getWebpackConfigPath } from '../lib/compiler/helpers/get-webpack-config import { TsConfigProvider } from '../lib/compiler/helpers/tsconfig-provider'; import { PluginsLoader } from '../lib/compiler/plugins/plugins-loader'; import { TypeScriptBinaryLoader } from '../lib/compiler/typescript-loader'; -import { deleteOutDirIfEnabled } from '../lib/compiler/helpers/delete-out-dir'; import { Configuration, ConfigurationLoader, @@ -21,7 +21,7 @@ import { defaultWebpackConfigFilename, } from '../lib/configuration/defaults'; import { FileSystemReader } from '../lib/readers'; -import { ERROR_PREFIX } from '../lib/ui'; +import { ERROR_PREFIX, INFO_PREFIX } from '../lib/ui'; import { isModuleAvailable } from '../lib/utils/is-module-available'; import { AbstractAction } from './abstract.action'; import webpack = require('webpack'); @@ -109,6 +109,20 @@ export class BuildAction extends AbstractAction { watchAssetsMode, ); + const typeCheck = getValueOrDefault( + configuration, + 'compilerOptions.typeCheck', + appName, + 'typeCheck', + commandOptions, + ); + if (typeCheck && builder.type !== 'swc') { + console.warn( + INFO_PREFIX + + ` "typeCheck" will not have any effect when "builder" is not "swc".`, + ); + } + switch (builder.type) { case 'tsc': return this.runTsc( diff --git a/commands/build.command.ts b/commands/build.command.ts index 1e3f03f18..ce075cb8c 100644 --- a/commands/build.command.ts +++ b/commands/build.command.ts @@ -1,5 +1,5 @@ import { Command, CommanderStatic } from 'commander'; -import { ERROR_PREFIX, INFO_PREFIX } from '../lib/ui'; +import { ERROR_PREFIX } from '../lib/ui'; import { AbstractCommand } from './abstract.command'; import { Input } from './command.input'; @@ -60,12 +60,6 @@ export class BuildCommand extends AbstractCommand { value: command.builder, }); - if (command.typeCheck && command.builder !== 'swc') { - console.warn( - INFO_PREFIX + - ` "typeCheck" will not have any effect when "builder" is not "swc".`, - ); - } options.push({ name: 'typeCheck', value: command.typeCheck, diff --git a/commands/start.command.ts b/commands/start.command.ts index 361f48fbd..e1b3aaa09 100644 --- a/commands/start.command.ts +++ b/commands/start.command.ts @@ -1,5 +1,5 @@ import { Command, CommanderStatic } from 'commander'; -import { ERROR_PREFIX, INFO_PREFIX } from '../lib/ui'; +import { ERROR_PREFIX } from '../lib/ui'; import { getRemainingFlags } from '../lib/utils/remaining-flags'; import { AbstractCommand } from './abstract.command'; import { Input } from './command.input'; @@ -95,12 +95,6 @@ export class StartCommand extends AbstractCommand { value: command.builder, }); - if (command.typeCheck && command.builder !== 'swc') { - console.warn( - INFO_PREFIX + - ` "typeCheck" will not have any effect when "builder" is not "swc".`, - ); - } options.push({ name: 'typeCheck', value: command.typeCheck,