Skip to content

Commit f03c08d

Browse files
committed
add types for error.js
1 parent 237cab2 commit f03c08d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/error.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/** @import { Base } from "./productions/base.js" */
2+
/** @import { Source } from "./tokeniser.js" */
23

34
/**
45
* @param {string} text
@@ -8,6 +9,10 @@ function lastLine(text) {
89
return splitted[splitted.length - 1];
910
}
1011

12+
/**
13+
* @param {string} base
14+
* @param {string} target
15+
*/
1116
function appendIfExist(base, target) {
1217
let result = base;
1318
if (target) {
@@ -37,10 +42,10 @@ function contextAsText(node) {
3742
*
3843
* @typedef {ReturnType<typeof error>} WebIDLErrorData
3944
*
40-
* @param {string} message error message
41-
* @param {*} position
45+
* @param {Source} source
46+
* @param {number} position
4247
* @param {*} current
43-
* @param {*} message
48+
* @param {string} message error message
4449
* @param {"Syntax" | "Validation"} kind error type
4550
* @param {WebIDL2ErrorOptions=} options
4651
*/

lib/tokeniser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ const reserved = [
125125

126126
/**
127127
* @typedef {ReturnType<typeof tokenise>[number]} Token
128+
* @typedef {Token[] & { name?: string }} Source
128129
* @param {string} str
129130
*/
130131
function tokenise(str) {
@@ -235,7 +236,7 @@ function tokenise(str) {
235236
export class Tokeniser {
236237
/** @type {Base} */
237238
current;
238-
/** @type {Token[] & { name?: string }} */
239+
/** @type {Source} */
239240
source;
240241

241242
/**

0 commit comments

Comments
 (0)