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 Typescript declaration #3

Closed
kernwig opened this issue Aug 6, 2020 · 5 comments
Closed

Add Typescript declaration #3

kernwig opened this issue Aug 6, 2020 · 5 comments

Comments

@kernwig
Copy link

kernwig commented Aug 6, 2020

This library is really hard to import into a Typescript project.
A couples lines in a .d.ts file de declare the two imports would make it easy.

@filipdanic
Copy link
Owner

Feel free to make a pull request with these and I’ll be happy to merge and publish a new version! :)

@kernwig
Copy link
Author

kernwig commented Aug 7, 2020

Turns out that the problem has nothing to do with Typescript. It doesn't work with Node.js v12.

const tz = require("compact-timezone-list");
console.log(tz);

$ node test.js

export default [
^^^^^^

SyntaxError: Unexpected token 'export'

The ES2015 module style in the source isn't compatible with Node.js v12 (which is as high as I can go right now).
I don't know how to fix this without possibly breaking the library for anyone else already dependent upon this file being an ES module. @filipdanic

@kernwig
Copy link
Author

kernwig commented Aug 18, 2020

@filipdanic
I created a PR that attempts to expand this library to work with CommonJS as well as ES Modules, and adds Typescript declarations. I am struggling with figuring out how to test it without publishing, but before going farther I figured I had best get your blessing on the addition.

@abdullahmujahidali
Copy link

Using Typescript is the only option? I am working on a non-typescript project in next JS.

@wparad
Copy link

wparad commented Sep 21, 2021

No but the PR #5 solves both issues.

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

No branches or pull requests

4 participants