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.

Import from index.ts export not working

See original GitHub issue

Issue :

Import from index.ts export not working, ex: file structure: app |–shared |–index.ts |–utils.ts

utils.ts:

export function myFunction(){...

index.ts:

export * from 'utils.ts';

import {myFunction} from ‘app/shared’ doesn’t work in jest (works when running the app). export {myFunction} from ‘app/shared.index’ works.

Expected behavior :

ts-jest should work the same was as plain ts

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:11

github_iconTop GitHub Comments

2reactions
ahnpnlcommented, Mar 11, 2020

Thanks a lot for the reproduce repo. I will take a look when there are some free times 👍

0reactions
ahnpnlcommented, Apr 28, 2020

Oh it’s nice to hear that.

FYI the error comes from jest runtime, not typescript itself and ts-jest internal typescript compiler delivered the compiled js and jest runtime takes care of the rest.

Since it’s related to how jest runtime accepts the transpiled codes, ts-jest can’t do anything.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Imports in index.ts file are not getting correctly resolved. #29171
When running the project normally, the calling order is reversed as all external files import via index.ts so everything works as expected. It ......
Read more >
Export all files in `index.ts` - Stack Overflow
In this case, you need to create an index.ts file in your components directory. First, import all of your components in it: import...
Read more >
Consolidate Your TypeScript Imports With index.ts Files
When importing modules, TypeScript initially looks for an index.ts file. If one cannot be found, it will look for a file with the...
Read more >
Using index.ts file to organize import statements.
Typescript module resolution picks up index.ts file from folder name if it is there and try to import packages. In this file, we...
Read more >
Documentation - Modules .d.ts - TypeScript
The types which are exported can then be re-used by consumers of the modules using either import or import type in TypeScript code...
Read more >

github_iconTop Related Medium Post

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