-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Search Terms
isImportTypeAssertionContainer
Suggestion
TypeScript's Compiler APIs include is functions for all kinds of Nodes. For example, isClassDeclaration, isBigIntLiteral, and so on.
In TypeScript 4.7 a new kind of node is introduced: ImportTypeAssertionContainer, but no isImportTypeAssertionContainer predicate function is exposed. For consistency with other kinds of Nodes, TypeScript should arguably also expose such a predicate function.
Use Cases
- Custom Transformers (visiting and transforming Nodes in an AST)
- Working with the Compiler APIs
- etc
Examples
function visitNode (node: TS.Node, context: TS.TransformationContext, typescript: typeof TS): TS.VisitResult<TS.Node> {
if (typescript.isImportTypeAssertionContainer(node) {
return visitImportTypeAssertionContainer(node, context, typescript);
}
else if (...) {
....
}
}Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue