From 7b595166ae239f75b2e22eec1f143f326d8a0ae4 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Thu, 10 Feb 2022 18:49:51 +0800 Subject: [PATCH 01/19] feat: Support ESM declaration imports; add an `AcornJsxParser` class and `tokTypes` const --- index.d.ts | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/index.d.ts b/index.d.ts index f37b1df..f73a499 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,12 +1,26 @@ -import { Parser } from 'acorn' +import acorn from 'acorn'; -declare const jsx: (options?: jsx.Options) => (BaseParser: typeof Parser) => typeof Parser; +export const jsx: (options?: jsx.Options) => (BaseParser: typeof acorn.Parser) => typeof acorn.Parser; -declare namespace jsx { - interface Options { - allowNamespacedObjects?: boolean; - allowNamespaces?: boolean; - } +export interface Options { + allowNamespacedObjects?: boolean; + allowNamespaces?: boolean; } -export = jsx; +export const tokTypes: { + jsxName: acorn.TokenType, + jsxText: acorn.TokenType, + jsxTagEnd: acorn.TokenType, + jsxTagStart: acorn.TokenType +} & typeof acorn.tokTypes; + +export class AcornJsxParser extends acorn.Parser { + static readonly acornJsx: { + tokTypes: typeof tokTypes + }; + + jsx_readString(quote: number): void; +} + +export as namespace jsx; +export default jsx; From dda96cc6c267f7f9e11f9a2cc6f51805f40066ad Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 13 Feb 2022 05:35:01 +0800 Subject: [PATCH 02/19] feat: add missing `tokContexts` property on `acornJsx` --- index.d.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index f73a499..79f4324 100644 --- a/index.d.ts +++ b/index.d.ts @@ -8,15 +8,22 @@ export interface Options { } export const tokTypes: { - jsxName: acorn.TokenType, - jsxText: acorn.TokenType, - jsxTagEnd: acorn.TokenType, - jsxTagStart: acorn.TokenType + jsxName: acorn.TokenType, + jsxText: acorn.TokenType, + jsxTagEnd: acorn.TokenType, + jsxTagStart: acorn.TokenType } & typeof acorn.tokTypes; +export const tokContexts: { + tc_oTag: acorn.TokContext, + tc_cTag: acorn.TokContext, + tc_expr: acorn.TokContext +}; + export class AcornJsxParser extends acorn.Parser { static readonly acornJsx: { - tokTypes: typeof tokTypes + tokTypes: typeof tokTypes; + tokContexts: typeof tokContexts }; jsx_readString(quote: number): void; From baa0a61d06af0e6951db8dcecc1e95592f8868ea Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 13 Feb 2022 06:01:26 +0800 Subject: [PATCH 03/19] feat: add missing jsx_ methods to `AcornJsxParser` --- index.d.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/index.d.ts b/index.d.ts index 79f4324..8ddfa89 100644 --- a/index.d.ts +++ b/index.d.ts @@ -26,7 +26,23 @@ export class AcornJsxParser extends acorn.Parser { tokContexts: typeof tokContexts }; + jsx_readToken(): string; + jsx_readNewLine(normalizeCRLF: boolean): void; jsx_readString(quote: number): void; + jsx_readEntity(): string; + jsx_readWord(): void; + jsx_parseIdentifier(): acorn.Node; + jsx_parseNamespacedName(): acorn.Node; + jsx_parseElementName(): acorn.Node | string; + jsx_parseAttributeValue(): acorn.Node; + jsx_parseEmptyExpression(): acorn.Node; + jsx_parseExpressionContainer(): acorn.Node; + jsx_parseAttribute(): acorn.Node; + jsx_parseOpeningElementAt(startPos: number, startLoc?: acorn.SourceLocation): acorn.Node; + jsx_parseClosingElementAt(startPos: number, startLoc?: acorn.SourceLocation): acorn.Node; + jsx_parseElementAt(startPos: number, startLoc?: acorn.SourceLocation): acorn.Node; + jsx_parseText(): acorn.Node; + jsx_parseElement(): acorn.Node; } export as namespace jsx; From 85265247b3ef4e4a22cf33ba15cd6cf3d5f978fa Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 13 Feb 2022 06:12:34 +0800 Subject: [PATCH 04/19] feat: add instance properties to `AcornJsxParser` --- index.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.d.ts b/index.d.ts index 8ddfa89..ffe2f24 100644 --- a/index.d.ts +++ b/index.d.ts @@ -26,6 +26,14 @@ export class AcornJsxParser extends acorn.Parser { tokContexts: typeof tokContexts }; + pos: number; + start: number; + input: string; + lineStart: number; + type: acorn.TokenType; + exprAllowed: boolean; + context: acorn.TokContext[]; + jsx_readToken(): string; jsx_readNewLine(normalizeCRLF: boolean): void; jsx_readString(quote: number): void; From def9eddcbbe5b9d1481656840b40223e6cbdb934 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 13 Feb 2022 06:16:45 +0800 Subject: [PATCH 05/19] fix: return `AcornJsxParser` from constructor --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index ffe2f24..43a1673 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,6 @@ import acorn from 'acorn'; -export const jsx: (options?: jsx.Options) => (BaseParser: typeof acorn.Parser) => typeof acorn.Parser; +export const jsx: (options?: jsx.Options) => (BaseParser: typeof acorn.Parser) => typeof AcornJsxParser export interface Options { allowNamespacedObjects?: boolean; From 2383cca62332617207e08ba0eaee2b98226ca7c0 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 13 Feb 2022 08:17:35 +0800 Subject: [PATCH 06/19] drop properties belonging on Acorn instead --- index.d.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/index.d.ts b/index.d.ts index 43a1673..811fa2b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -26,14 +26,6 @@ export class AcornJsxParser extends acorn.Parser { tokContexts: typeof tokContexts }; - pos: number; - start: number; - input: string; - lineStart: number; - type: acorn.TokenType; - exprAllowed: boolean; - context: acorn.TokContext[]; - jsx_readToken(): string; jsx_readNewLine(normalizeCRLF: boolean): void; jsx_readString(quote: number): void; From e4eca02af874a0fc00e4872ed68e89313cd57b07 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Mon, 25 Apr 2022 16:33:54 +0800 Subject: [PATCH 07/19] fix: use import with namespace specifier for acorn (avoids interop linting error) --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 811fa2b..73b5fa9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,4 @@ -import acorn from 'acorn'; +import * as acorn from 'acorn'; export const jsx: (options?: jsx.Options) => (BaseParser: typeof acorn.Parser) => typeof AcornJsxParser From d97bd96c364c86172d7f37fddf5ff55389e1bac6 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Fri, 6 May 2022 09:48:53 +0800 Subject: [PATCH 08/19] fix: switch `tokContexts` to type `TokContexts` (as not available as a named constant) --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 73b5fa9..155f593 100644 --- a/index.d.ts +++ b/index.d.ts @@ -14,7 +14,7 @@ export const tokTypes: { jsxTagStart: acorn.TokenType } & typeof acorn.tokTypes; -export const tokContexts: { +export type TokContexts = { tc_oTag: acorn.TokContext, tc_cTag: acorn.TokContext, tc_expr: acorn.TokContext @@ -23,7 +23,7 @@ export const tokContexts: { export class AcornJsxParser extends acorn.Parser { static readonly acornJsx: { tokTypes: typeof tokTypes; - tokContexts: typeof tokContexts + tokContexts: TokContexts }; jsx_readToken(): string; From 620551bed4f30f7080ffa18c72eb9fa3100a5ab8 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Fri, 6 May 2022 09:55:58 +0800 Subject: [PATCH 09/19] refactor: avoid exporting `jsx` as named export --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 155f593..41e6c6a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,6 @@ import * as acorn from 'acorn'; -export const jsx: (options?: jsx.Options) => (BaseParser: typeof acorn.Parser) => typeof AcornJsxParser +declare function jsx(options?: jsx.Options): (BaseParser: typeof acorn.Parser) => typeof AcornJsxParser; export interface Options { allowNamespacedObjects?: boolean; From 835ea91cc559c0d5e739333a8998ddc58c0708a4 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Fri, 6 May 2022 15:33:58 +0800 Subject: [PATCH 10/19] fix: in place of exporting non-existent class, export constructor and interface --- index.d.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 41e6c6a..7cad6d3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,6 @@ import * as acorn from 'acorn'; -declare function jsx(options?: jsx.Options): (BaseParser: typeof acorn.Parser) => typeof AcornJsxParser; +declare function jsx(options?: jsx.Options): (BaseParser: typeof acorn.Parser) => AcornJsxParser; export interface Options { allowNamespacedObjects?: boolean; @@ -20,12 +20,21 @@ export type TokContexts = { tc_expr: acorn.TokContext }; -export class AcornJsxParser extends acorn.Parser { - static readonly acornJsx: { +type P = typeof acorn.Parser; + +// We pick (statics) from acorn rather than plain extending to avoid complaint +// about base constructors needing the same return type (i.e., we return +// `IAcornJsxParser` here) +export interface AcornJsxParser extends Pick { + readonly acornJsx: { tokTypes: typeof tokTypes; tokContexts: TokContexts }; + new (options: acorn.Options, input: string, startPos?: number): IAcornJsxParser; +} + +export interface IAcornJsxParser extends acorn.Parser { jsx_readToken(): string; jsx_readNewLine(normalizeCRLF: boolean): void; jsx_readString(quote: number): void; From 54599840aac1f77f6c2fc11874d369e93c1f7431 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Thu, 12 May 2022 11:16:48 +0800 Subject: [PATCH 11/19] refactor: use without prefix --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 7cad6d3..d5e0bf0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,6 @@ import * as acorn from 'acorn'; -declare function jsx(options?: jsx.Options): (BaseParser: typeof acorn.Parser) => AcornJsxParser; +declare function jsx(options?: Options): (BaseParser: typeof acorn.Parser) => AcornJsxParser; export interface Options { allowNamespacedObjects?: boolean; From af6247d297f27acfec1f97e73b4d5e27e7fe377e Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Thu, 12 May 2022 11:28:40 +0800 Subject: [PATCH 12/19] refactor: export `TokTypes` interface and a single `jsx` export with call signature and `tokTypes` property in place of a separate `const tokTypes` --- index.d.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index d5e0bf0..e5d4da4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,18 +1,23 @@ import * as acorn from 'acorn'; -declare function jsx(options?: Options): (BaseParser: typeof acorn.Parser) => AcornJsxParser; +type tokTypes = typeof acorn.tokTypes; export interface Options { allowNamespacedObjects?: boolean; allowNamespaces?: boolean; } -export const tokTypes: { +export interface TokTypes extends tokTypes { jsxName: acorn.TokenType, jsxText: acorn.TokenType, jsxTagEnd: acorn.TokenType, jsxTagStart: acorn.TokenType -} & typeof acorn.tokTypes; +} + +declare const jsx: { + tokTypes: TokTypes; + (options?: acorn.Options): (BaseParser: typeof acorn.Parser) => AcornJsxParser +} export type TokContexts = { tc_oTag: acorn.TokContext, @@ -27,7 +32,7 @@ type P = typeof acorn.Parser; // `IAcornJsxParser` here) export interface AcornJsxParser extends Pick { readonly acornJsx: { - tokTypes: typeof tokTypes; + tokTypes: TokTypes; tokContexts: TokContexts }; From d80ceefcd843e1d22ad4382b36f477237fa9da5b Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Thu, 12 May 2022 11:31:51 +0800 Subject: [PATCH 13/19] fix: drop extra `export as namespace` --- index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index e5d4da4..b1bb833 100644 --- a/index.d.ts +++ b/index.d.ts @@ -59,5 +59,4 @@ export interface IAcornJsxParser extends acorn.Parser { jsx_parseElement(): acorn.Node; } -export as namespace jsx; export default jsx; From 1c2fa2c9c98c1195d496ec07baf0053b1ff039d3 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Thu, 12 May 2022 20:51:36 +0800 Subject: [PATCH 14/19] fix: use `exports = jsx` (and use jsx.Options) --- index.d.ts | 105 +++++++++++++++++++++++++++-------------------------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/index.d.ts b/index.d.ts index b1bb833..fea169c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,62 +1,65 @@ import * as acorn from 'acorn'; -type tokTypes = typeof acorn.tokTypes; - -export interface Options { - allowNamespacedObjects?: boolean; - allowNamespaces?: boolean; +declare const jsx: { + tokTypes: typeof acorn.tokTypes; + (options?: jsx.Options): (BaseParser: typeof acorn.Parser) => jsx.AcornJsxParser } -export interface TokTypes extends tokTypes { - jsxName: acorn.TokenType, - jsxText: acorn.TokenType, - jsxTagEnd: acorn.TokenType, - jsxTagStart: acorn.TokenType -} +declare namespace jsx { -declare const jsx: { - tokTypes: TokTypes; - (options?: acorn.Options): (BaseParser: typeof acorn.Parser) => AcornJsxParser -} + type tokTypes = typeof acorn.tokTypes; -export type TokContexts = { - tc_oTag: acorn.TokContext, - tc_cTag: acorn.TokContext, - tc_expr: acorn.TokContext -}; - -type P = typeof acorn.Parser; - -// We pick (statics) from acorn rather than plain extending to avoid complaint -// about base constructors needing the same return type (i.e., we return -// `IAcornJsxParser` here) -export interface AcornJsxParser extends Pick { - readonly acornJsx: { - tokTypes: TokTypes; - tokContexts: TokContexts + export interface TokTypes extends tokTypes { + jsxName: acorn.TokenType, + jsxText: acorn.TokenType, + jsxTagEnd: acorn.TokenType, + jsxTagStart: acorn.TokenType + } + + export interface Options { + allowNamespacedObjects?: boolean; + allowNamespaces?: boolean; + } + + export type TokContexts = { + tc_oTag: acorn.TokContext, + tc_cTag: acorn.TokContext, + tc_expr: acorn.TokContext }; - new (options: acorn.Options, input: string, startPos?: number): IAcornJsxParser; -} + type P = typeof acorn.Parser; + + // We pick (statics) from acorn rather than plain extending to avoid complaint + // about base constructors needing the same return type (i.e., we return + // `IAcornJsxParser` here) + export interface AcornJsxParser extends Pick { + readonly acornJsx: { + tokTypes: TokTypes; + tokContexts: TokContexts + }; + + new (options: acorn.Options, input: string, startPos?: number): IAcornJsxParser; + } -export interface IAcornJsxParser extends acorn.Parser { - jsx_readToken(): string; - jsx_readNewLine(normalizeCRLF: boolean): void; - jsx_readString(quote: number): void; - jsx_readEntity(): string; - jsx_readWord(): void; - jsx_parseIdentifier(): acorn.Node; - jsx_parseNamespacedName(): acorn.Node; - jsx_parseElementName(): acorn.Node | string; - jsx_parseAttributeValue(): acorn.Node; - jsx_parseEmptyExpression(): acorn.Node; - jsx_parseExpressionContainer(): acorn.Node; - jsx_parseAttribute(): acorn.Node; - jsx_parseOpeningElementAt(startPos: number, startLoc?: acorn.SourceLocation): acorn.Node; - jsx_parseClosingElementAt(startPos: number, startLoc?: acorn.SourceLocation): acorn.Node; - jsx_parseElementAt(startPos: number, startLoc?: acorn.SourceLocation): acorn.Node; - jsx_parseText(): acorn.Node; - jsx_parseElement(): acorn.Node; + export interface IAcornJsxParser extends acorn.Parser { + jsx_readToken(): string; + jsx_readNewLine(normalizeCRLF: boolean): void; + jsx_readString(quote: number): void; + jsx_readEntity(): string; + jsx_readWord(): void; + jsx_parseIdentifier(): acorn.Node; + jsx_parseNamespacedName(): acorn.Node; + jsx_parseElementName(): acorn.Node | string; + jsx_parseAttributeValue(): acorn.Node; + jsx_parseEmptyExpression(): acorn.Node; + jsx_parseExpressionContainer(): acorn.Node; + jsx_parseAttribute(): acorn.Node; + jsx_parseOpeningElementAt(startPos: number, startLoc?: acorn.SourceLocation): acorn.Node; + jsx_parseClosingElementAt(startPos: number, startLoc?: acorn.SourceLocation): acorn.Node; + jsx_parseElementAt(startPos: number, startLoc?: acorn.SourceLocation): acorn.Node; + jsx_parseText(): acorn.Node; + jsx_parseElement(): acorn.Node; + } } -export default jsx; +export = jsx; From 4cfaf9fb9deea8bb3ba7968825d375258a972cb0 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 15 May 2022 12:08:36 +0800 Subject: [PATCH 15/19] refactor: prefer interface over type, avoid redundant `export` on types within namespace, rename to use Ctor convention --- index.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/index.d.ts b/index.d.ts index fea169c..963f7e8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,46 +2,46 @@ import * as acorn from 'acorn'; declare const jsx: { tokTypes: typeof acorn.tokTypes; - (options?: jsx.Options): (BaseParser: typeof acorn.Parser) => jsx.AcornJsxParser + (options?: jsx.Options): (BaseParser: typeof acorn.Parser) => jsx.AcornJsxParserCtor } declare namespace jsx { type tokTypes = typeof acorn.tokTypes; - export interface TokTypes extends tokTypes { + interface TokTypes extends tokTypes { jsxName: acorn.TokenType, jsxText: acorn.TokenType, jsxTagEnd: acorn.TokenType, jsxTagStart: acorn.TokenType } - export interface Options { + interface Options { allowNamespacedObjects?: boolean; allowNamespaces?: boolean; } - export type TokContexts = { + interface TokContexts { tc_oTag: acorn.TokContext, tc_cTag: acorn.TokContext, tc_expr: acorn.TokContext - }; + } type P = typeof acorn.Parser; // We pick (statics) from acorn rather than plain extending to avoid complaint // about base constructors needing the same return type (i.e., we return - // `IAcornJsxParser` here) - export interface AcornJsxParser extends Pick { + // `AcornJsxParser` here) + interface AcornJsxParserCtor extends Pick { readonly acornJsx: { tokTypes: TokTypes; tokContexts: TokContexts }; - new (options: acorn.Options, input: string, startPos?: number): IAcornJsxParser; + new (options: acorn.Options, input: string, startPos?: number): AcornJsxParser; } - export interface IAcornJsxParser extends acorn.Parser { + interface AcornJsxParser extends acorn.Parser { jsx_readToken(): string; jsx_readNewLine(normalizeCRLF: boolean): void; jsx_readString(quote: number): void; From 41e8fcdb8e510f86845146198db8668b4b2ba735 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 15 May 2022 12:20:46 +0800 Subject: [PATCH 16/19] refactor: avoid extra type alias --- index.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 963f7e8..e0c0c2d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -27,12 +27,10 @@ declare namespace jsx { tc_expr: acorn.TokContext } - type P = typeof acorn.Parser; - // We pick (statics) from acorn rather than plain extending to avoid complaint // about base constructors needing the same return type (i.e., we return // `AcornJsxParser` here) - interface AcornJsxParserCtor extends Pick { + interface AcornJsxParserCtor extends Pick { readonly acornJsx: { tokTypes: TokTypes; tokContexts: TokContexts From 71b7e6101a583c6d4d8ed604d325f57ed36dfcbb Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 15 May 2022 12:22:41 +0800 Subject: [PATCH 17/19] refactor: avoid exporting `tokTypes` and use CamelCase --- index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index e0c0c2d..549cd2d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -5,11 +5,11 @@ declare const jsx: { (options?: jsx.Options): (BaseParser: typeof acorn.Parser) => jsx.AcornJsxParserCtor } -declare namespace jsx { +type AcornTokTypes = typeof acorn.tokTypes; - type tokTypes = typeof acorn.tokTypes; +declare namespace jsx { - interface TokTypes extends tokTypes { + interface TokTypes extends AcornTokTypes { jsxName: acorn.TokenType, jsxText: acorn.TokenType, jsxTagEnd: acorn.TokenType, From b9766018af639ec1f5d4d563c6626211e8d46d73 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 15 May 2022 12:40:58 +0800 Subject: [PATCH 18/19] refactor: for now add a commit which redundantly but safely indicates the `tokTypes` type --- index.d.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 549cd2d..44dfaa0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,7 +1,14 @@ import * as acorn from 'acorn'; +interface TokTypes extends AcornTokTypes { + jsxName: acorn.TokenType, + jsxText: acorn.TokenType, + jsxTagEnd: acorn.TokenType, + jsxTagStart: acorn.TokenType +} + declare const jsx: { - tokTypes: typeof acorn.tokTypes; + tokTypes: TokTypes; (options?: jsx.Options): (BaseParser: typeof acorn.Parser) => jsx.AcornJsxParserCtor } From fd681708427f6b713f0820e00e65826ed16eb96f Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 15 May 2022 12:58:19 +0800 Subject: [PATCH 19/19] refactor: remove some redundancy --- index.d.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/index.d.ts b/index.d.ts index 44dfaa0..66ef62f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,6 @@ import * as acorn from 'acorn'; -interface TokTypes extends AcornTokTypes { +interface JsxTokTypes extends AcornTokTypes { jsxName: acorn.TokenType, jsxText: acorn.TokenType, jsxTagEnd: acorn.TokenType, @@ -8,7 +8,7 @@ interface TokTypes extends AcornTokTypes { } declare const jsx: { - tokTypes: TokTypes; + tokTypes: JsxTokTypes; (options?: jsx.Options): (BaseParser: typeof acorn.Parser) => jsx.AcornJsxParserCtor } @@ -16,12 +16,7 @@ type AcornTokTypes = typeof acorn.tokTypes; declare namespace jsx { - interface TokTypes extends AcornTokTypes { - jsxName: acorn.TokenType, - jsxText: acorn.TokenType, - jsxTagEnd: acorn.TokenType, - jsxTagStart: acorn.TokenType - } + type TokTypes = JsxTokTypes interface Options { allowNamespacedObjects?: boolean;