Importing a mix of types and values in an import using a custom path results in undefined imports in result JavaScript
See original GitHub issueGiven:
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:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top 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 >
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

@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 👍
@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: