Would be great to see some some typescript support (:
DefinitelyTyped does have typings for v4.4.2 here.
Would be great to see the typings officially supported and packaged with the repo though.
I definitely agree with this. Application code does not need to be typed, but it really helps when library code is typed.
No. Typings should never be packaged with individual repos, especially because maintainers who don't use typescript have no friendly way to keep the typings in sync.
DT or similar is the proper place for types, until JavaScript has them natively.
Typings should never be packaged with individual repos
I'll have to disagree with this. From the typescript handbook:
If you control the npm package you are publishing declarations for, then the first approach [bundling with your npm package] is favored. That way, your declarations and JavaScript always travel together.
This however is true:
especially because maintainers who don't use typescript have no friendly way to keep the typings in sync.
IMHO it'll be easier to maintain type definitions if they reside in the npm package. If the maintainers are willing to keep it updated, ofcourse.
The reason I posted the issue was to see if there's any interest in officially supporting typescript. Seems like the answer is no, and that's totally okay :)
That quote from the handbook only applies if you, the author of a package, also use TypeScript. If the author(s) do not use TypeScript, and TypeScript requires that those authors be even aware that TypeScript exists, then TypeScript has a flaw that needs addressing upstream.
I'm not sure I've been clear with my request. I was looking forward to official type definitions for tape, rather than third party definitions from DT or types. DT/types almost always has high quality typings, but I'd choose typings reviewed by the original maintainers over DT/types anyday.
I can still get typings from @types (previously from DT). Here's the npm @types package for tape. Notice that it's still 4.2.29 when tape is 4.6.3.
Provided tape has a fair number of typescript users, _official_ type definitions would help a long way. As a side effect, d.ts also means better javascript intellisense in VS Code, WebStorm, etc.
Type definitions add type-safety to javascript libraries for typescript users. Whether the author uses typescript or not is irrelevant. What matters is whether the author wishes to support typescript.
That only works if there's a CI task that fails if the typings are incorrect. How can that be done without imposing a typescript dev dependency on the package?
A devDependency on typescript will be required only to run tests. Alternatively, typescript could be installed globally in the build environment if that's an option. (d.ts files are tested by compiling a .ts file using tsc.)
The typings on DT aren't correct and/or not up to date. (the Test type is declared as an interface rather than a class/constructor, which means you can't access Test.prototype to override assertions, or use declaration merging to add new assertions. also, the newer extra arguments are missing.)
I could fix them, but it feels futile, because they'll just fall out of date again. (and I don't know how to, so I'd have to figure that out first.)
It would be much more gratifying to contribute to official type-definitions, if they shipped with the package - I'd be happy to update them via a PR, which would be easy, whereas having to sidetrack to unofficial typings in a separate package is just an annoying chore 馃檮
@mindplay-dk I鈥檓 afraid that鈥檚 just the risk of using types in a language without them. If they were in this package they鈥檇 fall out of sync too, since the maintainers don鈥檛 use TypeScript.
@ljharb you got this all wrong imo. TS typings packaged separately are almost always out of sync. The typings have one or two things wrong which defeats the purpose. TS is gradual typing - types can be incorporated slowly. It's not that hard. It's not that different than JS. You will get highly quality contributions too most likely.
If they were in this package they'd fall out of sync too
well, I think what people are requesting is that the tape codebase to be written in TS, not just an index.d.ts file.
@ORESoftware
well, I think what people are requesting is that the tape codebase to be written in TS, not just an index.d.ts file.
No, just the type definitions. VueJS is a great example.
@ljharb TBH your argument about maintainers not using it makes sense to me, and I agree. This discussion basically boils down to whether the maintainers wish to support typescript to make tape a first class choice for typescript users.
The tape codebase will not be written in anything but JavaScript, which includes alleged supersets (that aren鈥檛 always supersets).
Thus, the types will have to be maintained by someone who isn鈥檛 a tape author.
Thus, it makes sense not to keep them in this repo. DefinitelyTyped is the conventional place for out-of-repo types to live.
I鈥檓 not sure what more there is to discuss :-)
Fair Enough!
I would encourage you, however, to submit accurate typings for all the tape versions to DT, to benefit all TypeScript users - and if there鈥檚 anything short of using TS that i can do to make it easier for TS users to use tape, I鈥檇 be happy to.
The tape codebase will not be written in anything but JavaScript
that seems like a stubborn attitude :)
is it just because TS is the enemy?
Expecting someone to learn a different language just to support you is an interesting attitude as well :-)
TS is not that different than JavaScript dogg. And certainly not that different from _idiomatic ES6_. There's not much of an expectation here. But I will tell you one thing. I want to build a product for a company. I am looking at Node.js in 2018 and comparing it performance wise etc, to other languages like Golang. The static typing and speed of other languages is just too much to turn down. If libraries in Node-land like Sequelize were written in TS, I might choose Node.js, but all these libraries written in JS means they are just hard to use.
Tape is not the first library for which I have made a similar request - write the damn thing in TS. Think about it - you help 1000s of people. You aren't just doing it for me. It all targets Node.js runtime, so we still support the same community, etc. Don't get me wrong I still like Node.js the best.
I don't even use tape tbh, I am just here to support the TS fans. I looked at the codebase. There's like 5 source files. Somebody, even if it's not @ljharb could convert this to TS in a half a day.
Most helpful comment
Expecting someone to learn a different language just to support you is an interesting attitude as well :-)