Importing via import/export "pass-through" causes randomly undefined variables (TypeScript)
See original GitHub issueVersion
3.0.0
Reproduction link
https://github.com/ffxsam/repro-undefined-import
Node and OS info
yarn 1.9.4, Ubuntu 18.04
Steps to reproduce
- Clone and run
yarn
yarn serve
- Open Chrome console, note that
routes
isundefined
What is expected?
routes
should be an array of routes
What is actually happening?
routes
is undefined
Of note is this line in the code: https://github.com/ffxsam/repro-undefined-import/blob/master/src/components/LoginForm.vue#L100
Edit that and replace routeNames.DASHBOARD
with any arbitrary string, and save. Now you’ll see that routes
in the console is an array. Also updating the import to the following will fix it:
import { routeNames } from '../router/route-names';
This is very strange and took me hours to track down. It may or may not be a vue-cli issue, but I figured this was a good starting point. Sorry I don’t have a more descriptive issue report, but it’s so random, I’m not even sure how to describe it.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
node.js - Persistent undefined error in typescript import export
Whatever I do, whatever object I try export (class, function, const) with or without using a module: I get the same error. Maybe...
Read more >Modern JavaScript – Imports, Exports, Let, Const, and ...
When we declare a variable using the let keyword, we can assign a new value to that variable later but we cannot re-declare...
Read more >Cytoscape.js
js : A non-minified ESM ( import / export ) build without any bundled dependencies. This is intended to be consumed automatically by...
Read more >typescript-cheatsheet - GitHub Pages
In TypeScript, both undefined and null actually have their own types named ... Importing an exported declaration is done through using the import...
Read more >12.2.1 SOA Known Issues Page - Oracle
Oracle BPEL PM supports the use of variables with same names across ... This section lists all the known issues/limitations related to Import/Export....
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
Finally figured out… It’s due to a circular dependency here: https://github.com/ffxsam/repro-undefined-import/blob/a1b19fd90439f95bf218fda5edcff60065897864/src/router/routes/index.ts#L6
That’s the tough thing here, determining where the issue actually lies (webpack? TypeScript?). I don’t think there’s an immediate solution for this, so I’ll have to remain conscious of imports/re-exports.
Thanks for your help!
PS: Made the repo private, there was a bit more code in there that was I comfortable with. Not that there was anything terribly proprietary, but still. 😄