Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
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!