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

Module TypeGraphExport

Wrapper around GraphExport that also exports information about re-exported types.

JavaScript example 1

For example, suppose shouldContainType("foo") holds, and the following is the entry point for a package bar:

// bar.js
module.exports.xxx = require('foo');

then this would generate the following type model:

foo; bar; Member[xxx]

JavaScript example 2

For a more complex case, suppose the following type model exists:

foo.XYZ; foo; Member[x].Member[y].Member[z]

And the package exports something that matches a prefix of the access path above:

module.exports.blah = require('foo').x.y;

This would result in the following type model:

foo.XYZ; bar; Member[blah].Member[z]

Notice that the access path Member[blah].Member[z] consists of an access path generated from the API graph, with pieces of the access path from the original type model appended to it.

Import path

import semmle.javascript.frameworks.data.internal.ApiGraphModelsExport

Imports

Predicates

typeModel

Holds if type1, type2, path should be emitted as a type model, that is (type2, path) leads to an instance of type1.

Parameters