Skip to content

Commit 9a18bc0

Browse files
committed
fix(js): recognize tsgo in dependency-checks lint rule (#35048)
## Current Behavior The `@nx/dependency-checks` lint rule detects `tslib` as a required dependency by checking if the build command contains `tsc` (via `/\btsc\b/` regex). When a project uses `tsgo` as its compiler, the build command is `tsgo --build` which doesn't match — causing a false positive "tslib is not used" lint error. ## Expected Behavior The regex also matches `tsgo`, so projects using either `tsc` or `tsgo` correctly detect `tslib` as needed when `importHelpers: true` is set. ## Related Issue(s) N/A — discovered while enabling tsgo for the nx package (cherry picked from commit 1d01a67)
1 parent 51e9b7d commit 9a18bc0

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

packages/js/src/utils/find-npm-dependencies.spec.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,14 @@ describe('findNpmDependencies', () => {
170170
});
171171

172172
it.each`
173-
fileName
174-
${'tsconfig.base.json'}
175-
${'tsconfig.json'}
173+
fileName | command
174+
${'tsconfig.base.json'} | ${'tsc --build tsconfig.lib.json --pretty --verbose'}
175+
${'tsconfig.json'} | ${'tsc --build tsconfig.lib.json --pretty --verbose'}
176+
${'tsconfig.base.json'} | ${'tsgo --build tsconfig.lib.json'}
177+
${'tsconfig.json'} | ${'tsgo --build tsconfig.lib.json'}
176178
`(
177-
'should pick up helper npm dependencies when using tsc and run-commands',
178-
({ fileName }) => {
179+
'should pick up helper npm dependencies when using "$command" and run-commands',
180+
({ fileName, command }) => {
179181
vol.fromJSON(
180182
{
181183
[`./${fileName}`]: JSON.stringify({
@@ -199,7 +201,7 @@ describe('findNpmDependencies', () => {
199201
build: {
200202
executor: 'nx:run-commands',
201203
options: {
202-
command: 'tsc --build tsconfig.lib.json --pretty --verbose',
204+
command,
203205
},
204206
},
205207
},

packages/js/src/utils/find-npm-dependencies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ function collectHelperDependencies(
244244
// For inferred targets or manually added run-commands, check if user is using `tsc` in build target.
245245
if (
246246
target.executor === 'nx:run-commands' &&
247-
/\btsc\b/.test(target.options.command)
247+
/\b(tsc|tsgo)\b/.test(target.options.command)
248248
) {
249249
const tsConfigFileName = getRootTsConfigFileName();
250250
if (tsConfigFileName) {

0 commit comments

Comments
 (0)