Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify types in the main export #5

Closed
Arual90 opened this issue Jan 31, 2018 · 1 comment
Closed

Specify types in the main export #5

Arual90 opened this issue Jan 31, 2018 · 1 comment
Assignees
Labels

Comments

@Arual90
Copy link
Contributor

Arual90 commented Jan 31, 2018

Flow is unable to retrieve the types if i import the functions like this:
import {api} from '@contactlab/appy'

But works if the import is written like this:
import api from '@contactlab/appy/dist/api'

@Arual90 Arual90 added the bug label Jan 31, 2018
@Arual90 Arual90 self-assigned this Jan 31, 2018
@Arual90 Arual90 changed the title Specify types of the main export Specify types in the main export Jan 31, 2018
@StefanoMagrassi
Copy link
Contributor

@Arual90 let's try something like:

// src/api/index.js
// ----------------
// ...

export type Config = {| ...
export type ApiFn = (m: Method, a: string, t: string, b: ?RequestOptions) ...

// ...

// src/index.js
// ----------------
// ...

import type {Config, ApiFn} from './api';
import type {RequestFn} from './request';

import request from './request';
import api from './api';

interface Appy {
  request: RequestFn;
  api: (config: Config) => ApiFn; 
}

export default ({
  request,
  api
}: Appy);

Arual90 pushed a commit that referenced this issue Feb 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants