question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Importing a mix of types and values in an import using a custom path results in undefined imports in result JavaScript

See original GitHub issue

Given:

file1.ts:

export type Foo = 'bar';

export const baz = 'inga'; // ;)

file2.ts:

import { Foo, baz } from '@custom/scope/file1';

[...]

When the code is compiled, the Javascript import will read something like this:

file2.js:

import { Foo, baz } from '@custom/scope/file1';

but Foo will be undefined and cause errors.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
booninitecommented, Apr 8, 2020

@danielpza I wasn’t able to pick up the fix today, I should be able to try it out tomorrow and can let you know 👍

0reactions
DmitryKoterovcommented, May 4, 2020

@danielpza Unfortunately PR #53 doesn’t help, still the same effect.

Here is a with minimal code which reproduces the issue: https://github.com/DmitryKoterov/typescript-transform-paths-bug - could you please take a look?

Those excess import symbols don’t allow to use es6 modules since node complains on an attempt to import an undefined symbol:

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

import - JavaScript - MDN Web Docs - Mozilla
The identifier being imported is a live binding, because the module exporting it may mutate it and the imported value would change. However,...
Read more >
"Uncaught SyntaxError: Cannot use import statement outside ...
There are three ways to solve this:- · 1. The first: In the script, include type=module · 2. The second: In node.js, into...
Read more >
Documentation - Modules - TypeScript
With TypeScript 3.8, you can import a type using the import statement, or using ... per module. default exports are imported using a...
Read more >
Understanding Modules and Import and Export Statements in ...
In this tutorial, you will learn what a JavaScript module is and how to use import and export to organize your code.
Read more >
Working with JavaScript in Visual Studio Code
Using the TypeScript language service, VS Code can provide smart completions (IntelliSense) as well as type checking for JavaScript.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found