1111
1212/** @typedef {import("@eslint/core").VisitTraversalStep } VisitTraversalStep */
1313/** @typedef {import("@eslint/core").CallTraversalStep } CallTraversalStep */
14- /** @typedef {import("@eslint/core").TextSourceCode } TextSourceCode */
1514/** @typedef {import("@eslint/core").TraversalStep } TraversalStep */
1615/** @typedef {import("@eslint/core").SourceLocation } SourceLocation */
1716/** @typedef {import("@eslint/core").SourceLocationWithOffset } SourceLocationWithOffset */
1817/** @typedef {import("@eslint/core").SourceRange } SourceRange */
1918/** @typedef {import("@eslint/core").Directive } IDirective */
2019/** @typedef {import("@eslint/core").DirectiveType } DirectiveType */
20+ /** @typedef {import("@eslint/core").SourceCodeBaseTypeOptions } SourceCodeBaseTypeOptions */
21+ /**
22+ * @typedef {import("@eslint/core").TextSourceCode<Options> } TextSourceCode<Options>
23+ * @template {SourceCodeBaseTypeOptions} [Options=SourceCodeBaseTypeOptions]
24+ */
2125
2226//-----------------------------------------------------------------------------
2327// Helpers
@@ -212,7 +216,8 @@ export class Directive {
212216
213217/**
214218 * Source Code Base Object
215- * @implements {TextSourceCode}
219+ * @template {SourceCodeBaseTypeOptions & {SyntaxElementWithLoc: object}} [Options=SourceCodeBaseTypeOptions & {SyntaxElementWithLoc: object}]
220+ * @implements {TextSourceCode<Options>}
216221 */
217222export class TextSourceCodeBase {
218223 /**
@@ -223,7 +228,7 @@ export class TextSourceCodeBase {
223228
224229 /**
225230 * The AST of the source code.
226- * @type {object }
231+ * @type {Options['RootNode'] }
227232 */
228233 ast ;
229234
@@ -237,7 +242,7 @@ export class TextSourceCodeBase {
237242 * Creates a new instance.
238243 * @param {Object } options The options for the instance.
239244 * @param {string } options.text The source code text.
240- * @param {object } options.ast The root AST node.
245+ * @param {Options['RootNode'] } options.ast The root AST node.
241246 * @param {RegExp } [options.lineEndingPattern] The pattern to match lineEndings in the source code.
242247 */
243248 constructor ( { text, ast, lineEndingPattern = / \r ? \n / u } ) {
@@ -248,7 +253,7 @@ export class TextSourceCodeBase {
248253
249254 /**
250255 * Returns the loc information for the given node or token.
251- * @param {object } nodeOrToken The node or token to get the loc information for.
256+ * @param {Options['SyntaxElementWithLoc'] } nodeOrToken The node or token to get the loc information for.
252257 * @returns {SourceLocation } The loc information for the node or token.
253258 */
254259 getLoc ( nodeOrToken ) {
@@ -267,7 +272,7 @@ export class TextSourceCodeBase {
267272
268273 /**
269274 * Returns the range information for the given node or token.
270- * @param {object } nodeOrToken The node or token to get the range information for.
275+ * @param {Options['SyntaxElementWithLoc'] } nodeOrToken The node or token to get the range information for.
271276 * @returns {SourceRange } The range information for the node or token.
272277 */
273278 getRange ( nodeOrToken ) {
@@ -290,8 +295,8 @@ export class TextSourceCodeBase {
290295 /* eslint-disable no-unused-vars -- Required to complete interface. */
291296 /**
292297 * Returns the parent of the given node.
293- * @param {object } node The node to get the parent of.
294- * @returns {object |undefined } The parent of the node.
298+ * @param {Options['SyntaxElementWithLoc'] } node The node to get the parent of.
299+ * @returns {Options['SyntaxElementWithLoc'] |undefined } The parent of the node.
295300 */
296301 getParent ( node ) {
297302 throw new Error ( "Not implemented." ) ;
@@ -300,8 +305,8 @@ export class TextSourceCodeBase {
300305
301306 /**
302307 * Gets all the ancestors of a given node
303- * @param {object } node The node
304- * @returns {Array<object > } All the ancestor nodes in the AST, not including the provided node, starting
308+ * @param {Options['SyntaxElementWithLoc'] } node The node
309+ * @returns {Array<Options['SyntaxElementWithLoc'] > } All the ancestor nodes in the AST, not including the provided node, starting
305310 * from the root node at index 0 and going inwards to the parent node.
306311 * @throws {TypeError } When `node` is missing.
307312 */
@@ -325,7 +330,7 @@ export class TextSourceCodeBase {
325330
326331 /**
327332 * Gets the source code for the given node.
328- * @param {object } [node] The AST node to get the text for.
333+ * @param {Options['SyntaxElementWithLoc'] } [node] The AST node to get the text for.
329334 * @param {number } [beforeCount] The number of characters before the node to retrieve.
330335 * @param {number } [afterCount] The number of characters after the node to retrieve.
331336 * @returns {string } The text representing the AST node.
0 commit comments