Skip to content

Commit e8e7e88

Browse files
Merge pull request #30094 from Kingwl/improve_completions_for_optional_props
check completions with assignable rather than identity
2 parents 2888510 + 4d7ec38 commit e8e7e88

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7406,7 +7406,7 @@ namespace ts {
74067406
const nameType = property.name && getLiteralTypeFromPropertyName(property.name);
74077407
const name = nameType && isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
74087408
const expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name);
7409-
return !!expected && isLiteralType(expected) && !isTypeIdenticalTo(getTypeOfNode(property), expected);
7409+
return !!expected && isLiteralType(expected) && !isTypeAssignableTo(getTypeOfNode(property), expected);
74107410
});
74117411
}
74127412

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference path="fourslash.ts" />
2+
// @strict: true
3+
4+
//// interface Options {
5+
//// hello?: boolean;
6+
//// world?: boolean;
7+
//// }
8+
//// declare function foo(options?: Options): void;
9+
//// foo({
10+
//// hello: true,
11+
//// /**/
12+
//// });
13+
14+
verify.completions({
15+
marker: "",
16+
includes: ['world']
17+
});
18+

0 commit comments

Comments
 (0)