Skip to content

Missing Compiler API predicate function: isNamedTupleMember #40004

Closed
@wessberg

Description

@wessberg

Search Terms

isNamedTupleMember

Suggestion

TypeScript's Compiler APIs include is functions for all kinds of Nodes. For example, isClassDeclaration, isBigIntLiteral, and so on.

In TypeScript 4.0.1-rc1, a new kind of node is introduced: NamedTupleMember, but no isNamedTupleMember 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.isNamedTupleMember(node) {
        return visitNamedTupleMember(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

No one assigned

    Labels

    APIRelates to the public API for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions