Skip to content

Commit

Permalink
fix(api): use interface symbol as alias
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsdev committed Nov 7, 2022
1 parent 732fe0d commit 4a38b19
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 153 deletions.
3 changes: 2 additions & 1 deletion packages/api/src/tree.ts
Expand Up @@ -108,7 +108,8 @@ function _generateTypeTree(
if (
associatedSymbol &&
!isArrayType(tsCtx, type) &&
!isTupleType(tsCtx, type)
!isTupleType(tsCtx, type) &&
!isInterfaceType(tsCtx, type)
) {
isAnonymousSymbol = associatedSymbol.name === "__type"
symbol = associatedSymbol
Expand Down
95 changes: 5 additions & 90 deletions tests/baselines/reference/class.localized.tree
Expand Up @@ -195,24 +195,7 @@ class TestClass implements TestInterface {
{
"kindText": "interface",
"kind": "interface",
"symbol": {
"name": "TestInterface",
"locations": [
{
"fileName": "cases/class.ts",
"range": {
"start": {
"line": 0,
"character": 10
},
"end": {
"line": 0,
"character": 23
}
}
}
]
},
"alias": "TestInterface",
"locations": [
{
"fileName": "cases/class.ts",
Expand Down Expand Up @@ -438,24 +421,7 @@ class TestClass implements TestInterface {
{
"kindText": "interface",
"kind": "interface",
"symbol": {
"name": "TestInterface",
"locations": [
{
"fileName": "cases/class.ts",
"range": {
"start": {
"line": 0,
"character": 10
},
"end": {
"line": 0,
"character": 23
}
}
}
]
},
"alias": "TestInterface",
"locations": [
{
"fileName": "cases/class.ts",
Expand Down Expand Up @@ -780,24 +746,7 @@ class TestClass implements TestInterface {
{
"kindText": "interface",
"kind": "interface",
"symbol": {
"name": "TestInterface",
"locations": [
{
"fileName": "cases/class.ts",
"range": {
"start": {
"line": 0,
"character": 10
},
"end": {
"line": 0,
"character": 23
}
}
}
]
},
"alias": "TestInterface",
"locations": [
{
"fileName": "cases/class.ts",
Expand Down Expand Up @@ -1161,24 +1110,7 @@ const _a = new TestClass("param")
{
"kindText": "interface",
"kind": "interface",
"symbol": {
"name": "TestInterface",
"locations": [
{
"fileName": "cases/class.ts",
"range": {
"start": {
"line": 0,
"character": 10
},
"end": {
"line": 0,
"character": 23
}
}
}
]
},
"alias": "TestInterface",
"locations": [
{
"fileName": "cases/class.ts",
Expand Down Expand Up @@ -1490,24 +1422,7 @@ const _a = new TestClass("param")
{
"kindText": "interface",
"kind": "interface",
"symbol": {
"name": "TestInterface",
"locations": [
{
"fileName": "cases/class.ts",
"range": {
"start": {
"line": 0,
"character": 10
},
"end": {
"line": 0,
"character": 23
}
}
}
]
},
"alias": "TestInterface",
"locations": [
{
"fileName": "cases/class.ts",
Expand Down
10 changes: 5 additions & 5 deletions tests/baselines/reference/class.tree
Expand Up @@ -284,7 +284,7 @@ class TestClass implements TestInterface {
],
"implementsTypes": [],
"constructSignatures": [],
"symbolMeta": {
"aliasSymbolMeta": {
"name": "TestInterface",
"flags": 64,
"declarations": [
Expand Down Expand Up @@ -532,7 +532,7 @@ class TestClass implements TestInterface {
],
"implementsTypes": [],
"constructSignatures": [],
"symbolMeta": {
"aliasSymbolMeta": {
"name": "TestInterface",
"flags": 64,
"declarations": [
Expand Down Expand Up @@ -877,7 +877,7 @@ class TestClass implements TestInterface {
],
"implementsTypes": [],
"constructSignatures": [],
"symbolMeta": {
"aliasSymbolMeta": {
"name": "TestInterface",
"flags": 64,
"declarations": [
Expand Down Expand Up @@ -1250,7 +1250,7 @@ const _a = new TestClass("param")
],
"implementsTypes": [],
"constructSignatures": [],
"symbolMeta": {
"aliasSymbolMeta": {
"name": "TestInterface",
"flags": 64,
"declarations": [
Expand Down Expand Up @@ -1576,7 +1576,7 @@ const _a = new TestClass("param")
],
"implementsTypes": [],
"constructSignatures": [],
"symbolMeta": {
"aliasSymbolMeta": {
"name": "TestInterface",
"flags": 64,
"declarations": [
Expand Down
57 changes: 3 additions & 54 deletions tests/baselines/reference/jsxFunctionComponent.localized.tree
Expand Up @@ -167,24 +167,7 @@ function Comp(props: { abc: string, ad?: number }) {
{
"kindText": "interface",
"kind": "interface",
"symbol": {
"name": "Element",
"locations": [
{
"fileName": "../node_modules/@types/react/index.d.ts",
"range": {
"start": {
"line": 3121,
"character": 18
},
"end": {
"line": 3121,
"character": 25
}
}
}
]
},
"alias": "Element",
"purpose": "return",
"locations": [
{
Expand Down Expand Up @@ -743,24 +726,7 @@ function Comp(props: { abc: string, ad?: number }) {
{
"kindText": "interface",
"kind": "interface",
"symbol": {
"name": "Element",
"locations": [
{
"fileName": "../node_modules/@types/react/index.d.ts",
"range": {
"start": {
"line": 3121,
"character": 18
},
"end": {
"line": 3121,
"character": 25
}
}
}
]
},
"alias": "Element",
"purpose": "return",
"locations": [
{
Expand Down Expand Up @@ -2031,24 +1997,7 @@ const a = <Comp abc="asc" ad={4} />
{
"kindText": "interface",
"kind": "interface",
"symbol": {
"name": "Element",
"locations": [
{
"fileName": "../node_modules/@types/react/index.d.ts",
"range": {
"start": {
"line": 3121,
"character": 18
},
"end": {
"line": 3121,
"character": 25
}
}
}
]
},
"alias": "Element",
"purpose": "return",
"locations": [
{
Expand Down
6 changes: 3 additions & 3 deletions tests/baselines/reference/jsxFunctionComponent.tree
Expand Up @@ -569,7 +569,7 @@ function Comp(props: { abc: string, ad?: number }) {
},
"implementsTypes": [],
"constructSignatures": [],
"symbolMeta": {
"aliasSymbolMeta": {
"name": "Element",
"flags": 64,
"declarations": [
Expand Down Expand Up @@ -1183,7 +1183,7 @@ function Comp(props: { abc: string, ad?: number }) {
},
"implementsTypes": [],
"constructSignatures": [],
"symbolMeta": {
"aliasSymbolMeta": {
"name": "Element",
"flags": 64,
"declarations": [
Expand Down Expand Up @@ -2560,7 +2560,7 @@ const a = <Comp abc="asc" ad={4} />
},
"implementsTypes": [],
"constructSignatures": [],
"symbolMeta": {
"aliasSymbolMeta": {
"name": "Element",
"flags": 64,
"declarations": [
Expand Down

0 comments on commit 4a38b19

Please sign in to comment.