Skip to content

call to imported throw does not work on nested properties #45

@michaelangeloio

Description

@michaelangeloio

The following code works:

export const someObjectLiteral = {
  objectLiteralThrow({ someArg}: { someArg: string}) {
    throw new Error('hi khue')
  },
  nestedObjectLiteral: {
    nestedObjectLiteralThrow: () => {
      throw new Error('hi khue')
    },
  },
}

export const callToLiteral = () => {
  someObjectLiteral.nestedObjectLiteral.nestedObjectLiteralThrow()
  SomeObject.someExampleThrow()
}

However the following code does not:

import { someObjectLiteral } from './something'

export const callToLiteral = () => {
  someObjectLiteral.nestedObjectLiteral.nestedObjectLiteralThrow()
  SomeObject.someExampleThrow()
}

Most likely need to revisit the import_usage_finder.rs implementation to track nested properties as it visits the AST.
https://github.com/michaelangeloio/does-it-throw/blob/main/crates/does-it-throw/src/import_usage_finder.rs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions