Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

A Typescript definitions file would be great #45

Open
Taytay opened this issue Jun 22, 2014 · 3 comments
Open

A Typescript definitions file would be great #45

Taytay opened this issue Jun 22, 2014 · 3 comments

Comments

@Taytay
Copy link
Contributor

Taytay commented Jun 22, 2014

I'll be using asynquence in Typescript in addition to Javascript.

A definition file is a header file. A file like this (asynquence.d.ts) would tell Typescript what the asynquence API looks like, so that it can auto-complete, give compiler errors if you pass the wrong type, leave off a parameter, etc. It will obviously take some familiarity with Typescript to write one. There are definition files for most popular frameworks/libraries: DefinitelyTyped project.

I will start playing with generating one, and will post back here if I have much luck.

@getify
Copy link
Owner

getify commented Jun 23, 2014

Thanks! :)

@shaddyhm
Copy link

shaddyhm commented Oct 16, 2017

@getify I did a pull request adding types. Let me know if I am missing anything.

[Editor: for reference, the PR: #104]

@getify
Copy link
Owner

getify commented Oct 16, 2017

I don't know typescript, so I cannot say for sure, but the types file seems to indicate some assumptions of usage that are not strictly required. For example, the val(..) method can accept either a function or an immediate value, but the types seem to indicate it only takes a function.

Is the intention of a TS file to provide a guideline that restricts someone's usage of an API to a potentially safer subset, or is the intention to encode all of the possible types for any input or output operation?

If the former, then this particular opinionated usage seems like it should be at a minimum some optional thing, like maybe in a folder of possible definitions that someone could pick from to opt-in to.

If the latter, I don't think from what I'm reading that it adequately does that. Moreover, as many of the inputs/outputs can in fact be "Any" (function, sequence, regular value), does that mean that having type definitions for this API is not particularly helpful? What's the point of having a bunch of "Any"s all over the definition file?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants