Skip to content
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

Add TS typings + build improvements #54

Merged
merged 9 commits into from
Sep 17, 2019
Merged

Conversation

thw0rted
Copy link
Contributor

Hi @DanielJDufour , I came to add TS typings and wound up fixing a few build issues as well. I tried to make each fix as its own commit so you can examine them separately. I can also make separate PRs if you'd like, but the overall scope is still pretty small so I thought it might be OK to do as one.

I've tested the reconfigured build and it works in my consuming applications, but I didn't add a "smoke test" or anything automated that uses the build artifact.

@DanielJDufour
Copy link
Collaborator

Awesome. I'll take a look!

@thw0rted
Copy link
Contributor Author

Give me a couple minutes, I didn't notice that Travis failed. I was futzing with the rollup config for terser and didn't re-run tests afterwards. (The good news is that apparently the tests do use the build artifact, which I should have noticed. Sorry!)

@DanielJDufour
Copy link
Collaborator

No worries :-)

@thw0rted
Copy link
Contributor Author

OK, the commit I'm pushing now uses resolve('../') which checks the main field in package.json to determine where to find the entry point. I was going to try to add a second test set, or at least an alternate mode for testing, that consumes the ESM package, but apparently Mocha is still working on built-in ESM / MJS support, so I'll have to save that for another day.

mgrs.js Outdated
@@ -286,10 +287,10 @@ function UTMtoLL(utm) {
/**
* Calculates the MGRS letter designator for the given latitude.
*
* @private
* @param {number} lat The latitude in WGS84 to get the letter designator
* @private // TODO: is this actually private? If so, why is it exported?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! that line should be deleted. I recently made it public (i.e. exported it), so that I could test it: https://github.com/proj4js/mgrs/blob/master/test/test.js#L123

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, there's public, then there's public. If you don't think it warrants showing up on the public API I don't think there's any problem with leaving @private in the JSDoc. Typescript has an @internal annotation that works in a similar way, that excludes it from generated typings.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it the way that is now then. I'm worried about making the API more complicated without a clear use case. If a clear use case for people using getLetterDesignator comes up independent of forward or inverse, I'll change my mind :-)

Could you replace the TODO with // hiding from the public API to keep things simple for users or something to that effect?

package.json Outdated
"pretest": "npm run clean && npm run build",
"test": "nyc mocha test/test.js",
"clean": "rimraf dist",
"build": "mkdirp dist && rollup -c"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide more context on why the switch to mkdirp from mkdir -p? Is there any alternative to mkdirp? Unfortunately, it doesn't look like the project is still being maintained: https://www.npmjs.com/package/mkdirp
https://www.npmjs.com/package/mkdirp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mkdir -p on Windows makes a directory called "-p". I wish I were kidding.

I didn't bother researching to see if there's a maintained project for this, and honestly it's a tiny chunk of functionality so it might be simpler to just write a 4-line script that does it using fs methods, but I don't know of a cross-platform way to do this using shell commands.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just change mkdirp to mkdir and removed the mkdirp dependency. I don't think the -p is necessary. Let me know if I missed anything!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced mkdirp with mkdir. Let me know if this doesn't work for some reason.

@DanielJDufour
Copy link
Collaborator

I made just a couple comments. Other than that, looks good to go!

@thw0rted
Copy link
Contributor Author

Hopefully that clears things up, if you want to make any changes (or just revert any of the "fixes" I put in) please feel free.

@DanielJDufour
Copy link
Collaborator

Awesome! Thanks for the quick feedback :-)

@thw0rted
Copy link
Contributor Author

FYI that change I made is from the GH in-browser text editor. Since you're a maintainer here and I set the PR to "allow edits", you should also have permissions to do that. (I don't mind doing it, I just wanted to make sure you were aware.)

Copy link
Collaborator

@DanielJDufour DanielJDufour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thank you!

@DanielJDufour DanielJDufour merged commit 4df7152 into proj4js:master Sep 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants