Typescript import path-to-regexp error
See original GitHub issueAfter upgrading to 4.3.1 i get the following typescript error
generatePath.js?3f47:13 Uncaught TypeError: path_to_regexp__WEBPACK_IMPORTED_MODULE_0___default.a.compile is not a function
at compileGenerator (generatePath.js?3f47:13)
at generatePath (generatePath.js?3f47:33)
at Redirect.computeTo (Redirect.js?6842:62)
at Redirect.perform (Redirect.js?6842:77)
at Redirect.componentDidMount (Redirect.js?6842:41)
at commitLifeCycles (react-dom.development.js?f8c1:14248)
at commitAllLifeCycles (react-dom.development.js?f8c1:15342)
at HTMLUnknownElement.callCallback (react-dom.development.js?f8c1:100)
at Object.invokeGuardedCallbackDev (react-dom.development.js?f8
I think the import statement in generatePath.js should be
import * as pathToRegexp from "path-to-regexp";
instead of
import pathToRegexp from "path-to-regexp";
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Typescript import path-to-regexp error · Issue #6203 - GitHub
I checked path-to-regexp the downloaded package and for some reason, it downgraded to old 0.1.7. This dependency version comes from express.js ...
Read more >'path-to-regexp' does not contain a default export (imported as ...
Attempted import error: 'path-to-regexp' does not contain a default export (imported as 'pathToRegexp'). This error occurred during the build ...
Read more >path-to-regexp - npm
The pathToRegexp function will return a regular expression object based on the provided path argument. It accepts the following arguments: path ...
Read more >'path-to-regexp' does not contain a default export (imported as ...
Coding example for the question Attempted import error: 'path-to-regexp' does not contain a default export (imported as 'pathToRegexp')-Reactjs.
Read more >How to fix error TS7016: Could not find a declaration file for ...
How to fix error TS7016: Could not find a declaration file for module 'XYZ'. 'file.js' implicitly has an 'any' type · Try `npm...
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

@timdorr This should not be marked as closed. This is a very real issue on the latest stable.
It‘s a workaround but no real solution. @timdorr can you explain why this was closed?