You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
first(rule(matchRegExp(/I am (.*)/),match=>match.reply(`hi, ${match.groups[1]}`)),
...
);
What type is match? All we really know is that it's the input type to matchRegExp plus IRegExpMatch, which is to say that matchRegExp adds groups to the input type. But as to the overall type, and thus e.g. the type of match.reply, we've got nothing, because we don't specify the input type to rule. Which, by the way, is the answer for now:
first<YourTypeHere>(rule<YourTypeHere>(matchRegExp(/I am (.*)/),match=>match.reply(`hi, ${match.groups[1]}`)),
...
);
There are two things we'd like to be able to do here to make things more concise. The first is to be able to infer the type of rule by setting it in the enclosing first:
first<YourTypeHere>(rule(matchRegExp(/I am (.*)/),match=>match.reply(`hi, ${match.groups[1]}`)),// type is not named, so infer it to be YourTypeHere
...
);
Until one or both of these suggestions is implemented, we're just going to be a little less concise than I would prefer if you want typing, which I do.
If you leave it out then match will always be any, which is no worse than working in plain old JavaScript...
The text was updated successfully, but these errors were encountered:
Consider this:
What type is
match
? All we really know is that it's the input type tomatchRegExp
plusIRegExpMatch
, which is to say thatmatchRegExp
addsgroups
to the input type. But as to the overall type, and thus e.g. the type ofmatch.reply
, we've got nothing, because we don't specify the input type torule
. Which, by the way, is the answer for now:There are two things we'd like to be able to do here to make things more concise. The first is to be able to infer the type of rule by setting it in the enclosing
first
:That this does not work is TypeScript issue #15680.
The other is to create typed shorthands for the helpers:
That this does not work is TypeScript issue #15877
Until one or both of these suggestions is implemented, we're just going to be a little less concise than I would prefer if you want typing, which I do.
If you leave it out then match will always be
any
, which is no worse than working in plain old JavaScript...The text was updated successfully, but these errors were encountered: