Skip to content

Commit 1fa487e

Browse files
committed
change error to possibly null or undefined
1 parent fca2ca0 commit 1fa487e

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27495,7 +27495,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2749527495

2749627496
// use to determine if a parameter may be undefined or null (or is unknown/unconstrained)
2749727497
function getUnknownIfMaybeUnknown(type: Type) {
27498-
return (strictNullChecks && type.flags & TypeFlags.Instantiable) ? getBaseConstraintOfType(type) || unknownType : type;
27498+
return (strictNullChecks && type.flags & TypeFlags.Instantiable) ? getBaseConstraintOfType(type) || unknownUnionType : type;
2749927499
}
2750027500

2750127501
function getTypeWithDefault(type: Type, defaultExpression: Expression) {

tests/baselines/reference/unconstrainedTypeComparison.errors.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
unconstrainedTypeComparison.ts(2,12): error TS18046: 'a' is of type 'unknown'.
2-
unconstrainedTypeComparison.ts(2,16): error TS18046: 'b' is of type 'unknown'.
1+
unconstrainedTypeComparison.ts(2,12): error TS18049: 'a' is possibly 'null' or 'undefined'.
2+
unconstrainedTypeComparison.ts(2,16): error TS18049: 'b' is possibly 'null' or 'undefined'.
33
unconstrainedTypeComparison.ts(6,12): error TS18049: 'a' is possibly 'null' or 'undefined'.
44
unconstrainedTypeComparison.ts(6,16): error TS18049: 'b' is possibly 'null' or 'undefined'.
55
unconstrainedTypeComparison.ts(10,12): error TS18046: 'a' is of type 'unknown'.
66
unconstrainedTypeComparison.ts(10,16): error TS18046: 'b' is of type 'unknown'.
7-
unconstrainedTypeComparison.ts(14,12): error TS18046: 'a' is of type 'unknown'.
8-
unconstrainedTypeComparison.ts(14,16): error TS18046: 'b' is of type 'unknown'.
7+
unconstrainedTypeComparison.ts(14,12): error TS18049: 'a' is possibly 'null' or 'undefined'.
8+
unconstrainedTypeComparison.ts(14,16): error TS18049: 'b' is possibly 'null' or 'undefined'.
99
unconstrainedTypeComparison.ts(18,12): error TS18049: 'a' is possibly 'null' or 'undefined'.
1010
unconstrainedTypeComparison.ts(18,16): error TS18049: 'b' is possibly 'null' or 'undefined'.
1111
unconstrainedTypeComparison.ts(22,12): error TS18046: 'a' is of type 'unknown'.
@@ -24,9 +24,9 @@ unconstrainedTypeComparison.ts(45,16): error TS18048: 'b' is possibly 'undefined
2424
function f1<T>(a: T, b: T): boolean {
2525
return a > b;
2626
~
27-
!!! error TS18046: 'a' is of type 'unknown'.
27+
!!! error TS18049: 'a' is possibly 'null' or 'undefined'.
2828
~
29-
!!! error TS18046: 'b' is of type 'unknown'.
29+
!!! error TS18049: 'b' is possibly 'null' or 'undefined'.
3030
}
3131

3232
function f2<T extends {} | undefined | null>(a: T, b: T): boolean {
@@ -48,9 +48,9 @@ unconstrainedTypeComparison.ts(45,16): error TS18048: 'b' is possibly 'undefined
4848
function f4<T, U extends T>(a: U, b: U): boolean {
4949
return a > b;
5050
~
51-
!!! error TS18046: 'a' is of type 'unknown'.
51+
!!! error TS18049: 'a' is possibly 'null' or 'undefined'.
5252
~
53-
!!! error TS18046: 'b' is of type 'unknown'.
53+
!!! error TS18049: 'b' is possibly 'null' or 'undefined'.
5454
}
5555

5656
function f5<T extends {} | undefined | null, U extends T>(a: U, b: U): boolean {

0 commit comments

Comments
 (0)