Remove getNonNullableType application in checkIdentifier

This commit is contained in:
bgenia 2024-11-17 15:04:30 +03:00
Родитель b3c67d3202
Коммит 46cd4219dd
2 изменённых файлов: 15 добавлений и 2 удалений

Просмотреть файл

@ -30525,8 +30525,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const initialType = isAutomaticTypeInNonNull ? undefinedType :
assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration as VariableLikeDeclaration) : type) :
typeIsAutomatic ? undefinedType : getOptionalType(type);
const flowType = isAutomaticTypeInNonNull ? getNonNullableType(getFlowTypeOfReference(node, type, initialType, flowContainer)) :
getFlowTypeOfReference(node, type, initialType, flowContainer);
const flowType = getFlowTypeOfReference(node, type, initialType, flowContainer);
// A variable is considered uninitialized when it is possible to analyze the entire control flow graph
// from declaration to use, and when the variable's declared type doesn't include undefined but the
// control flow based type does include undefined.

Просмотреть файл

@ -0,0 +1,14 @@
/// <reference path="fourslash.ts" />
// Issue #60514
// @strict: true
//// declare function foo(): number | undefined
//// let x;
//// x = foo();
//// let [|y2|] = [|x|]!;
const [afterAssertion, beforeAssertion] = test.ranges()
verify.typeAtLocation(beforeAssertion, "number | undefined")
verify.typeAtLocation(afterAssertion, "number")