Skip to content

Add Regex String Types #43048

Closed
Closed
@NightshadeX9X

Description

@NightshadeX9X

Add Regex String Types

⭐ Suggestion

I'd like to see Regex types be added into typescript. This would allow us to create types for specific necessary strings. I feel like adding template literal types was a step in the right direction, but this would be even better.

📃 Example

type AllUppercase = /^[A-Z]+$/;

let myLowercaseVariable: AllUppercase = "test"; // error
let myUppercaseVariable: AllUppercase = "TEST"; // works

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions