Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[utils] Use template literal types to parse esquery selectors to automatically type complex selectors #4065

Open
Labels
accepting prsGo ahead, send a pull request that resolves this issueenhancementNew feature or requestpackage: utilsIssues related to the @typescript-eslint/utils package
@bradzacher

Description

@bradzacher

Template literal types (https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html) were released in TS 4.1. since their announcement people have done all sorts of crazy and wonderful things with them - from simple cases like auto prefixing keys to ridiculous things like SQL query parsers.

We should be able to leverage them as part of our ESLint types to automatically type thenode argument of an ESLint rule selector.

We don't need to handle every crazy case (selectors can get pretty complicated!) but at least handling things like property existence checks, sibling checks, and the:exit special selector would be great.

For reference here are the docs on, and implementation of esquery selectors
https://github.com/estools/esquery

It's worth mentioning that if we find that template literal types are too slow or complex, an alternative might be to consider using codegen to generate a number of common cases statically. But I'd love to achieve this using template literal types if possible!

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancementNew feature or requestpackage: utilsIssues related to the @typescript-eslint/utils package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp