-
Notifications
You must be signed in to change notification settings - Fork 171
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
Switch to typescript #12
Conversation
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.
good first iteration, I think we can improve it a bit further
@baywet |
when I locally install my package, I can see |
the behavior of the npm publish command is that it well take everything located in the current folder.
|
(the test folder name was caught by md, i meant _ _ test _ _ without the spaces) |
I did add
This was adding all the folders to respective node_modules, I wonder it would do same when I run Also, please let me know if this P.R is readyToMerge? |
besides the additional exclusions I was mentioning in my previous comment, it looks good to me. Great work! |
Thanks @baywet |
Thank you! Great team effort! And no, please don't add me as maintainer, I don't have the time to maintain this additional project on a regular basis. |
@baywet Unable to require package and use directly, instead need to call functions using var csc = require('country-state-city')
console.log(csc.default.getAllCountries()) it should be var csc = require('country-state-city')
console.log(csc.getAllCountries()) |
hum I think that's because you have other declarations in your files outside of the default one. So it gets transpiled down to a module, containing a default one a a few other ones. |
export = csc But I am not sure whether it will work with |
Will need to check it thorough, for now I have reverted npm release. Will spend sometime figuring out this issue and will fix it for both require and import if possible |
@baywet export = {
getCountries() {}
} I have tested it with |
Just as a follow up, today I upgraded some of my production projects to this latest version. However I have an additional suggestion, today methods have an implicit return type or implicit any. If you declared interfaces for country and state, that'd allow consumers to leverage those interfaces in their code and provide even better type check. interface ICountry {
id: string;
name: string;
phonecode: string;
sortname: string;
}
interface IState {
id: string;
name: string;
country_id: string;
}
interface ICity {
id: string;
name: string;
state_id: string;
} And then all you should need to do is type the return of the methods like this getCountryById: function (id: string) : ICountry {
return _findEntry(countryList, id);
}, |
No description provided.