manuelmhtr / countries-and-timezones

Minimalistic library to work with countries and timezones data
MIT License
224 stars 67 forks source link

TypeScript typings issue #38

Closed sannysoft closed 2 years ago

sannysoft commented 3 years ago

Getting the following error with TypeScript 4.3.5: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier

manuelmhtr commented 2 years ago

Hi @benj-dobs, @kherock I'm not a TS expert, any thoughts would be appreciated 🙏

benj-dobs commented 2 years ago

Interesting, not sure why you're getting it and I'm not. I'll look into it.

kherock commented 2 years ago

@benj-dobs Do you have "skipLibCheck": true in your tsconfig? The error is from the inlined json from the rollup json loader which lacks a 'declare'modifier.

benj-dobs commented 2 years ago

Yep @kherock you've nailed it.

I spent a bit of time yesterday trying to configure Rollup to generate the files a different way, but I'm not too familiar with Rollup and I couldn't make it work. I can look into it again at a later date but I'm not totally sure when I'll get around to it.

If we don't have a better option, I guess we could replace the JSON const object type with something more general, so we don't have to import the JSON file into the d.ts file at all.

manuelmhtr commented 2 years ago

Hi all, This problem is fixed in v3.2.2 with the temporary solution of adding the declare keyword with a bash script (https://github.com/manuelmhtr/countries-and-timezones/pull/40). In case rollup-plugin-dts gets fixed (@kherock) we could move to a cleaner and definitive solution.

@benj-dobs feel free to modify or close https://github.com/manuelmhtr/countries-and-timezones/pull/39 in case there's something we should keep from it.