Conversation
These come from the @types/long NPM package, originally written by Denis Cappellin.
| /** | ||
| * Returns this Long with bits logically shifted to the right by the given amount. | ||
| */ | ||
| shru(numBits: number | Long): Long; |
There was a problem hiding this comment.
This one has an additional alias shr_u
| /** | ||
| * Returns this Long modulo the specified. | ||
| */ | ||
| mod(other: Long | number | string): Long; |
There was a problem hiding this comment.
This one has an additional rem alias
| /** | ||
| * Tests if this Long's value is greater than or equal the specified's. | ||
| */ | ||
| gte(other: Long | number | string): boolean; |
| /** | ||
| * Tests if this Long's value is less than or equal the specified's. | ||
| */ | ||
| lte(other: Long | number | string): boolean; |
| /** | ||
| * Tests if this Long's value differs from the specified's. | ||
| */ | ||
| neq(other: Long | number | string): boolean; |
| /** | ||
| * Tests if this Long's value equals zero. | ||
| */ | ||
| isZero(): boolean; |
types/index.d.ts
Outdated
| /** | ||
| * Converts the specified value to a Long. | ||
| */ | ||
| static fromValue(val: Long | number | string | {low: number, high: number, unsigned: boolean}): Long; |
There was a problem hiding this comment.
This function accepts a second argument unsigned, see: https://github.com/dcodeIO/long.js/blob/master/src/long.js#L280
| @@ -0,0 +1,377 @@ | |||
| // TypeScript Version: 2.4 | |||
| export default Long; | |||
There was a problem hiding this comment.
Might be that we have to add something around here to make this work with just the sources under node.
There was a problem hiding this comment.
Not sure what you mean by this. Do you mean when using ts-node?
There was a problem hiding this comment.
Currently, the main file used under node is the source file, which just has module.exports = Long. The last time I checked interoperability with a default export requires some additional care there, like defining a property __esModule plus a default property, or something like this.
There was a problem hiding this comment.
Ah, yeah I had to use esModuleInterop: true in my tsconfig.json to make this work. It'll probably be a webpack setting I'm assuming.
There was a problem hiding this comment.
Issue is that the sources are served under node, so no webpack or tsc involved. Should probably manually add what tsc does with esModuleInterop: true to src/index.js.
There was a problem hiding this comment.
no webpack or tsc involved
In that case I'm confused. How would this TypeScript declarations file be affecting Node?
There was a problem hiding this comment.
I had to use
esModuleInterop: truein mytsconfig.jsonto make this work.
Just to be clear, this was in reference to another TS project, not this one.
There was a problem hiding this comment.
I see. I thought more in a sense of "polyfilling" something into src/long.js that would allow a loader using import Long from "long"; to actually work (it wouldn't currently, I think, erroring with 'there is no default export' or something). I haven't looked this up yet, but I think there might be a workaround like this in loaders if the exported object has an __esModule property plus a default property that indicates the default export - but I might as well be misunderstanding something here.
There was a problem hiding this comment.
Okay, I see. I think that can be addressed separately from this PR and anyone needing to use this can just use the esModuleInterop: true workaround for the time being.
|
Looking good so far, thanks! Just a few comments, and let me also suggest to place typing at |
SGTM. There was other stuff for testing in that folder, but I removed the testing code for the time being because of the Travis peer dependency issue. |
|
👍 |
|
Thank you! :) |
|
@dcodeIO Could you release a new version please? |
|
@dcodeIO Could you publish this please? |
|
@dcodeIO Can you please publish this? Current 4.0.0 version does not have the type definitions. What is the use of keeping the type definition in the repo and not publishing it to npm? |
These come from the
@types/longNPM package, originally written by DenisCappellin @cappellin, I only made a few modifications when I brought these over.
The
dtslinttool lints theindex.d.tsfile and tests it by compiling (but not running) the test file, compiling using thetsconfig.jsonfile. See the dtslint docs for more info on that.I modified this because
import Long from 'long';was not working in a different project. I did not include the custom tslint file (didn't take the time to read the modifications; it's already being linted by dtslint). I'm pretty new to TS so there may be something wrong, but having it here should allow for a better feedback loop to correct any issues.