Skip to content

Commit 6499862

Browse files
committed
fix: fix some inconsistent type definitions
2 parents 41d48d8 + f8ce0d2 commit 6499862

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

espree.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import { getLatestEcmaVersion, getSupportedEcmaVersions } from "./lib/options.js
6868
* @typedef {import("./lib/options").ParserOptions} ParserOptions
6969
* @typedef {import("./lib/token-translator").EsprimaToken} EsprimaToken
7070
* @typedef {import("./lib/token-translator").TokenRange} TokenRange
71+
* @typedef {import("@types/estree").Program} Program
7172
*/
7273

7374

@@ -131,8 +132,8 @@ export function tokenize(code, options) {
131132
/**
132133
* Parses the given code.
133134
* @param {string} code The code to tokenize.
134-
* @param {ParserOptions} options Options defining how to tokenize.
135-
* @returns {acorn.Node} The "Program" AST node.
135+
* @param {ParserOptions} options Options defining how to parse.
136+
* @returns {Program} The "Program" AST node.
136137
* @throws {SyntaxError} If the input code is invalid.
137138
*/
138139
export function parse(code, options) {

lib/espree.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { normalizeOptions } from "./options.js";
55

66
/**
77
* @typedef {import("acorn")} acorn
8-
* @typedef {import("./token-translator").TokenRange} TokenRange
8+
* @typedef {import("./token-translator").Range} Range
9+
* @typedef {import("./token-translator").Location} Location
910
*/
1011

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

2525
/**

lib/token-translator.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525
*/
2626

2727
/**
28-
* @typedef {[number, number]} TokenRange
28+
* @typedef {[number, number]} Range
2929
*/
3030

3131
/**
3232
* @typedef {Object} EsprimaToken
3333
* @property {string} type The type of this token.
3434
* @property {string} value The string content of the token.
3535
* @property {Location|undefined} loc Location in source text.
36-
* @property {number|undefined} start start column.
37-
* @property {number|undefined} end end column.
38-
* @property {TokenRange|undefined} range [start, end] range
36+
* @property {number|undefined} start start index of the token in source code.
37+
* @property {number|undefined} end end index of the token in source code.
38+
* @property {Range|undefined} range [start, end] range
3939
*/
4040

4141
// Esprima Token Types

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@
3333
},
3434
"license": "BSD-2-Clause",
3535
"dependencies": {
36-
"acorn": "^8.7.0",
37-
"acorn-jsx": "^5.3.1",
36+
"acorn": "^8.7.1",
37+
"acorn-jsx": "^5.3.2",
3838
"eslint-visitor-keys": "^3.3.0"
3939
},
4040
"devDependencies": {
4141
"@rollup/plugin-commonjs": "^17.1.0",
4242
"@rollup/plugin-json": "^4.1.0",
4343
"@rollup/plugin-node-resolve": "^11.2.0",
44+
"@types/estree": "^0.0.51",
4445
"c8": "^7.11.0",
4546
"chai": "^4.3.4",
4647
"eslint": "^7.22.0",

0 commit comments

Comments
 (0)