From c120fb8340752419bee010356bc744f6abc2b82e Mon Sep 17 00:00:00 2001 From: Prev Wong Date: Tue, 2 Apr 2024 20:15:33 +0800 Subject: [PATCH] fix: stringifier types --- packages/parser/src/index.ts | 1 + packages/parser/src/parser.ts | 2 -- packages/parser/src/stringifier.ts | 7 ++----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/parser/src/index.ts b/packages/parser/src/index.ts index 5a766dac..66e9e9b4 100644 --- a/packages/parser/src/index.ts +++ b/packages/parser/src/index.ts @@ -1,2 +1,3 @@ export * from './parser'; +export * from './stringifier'; export * from './utils'; diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index fd183636..d0795e41 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -9,8 +9,6 @@ import { Stringifier, StringifierOpts } from './stringifier'; import { TokenType } from './tokens'; import { getIdentifierFromStr } from './utils'; -export { StringifierOpts } from './stringifier'; - const parseWithAcorn = (source: string, loc: number) => { const JSXParser = AcornParser.extend(jsx()); diff --git a/packages/parser/src/stringifier.ts b/packages/parser/src/stringifier.ts index 1c74af88..4ac2361d 100644 --- a/packages/parser/src/stringifier.ts +++ b/packages/parser/src/stringifier.ts @@ -6,10 +6,7 @@ import { EXTERNAL_IDENTIFIER_PREFIX_SYMBOL } from './utils'; import { Writer, WriterResult } from './writer'; export type StringifierOpts = { - onStringifyNode: ( - node: t.ASTNode, - stringifier: _Stringifier - ) => t.ASTNode | null | undefined; + onStringifyNode: (node: t.ASTNode) => t.ASTNode | null | undefined; }; class _Stringifier { @@ -101,7 +98,7 @@ class _Stringifier { } stringify(node: t.ASTNode, precedence: Precedence = Precedence.Sequence) { - const value = this.opts.onStringifyNode(node, this); + const value = this.opts.onStringifyNode(node); if (value) { node = value;