Skip to content

Remove nonNullUnknownType #57665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1966,7 +1966,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
var nonInferrableAnyType = createIntrinsicType(TypeFlags.Any, "any", ObjectFlags.ContainsWideningType, "non-inferrable");
var intrinsicMarkerType = createIntrinsicType(TypeFlags.Any, "intrinsic");
var unknownType = createIntrinsicType(TypeFlags.Unknown, "unknown");
var nonNullUnknownType = createIntrinsicType(TypeFlags.Unknown, "unknown", /*objectFlags*/ undefined, "non-null");
var undefinedType = createIntrinsicType(TypeFlags.Undefined, "undefined");
var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(TypeFlags.Undefined, "undefined", ObjectFlags.ContainsWideningType, "widening");
var missingType = createIntrinsicType(TypeFlags.Undefined, "undefined", /*objectFlags*/ undefined, "missing");
Expand Down Expand Up @@ -17262,7 +17261,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (includes & TypeFlags.AnyOrUnknown) {
return includes & TypeFlags.Any ?
includes & TypeFlags.IncludesWildcard ? wildcardType : anyType :
includes & TypeFlags.Null || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType;
unknownType;
}
if (includes & TypeFlags.Undefined) {
// If type set contains both undefinedType and missingType, remove missingType
Expand Down Expand Up @@ -27705,8 +27704,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === SyntaxKind.NonNullExpression && !(resultType.flags & TypeFlags.Never) && getTypeWithFacts(resultType, TypeFacts.NEUndefinedOrNull).flags & TypeFlags.Never) {
return declaredType;
}
// The non-null unknown type should never escape control flow analysis.
return resultType === nonNullUnknownType ? unknownType : resultType;
return resultType;

function getOrSetCacheKey() {
if (isKeySet) {
Expand Down