Skip to content

Home > vue-metamorph > astHelpers > createNamedImport

astHelpers.createNamedImport() function

Inserts a named import at the top of a script, or inserts a named import on an existing import declaration for the moduleSpecifier

Signature:

typescript
export declare function createNamedImport(ast: namedTypes.Program, moduleSpecifier: string, importName: string, localName?: string): void;

Parameters

Parameter

Type

Description

ast

namedTypes.Program

The script AST

moduleSpecifier

string

The module name to import from

importName

string

The name of the import

localName

string

(Optional) (optional) The local name of the named import

**Returns:**

void