vvo / tzdb

🕰 Simplified, grouped and always up to date list of time zones, with major cities
MIT License
772 stars 53 forks source link

`abbreviations` isn't defined in the typescript definition file #255

Open stkrzysiak opened 2 years ago

stkrzysiak commented 2 years ago

When running node version 14.x the lack of typescript definition causes an error, but this doesn't happen in node v16.x. Not sure exactly why but will PR the fix.

➜  node-vanilla node index.js                                                          
xxxxxx/node-vanilla/index.js:1
import { abbreviations } from '@vvo/tzdb';
         ^^^^^^^^^^^^^
SyntaxError: The requested module '@vvo/tzdb' does not provide an export named 'abbreviations'
    at ModuleJob._instantiate (internal/modules/esm/module_job.js:92:21)
    at async ModuleJob.run (internal/modules/esm/module_job.js:107:20)
    at async Loader.import (internal/modules/esm/loader.js:179:24)
➜  node-vanilla nvm use v16.0.0
Now using node v16.0.0 (npm v7.10.0)
➜  node-vanilla node index.js  
ACT

index.js:

import { abbreviations } from '@vvo/tzdb';
console.log(abbreviations[Object.keys(abbreviations)[0]]);
stkrzysiak commented 2 years ago

PR up, not sure why it didn't link up, build failing but vercel gives me a 404. #256

BenceSzalai commented 1 year ago

Hi! TypeScript TSC gives me TS2305: Module '"@vvo/tzdb"' has no exported member 'abbreviations'.

Is there a reason for the abbreviations to not be in index.d.ts? Or more precisely do we know why #256 is failing?

stkrzysiak commented 1 year ago

I forgot about this issue entirely, can you provide me steps to reproduce what you're seeing @BenceSzalai

BenceSzalai commented 1 year ago

In my setup simply making a new TypeScript file anywhere with the following triggers the issue:

import { abbreviations } from '@vvo/tzdb'

Right now my workaround is to add a definition manually before the import like this:

declare module '@vvo/tzdb' {
  export const abbreviations: Record<string, string>
}