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

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

Open
michaelangeloio opened this issue Nov 10, 2023 · 0 comments
Open

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

michaelangeloio opened this issue Nov 10, 2023 · 0 comments
Labels
enhancement New feature or request limitation

Comments

@michaelangeloio
Copy link
Owner

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

@michaelangeloio michaelangeloio added enhancement New feature or request limitation labels Nov 10, 2023
@michaelangeloio michaelangeloio changed the title calls to imported throws do not work on nested properties call to imported throw does not work on nested properties Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request limitation
Projects
None yet
Development

No branches or pull requests

1 participant