renatorib / react-powerplug

:electric_plug: Renderless Containers
https://renatorib.github.io/react-powerplug
MIT License
2.68k stars 101 forks source link

Upgrade typescript definition #161

Closed TrySound closed 6 years ago

TrySound commented 6 years ago

There was a few changes and we need to upgrade typescript definitions.

Changes are in these commits https://github.com/renatorib/react-powerplug/commit/4cfb56f62c44ba92a4c4d0439ece95734726f163 https://github.com/renatorib/react-powerplug/commit/e747c261fa8d952ef2076077aa30a4a34ac7bff2 https://github.com/renatorib/react-powerplug/commit/1e6f5b0054af3d1acd380309cff1f611ab5fd34d https://github.com/renatorib/react-powerplug/commit/7cb56d02ade57e262d8b45c0f797560757f3f11d

/cc @theKashey @renatorib

theKashey commented 6 years ago
TrySound commented 6 years ago

Corrected a bit

theKashey commented 6 years ago

I heard about generation Flow from TS, or TS from Flow. It will be great to have a single source of types. PS: But https://github.com/joarwilk/flowgen doesn't work for me.

TrySound commented 6 years ago

That's the point. Type systems are different. For example, typescript definitions exports all types even implementation details. This is not acceptable to me in flow where I carefully work with types as a part of api.

Generation will probably will work with generating definitions from less opinionated about javascript type systems like reason.

theKashey commented 6 years ago

For example, typescript definitions exports all types even implementation details.

Just split d.ts into 2 files, and, while types will be still visible for compiler, they will not be a part of autocomplete stuff.

TrySound commented 6 years ago

@theKashey I don't get, how omitting export can make types invisible for compiler? I thought it's just some kind of convention "export everything and always".

theKashey commented 6 years ago

original d.ts

export type InternalStuff = {};                              // oh! exposed internals
export type CoolStuff = { value : InternalStuff } // I need only this!!!

🤔🤔🤔🤔🤔🤔🤔🤔🤔

internals.d.ts

export type InternalStuff = {};                            

original d.ts

import {InternalStuff} from './internals.d.ts'; // not exported!
export type CoolStuff = { value : InternalStuff }

Bingo!

That's basically how d.ts looks like if generated from TS files - scattered across original modules, providing the same "import" experience.

TrySound commented 6 years ago

I don't get what's wrong with this.

type InternalStuff = {};
export type CoolStuff = { value : InternalStuff }

Why this tambourine dancing?

TrySound commented 6 years ago

Anyway, I want to release new rc to test form component in my app. Would be good to update ts before that.

theKashey commented 6 years ago

I don't get what's wrong with this.

Also have no idea why linting is against it. I'll try to update typing in my first free time slot.

everdimension commented 5 years ago

I think you rushed a bit when you updated types.

Currently, not all components pass reset and resetState callbacks (i.e. Focus, Hover, maybe more)

But your typings say that they do: https://github.com/renatorib/react-powerplug/blob/v1.0.0/types/index.d.ts#L14

(because FocusRender has type of RenderFn, and RenderFn extends SharedProps)

This is a mistake