Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wrap TypeOperator node (#1208)
- Loading branch information
Showing
11 changed files
with
113 additions
and
63 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
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
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
packages/ts-morph/src/compiler/ast/type/TypeOperatorTypeNode.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 { ts } from "@ts-morph/common"; | ||
import { TypeNode } from "./TypeNode"; | ||
|
||
export class TypeOperatorTypeNode extends TypeNode<ts.TypeOperatorNode> { | ||
/** | ||
* Gets the node within the type operator. | ||
*/ | ||
getTypeNode(): TypeNode { | ||
return this._getNodeFromCompilerNode(this.compilerNode.type); | ||
} | ||
} |
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
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
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
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
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
17 changes: 17 additions & 0 deletions
17
packages/ts-morph/src/tests/compiler/ast/type/typeOperatorTypeNodeTests.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,17 @@ | ||
import { SyntaxKind } from "@ts-morph/common"; | ||
import { expect } from "chai"; | ||
import { TypeOperatorTypeNode } from "../../../../compiler"; | ||
import { getInfoFromTextWithDescendant } from "../../testHelpers"; | ||
|
||
describe(nameof(TypeOperatorTypeNode), () => { | ||
function getNode(text: string) { | ||
return getInfoFromTextWithDescendant<TypeOperatorTypeNode>(text, SyntaxKind.TypeOperator); | ||
} | ||
|
||
describe(nameof<TypeOperatorTypeNode>(d => d.getType), () => { | ||
it("should get the type", () => { | ||
const { descendant } = getNode("var t: readonly string;"); | ||
expect(descendant.getTypeNode().getText()).to.equal("string"); | ||
}); | ||
}); | ||
}); |
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