Skip to content

Commit 2aa5fa1

Browse files
committed
JS: Add comment and examples in FlowImpl doc
1 parent 72cc439 commit 2aa5fa1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

javascript/ql/lib/semmle/javascript/internal/NameResolution.qll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,32 @@ module NameResolution {
271271
*/
272272
module TypeFlow = FlowImpl<TypeConfig>;
273273

274+
/**
275+
* Generates a directed graph for tracking type names or value names back toward their definition.
276+
* The ultimate definition might not be in the database, but the graph lets us track as far as we can.
277+
*
278+
* The module parameter determines whether types or values should be tracked.
279+
*
280+
* The example below illustrates the need for two separate instantiations of this module.
281+
* When tracking through the nodes corresponding to `X`, we need to remember whether a type or value was tracked.
282+
*
283+
* ```ts
284+
* // lib.ts
285+
* class C1 {}
286+
* class C2 {}
287+
*
288+
* const X = C1;
289+
* type X = C2;
290+
*
291+
* export { X }
292+
*
293+
* // use.ts
294+
* import { X } from "./lib"
295+
*
296+
* var x1 = X // should refer to C1
297+
* var x2: X; // should refer to C2
298+
* ```
299+
*/
274300
private module FlowImpl<TypeResolutionInputSig S> {
275301
/**
276302
* Gets the exported member of `mod` named `name`.

0 commit comments

Comments
 (0)