Skip to content

Commit

Permalink
Merge pull request #2792 from nestjs/fix/type-check-error-2791
Browse files Browse the repository at this point in the history
fix: show type check warning only when builder is not swc
  • Loading branch information
kamilmysliwiec authored Nov 20, 2024
2 parents 6d77fd3 + 2e23003 commit 5be20eb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
18 changes: 16 additions & 2 deletions actions/build.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ 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';
import { getWebpackConfigPath } from '../lib/compiler/helpers/get-webpack-config-path';
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,
Expand All @@ -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');
Expand Down Expand Up @@ -109,6 +109,20 @@ export class BuildAction extends AbstractAction {
watchAssetsMode,
);

const typeCheck = getValueOrDefault<boolean>(
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(
Expand Down
8 changes: 1 addition & 7 deletions commands/build.command.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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,
Expand Down
8 changes: 1 addition & 7 deletions commands/start.command.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5be20eb

Please sign in to comment.