Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predefined Input can not be assigned to InputSource when using with TypeScript < 4.7 #62

Open
tim3trick opened this issue Aug 23, 2022 · 6 comments

Comments

@tim3trick
Copy link

I just installed magic-regexp via yarn add magic-regexp and tried the first example from https://regexp.dev/getting-started/examples

Typescript does not like it though: Argument of type 'Input<"\\d", never>' is not assignable to parameter of type 'InputSource<string, never>'.

The code can also be simplified even more:
const regex = createRegExp(oneOrMore(digit));

I have created a codesandbox for showcasing this: https://codesandbox.io/s/gracious-swartz-3sdfcs

@tim3trick
Copy link
Author

Addition: oneOrMore('x') fails with the same when used inside and,
i have updated the sandbox: https://codesandbox.io/s/angry-wave-fr0m5s?file=/src/index.ts

Code that fails:
createRegExp( oneOrMore('a') .and('.') .and(oneOrMore('b')) )

@danielroe danielroe added the bug Something isn't working label Aug 23, 2022
@danielroe
Copy link
Member

You can see it working fine in stackblitz (here). It also works fine for me locally.

CleanShot 2022-08-23 at 10 59 54

Are you getting this locally, or just in codesandbox (which seems to be using TS 4.4)? If so, what is your local TypeScript version?

@danielroe danielroe removed the bug Something isn't working label Aug 23, 2022
@tim3trick
Copy link
Author

I get this locally with 4.6.3 as well.

@danielroe
Copy link
Member

Yes - confirmed. You need features from TS 4.7+; versions below that show this error.

@danielroe danielroe changed the title Bug: Predefined Input can not be assigned to InputSource Predefined Input can not be assigned to InputSource when using with TypeScript < 7.4 Aug 23, 2022
@tim3trick
Copy link
Author

Excuse the question, but am I supposed to to something with the ticket?

@danielroe
Copy link
Member

danielroe commented Aug 27, 2022

@tim3trick No need to do anything. For now you can use a newer version of TypeScript. I'll keep this open until I've had a chance to see whether it's possible to make the features of this library work with earlier versions of TS or whether I should instead mention it in the README.

@danielroe danielroe changed the title Predefined Input can not be assigned to InputSource when using with TypeScript < 7.4 Predefined Input can not be assigned to InputSource when using with TypeScript < 4.7 Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants