Skip to content

Commit 1f0afee

Browse files
authored
Fix eslint warning forbidden non-null assertion (#324)
1 parent b846e80 commit 1f0afee

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/transforms/v2-to-v3/ts-type/getTypeRefForString.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ export const getTypeRefForString = (
2424
return j.tsTypeReference(j.identifier(v3ClientTypeString));
2525
}
2626

27-
if (v3ClientTypeString.startsWith("Array<")) {
28-
const type = arrayRegex.exec(v3ClientTypeString)![1];
27+
const arrayRegexMatches = arrayRegex.exec(v3ClientTypeString);
28+
if (arrayRegexMatches) {
29+
const type = arrayRegexMatches[1];
2930
const typeArgument = getTypeRefForString(j, v3ClientDefaultLocalName, type);
3031
return j.tsTypeReference.from({
3132
typeName: j.identifier("Array"),
@@ -35,8 +36,9 @@ export const getTypeRefForString = (
3536
});
3637
}
3738

38-
if (v3ClientTypeString.startsWith("Record<")) {
39-
const type = recordRegex.exec(v3ClientTypeString)![1];
39+
const recordRegexMatches = recordRegex.exec(v3ClientTypeString);
40+
if (recordRegexMatches) {
41+
const type = recordRegexMatches[1];
4042
const typeArgument = getTypeRefForString(j, v3ClientDefaultLocalName, type);
4143
return j.tsTypeReference.from({
4244
typeName: j.identifier("Record"),

0 commit comments

Comments
 (0)