Skip to content

Commit e2178ec

Browse files
author
Andy
authored
In getSymbolAtLocation, return undefined instead of unknownSymbol (microsoft#21774)
* In getSymbolAtLocation, return undefined instead of unknownSymbol * Update check in completions to look for undefined instead of unknownSymbol
1 parent 16f3b93 commit e2178ec

60 files changed

Lines changed: 37 additions & 372 deletions

File tree

Some content is hidden

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

src/compiler/checker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24628,7 +24628,8 @@ namespace ts {
2462824628

2462924629
if (entityName.kind === SyntaxKind.Identifier) {
2463024630
if (isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) {
24631-
return getIntrinsicTagSymbol(<JsxOpeningLikeElement>entityName.parent);
24631+
const symbol = getIntrinsicTagSymbol(<JsxOpeningLikeElement>entityName.parent);
24632+
return symbol === unknownSymbol ? undefined : symbol;
2463224633
}
2463324634

2463424635
return resolveEntityName(entityName, SymbolFlags.Value, /*ignoreErrors*/ false, /*dontResolveAlias*/ true);

src/services/completions.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -923,9 +923,8 @@ namespace ts.Completions {
923923
}
924924
else if (isStartingCloseTag) {
925925
const tagName = (<JsxElement>contextToken.parent.parent).openingElement.tagName;
926-
const tagSymbol = Debug.assertDefined(typeChecker.getSymbolAtLocation(tagName));
927-
928-
if (!typeChecker.isUnknownSymbol(tagSymbol)) {
926+
const tagSymbol = typeChecker.getSymbolAtLocation(tagName);
927+
if (tagSymbol) {
929928
symbols = [tagSymbol];
930929
}
931930
completionKind = CompletionKind.MemberLike;
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
=== tests/cases/compiler/conflictMarkerTrivia3.tsx ===
22
const x = <div>
33
>x : Symbol(x, Decl(conflictMarkerTrivia3.tsx, 0, 5))
4-
>div : Symbol(unknown)
54

65
<<<<<<< HEAD

tests/baselines/reference/es3-jsx-preserve.symbols

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ const React: any = null;
44

55
const elem = <div></div>;
66
>elem : Symbol(elem, Decl(es3-jsx-preserve.tsx, 2, 5))
7-
>div : Symbol(unknown)
8-
>div : Symbol(unknown)
97

108

tests/baselines/reference/es3-jsx-react-native.symbols

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ const React: any = null;
44

55
const elem = <div></div>;
66
>elem : Symbol(elem, Decl(es3-jsx-react-native.tsx, 2, 5))
7-
>div : Symbol(unknown)
8-
>div : Symbol(unknown)
97

108

tests/baselines/reference/es3-jsx-react.symbols

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ const React: any = null;
44

55
const elem = <div></div>;
66
>elem : Symbol(elem, Decl(es3-jsx-react.tsx, 2, 5))
7-
>div : Symbol(unknown)
8-
>div : Symbol(unknown)
97

108

tests/baselines/reference/importHelpersInTsx.symbols

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ declare var o: any;
77

88
export const x = <span {...o} />
99
>x : Symbol(x, Decl(external.tsx, 2, 12))
10-
>span : Symbol(unknown)
1110
>o : Symbol(o, Decl(external.tsx, 1, 11))
1211

1312
=== tests/cases/compiler/script.tsx ===
@@ -19,7 +18,6 @@ declare var o: any;
1918

2019
const x = <span {...o} />
2120
>x : Symbol(x, Decl(script.tsx, 2, 5))
22-
>span : Symbol(unknown)
2321
>o : Symbol(o, Decl(script.tsx, 1, 11))
2422

2523
=== tests/cases/compiler/tslib.d.ts ===

tests/baselines/reference/jsFileCompilationTypeAssertions.symbols

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
0 as number;
33
var v = <string>undefined;
44
>v : Symbol(v, Decl(a.js, 1, 3))
5-
>string : Symbol(unknown)
65

tests/baselines/reference/jsxAndTypeAssertion.symbols

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,23 @@ var x: any;
1010

1111
x = <any> { test: <any></any> };
1212
>x : Symbol(x, Decl(jsxAndTypeAssertion.tsx, 4, 3))
13-
>any : Symbol(unknown)
14-
>any : Symbol(unknown)
15-
>any : Symbol(unknown)
1613

1714
x = <any><any></any>;
18-
>any : Symbol(unknown)
19-
>any : Symbol(unknown)
20-
>any : Symbol(unknown)
2115

2216
x = <foo>hello {<foo>{}} </foo>;
23-
>foo : Symbol(unknown)
24-
>foo : Symbol(unknown)
25-
>foo : Symbol(unknown)
2617

2718
x = <foo test={<foo>{}}>hello</foo>;
28-
>foo : Symbol(unknown)
2919
>test : Symbol(test, Decl(jsxAndTypeAssertion.tsx, 11, 8))
30-
>foo : Symbol(unknown)
31-
>foo : Symbol(unknown)
3220

3321
x = <foo test={<foo>{}}>hello{<foo>{}}</foo>;
34-
>foo : Symbol(unknown)
3522
>test : Symbol(test, Decl(jsxAndTypeAssertion.tsx, 13, 8))
36-
>foo : Symbol(unknown)
37-
>foo : Symbol(unknown)
38-
>foo : Symbol(unknown)
3923

4024
x = <foo>x</foo>, x = <foo/>;
41-
>foo : Symbol(unknown)
42-
>foo : Symbol(unknown)
43-
>foo : Symbol(unknown)
4425

4526
<foo>{<foo><foo>{/foo/.test(x) ? <foo><foo></foo> : <foo><foo></foo>}</foo>}</foo>
46-
>foo : Symbol(unknown)
47-
>foo : Symbol(unknown)
48-
>foo : Symbol(unknown)
4927
>/foo/.test : Symbol(RegExp.test, Decl(lib.d.ts, --, --))
5028
>test : Symbol(RegExp.test, Decl(lib.d.ts, --, --))
5129
>x : Symbol(x, Decl(jsxAndTypeAssertion.tsx, 4, 3))
52-
>foo : Symbol(unknown)
53-
>foo : Symbol(unknown)
54-
>foo : Symbol(unknown)
55-
>foo : Symbol(unknown)
56-
>foo : Symbol(unknown)
57-
>foo : Symbol(unknown)
58-
>foo : Symbol(unknown)
59-
>foo : Symbol(unknown)
6030

6131

6232

tests/baselines/reference/jsxEmitAttributeWithPreserve.symbols

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ declare var React: any;
33
>React : Symbol(React, Decl(jsxEmitAttributeWithPreserve.tsx, 0, 11))
44

55
<foo data/>
6-
>foo : Symbol(unknown)
76
>data : Symbol(data, Decl(jsxEmitAttributeWithPreserve.tsx, 1, 4))
87

0 commit comments

Comments
 (0)