CodeQL library for JavaScript/TypeScript
codeql/javascript-all 2.6.11 (changelog, source)
Search

Member predicate LazyCache::LazyCacheImport::getImportedModuleNode

Gets the data flow node corresponding to the imported module.

For example:

// ES2015 style
import * as foo from "fs"; // Gets the node for `foo`
import { readSync } from "fs"; // Gets a node representing the destructured import

// CommonJS style
require("fs"); // Gets the return value

// AMD style
define(["fs"], function(fs) { // Gets the node for the `fs` parameter
});

For default imports, this gets two nodes: the default import node, and a node representing the imported module:

import foo from "fs"; // gets both `foo` and a node representing the imported module

This behaviour is to support non-standard compilers that treat default imports as namespace imports. Use getImportedModuleNodeStrict() to avoid this behaviour in cases where it would cause ambiguous data flow.

Node getImportedModuleNode()