Atom-ide-ui: Publish Flow types for atom-ide-ui

Created on 18 Oct 2017  路  10Comments  路  Source: facebookarchive/atom-ide-ui

The example Provider API code in the API references the type HyperclickSuggestion.

    getSuggestionForWord(
      textEditor: TextEditor,
      text: string,
      range: Range
    ): ?HyperclickSuggestion {

https://atom.io/packages/hyperclick

I assume this would be imported as follows:

import type { HyperclickSuggestion } from 'atom-ide-ui'

But I'm not sure if it makes sense to have the whole of atom-ide-ui to be listed as a dependency in a 3rd party package, just to get access to a type. Can you please clarify?

Most helpful comment

To be honest this might have to wait for https://github.com/flowtype/flow-typed/issues/1494, which would be more TypeScript-y, so we'd have something like @flowtype/atom.

All 10 comments

Unfortunately there isn't a great solution for this in the Flow-typed world. Ideally we could have a @typed/atom-ide-ui you could install or something like that.. maybe I'll make a atom-ide-ui-types at some point.

Installing atom-ide-ui as a dev dependency definitely would work, but you can also just copy+paste the API from https://github.com/facebook-atom/atom-ide-ui/blob/master/modules/atom-ide-ui/pkg/hyperclick/lib/types.js.

I see flow-libs/atom-ide.js.flow type definitions in atom-languageclient. Are they written manually or somehow generated or copy-pasted from here?

See also related question: https://github.com/atom/atom-languageclient/issues/142

They are copy pasted, hence the need for this issue :) You can probably just copy+paste them as well as a short-term solution.

Thanks, but for my own plugin, I switched to Scala.js. I'm still interested in this because for doing my stuff in Scala I will need to port Flow type defs to Scala.js (and I thought of generating it).

I actually attempted to use Flow at first, but this situation with no public type-defs discouraged me. I just know too little about Flow and I though that flow-typed would have everything I need. Unfortunately, it doesn't.

Anyway, what's the way to solve this issue? Is it complicated?

@laughedelic you should be able to just copy the flow-libs directory and then add that to your .flowconfig. Ideally we'd publish those files to flow-typed as you've mentioned already, but it's a bit weird because what module name would you use? -- we've tossed around the idea of adding a atom-typed npm package that is a stub for the purposes of flow-typed for example (cc @wbinnssmith)

https://www.npmjs.com/package/atom-typed

but it's a bit weird because what module name would you use?

Why is it a problem? I see three things here (in those flow-libs/ folders here and in the languageclient), just like the repos are separated:

  • atom
  • atom-ide-ui
  • atom-languageclient

Wouldn't it make sense to publish these 3 things separately to flow-typed (under these names)? Btw, they can have dependencies, right?

It doesn't quite make sense because flow-typed is designed to analyze your dependencies from package.json and automatically pull down the definitions from flow-typed accordingly. In this case it doesn't really make sense to pull down atom/atom-ide-ui as dependencies as they aren't really dependencies in the Node sense.

There's no good solution to type 'special' modules like atom with the flow-typed module without some kind of atom-typed wrapper. Also, flow-typed doesn't support dependencies :(

Also, flow-typed doesn't support dependencies :(

I see. I think this is a real bummer 馃憥 for the whole Flow ecosystem.. Just some types floating around and copy-pasted from one place to another..

Anyway, thanks for explanation, I understand the situation better now.

To be honest this might have to wait for https://github.com/flowtype/flow-typed/issues/1494, which would be more TypeScript-y, so we'd have something like @flowtype/atom.

Oh, that's interesting. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Arcanemagus picture Arcanemagus  路  4Comments

emayljames picture emayljames  路  4Comments

TeeSeal picture TeeSeal  路  5Comments

tiagonervis picture tiagonervis  路  4Comments

beriberikix picture beriberikix  路  3Comments