benjamn / benjamn/ast-types

Idea: "Virtual" type definitions

Open
#94 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
194
Avg merge
22h 43m
Merged PRs (30d)
10

Description

The idea is to be able to treat different node types as if they were the same type. You already have a type which could be considered virtual: `Function`, which defines the shared properties of `FunctionExpression`s and `FunctionDeclaration`s. However, `FunctionExpression` and `FunctionDeclaration` have to explicitly "inherit" from `Function`.

Lets consider another example: `Identifier` and `JSXIdentifier`. For static analysis and code mods, I might want to treat both of these types as identical.

I would like to be able to write logic to process nodes independently of the concrete node type. Virtual types could be created dynamically and concrete node types could be associated with virtual types dynamically.

I'm not sure if what I'm saying makes sense at all , I'm not especially good at expressing my ideas. Or maybe something like this is already possible to do and I just don't know how. Happy to talk about this via a different channel.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing how the existing virtual Function type relates to FunctionExpression and FunctionDeclaration, then compare that behavior with Identifier and JSXIdentifier. Determine whether virtual types can be created and associated dynamically; done should include a clear API and behavior for processing concrete nodes through those virtual types.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.