Skip to content

Commit 76a05ae

Browse files
author
William Luke
authored
fix(sdk): throw on unsupported ts version (#7843)
1 parent 82c0b56 commit 76a05ae

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

src/packages/sdk/src/predefinedGeneratorResolvers.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,25 +165,26 @@ function checkYarnVersion() {
165165
*/
166166
function checkTypeScriptVersion() {
167167
const minVersion = '4.1.0'
168+
let output
168169
try {
169-
const output = execa.sync('tsc', ['-v'], {
170+
output = execa.sync('tsc', ['-v'], {
170171
preferLocal: true,
171172
})
172-
if (output.stdout) {
173-
const currentVersion = output.stdout.split(' ')[1]
174-
if (semverLt(currentVersion, minVersion)) {
175-
throw new Error(
176-
`Your ${chalk.bold(
177-
'typescript',
178-
)} version is ${currentVersion}, which is outdated. Please update it to ${chalk.bold(
179-
minVersion,
180-
)} or ${chalk.bold('newer')} in order to use Prisma Client.`,
181-
)
182-
}
183-
}
184173
} catch (e) {
185174
// They do not have TS installed, we ignore (example: JS project)
186175
}
176+
if (output?.stdout) {
177+
const currentVersion = output.stdout.split(' ')[1]
178+
if (semverLt(currentVersion, minVersion)) {
179+
throw new Error(
180+
`Your ${chalk.bold(
181+
'typescript',
182+
)} version is ${currentVersion}, which is outdated. Please update it to ${chalk.bold(
183+
minVersion,
184+
)} or ${chalk.bold('newer')} in order to use Prisma Client.`,
185+
)
186+
}
187+
}
187188
}
188189
/**
189190
* Returns true, if semver version `a` is lower than `b`

0 commit comments

Comments
 (0)