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

Initial Flow definition for emotion #129

Closed
thangngoc89 opened this issue Jul 11, 2017 · 6 comments
Closed

Initial Flow definition for emotion #129

thangngoc89 opened this issue Jul 11, 2017 · 6 comments

Comments

@thangngoc89
Copy link
Contributor

I'm integrating emotion into a Flow typed project, I've created a simple emotion flow definition. It's far from complete and only serves my use cases with template literal. I hope this will be a good starting point for anyone working on a flow definition.

// @flow

type $npm$emotion$Interpolation =
  | ((executionContext: Object) => string)
  | string
  | number
  | React$Component
  | React$Element

type $npm$emotion$React = (
  strings: Array<string>,
  ...interpolations: Array<$npm$emotion$Interpolation>
) => ReactClass<*>

type $npm$emotion$Component = ReactClass<*> | ((props: *) => React$Element<*>)

declare module "emotion" {
  declare module.exports: any
}

declare module "emotion/react" {
  declare type Interpolation = $npm$emotion$Interpolation

  declare type EmotionReact = $npm$emotion$React

  declare module.exports: {
    (baseComponent: Interpolation): EmotionReact,
    a: EmotionReact,
    abbr: EmotionReact,
    address: EmotionReact,
    area: EmotionReact,
    article: EmotionReact,
    aside: EmotionReact,
    audio: EmotionReact,
    b: EmotionReact,
    base: EmotionReact,
    bdi: EmotionReact,
    bdo: EmotionReact,
    big: EmotionReact,
    blockquote: EmotionReact,
    body: EmotionReact,
    br: EmotionReact,
    button: EmotionReact,
    canvas: EmotionReact,
    caption: EmotionReact,
    cite: EmotionReact,
    code: EmotionReact,
    col: EmotionReact,
    colgroup: EmotionReact,
    data: EmotionReact,
    datalist: EmotionReact,
    dd: EmotionReact,
    del: EmotionReact,
    details: EmotionReact,
    dfn: EmotionReact,
    dialog: EmotionReact,
    div: EmotionReact,
    dl: EmotionReact,
    dt: EmotionReact,
    em: EmotionReact,
    embed: EmotionReact,
    fieldset: EmotionReact,
    figcaption: EmotionReact,
    figure: EmotionReact,
    footer: EmotionReact,
    form: EmotionReact,
    h1: EmotionReact,
    h2: EmotionReact,
    h3: EmotionReact,
    h4: EmotionReact,
    h5: EmotionReact,
    h6: EmotionReact,
    head: EmotionReact,
    header: EmotionReact,
    hgroup: EmotionReact,
    hr: EmotionReact,
    html: EmotionReact,
    i: EmotionReact,
    iframe: EmotionReact,
    img: EmotionReact,
    input: EmotionReact,
    ins: EmotionReact,
    kbd: EmotionReact,
    keygen: EmotionReact,
    label: EmotionReact,
    legend: EmotionReact,
    li: EmotionReact,
    link: EmotionReact,
    main: EmotionReact,
    map: EmotionReact,
    mark: EmotionReact,
    menu: EmotionReact,
    menuitem: EmotionReact,
    meta: EmotionReact,
    meter: EmotionReact,
    nav: EmotionReact,
    noscript: EmotionReact,
    object: EmotionReact,
    ol: EmotionReact,
    optgroup: EmotionReact,
    option: EmotionReact,
    output: EmotionReact,
    p: EmotionReact,
    param: EmotionReact,
    picture: EmotionReact,
    pre: EmotionReact,
    progress: EmotionReact,
    q: EmotionReact,
    rp: EmotionReact,
    rt: EmotionReact,
    ruby: EmotionReact,
    s: EmotionReact,
    samp: EmotionReact,
    script: EmotionReact,
    section: EmotionReact,
    select: EmotionReact,
    small: EmotionReact,
    source: EmotionReact,
    span: EmotionReact,
    strong: EmotionReact,
    style: EmotionReact,
    sub: EmotionReact,
    summary: EmotionReact,
    sup: EmotionReact,
    table: EmotionReact,
    tbody: EmotionReact,
    td: EmotionReact,
    textarea: EmotionReact,
    tfoot: EmotionReact,
    th: EmotionReact,
    thead: EmotionReact,
    time: EmotionReact,
    title: EmotionReact,
    tr: EmotionReact,
    track: EmotionReact,
    u: EmotionReact,
    ul: EmotionReact,
    var: EmotionReact,
    video: EmotionReact,
    wbr: EmotionReact,

    // SVG
    circle: EmotionReact,
    clipPath: EmotionReact,
    defs: EmotionReact,
    ellipse: EmotionReact,
    g: EmotionReact,
    image: EmotionReact,
    line: EmotionReact,
    linearGradient: EmotionReact,
    mask: EmotionReact,
    path: EmotionReact,
    pattern: EmotionReact,
    polygon: EmotionReact,
    polyline: EmotionReact,
    radialGradient: EmotionReact,
    rect: EmotionReact,
    stop: EmotionReact,
    svg: EmotionReact,
    text: EmotionReact,
    tspan: EmotionReact,
  }
}
@hawkins
Copy link
Contributor

hawkins commented Jul 17, 2017

Thanks for this!

And for what it's worth, I've been planning to work on flow definitions as soon as #37 is finished. Of course no hard feelings if you or someone else is itching to get this sooner than I am. 😋

@FezVrasta
Copy link
Member

FezVrasta commented Feb 6, 2018

Is there anything available to annotate styled components?

styled.div`
  color: ${color}; /* I want to annotate `color` as `string` */
`

@zaynv
Copy link

zaynv commented Mar 22, 2018

I see that the source code is written in Flow, does this mean that I can use emotion now with Flow or is it still necessary to wait for someone to write the definitions for it?

@dashed
Copy link

dashed commented May 21, 2018

@thangngoc89 have you ever considered adding your definitions to https://github.com/flowtype/flow-typed ?

@stale
Copy link

stale bot commented Aug 7, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 7, 2018
@stale stale bot closed this as completed Aug 14, 2018
@mgrip
Copy link

mgrip commented Dec 25, 2018

Any chance this could be reopened to add types for Interpolation? Would be helpful to validate entries in the style object. I believe currently its typed as any

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants