“emitted file Xyz.d.ts overwites a previously emitted file of the same name” May 1, 2020
Posted by kevinbe71 in Development, React, TypeScript, Uncategorized, Web Development.Tags: bisect, Git, redux, rollup, TypeScript
add a comment
After making some recent changes and then upgrading rollup to 2.7.6 (from a 1.x release) I started seeing 2 of these warnings appear:
(!) The emitted file “actions\Xyz.d.ts” overwrites a previously emitted file of the same name.
(!) The emitted file “actions\Xyz.d.ts” overwrites a previously emitted file of the same name.
I used git bisect to quickly track down the commit that caused this issue and, fortunately, it was pretty obvious then:
I had 2 variations of imports of this file:
import * as Xyz from “./Xyz”;
import * as Xyz from “./xyz”;
This may not jump out to you immediately but the difference is a camelCase name vs a PascalCase name of the same file. The true file was called “xyz” but if you’re using Mac OS X or Windows then the compiler actually permits this. The newer version of rollup wasn’t letting things be… if wasn’t happy (which was a good thing)!
Cannot Read Property Pathname of Undefined September 1, 2019
Posted by kevinbe71 in Development, Javascript, node, React, TypeScript, Web Development.Tags: react-router, redux
add a comment
A new project I recently started requires a universal app and an electron client. I had already got the base of the SSR part done so I moved on to the electron app. I had started the whole project off with a template but it didn’t have the electron part, so I had to add that myself.
It was actually quite tough to get everything together for the electron app as I wanted it to use TypeScript and that necessitated two webpack configs (one for the main script and the other for the renderer).
Anyway, once I had that working I ran into one final problem: “Uncaught TypeError: Cannot read property ‘pathname’ of undefined” in the react-router.js file. It occurred on a line that was referencing “this.state.location.pathname”
I didn’t find an answer by doing a lot of scouring of the web. As a consequence I started reading the docs: electron, redux, and react router’s docs to be specific. Eventually I saw something that caught my eye: “import { BrowserRouter as Router, Route } from ‘react-router-dom'” – BrowserRouter AS Router! Wow, that’s pretty easy to miss: in all of the source code I’d reviewed I’d seen “” but hadn’t looked closely enough at the import statement (or perhaps it was missing?) In any case, this resolve the error.