Skip to content

Commit 371af6f

Browse files
committed
Add some missing JSDoc
1 parent 9dd2f9b commit 371af6f

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

src/scopes.d.ts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,25 @@
66
* The decoded scopes information found in a source map.
77
*/
88
export interface ScopeInfo {
9+
/**
10+
* The length of {@linkcode scopes} must match the length of "sources" in the source map JSON. Each entry describes the scope tree of the corresponding source file.
11+
*/
912
scopes: (OriginalScope | null)[];
13+
14+
/**
15+
* The range tree of the generated bundle. Multiple top-level ranges are allowed but must not overlap source position wise.
16+
*/
1017
ranges: GeneratedRange[];
1118
}
1219

1320
/**
1421
* A scope in the authored source.
1522
*/
1623
export interface OriginalScope {
24+
/** The beginning of this scope (inclusive). */
1725
start: Position;
26+
27+
/** The end of this scope (exclusive) */
1828
end: Position;
1929

2030
/**
@@ -42,15 +52,28 @@ export interface OriginalScope {
4252
*/
4353
variables: string[];
4454

55+
/**
56+
* The child scopes. When manually building scopes, {@linkcode children} must be sorted, not
57+
* overlap each other and be contained within [start, end).
58+
*/
4559
children: OriginalScope[];
60+
61+
/** The parent scope or `undefined` for top-level scopes. */
4662
parent?: OriginalScope;
4763
}
4864

4965
/**
50-
* A range (can be a scope) in the generated JavaScript.
66+
* A range (can be a scope) in the generated JavaScript/WASM.
67+
*
68+
* The name "range" was chosen deliberately as a GeneratedRange does not necessarily
69+
* correspond to a lexical JavaScript scope. E.g. inlining, or concatenating multiple
70+
* bundles can result in generated ranges that are not lexical scopes.
5171
*/
5272
export interface GeneratedRange {
73+
/** The beginning of this range (inclusive) */
5374
start: Position;
75+
76+
/** The end of this range (exclusive) */
5477
end: Position;
5578

5679
/**
@@ -83,7 +106,13 @@ export interface GeneratedRange {
83106
*/
84107
values: Binding[];
85108

109+
/**
110+
* The child ranges. When manually building ranges, {@linkcode children} must be sorted,
111+
* not overlap each other and be contained within [start, end).
112+
*/
86113
children: GeneratedRange[];
114+
115+
/** The parent range or `undefined` for top-level ranges. */
87116
parent?: GeneratedRange;
88117
}
89118

@@ -111,15 +140,28 @@ export interface SubRangeBinding {
111140
to: Position;
112141
}
113142

143+
/**
144+
* A position with 0-based line and column numbers.
145+
*
146+
* A {@linkcode Position} object by itself does not imply a position in original source
147+
* or generated code. It is used in both and normally it is clear from context.
148+
*/
114149
export interface Position {
115150
line: number;
116151
column: number;
117152
}
118153

154+
/**
155+
* A position with 0-based line and column numbers in a specific original source file.
156+
*/
119157
export interface OriginalPosition extends Position {
158+
/** The 0-based index into "sources" in the source map. Or into {@linkcode ScopeInfo.scopes}. */
120159
sourceIndex: number;
121160
}
122161

162+
/**
163+
* A standard source map json object as per https://tc39.es/ecma426.
164+
*/
123165
export interface SourceMapJson {
124166
version: 3;
125167
sources: (string | null)[];

0 commit comments

Comments
 (0)