Enhancement: [no-type-alias] allowTemplateLiterals #5095
Labels
enhancement: plugin rule option
New rule option for an existing eslint-plugin rule
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
wontfix
This will not be worked on
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Link to the rule's documentation
https://typescript-eslint.io/rules/no-type-alias
Description
Template Literals is a powerfull TypeScript feature, allowing to specify exact form a string may take. Using template literals allows to force specific input form, eg:
but also allowing to mapping keys to another type (see examples in link above).
There might be (and in my case actually is) a case, where type aliasing is generally not allowed (apart from unions / intersections), with template literal being exception, as it's recommended to share the single definition of this type rather than have to use the template literal type in many different places, as that may lead to issues when the form of the template literal type changes.
I'd love to suggest adding new
allowTemplateLiterals
option that would handle such case. Template Literals are a new, unique form of typescript type and while there is an option to whitelist any other type (mapped types, generics, tuples, literals, etc), there is no real way to whitelist template literals.Fail
Pass
Additional Info
For reference, #5092 (unmerged at the time of creating this issue) adds handling of type literals which are unhandled in current version of the plugin, see #5043
The text was updated successfully, but these errors were encountered: