Skip to content

Commit

Permalink
fix: fix some inconsistent type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
srijan-paul committed May 6, 2022
2 parents 41d48d8 + f8ce0d2 commit 625af0c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions espree.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import { getLatestEcmaVersion, getSupportedEcmaVersions } from "./lib/options.js
* @typedef {import("./lib/options").ParserOptions} ParserOptions
* @typedef {import("./lib/token-translator").EsprimaToken} EsprimaToken
* @typedef {import("./lib/token-translator").TokenRange} TokenRange
* @typedef {import("@types/estree").Program} Program
*/


Expand Down Expand Up @@ -131,8 +132,8 @@ export function tokenize(code, options) {
/**
* Parses the given code.
* @param {string} code The code to tokenize.
* @param {ParserOptions} options Options defining how to tokenize.
* @returns {acorn.Node} The "Program" AST node.
* @param {ParserOptions} options Options defining how to parse.
* @returns {Program} The "Program" AST node.
* @throws {SyntaxError} If the input code is invalid.
*/
export function parse(code, options) {
Expand Down
12 changes: 6 additions & 6 deletions lib/espree.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { normalizeOptions } from "./options.js";

/**
* @typedef {import("acorn")} acorn
* @typedef {import("./token-translator").TokenRange} TokenRange
* @typedef {import("./token-translator").Range} Range
* @typedef {import("./token-translator").Location} Location
*/

const STATE = Symbol("espree's internal state");
Expand All @@ -15,11 +16,10 @@ const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode");
* @typedef {Object} EsprimaComment
* @property {"Block"|"Line"} type Type of the comment, can either be "Block" (multiline) or "Line" (single line).
* @property {string} text Contents of the comment.
* @property {number|undefined} start Start column of a comment.
* @property {number|undefined} end End column of the comment.
* @property {TokenRange|undefined} range The [start, end] range of a comment.
* @property {acorn.Position} startLoc Start location of the comment.
* @property {acorn.Position} endLoc End location of the comment.
* @property {number|undefined} start Start index of the comment in source code.
* @property {number|undefined} end End index of the comment in source code.
* @property {Range|undefined} range The [start, end] range of a comment.
* @property {Location} loc Location of the comment.
*/

/**
Expand Down
8 changes: 4 additions & 4 deletions lib/token-translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
*/

/**
* @typedef {[number, number]} TokenRange
* @typedef {[number, number]} Range
*/

/**
* @typedef {Object} EsprimaToken
* @property {string} type The type of this token.
* @property {string} value The string content of the token.
* @property {Location|undefined} loc Location in source text.
* @property {number|undefined} start start column.
* @property {number|undefined} end end column.
* @property {TokenRange|undefined} range [start, end] range
* @property {number|undefined} start start index of the token in source code.
* @property {number|undefined} end end index of the token in source code.
* @property {Range|undefined} range [start, end] range
*/

// Esprima Token Types
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
},
"license": "BSD-2-Clause",
"dependencies": {
"@types/estree": "^0.0.51",
"acorn": "^8.7.0",
"acorn-jsx": "^5.3.1",
"eslint-visitor-keys": "^3.3.0"
Expand Down

0 comments on commit 625af0c

Please sign in to comment.