Flow: Namespace '"date-fns"' has no exported member 'Locale'
See original GitHub issueI compiled the following code…
src/index.ts)
import {format as dateFormat} from 'date-fns-tz';
dateFormat(new Date(), 'YYYYMMdd', {timeZone: 'America/New_York'});
The following error occurred.
./node_modules/.bin/tsc --project tsconfigs.json
node_modules/date-fns-tz/typings.d.ts:34:31 - error TS2694: Namespace '"date-fns"' has no exported member 'Locale'.
34 locale?: import('date-fns').Locale
~~~~~~
Found 1 error.
Environments
package-lock.json)
{
"name": "reproduce-date-fns-tz-typing-bug",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"date-fns": {
"version": "2.0.0-alpha.13",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.0.0-alpha.13.tgz",
"integrity": "sha1-oP1yPEZ7XFupi8nX/hvu9eak1ZY="
},
"date-fns-tz": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/date-fns-tz/-/date-fns-tz-1.0.6.tgz",
"integrity": "sha512-g0IY9CebRuyB5e2GIueO9mHpySpauMxSkbdkmVQEWi/R3w49ikYxC3dBNruGSOegwiNLI9cjuM0POZOFX0r8zQ=="
},
"typescript": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.3.3.tgz",
"integrity": "sha512-Y21Xqe54TBVp+VDSNbuDYdGw0BpoR/Q6wo/+35M8PAU0vipahnyduJWirxxdxjsAkS7hue53x2zp8gz7F05u0A=="
}
}
}
tsconfigs.json)
{
"compilerOptions": {
"lib": [
"es2018"
],
"module": "commonjs",
"newLine": "LF",
"target": "es5",
"strict": true
},
"include": [
"./src"
]
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Namespace 'Intl' has no exported member 'LocalesArgument'
Using React and TypeScript I'm trying to type a function that passes arguments to Date.toLocaleString but when I try to use Intl.LocalesArgument ...
Read more >date-fns - modern JavaScript date utility library
date-fns provides the most comprehensive yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.
Read more >“Namespace '"fs"' has no exported member ... - Code Grepper
Queries related to “Namespace '"fs"' has no exported member 'MakeDirectoryOption”. Module '"react"' has no exported member 'Node'.
Read more >ERROR: Namespace 'dayjs' has no exported member ... - Reddit
I've looked into it and the generated some-random-component.d.ts looks like the following for the locale object. locale = { ... daysOfWeek: ...
Read more >How to Add react-i18next to Your React app | by Emily Xiong
React-i18next is internationalization framework for React. This blog is a step-by-step guide about adding react-118next to a React project, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hmmm We no longer have that original issue, but now it just says
when we run flow @marnusw
date-fns-tzimports the typeLocalefromdate-fnshere: https://github.com/marnusw/date-fns-tz/blob/master/src/index.js.flow#L4As far as I can tell looking at
date-fnsthat type is not exported. So, when I run flow in a project depending on date-fns-tz, I get the following error:That error is coming from within
date-fns-tzwhen flow evaluates its types.I thought it was perhaps an issue with the version of
date-fnsbut that appears not to be the case because even the earliest version allowed by the peerDependency range does not haveLocaleas an exported type.Hopefully that helps. I tried my hand at updating with a PR myself, but when I found that
Localewas not exported at all from date-fns, I figured it would probably take some higher level decision-making about where that type should be defined. Perhaps a pull request against date-fns to export that type might be in order.