Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove acorn-walk ambient type definitions #4391

Merged
merged 1 commit into from Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/utils/pureComments.ts
@@ -1,5 +1,5 @@
import * as acorn from 'acorn';
import { type BaseWalker, base as basicWalker } from 'acorn-walk';
import { base as basicWalker } from 'acorn-walk';
import {
BinaryExpression,
CallExpression,
Expand Down Expand Up @@ -29,7 +29,7 @@ interface NodeWithComments extends acorn.Node {
function handlePureAnnotationsOfNode(
node: acorn.Node,
state: CommentState,
type: string = node.type
type = node.type
): void {
const { annotations } = state;
let comment = annotations[state.annotationIndex];
Expand All @@ -38,7 +38,7 @@ function handlePureAnnotationsOfNode(
comment = annotations[++state.annotationIndex];
}
if (comment && comment.end <= node.end) {
(basicWalker as BaseWalker<CommentState>)[type](node, state, handlePureAnnotationsOfNode);
basicWalker[type](node, state, handlePureAnnotationsOfNode);
while ((comment = annotations[state.annotationIndex]) && comment.end <= node.end) {
++state.annotationIndex;
annotateNode(node, comment, false);
Expand Down
11 changes: 0 additions & 11 deletions typings/declarations.d.ts
Expand Up @@ -9,17 +9,6 @@ declare module 'rollup-plugin-string' {
export const string: import('rollup').PluginImpl;
}

declare module 'acorn-walk' {
type WalkerCallback<TState> = (node: acorn.Node, state: TState) => void;
type RecursiveWalkerFn<TState> = (
node: acorn.Node,
state: TState,
callback: WalkerCallback<TState>
) => void;
export type BaseWalker<TState> = Record<string, RecursiveWalkerFn<TState>>;
export const base: BaseWalker<unknown>;
}

declare module 'is-reference' {
export default function is_reference(
node: NodeWithFieldDefinition,
Expand Down