File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -9130,7 +9130,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
91309130 return false;
91319131 }
91329132 if ((isPropertySignature(annotatedDeclaration) || isPropertyDeclaration(annotatedDeclaration)) && annotatedDeclaration.questionToken) {
9133- return getTypeWithFacts(type, TypeFacts.NEUndefined) === typeFromTypeNode;
9133+ // When `exactOptionalPropertyTypes` is enabled we interpret optional properties as written,
9134+ // so reusing the existing annotation even if it doesn't include `undefined` is fine.
9135+ // When it's disabled, optional properties implicitly include `undefined`, so the annotation
9136+ // without `| undefined` must *not* be treated as equivalent.
9137+ return exactOptionalPropertyTypes ? getTypeWithFacts(type, TypeFacts.NEUndefined) === typeFromTypeNode : false;
91349138 }
91359139 if (isParameter(annotatedDeclaration) && hasEffectiveQuestionToken(annotatedDeclaration)) {
91369140 return getTypeWithFacts(type, TypeFacts.NEUndefined) === typeFromTypeNode;
Original file line number Diff line number Diff line change 1+ /// <reference path='fourslash.ts' />
2+ //
3+ // Regression test for GH#63276: "Missing undefined for hover".
4+ //
5+ // @strict : true
6+ // @exactOptionalPropertyTypes : false
7+
8+ //// type X/*1*/ = {
9+ //// a?: A;
10+ //// b?: A;
11+ //// c?: A;
12+ //// };
13+ ////
14+ //// type A = {};
15+
16+ verify . quickInfoAt ( "1" , `type X = {
17+ a?: A | undefined;
18+ b?: A | undefined;
19+ c?: A | undefined;
20+ }` ) ;
21+
You can’t perform that action at this time.
0 commit comments