MithrilJS / mithril.d.ts

Types for mithril.js
MIT License
80 stars 11 forks source link

ospec.d.ts #39

Closed maranomynet closed 5 years ago

maranomynet commented 5 years ago

Hi, I made a quick stab at writing TypeScript definitions for ospec.

https://gist.github.com/maranomynet/1368f8ce0fd344efcd3b9dd5dea637b4

(BTW: Any corrections or improvements would we much appreciated.)

So, what would be the appropriate next step in order to get this published somewhere?

spacejack commented 5 years ago

@maranomynet Apologies, I had started work on this a while ago (repo here) but haven't put aside the time to actually finish it off.

I took a quick look at yours, and it looks like you have some types I missed. Our approaches are a bit different, I'm not sure if one has an advantage over another.

I'm totally fine with you taking the lead and submitting to Definitely Typed if you like, I probably won't have much time to get back into this until next week.

maranomynet commented 5 years ago

I'm a bit of a newbie when it comes to writing definitions, and it shows. So nice to learn from how your approach is different.

I'll fork DefinitelyTyped, make an ospec branch based on your definition file, adding the missing bits and some "tests", and then @-mention you for a quick review/sanity check before submitting a formal PR. Sound ok?

spacejack commented 5 years ago

Sure, you can include isiahmeadows on that as well.

One thing I was going for with my definitions (which might also work with yours, I haven't tested them) is you can just import o from 'ospec' and all types are available on o. Eg: o.Results, o.Test, etc.

maranomynet commented 5 years ago

I see. What would be the use case where one needs direct access to Results, Test, etc.?

maranomynet commented 5 years ago

err... I guess Results and Reporter are useful, but what about Test and Spy and Assertion?

(I'm simply curious.)

spacejack commented 5 years ago

Not sure there will always be a use case, I just don't like to be in a situation where I can't declare the type of something in userland.

let test: o.Test
// later...
test = o(value, f)
// or
function myfunc (spy: o.Spy<A, R>) {...

All types in the Ospec namespace are automatically available to userland code.