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

chrono-node 2.1.6 fails to compile with typescript + react #341

Closed
caass opened this issue Aug 8, 2020 · 2 comments
Closed

chrono-node 2.1.6 fails to compile with typescript + react #341

caass opened this issue Aug 8, 2020 · 2 comments

Comments

@caass
Copy link

caass commented Aug 8, 2020

I'm trying to use this package with my Typescript + React app -- it seems super awesome! Unfortunately, I get compiler errors when including it 😢

TypeScript error in [...]/node_modules/chrono-node/dist/index.d.ts(32,10):
'from' expected.  TS1005

    30 |     PM = 1
    31 | }
  > 32 | export * as de from "./locales/de";
       |          ^
    33 | export * as en from "./locales/en";
    34 | export * as fr from "./locales/fr";
    35 | export * as ja from "./locales/ja";

I thought this was related to this issue, but apparently this has been a feature since 2018. I'm concerned that this is an issue with react-scripts or my tsconfig.json.

Here's what I'm working with:

❯ cat tsconfig.json
{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react"
  },
  "include": ["src"]
}

❯ yarn --version
1.22.4

❯ node --version
v14.6.0

❯ yarn why chrono-node | grep "Found"
=> Found "chrono-node@2.1.6"

❯ yarn why typescript | grep "Found"
=> Found "typescript@3.7.5"

❯ yarn why react-scripts | grep "Found"
=> Found "react-scripts@3.4.1"

I tried changing the node version to 12.x, the chrono version to 1.x, and the react-scripts version to 3.4.0, but none of those worked. If necessary, I can create a minimal reproducible example, but I'm hoping this is an easy fix 🤞

@wanasit
Copy link
Owner

wanasit commented Aug 8, 2020

ok. I updated the index.ts to avoid export * ... usage in 3225daf
Could you try update to 2.1.7?

@caass
Copy link
Author

caass commented Aug 8, 2020

Thank you for your quick response! I had tried something similar with no success, and upon updating I get this error message:

TypeError: chrono_node__WEBPACK_IMPORTED_MODULE_3___default.a is undefined

>  8 |     const result = chrono.parse(input, new Date(), {
   9 |       forwardDate: true,
  10 |     });

So I tried digging a bit more, and I think the issue had to do with me trying to access result[0] before there was any input to parse. Additionally, I was trying to import in a way that didn't work. I tried a bunch of different syntaxes, and for some reason now the `import * as chrono from 'chrono-node' seems to be working, even though it wasn't before. If I can reproduce the issue, I'll re-open it.

Thank you so much for your time, I'm glad this was resolvable!

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

2 participants