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
Fake Typescript support #562
Comments
All I actually need is for the function's signature to be written like function parse(input: string): MyType { ... } (or whatever) |
You can be inspired by this. Beforehand it is necessary to label types of all code blocks, it can be done with annotations. After this preparatory work it is possible to enter information on types in the generator. |
@Mingun - this is interesting, but also very difficult to understand Your annotation thing seems to be a near-ideal case here - that would allow the annotation of individual parsing rules with types, allowing the return of more than one real type |
(The weird moment when I understood @Mingun is Russian too.) Actually TypeScript won't make development of grammars any easier, because you have to annotate types everywhere, and because its type system is kinda broken. Recently I've made a small experiment on making a PEG.ts, and TypeScript's type checker spew such horrific error messages when I fed it with recursive types, that I couldn't even finish it. I'd recommend to look rather into Infernu support. |
@polkovnikov-ph - yeah, that choice isn't in my hands, and besides, as a 1990s c++ template dev, typescript's error messages do not scare me |
Hi! Related to this, in the plugin We did it using a table of pairs I am cc you, just in case you decided to optionally add type information on pegjs at the DSL level to anonnate productions directly. |
People are still asking for this in #597 The new maintainer created and housed a This is a same-day "we have typescript" with no major changes, which can be done in five lines of code plus the replacement es6 module footer. I don't understand why it isn't being done I have a patch ready against |
metadevpro/ts-pegjs#92 - plan to enhance existing JS results using estree injection |
Issue type
Wut
So, I'm actually pretty into @pjmolina 's typescript plugin from #514. However, at the end, it returns
all
.I was hoping that you would help me cheat. I actually just want to write the signature to
parse/1
slightly differently, by adding some kind of thing to thepeg
syntax that says "make this the return type ofparse/1
," and also by marking the in argument:string
if there's an out type. Then, you'd just have to blindly typecast the last return value, et voila.To a typescript (or flowtype) user, this would have a profound impact on checkability, even though it's fake.
How many cappucinos do I need to mail you in order to make this happen, and to what address would I send them
The text was updated successfully, but these errors were encountered: