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

Unexpected result using latest typescript 5.5.3 #98

Open
mauriciovillalobos opened this issue Jul 22, 2024 · 2 comments
Open

Unexpected result using latest typescript 5.5.3 #98

mauriciovillalobos opened this issue Jul 22, 2024 · 2 comments

Comments

@mauriciovillalobos
Copy link

Seems like there is something wrong with the interactions using typescript 5.5.3

Given a simple reproduction scenario

import { ast, query } from '@phenomnomnominal/tsquery';

const jestConfig = `
  /* eslint-disable */
  export default {
    coverageDirectory: '../../coverage/apps'
  };
`;

const jestAst = ast(jestConfig);
const nodes = query(
  jestAst,
  'Identifier[name="coverageDirectory"] ~ StringLiteral',
  { visitAllChildren: true }
);
console.log(nodes.length); // <--

Logs 1 using typescript@5.4.5 and 0 using typescript@5.5.3

Haven't checked further to know specifics about why it fails.

This scenario is available on stackblitz https://stackblitz.com/edit/stackblitz-starters-b9kfqj?file=index.ts

@phenomnomnominal
Copy link
Owner

Interesting, the AST is the same so it looks like something in the traversal logic must have changed. I don't have time to debug this right now, so here's a quick solution:

PropertyAssignment:has(Identifier[name="coverageDirectory"]) StringLiteral

I think it's a slightly clearer query anyway 😊

@mauriciovillalobos
Copy link
Author

Hey, thanks for the quick response.

This is being used by another library which is the one my project depends on. I'll bring it up in that other repo.

Feel free to leave this issue open or close it as you see fit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants