Skip to main content

Import AST Python Object

The Import object matches a Python import.

The astType value for this node is importstatement.

Code Pattern

This object catches the following code pattern

import module

Usage

const node = ... <import data> ...


// detect if the package `foobar` is used
if(node.packages) {
node.packages.forEach(p => {
if(p.name && p.name.value && p.name.value === "foobar") {
// do something
}
});
}

Attributes