Javascript es6 re-exports

391 views Asked by At

EDIT Maybe I found the problem, would like if someone could confirm the situation: It seems like test.js is importing index.js which is importing test.js, and export has not an stop infinite-loop inclusion... Is it right? Is there any workaround like Don't include this file if it's the calling one?


I'm facing a strange problem. I'm trying to import some objects from a re-export (tcomb-react-native is not relevant here as the problem is with import/export).

|-- index.js
|-- simpleTypes.js
|-- userType.js

index.js:

export { UserType, UserTypeBase } from './test';
export { TextMax9Type } from './simpleTypes';

simpleTypes.js:

import t from 'tcomb-form-native';
export const TextMax9Type = t.refinement(t.String, s => s.length <= 9);

test.js:

import t from 'tcomb-form-native';
// import { TextMax9Type } from './'; // <----- NOT WORKING!
import { TextMax9Type } from './simpleTypes'; // <----- OK no error

export const UserTypeBase = {
    Name: TextMax9Type,
    Surname: TextMax9Type,
};

export const UserType = t.struct(UserTypeBase);

NOT WORKING error: Invalid argument props {} supplied to struct(props, [name]) combinator (expected a dictionary String-> Type)

So which is the problem with re-export that is exporting an empty object?

0

There are 0 answers