-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bug): adds support for missing node types
- Loading branch information
Showing
12 changed files
with
156 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...claration-tree-shaker/reference/is-referenced/visitor/visit-call-signature-declaration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {CallSignatureDeclaration, isComputedPropertyName} from "typescript"; | ||
import {VisitorOptions} from "../visitor-options"; | ||
|
||
/** | ||
* Visits the given CallSignatureDeclaration. | ||
* @param {CallSignatureDeclaration} currentNode | ||
* @param {VisitorOptions} options | ||
*/ | ||
export function visitCallSignatureDeclaration(currentNode: CallSignatureDeclaration, {continuation}: VisitorOptions): void { | ||
// Check if any of the type parameters references the Node | ||
if (currentNode.typeParameters != null) { | ||
for (const typeParameter of currentNode.typeParameters) { | ||
continuation(typeParameter, currentNode); | ||
} | ||
} | ||
|
||
// Check if any of the parameters references the node | ||
if (currentNode.parameters != null) { | ||
for (const parameter of currentNode.parameters) { | ||
continuation(parameter, currentNode); | ||
} | ||
} | ||
|
||
// Check if the type of the function references the Node | ||
if (currentNode.type != null) { | ||
continuation(currentNode.type, currentNode); | ||
} | ||
|
||
if (currentNode.name != null && isComputedPropertyName(currentNode.name)) { | ||
continuation(currentNode.name); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...er/declaration-tree-shaker/reference/is-referenced/visitor/visit-conditional-type-node.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {ConditionalTypeNode} from "typescript"; | ||
import {VisitorOptions} from "../visitor-options"; | ||
|
||
/** | ||
* Visits the given ConditionalTypeNode. | ||
* @param {ConditionalTypeNode} currentNode | ||
* @param {VisitorOptions} options | ||
*/ | ||
export function visitConditionalTypeNode(currentNode: ConditionalTypeNode, {continuation}: VisitorOptions): void { | ||
continuation(currentNode.checkType); | ||
continuation(currentNode.extendsType); | ||
continuation(currentNode.falseType); | ||
continuation(currentNode.trueType); | ||
} |
13 changes: 13 additions & 0 deletions
13
...sformer/declaration-tree-shaker/reference/is-referenced/visitor/visit-enum-declaration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {EnumDeclaration} from "typescript"; | ||
import {VisitorOptions} from "../visitor-options"; | ||
|
||
/** | ||
* Visits the given EnumDeclaration. | ||
* @param {EnumDeclaration} currentNode | ||
* @param {VisitorOptions} options | ||
*/ | ||
export function visitEnumDeclaration(currentNode: EnumDeclaration, {continuation}: VisitorOptions): void { | ||
for (const member of currentNode.members) { | ||
continuation(member, currentNode); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../transformer/declaration-tree-shaker/reference/is-referenced/visitor/visit-enum-member.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {EnumMember, isComputedPropertyName} from "typescript"; | ||
import {VisitorOptions} from "../visitor-options"; | ||
|
||
/** | ||
* Visits the given EnumMember. | ||
* @param {EnumMember} currentNode | ||
* @param {VisitorOptions} options | ||
*/ | ||
export function visitEnumMember(currentNode: EnumMember, {continuation}: VisitorOptions): void { | ||
// Check if the initializer references the Node | ||
if (currentNode.initializer != null) { | ||
continuation(currentNode.initializer); | ||
} | ||
|
||
// Check if the name is a binding pattern that references the identifier | ||
if (isComputedPropertyName(currentNode.name)) { | ||
continuation(currentNode.name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...ormer/declaration-tree-shaker/reference/is-referenced/visitor/visit-optional-type-node.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {OptionalTypeNode} from "typescript"; | ||
import {VisitorOptions} from "../visitor-options"; | ||
|
||
/** | ||
* Visits the given OptionalTypeNode. | ||
* @param {OptionalTypeNode} currentNode | ||
* @param {VisitorOptions} options | ||
*/ | ||
export function visitOptionalTypeNode(currentNode: OptionalTypeNode, {continuation}: VisitorOptions): void { | ||
continuation(currentNode.type); | ||
} |
11 changes: 11 additions & 0 deletions
11
...claration-tree-shaker/reference/is-referenced/visitor/visit-property-access-expression.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {PropertyAccessExpression} from "typescript"; | ||
import {VisitorOptions} from "../visitor-options"; | ||
|
||
/** | ||
* Visits the given PropertyAccessExpression. | ||
* @param {PropertyAccessExpression} currentNode | ||
* @param {VisitorOptions} options | ||
*/ | ||
export function visitPropertyAccessExpression(currentNode: PropertyAccessExpression, {continuation}: VisitorOptions): void { | ||
continuation(currentNode.expression); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...ansformer/declaration-tree-shaker/reference/is-referenced/visitor/visit-qualified-name.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {QualifiedName} from "typescript"; | ||
import {VisitorOptions} from "../visitor-options"; | ||
|
||
/** | ||
* Visits the given QualifiedName. | ||
* @param {QualifiedName} currentNode | ||
* @param {VisitorOptions} options | ||
*/ | ||
export function visitQualifiedName(currentNode: QualifiedName, {continuation}: VisitorOptions): void { | ||
continuation(currentNode.left); | ||
} |
13 changes: 13 additions & 0 deletions
13
...nsformer/declaration-tree-shaker/reference/is-referenced/visitor/visit-tuple-type-node.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {TupleTypeNode} from "typescript"; | ||
import {VisitorOptions} from "../visitor-options"; | ||
|
||
/** | ||
* Visits the given TupleTypeNode. | ||
* @param {TupleTypeNode} currentNode | ||
* @param {VisitorOptions} options | ||
*/ | ||
export function visitTupleTypeNode(currentNode: TupleTypeNode, {continuation}: VisitorOptions): void { | ||
for (const typeNode of currentNode.elementTypes) { | ||
continuation(typeNode); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters