Skip to content

Commit

Permalink
fix: handle import type statement [sc-0] (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
umutuzgur authored Jan 31, 2023
1 parent 50aff41 commit 827cf71
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { add } from './dep1'
import { subtract as random } from './dep4'
import { subtract } from './dep2'
import * as axios from 'axios'
import type { UniqueType } from './type'

export function doMath (num: number): number {
return add(num, subtract(10, 7))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type UniqueType = {
field: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ describe('dependency-parser - parser()', () => {
toAbsolutePath('dep2.ts'),
toAbsolutePath('dep3.ts'),
toAbsolutePath('dep4.js'),
toAbsolutePath('type.ts'),
])
})

Expand Down
13 changes: 12 additions & 1 deletion package/src/services/check-parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@ import * as path from 'path'
import * as fs from 'fs'
import * as acorn from 'acorn'
import * as walk from 'acorn-walk'
import { TSESTree } from '@typescript-eslint/typescript-estree'
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree'
import { Collector } from './collector'
import { DependencyParseError } from './errors'

// Our custom configuration to handle walking errors
// eslint-disable-next-line @typescript-eslint/no-empty-function
const ignore = (_node: any, _st: any, _c: any) => {}
Object.values(AST_NODE_TYPES).forEach((astType) => {
// Only handle the TS specific ones
if (!astType.startsWith('TS')) {
return
}
walk.base[astType] = walk.base[astType] ?? ignore
})

type Module = {
localDependencies: Array<string>,
npmDependencies: Array<string>
Expand Down

0 comments on commit 827cf71

Please sign in to comment.