Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
bashmish committed Oct 21, 2024
1 parent 4361561 commit 0f5a468
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/pluginutils/src/attachScopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const attachScopes: AttachScopes = function attachScopes(ast, propertyName = 'sc
}

// create new block scope
if (node.type === 'BlockStatement' && !/Function/.test(parent.type)) {
if (node.type === 'BlockStatement' && parent && !/Function/.test(parent.type)) {
newScope = new Scope({
parent: scope,
block: true
Expand Down
8 changes: 4 additions & 4 deletions packages/pluginutils/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { BaseNode } from 'estree';
import type { Node } from 'estree';

export interface AttachedScope {
parent?: AttachedScope;
isBlockScope: boolean;
declarations: { [key: string]: boolean };
addDeclaration(node: BaseNode, isBlockDeclaration: boolean, isVar: boolean): void;
addDeclaration(node: Node, isBlockDeclaration: boolean, isVar: boolean): void;
contains(name: string): boolean;
}

Expand Down Expand Up @@ -37,7 +37,7 @@ export function addExtension(filename: string, ext?: string): string;
* Each `Scope` object has a `scope.contains(name)` method that returns `true`
* if a given name is defined in the current scope or a parent scope.
*/
export function attachScopes(ast: BaseNode, propertyName?: string): AttachedScope;
export function attachScopes(ast: Node, propertyName?: string): AttachedScope;

/**
* Constructs a filter function which can be used to determine whether or not
Expand Down Expand Up @@ -66,7 +66,7 @@ export function dataToEsm(data: unknown, options?: DataToEsmOptions): string;
* Extracts the names of all assignment targets based upon specified patterns.
* @param param An `acorn` AST Node.
*/
export function extractAssignedNames(param: BaseNode): string[];
export function extractAssignedNames(param: Node): string[];

/**
* Constructs a bundle-safe identifier from a `string`.
Expand Down

0 comments on commit 0f5a468

Please sign in to comment.