Help: finding adjacent types
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 194
- Avg merge
- 22h 43m
- Merged PRs (30d)
- 10
Description
Im looking for a way to get the variable definition from `import` and `require` statements.
I already have functions that get the contents of the require / import (ie. the module) but not the variable itself.
```js
types.visit(ast, {
visitImportDeclaration: importDeclaration,
visitCallExpression: callExpression
})
```
Given the examples:
```js
import {Alpha} from 'github.com/reggi/ideal-repository#1.0.0'
// ^
let {Alpha} = require('something')
var {Alpha} = require('something')
const {Alpha} = require('something')
// ^
```
Id like something like this in return:
```js
[{
assignment: ['Alpha'],
dependency: 'something'
}]
```
I'd also need a way to differentiate if it's a a restructured variable or not.
Do I have to crawl the whole AST?
Contributor guide
No contributing guide indexed for this repository
Research direction
Review the existing importDeclaration and callExpression visitors shown in the issue, then trace how the AST represents import bindings, require assignments, and destructuring. Define the expected result for the supplied examples and distinguish destructured from non-destructured variables; completion should be verified against those cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100