Skip to content

Commit 5be20eb

Browse files
authoredNov 20, 2024··
Merge pull request #2792 from nestjs/fix/type-check-error-2791
fix: show type check warning only when builder is not swc
2 parents 6d77fd3 + 2e23003 commit 5be20eb

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed
 

Diff for: ‎actions/build.action.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { join } from 'path';
33
import * as ts from 'typescript';
44
import { Input } from '../commands';
55
import { AssetsManager } from '../lib/compiler/assets-manager';
6+
import { deleteOutDirIfEnabled } from '../lib/compiler/helpers/delete-out-dir';
67
import { getBuilder } from '../lib/compiler/helpers/get-builder';
78
import { getTscConfigPath } from '../lib/compiler/helpers/get-tsc-config.path';
89
import { getValueOrDefault } from '../lib/compiler/helpers/get-value-or-default';
910
import { getWebpackConfigPath } from '../lib/compiler/helpers/get-webpack-config-path';
1011
import { TsConfigProvider } from '../lib/compiler/helpers/tsconfig-provider';
1112
import { PluginsLoader } from '../lib/compiler/plugins/plugins-loader';
1213
import { TypeScriptBinaryLoader } from '../lib/compiler/typescript-loader';
13-
import { deleteOutDirIfEnabled } from '../lib/compiler/helpers/delete-out-dir';
1414
import {
1515
Configuration,
1616
ConfigurationLoader,
@@ -21,7 +21,7 @@ import {
2121
defaultWebpackConfigFilename,
2222
} from '../lib/configuration/defaults';
2323
import { FileSystemReader } from '../lib/readers';
24-
import { ERROR_PREFIX } from '../lib/ui';
24+
import { ERROR_PREFIX, INFO_PREFIX } from '../lib/ui';
2525
import { isModuleAvailable } from '../lib/utils/is-module-available';
2626
import { AbstractAction } from './abstract.action';
2727
import webpack = require('webpack');
@@ -109,6 +109,20 @@ export class BuildAction extends AbstractAction {
109109
watchAssetsMode,
110110
);
111111

112+
const typeCheck = getValueOrDefault<boolean>(
113+
configuration,
114+
'compilerOptions.typeCheck',
115+
appName,
116+
'typeCheck',
117+
commandOptions,
118+
);
119+
if (typeCheck && builder.type !== 'swc') {
120+
console.warn(
121+
INFO_PREFIX +
122+
` "typeCheck" will not have any effect when "builder" is not "swc".`,
123+
);
124+
}
125+
112126
switch (builder.type) {
113127
case 'tsc':
114128
return this.runTsc(

Diff for: ‎commands/build.command.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Command, CommanderStatic } from 'commander';
2-
import { ERROR_PREFIX, INFO_PREFIX } from '../lib/ui';
2+
import { ERROR_PREFIX } from '../lib/ui';
33
import { AbstractCommand } from './abstract.command';
44
import { Input } from './command.input';
55

@@ -60,12 +60,6 @@ export class BuildCommand extends AbstractCommand {
6060
value: command.builder,
6161
});
6262

63-
if (command.typeCheck && command.builder !== 'swc') {
64-
console.warn(
65-
INFO_PREFIX +
66-
` "typeCheck" will not have any effect when "builder" is not "swc".`,
67-
);
68-
}
6963
options.push({
7064
name: 'typeCheck',
7165
value: command.typeCheck,

Diff for: ‎commands/start.command.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Command, CommanderStatic } from 'commander';
2-
import { ERROR_PREFIX, INFO_PREFIX } from '../lib/ui';
2+
import { ERROR_PREFIX } from '../lib/ui';
33
import { getRemainingFlags } from '../lib/utils/remaining-flags';
44
import { AbstractCommand } from './abstract.command';
55
import { Input } from './command.input';
@@ -95,12 +95,6 @@ export class StartCommand extends AbstractCommand {
9595
value: command.builder,
9696
});
9797

98-
if (command.typeCheck && command.builder !== 'swc') {
99-
console.warn(
100-
INFO_PREFIX +
101-
` "typeCheck" will not have any effect when "builder" is not "swc".`,
102-
);
103-
}
10498
options.push({
10599
name: 'typeCheck',
106100
value: command.typeCheck,

0 commit comments

Comments
 (0)
Please sign in to comment.