Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
fix: import Identifier/Literal type through TSESTree
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwilsonperkin committed Sep 28, 2023
1 parent d0ee37d commit 61aba0f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/traverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from './cache';
import { log } from './log';
import { MapLike } from 'typescript';
import type { TSESTree } from '@typescript-eslint/types';

export interface FileStats {
path: string;
Expand Down Expand Up @@ -286,13 +287,13 @@ async function parse(path: string, config: TraverseConfig): Promise<FileStats> {
target = source.quasis[0].value.cooked;
}
} else {
target = (source as any).value as string;
target = (source as TSESTree.Literal).value as string;
}
break;

// require('./x') || await require('./x')
case AST_NODE_TYPES.CallExpression: {
if ((node.callee as any)?.name !== 'require') {
if ((node.callee as TSESTree.Identifier)?.name !== 'require') {
break;
}

Expand All @@ -307,7 +308,7 @@ async function parse(path: string, config: TraverseConfig): Promise<FileStats> {
target = argument.quasis[0].value.cooked;
}
} else {
target = (argument as any).value as string;
target = (argument as TSESTree.Literal).value as string;
}
break;
}
Expand Down

0 comments on commit 61aba0f

Please sign in to comment.