strict ts + fixes

This commit is contained in:
Yura Dupyn 2026-02-07 14:57:01 +01:00
parent 1b406899e0
commit d45207342c
9 changed files with 15 additions and 12 deletions

View file

@ -147,16 +147,12 @@ export function scanNumber(cursor: Cursor): Result<{ value: number, span: Span }
const startNumberLocation = cursor.currentLocation();
let c: CodePoint;
// 1. Optional Sign
c = cursor.peek();
if (c === char("-")) {
if (cursor.peek() === char("-")) {
cursor.next();
}
// 2. Integer Part
c = cursor.peek();
const integerPartDigitCount = cursor.consumeWhile(isDigit);
if (integerPartDigitCount === 0) {
return Result.error({
@ -238,7 +234,10 @@ export function scanString(cursor: Cursor): Result<{ value: string, span: Span }
// 2. Escape Sequences
const escapeStart = cursor.currentLocation();
cursor.next(); // consume backslash
const escaped = cursor.peek();
if (cursor.eof()) {
return Result.error({ tag: "UnexpectedEOF", span: cursor.makeSpan(start) });
}
const escaped = cursor.peek() as CodePoint; // it can't be `undefined`
switch (escaped) {
case char('n'): value += '\n'; cursor.next(); break;