Help: finding adjacent types
reggi opened this issue · comments
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.
types.visit(ast, {
visitImportDeclaration: importDeclaration,
visitCallExpression: callExpression
})
Given the examples:
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:
[{
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?