Skip to content

Home > vue-metamorph > astHelpers > findImportDeclaration

astHelpers.findImportDeclaration() function

Finds an existing import declaration for a module

Signature:

typescript
export declare function findImportDeclaration(ast: namedTypes.Program, moduleSpecifier: string): namedTypes.ImportDeclaration | null;

Parameters

Parameter

Type

Description

ast

namedTypes.Program

The script AST

moduleSpecifier

string

The module name

**Returns:**

namedTypes.ImportDeclaration | null

The ImportDeclaration node if one was found, or null