-
Notifications
You must be signed in to change notification settings - Fork 13
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
Rewrite with TypeScript & move to ESM #20
Conversation
036731b
to
3eb0e83
Compare
I don't really see the point of rewriting such a simple package in TS. |
I noticed the TypeScript definition issue chalk/supports-color#138 while writing this pull request. I actually solved some potential problems while I was writing this pull request. For example the function parseVersion(versionString) {
if (/^\d{3,4}$/.test(versionString)) {
// Env var doesn't always use dots. example: 4601 => 46.1.0
const m = /(\d{1,2})(\d{2})/.exec(versionString);
return {
major: 0,
minor: parseInt(m[1], 10),
patch: parseInt(m[2], 10)
};
}
const versions = (versionString || '').split('.').map(n => parseInt(n, 10));
return {
major: versions[0],
minor: versions[1],
patch: versions[2]
};
} We are accessing its regex result with Although we have TypeScript can help us to avoid lots of theses kinds of errors. But if you insist you don't need TypeScript, I can switch back to JavaScript. That's up to you. |
Let's see what James thinks. It's his repo after all. |
I made a simpler alternative in #21 as I agree with @sindresorhus that TS is overkill for a module like this and simply adding some JSDoc comments can achieve full strict typing with existing code. |
@voxpelli Wow. Thanks. |
Closing in favor of #21. |
Changes
.travis.yml
c8
instead ofnyc
supportsHyperlink.stdout
andsupportsHyperlink.stderr
process.env
, but the code to execute is insupports-color