Skip to content

Commit 2d66517

Browse files
authored
fix quickinfo of narrowed private filed (microsoft#43356)
* fix quickinfo of narrowed private filed * add test case. * adapt review.
1 parent a7a010a commit 2d66517

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23733,7 +23733,7 @@ namespace ts {
2373323733
// an dotted name expression, and if the location is not an assignment target, obtain the type
2373423734
// of the expression (which will reflect control flow analysis). If the expression indeed
2373523735
// resolved to the given symbol, return the narrowed type.
23736-
if (location.kind === SyntaxKind.Identifier) {
23736+
if (location.kind === SyntaxKind.Identifier || location.kind === SyntaxKind.PrivateIdentifier) {
2373723737
if (isRightSideOfQualifiedNameOrPropertyAccess(location)) {
2373823738
location = location.parent;
2373923739
}

tests/cases/fourslash/quickInfoOnNarrowedType.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,26 @@
1818
//// /*6*/s;
1919
////}
2020

21+
////class Foo {
22+
//// #privateProperty: string[] | null;
23+
//// constructor() {
24+
//// this.#privateProperty = null;
25+
//// }
26+
//// testMethod() {
27+
//// if (this.#privateProperty === null)
28+
//// return;
29+
//// this./*7*/#privateProperty;
30+
//// }
31+
////}
32+
2133
verify.quickInfos({
2234
1: "(parameter) strOrNum: string | number",
2335
2: "(parameter) strOrNum: number",
2436
3: "(parameter) strOrNum: string",
2537
4: "let s: string | undefined",
2638
5: "let s: string | undefined",
2739
6: "let s: string",
40+
7: "(property) Foo.#privateProperty: string[]"
2841
});
2942

3043
verify.completions(
@@ -33,4 +46,5 @@ verify.completions(
3346
{ marker: "3", includes: { name: "strOrNum", text: "(parameter) strOrNum: string" } },
3447
{ marker: ["4", "5"], includes: { name: "s", text: "let s: string | undefined" } },
3548
{ marker: "6", includes: { name: "s", text: "let s: string" } },
49+
{ marker: "7", includes: { name: "#privateProperty", text: "(property) Foo.#privateProperty: string[]" } }
3650
);

0 commit comments

Comments
 (0)