From 49d68d13518c301a8f29ec746130a55e95d6acc7 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Sun, 1 Jun 2025 18:25:31 +0200 Subject: [PATCH] chore: use erasableSyntaxOnly --- src/llhttp/http.ts | 11 ++++++++--- src/llhttp/url.ts | 10 ++++++---- tsconfig.json | 1 + tsconfig.test.json | 4 ++++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/llhttp/http.ts b/src/llhttp/http.ts index 20c50e80..e3f29a8b 100644 --- a/src/llhttp/http.ts +++ b/src/llhttp/http.ts @@ -1,8 +1,10 @@ import assert from 'assert'; import { type LLParse, source } from 'llparse'; -import Match = source.node.Match; -import Node = source.node.Node; +const { Node } = source.node; + +type Match = source.node.Match; +type Node = source.node.Node; import { type CharList, @@ -171,8 +173,11 @@ export class HTTP { private readonly span: ISpanMap; private readonly callback: ICallbackMap; private readonly nodes = new Map(); + private readonly llparse: LLParse; + + constructor(llparse: LLParse) { + this.llparse = llparse; - constructor(private readonly llparse: LLParse) { const p = llparse; this.url = new URL(p); diff --git a/src/llhttp/url.ts b/src/llhttp/url.ts index 00c4864c..5257a2b7 100644 --- a/src/llhttp/url.ts +++ b/src/llhttp/url.ts @@ -1,7 +1,7 @@ -import { type LLParse, source } from 'llparse'; +import { type LLParse, type source } from 'llparse'; -import Match = source.node.Match; -import Node = source.node.Node; +type Node = source.node.Node; +type Match = source.node.Match; import { ALPHA, @@ -30,8 +30,10 @@ export class URL { private readonly spanTable: SpanTable = new Map(); private readonly errorInvalid: Node; private readonly URL_CHAR: CharList; + private readonly llparse: LLParse; - constructor(private readonly llparse: LLParse, separateSpans = false) { + constructor(llparse: LLParse, separateSpans = false) { + this.llparse = llparse; const p = this.llparse; this.errorInvalid = p.error(ERROR.INVALID_URL, 'Invalid characters in url'); diff --git a/tsconfig.json b/tsconfig.json index ec9c80b9..6647a101 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "declaration": true, "pretty": true, "sourceMap": true, + "erasableSyntaxOnly": true }, "include": ["src/**/*.ts"], } \ No newline at end of file diff --git a/tsconfig.test.json b/tsconfig.test.json index c9387330..1328441e 100644 --- a/tsconfig.test.json +++ b/tsconfig.test.json @@ -1,4 +1,8 @@ { "extends": "./tsconfig.json", + "compilerOptions": { + "allowJs": true, + "checkJs": true + }, "include": ["bench/**/*.ts", "bin/**/*.ts", "src/**/*.ts", "test/**/*.ts", "eslint.config.mjs"], }