Skip to content

Proposal : regex literal type #6902

Closed
Closed

Description

Hello,
I would suggest to add a "regex literal" type to make ensuring that a string data matches a pattern at assigment.

As the literal string feature has been added in the latest release, i found very convenient to type my variables with, e.g. for typing my react props (size : "small"| "big" )... On the same idea, it could be convenient to be able to type a variable with a pattern.

Example :

    var myString : /\d{3}.*\d{2}/;
    myString="555hhhhh44" ; //correct
    myString="55dsds5dss4"; //error

In react it could be vey useful for defining a react prop like phone numbers, emails, dates, ...

regards
Xavier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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