Skip to content

In getSymbolAtLocation, return undefined instead of unknownSymbol #21774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
2 commits merged into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24624,7 +24624,8 @@ namespace ts {

if (entityName.kind === SyntaxKind.Identifier) {
if (isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) {
return getIntrinsicTagSymbol(<JsxOpeningLikeElement>entityName.parent);
const symbol = getIntrinsicTagSymbol(<JsxOpeningLikeElement>entityName.parent);
return symbol === unknownSymbol ? undefined : symbol;
}

return resolveEntityName(entityName, SymbolFlags.Value, /*ignoreErrors*/ false, /*dontResolveAlias*/ true);
Expand Down
5 changes: 2 additions & 3 deletions src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -923,9 +923,8 @@ namespace ts.Completions {
}
else if (isStartingCloseTag) {
const tagName = (<JsxElement>contextToken.parent.parent).openingElement.tagName;
const tagSymbol = Debug.assertDefined(typeChecker.getSymbolAtLocation(tagName));

if (!typeChecker.isUnknownSymbol(tagSymbol)) {
const tagSymbol = typeChecker.getSymbolAtLocation(tagName);
if (tagSymbol) {
symbols = [tagSymbol];
}
completionKind = CompletionKind.MemberLike;
Expand Down
1 change: 0 additions & 1 deletion tests/baselines/reference/conflictMarkerTrivia3.symbols
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
=== tests/cases/compiler/conflictMarkerTrivia3.tsx ===
const x = <div>
>x : Symbol(x, Decl(conflictMarkerTrivia3.tsx, 0, 5))
>div : Symbol(unknown)

<<<<<<< HEAD
2 changes: 0 additions & 2 deletions tests/baselines/reference/es3-jsx-preserve.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ const React: any = null;

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


2 changes: 0 additions & 2 deletions tests/baselines/reference/es3-jsx-react-native.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ const React: any = null;

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


2 changes: 0 additions & 2 deletions tests/baselines/reference/es3-jsx-react.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ const React: any = null;

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


2 changes: 0 additions & 2 deletions tests/baselines/reference/importHelpersInTsx.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ declare var o: any;

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

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

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

=== tests/cases/compiler/tslib.d.ts ===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
0 as number;
var v = <string>undefined;
>v : Symbol(v, Decl(a.js, 1, 3))
>string : Symbol(unknown)

30 changes: 0 additions & 30 deletions tests/baselines/reference/jsxAndTypeAssertion.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,23 @@ var x: any;

x = <any> { test: <any></any> };
>x : Symbol(x, Decl(jsxAndTypeAssertion.tsx, 4, 3))
>any : Symbol(unknown)
>any : Symbol(unknown)
>any : Symbol(unknown)

x = <any><any></any>;
>any : Symbol(unknown)
>any : Symbol(unknown)
>any : Symbol(unknown)

x = <foo>hello {<foo>{}} </foo>;
>foo : Symbol(unknown)
>foo : Symbol(unknown)
>foo : Symbol(unknown)

x = <foo test={<foo>{}}>hello</foo>;
>foo : Symbol(unknown)
>test : Symbol(test, Decl(jsxAndTypeAssertion.tsx, 11, 8))
>foo : Symbol(unknown)
>foo : Symbol(unknown)

x = <foo test={<foo>{}}>hello{<foo>{}}</foo>;
>foo : Symbol(unknown)
>test : Symbol(test, Decl(jsxAndTypeAssertion.tsx, 13, 8))
>foo : Symbol(unknown)
>foo : Symbol(unknown)
>foo : Symbol(unknown)

x = <foo>x</foo>, x = <foo/>;
>foo : Symbol(unknown)
>foo : Symbol(unknown)
>foo : Symbol(unknown)

<foo>{<foo><foo>{/foo/.test(x) ? <foo><foo></foo> : <foo><foo></foo>}</foo>}</foo>
>foo : Symbol(unknown)
>foo : Symbol(unknown)
>foo : Symbol(unknown)
>/foo/.test : Symbol(RegExp.test, Decl(lib.d.ts, --, --))
>test : Symbol(RegExp.test, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(jsxAndTypeAssertion.tsx, 4, 3))
>foo : Symbol(unknown)
>foo : Symbol(unknown)
>foo : Symbol(unknown)
>foo : Symbol(unknown)
>foo : Symbol(unknown)
>foo : Symbol(unknown)
>foo : Symbol(unknown)
>foo : Symbol(unknown)



Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ declare var React: any;
>React : Symbol(React, Decl(jsxEmitAttributeWithPreserve.tsx, 0, 11))

<foo data/>
>foo : Symbol(unknown)
>data : Symbol(data, Decl(jsxEmitAttributeWithPreserve.tsx, 1, 4))

4 changes: 0 additions & 4 deletions tests/baselines/reference/jsxEmitWithAttributes.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,15 @@ class A {

return [
<meta content="helloworld"></meta>,
>meta : Symbol(unknown)
>content : Symbol(content, Decl(test.tsx, 11, 8))
>meta : Symbol(unknown)

<meta content={c.a!.b}></meta>
>meta : Symbol(unknown)
>content : Symbol(content, Decl(test.tsx, 12, 8))
>c.a!.b : Symbol(b, Decl(test.tsx, 3, 6))
>c.a : Symbol(a, Decl(test.tsx, 2, 8))
>c : Symbol(c, Decl(test.tsx, 2, 3))
>a : Symbol(a, Decl(test.tsx, 2, 8))
>b : Symbol(b, Decl(test.tsx, 3, 6))
>meta : Symbol(unknown)

];
}
Expand Down
27 changes: 0 additions & 27 deletions tests/baselines/reference/jsxEsprimaFbTestSuite.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ declare var props;
>props : Symbol(props, Decl(jsxEsprimaFbTestSuite.tsx, 6, 11))

<a />;
>a : Symbol(unknown)

//<n:a n:v />; Namespace unsuported

//<a n:foo="bar"> {value} <b><c /></b></a>; Namespace unsuported

<a b={" "} c=" " d="&amp;" e="id=1&group=2" f="&#123456789" g="&#123*;" h="&#x;" />;
>a : Symbol(unknown)
>b : Symbol(b, Decl(jsxEsprimaFbTestSuite.tsx, 14, 2))
>c : Symbol(c, Decl(jsxEsprimaFbTestSuite.tsx, 14, 10))
>d : Symbol(d, Decl(jsxEsprimaFbTestSuite.tsx, 14, 16))
Expand All @@ -38,12 +36,9 @@ declare var props;
>h : Symbol(h, Decl(jsxEsprimaFbTestSuite.tsx, 14, 71))

<a b="&notanentity;" />;
>a : Symbol(unknown)
>b : Symbol(b, Decl(jsxEsprimaFbTestSuite.tsx, 16, 2))

<a
>a : Symbol(unknown)

/>;

<日本語></日本語>;
Expand All @@ -62,36 +57,21 @@ baz
>AbC_def : Symbol(AbC_def, Decl(jsxEsprimaFbTestSuite.tsx, 2, 11))

<a b={x ? <c /> : <d />} />;
>a : Symbol(unknown)
>b : Symbol(b, Decl(jsxEsprimaFbTestSuite.tsx, 28, 2))
>x : Symbol(x, Decl(jsxEsprimaFbTestSuite.tsx, 4, 11))
>c : Symbol(unknown)
>d : Symbol(unknown)

<a>{}</a>;
>a : Symbol(unknown)
>a : Symbol(unknown)

<a>{/* this is a comment */}</a>;
>a : Symbol(unknown)
>a : Symbol(unknown)

<div>@test content</div>;
>div : Symbol(unknown)
>div : Symbol(unknown)

<div><br />7x invalid-js-identifier</div>;
>div : Symbol(unknown)
>br : Symbol(unknown)
>div : Symbol(unknown)

<LeftRight left=<a /> right=<b>monkeys /> gorillas</b> />;
>LeftRight : Symbol(LeftRight, Decl(jsxEsprimaFbTestSuite.tsx, 3, 11))
>left : Symbol(left, Decl(jsxEsprimaFbTestSuite.tsx, 38, 10))
>a : Symbol(unknown)
>right : Symbol(right, Decl(jsxEsprimaFbTestSuite.tsx, 38, 21))
>b : Symbol(unknown)
>b : Symbol(unknown)

<a.b></a.b>;
>a : Symbol(a, Decl(jsxEsprimaFbTestSuite.tsx, 5, 11))
Expand All @@ -102,26 +82,19 @@ baz
>a : Symbol(a, Decl(jsxEsprimaFbTestSuite.tsx, 5, 11))

(<div />) < x;
>div : Symbol(unknown)
>x : Symbol(x, Decl(jsxEsprimaFbTestSuite.tsx, 4, 11))

<div {...props} />;
>div : Symbol(unknown)
>props : Symbol(props, Decl(jsxEsprimaFbTestSuite.tsx, 6, 11))

<div {...props} post="attribute" />;
>div : Symbol(unknown)
>props : Symbol(props, Decl(jsxEsprimaFbTestSuite.tsx, 6, 11))
>post : Symbol(post, Decl(jsxEsprimaFbTestSuite.tsx, 48, 15))

<div pre="leading" pre2="attribute" {...props}></div>;
>div : Symbol(unknown)
>pre : Symbol(pre, Decl(jsxEsprimaFbTestSuite.tsx, 50, 4))
>pre2 : Symbol(pre2, Decl(jsxEsprimaFbTestSuite.tsx, 50, 18))
>props : Symbol(props, Decl(jsxEsprimaFbTestSuite.tsx, 6, 11))
>div : Symbol(unknown)

<a> </a>;
>a : Symbol(unknown)
>a : Symbol(unknown)

7 changes: 0 additions & 7 deletions tests/baselines/reference/jsxFactoryAndFragment.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,3 @@ declare var h: any;

<></>;
<><span>1</span><><span>2.1</span><span>2.2</span></></>;
>span : Symbol(unknown)
>span : Symbol(unknown)
>span : Symbol(unknown)
>span : Symbol(unknown)
>span : Symbol(unknown)
>span : Symbol(unknown)

4 changes: 0 additions & 4 deletions tests/baselines/reference/jsxFactoryAndReactNamespace.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,15 @@ class A {

return [
<meta content="helloworld"></meta>,
>meta : Symbol(unknown)
>content : Symbol(content, Decl(test.tsx, 11, 8))
>meta : Symbol(unknown)

<meta content={c.a!.b}></meta>
>meta : Symbol(unknown)
>content : Symbol(content, Decl(test.tsx, 12, 8))
>c.a!.b : Symbol(b, Decl(test.tsx, 3, 6))
>c.a : Symbol(a, Decl(test.tsx, 2, 8))
>c : Symbol(c, Decl(test.tsx, 2, 3))
>a : Symbol(a, Decl(test.tsx, 2, 8))
>b : Symbol(b, Decl(test.tsx, 3, 6))
>meta : Symbol(unknown)

];
}
Expand Down
4 changes: 0 additions & 4 deletions tests/baselines/reference/jsxFactoryIdentifier.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,15 @@ class A {

return [
<meta content="helloworld"></meta>,
>meta : Symbol(unknown)
>content : Symbol(content, Decl(test.tsx, 11, 8))
>meta : Symbol(unknown)

<meta content={c.a!.b}></meta>
>meta : Symbol(unknown)
>content : Symbol(content, Decl(test.tsx, 12, 8))
>c.a!.b : Symbol(b, Decl(test.tsx, 3, 6))
>c.a : Symbol(a, Decl(test.tsx, 2, 8))
>c : Symbol(c, Decl(test.tsx, 2, 3))
>a : Symbol(a, Decl(test.tsx, 2, 8))
>b : Symbol(b, Decl(test.tsx, 3, 6))
>meta : Symbol(unknown)

];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export class AppComponent {
>createElement : Symbol(createElement, Decl(test.tsx, 7, 11))

return <div />;
>div : Symbol(unknown)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class AppComponent {
>render : Symbol(AppComponent.render, Decl(test.tsx, 6, 27))

return <div />;
>div : Symbol(unknown)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,15 @@ class A {

return [
<meta content="helloworld"></meta>,
>meta : Symbol(unknown)
>content : Symbol(content, Decl(test.tsx, 11, 8))
>meta : Symbol(unknown)

<meta content={c.a!.b}></meta>
>meta : Symbol(unknown)
>content : Symbol(content, Decl(test.tsx, 12, 8))
>c.a!.b : Symbol(b, Decl(test.tsx, 3, 6))
>c.a : Symbol(a, Decl(test.tsx, 2, 8))
>c : Symbol(c, Decl(test.tsx, 2, 3))
>a : Symbol(a, Decl(test.tsx, 2, 8))
>b : Symbol(b, Decl(test.tsx, 3, 6))
>meta : Symbol(unknown)

];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,15 @@ class A {

return [
<meta content="helloworld"></meta>,
>meta : Symbol(unknown)
>content : Symbol(content, Decl(test.tsx, 11, 8))
>meta : Symbol(unknown)

<meta content={c.a!.b}></meta>
>meta : Symbol(unknown)
>content : Symbol(content, Decl(test.tsx, 12, 8))
>c.a!.b : Symbol(b, Decl(test.tsx, 3, 6))
>c.a : Symbol(a, Decl(test.tsx, 2, 8))
>c : Symbol(c, Decl(test.tsx, 2, 3))
>a : Symbol(a, Decl(test.tsx, 2, 8))
>b : Symbol(b, Decl(test.tsx, 3, 6))
>meta : Symbol(unknown)

];
}
Expand Down
4 changes: 0 additions & 4 deletions tests/baselines/reference/jsxFactoryQualifiedName.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,15 @@ class A {

return [
<meta content="helloworld"></meta>,
>meta : Symbol(unknown)
>content : Symbol(content, Decl(test.tsx, 11, 8))
>meta : Symbol(unknown)

<meta content={c.a!.b}></meta>
>meta : Symbol(unknown)
>content : Symbol(content, Decl(test.tsx, 12, 8))
>c.a!.b : Symbol(b, Decl(test.tsx, 3, 6))
>c.a : Symbol(a, Decl(test.tsx, 2, 8))
>c : Symbol(c, Decl(test.tsx, 2, 3))
>a : Symbol(a, Decl(test.tsx, 2, 8))
>b : Symbol(b, Decl(test.tsx, 3, 6))
>meta : Symbol(unknown)

];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ export class AppComponent {
>createElement : Symbol(createElement, Decl(test.tsx, 7, 11))

return <div />;
>div : Symbol(unknown)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@ class Component {
>renderCallback : Symbol(Component.renderCallback, Decl(index.tsx, 5, 17))

return <div>test</div>;
>div : Symbol(unknown)
>div : Symbol(unknown)
}
};
Loading