Skip to content

Commit b0042a7

Browse files
authoredMar 29, 2024
Actually have a chance to reuse optional property signatures in the node builder (microsoft#57995)
1 parent 278b4f9 commit b0042a7

File tree

71 files changed

+335
-335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+335
-335
lines changed
 

‎src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8551,7 +8551,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
85518551
if (typeFromTypeNode === type) {
85528552
return true;
85538553
}
8554-
if (annotatedDeclaration && (isParameter(annotatedDeclaration) || isPropertyDeclaration(annotatedDeclaration)) && annotatedDeclaration.questionToken) {
8554+
if (annotatedDeclaration && (isParameter(annotatedDeclaration) || isPropertySignature(annotatedDeclaration) || isPropertyDeclaration(annotatedDeclaration)) && annotatedDeclaration.questionToken) {
85558555
return getTypeWithFacts(type, TypeFacts.NEUndefined) === typeFromTypeNode;
85568556
}
85578557
return false;

‎tests/baselines/reference/avoidNarrowingUsingConstVariableFromBindingElementWithLiteralInitializer.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ declare const foo: ["a", string, number] | ["b", string, boolean];
88
export function test(arg: { index?: number }) {
99
>test : (arg: { index?: number; }) => void
1010
> : ^^^^^^ ^^^^^^^^^
11-
>arg : { index?: number | undefined; }
12-
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11+
>arg : { index?: number; }
12+
> : ^^^^^^^^^^ ^^^
1313
>index : number | undefined
1414
> : ^^^^^^^^^^^^^^^^^^
1515

0 commit comments

Comments
 (0)