-
Notifications
You must be signed in to change notification settings - Fork 260
NODE-2716: Convert to Typescript #388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Ah so something I realized after the fact, currently when you In either case: import * as Long from 'long';
import { prototype, fromString as fromString$1, fromNumber, ZERO, isLong, fromInt, fromBits } from 'long'; Which the first line give you hope for a solution but alas the second line shows you that pulling apart the class into its individual components like As an aside, rollup (at least the rollup of today), is designed to take in esm style code and translate that to the other formats (commonjs, umd, iife) however we have a codebase written in commonjs and rely on rollup to translate that to esm. That's not in itself an issue its just the inverse of what the bundler tool is designed for today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lookin great so far! I have a few questions below. I'm also wondering if we shouldn't try to make jsdoc => typedoc
changes here, even if the types aren't in place everywhere, just to reduce the amount of future churn
src/map.ts
Outdated
if (typeof global.Map !== 'undefined') { | ||
exportedMap = global.Map; | ||
} else { | ||
exportedMap = require('core-js/es/map'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm shouldn't this otherwise be polyfilled by TypeScript for us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typescript doesn't do polyfills, that's a babel thing which is strange since we use babel to shim Buffer in browsers, we could have used babel to polyfill Map, that might still be a possible solution here instead of manually importing it (I loathe the directly added dependency). Although on the other hand perhaps we shouldn't be doing this logic of if Map exists on global and instead export the polyfill regardless since the point here is to use it on platforms where Map is not supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is covered in the bundling but browser would need window.Map
.
I have not found a solution to using I still need to fix up the gulp file to use plugins correctly and the rollup config still has issues with correctly shimming Buffer. |
Just noticed some places for code / logic improvement we can hold off on. I also saw some untyped arguments, are we leaving these untyped and doing more incremental progress? |
There's an issue with testing, I can confirm locally that tests pass on node 6.8 but tsc supports node 10+ so I can work on updating the EVG shell files to get both versions of node, and compile with one and test with the other but that might be best to leave to another pr, let me know what's best |
DBRefShape -> DBRefLike stop using `export *` to avoid tslib dep approximate _bsontype on timestamp
remove unneeded plugins
Converted the codebase to typescript. In order to get us up and running with testing I also did the leg work on bringing our tooling in sync with the driver, (for example we have to update prettier to get
import type
syntax). I brought in ts-node and got that working with mocha so tests are still being run and this works for both Nodeand the in browser karma tests(if the bundle is broken there's no karma tests! spoke too soon). This initial run is minimal changes needed to get us a compiling code base, unlike when we did this for the driver I opted to initially disable typescript'sstrict
rule which allows me to omit type annotations on functions mainly, which in a subsequent fix up PR would all be changed fromany
to something more meaningful.I also brought in our gulp file from the driver, along with the api-extractor config so we are ready to go on distributing typings.
Another pass will be to add the ts-doc information about access level and correctly formatting the
@param
tags etc.Currently this PR will break our rollup config, I'm working on getting that working with the new TS code but figured I get the ball rolling on this initial step.