Closed mehmetnyarar closed 4 years ago
I just want to drop a note here to mention that TypeScript declarations are handled independent of this source tree. See https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ip-address . They were last generated for ip-address 5.8.0 (and by different authors than @beaugunderson).
@mdmower I've been using TypeScript for 100% of my new code for the last year or so, I am in favor of moving this codebase to TS at some point, as well as moving the typings here before then for ease of updates :)
@beaugunderson Ohh, that's exciting news. I actually spent a good chunk of Saturday updating JSDoc in this code base so that tsc
can output more accurate declarations. My work is about half-done. I just haven't picked the best path forward for marking-up the external class members in attributes.js
and similar class-extension files. The best I've come up with so far is to type-cast all uses of this
like:
/** @type {import('../ipv6')} */ (this).valid
I'm not really proud of it, though. It seems like I should be able to mark methods as @memberof
to help the TypeScript parser pick up the correct type of this
automatically, but I haven't gotten that to work yet. With the above type-casting, the typescript parser (and VSCode intellisense) are able to pick up the correct type.
Functions like falseIfInvalid()
are also a little tricky since they obscure the underlying function's return type.
ah, hmm... I wonder if we should just make the move to TS now? probably easier than futzing with JSDoc annotations to get the types right :)
opened #111 to track
to4()
returnsAddress4
, notstring
.