mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Replace missingType with undefinedType in the IndexedAccessTypeNode's type (#52016)
This commit is contained in:
committed by
GitHub
parent
c06711da1b
commit
c9b5f2b022
@@ -17060,8 +17060,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
}
|
||||
const propType = getTypeOfSymbol(prop);
|
||||
return accessExpression && getAssignmentTargetKind(accessExpression) !== AssignmentKind.Definite ?
|
||||
getFlowTypeOfReference(accessExpression, propType) :
|
||||
return accessExpression && getAssignmentTargetKind(accessExpression) !== AssignmentKind.Definite ? getFlowTypeOfReference(accessExpression, propType) :
|
||||
accessNode && isIndexedAccessTypeNode(accessNode) && containsMissingType(propType) ? getUnionType([propType, undefinedType]) :
|
||||
propType;
|
||||
}
|
||||
if (everyType(objectType, isTupleType) && isNumericLiteralName(propName)) {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
=== tests/cases/compiler/typePredicateAcceptingPartialOfRefinedType.ts ===
|
||||
// repro #51953
|
||||
|
||||
interface Test {
|
||||
>Test : Symbol(Test, Decl(typePredicateAcceptingPartialOfRefinedType.ts, 0, 0))
|
||||
|
||||
testy?: string;
|
||||
>testy : Symbol(Test.testy, Decl(typePredicateAcceptingPartialOfRefinedType.ts, 2, 16))
|
||||
}
|
||||
|
||||
interface Options {
|
||||
>Options : Symbol(Options, Decl(typePredicateAcceptingPartialOfRefinedType.ts, 4, 1))
|
||||
|
||||
test: Test['testy'];
|
||||
>test : Symbol(Options.test, Decl(typePredicateAcceptingPartialOfRefinedType.ts, 6, 19))
|
||||
>Test : Symbol(Test, Decl(typePredicateAcceptingPartialOfRefinedType.ts, 0, 0))
|
||||
}
|
||||
|
||||
declare function includesAllRequiredOptions(options: Partial<Options>): options is Options;
|
||||
>includesAllRequiredOptions : Symbol(includesAllRequiredOptions, Decl(typePredicateAcceptingPartialOfRefinedType.ts, 8, 1))
|
||||
>options : Symbol(options, Decl(typePredicateAcceptingPartialOfRefinedType.ts, 10, 44))
|
||||
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
|
||||
>Options : Symbol(Options, Decl(typePredicateAcceptingPartialOfRefinedType.ts, 4, 1))
|
||||
>options : Symbol(options, Decl(typePredicateAcceptingPartialOfRefinedType.ts, 10, 44))
|
||||
>Options : Symbol(Options, Decl(typePredicateAcceptingPartialOfRefinedType.ts, 4, 1))
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/typePredicateAcceptingPartialOfRefinedType.ts ===
|
||||
// repro #51953
|
||||
|
||||
interface Test {
|
||||
testy?: string;
|
||||
>testy : string | undefined
|
||||
}
|
||||
|
||||
interface Options {
|
||||
test: Test['testy'];
|
||||
>test : string | undefined
|
||||
}
|
||||
|
||||
declare function includesAllRequiredOptions(options: Partial<Options>): options is Options;
|
||||
>includesAllRequiredOptions : (options: Partial<Options>) => options is Options
|
||||
>options : Partial<Options>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// @strict: true
|
||||
// @exactOptionalPropertyTypes: true
|
||||
// @noEmit: true
|
||||
|
||||
// repro #51953
|
||||
|
||||
interface Test {
|
||||
testy?: string;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
test: Test['testy'];
|
||||
}
|
||||
|
||||
declare function includesAllRequiredOptions(options: Partial<Options>): options is Options;
|
||||
Reference in New Issue
Block a user