ZeeCoder / use-resize-observer

A React hook that allows you to use a ResizeObserver to measure an element's size.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add TypeScript Definitions

imransl opened this issue · comments

I saw that the type definitions for TypeScript was removed due to #12. This is probably due to the not-so-good type definitions I created in a PR. My bad. However, we can still add type definitions using TypeScript's tsconfig.json. There is a setting called declaration that needs to be applied in it like here: https://github.com/frankwallis/react-slidedown/blob/master/tsconfig.json. TypeScript will then generate the TypeDefinitions automatically for us when we run its compiler.

It was specifically because of how this turned out:
#13 (comment)

I'm not comfortable adding TS definitions back in without knowing anything about TS myself, as I have no way of knowing whether anything TS-related that a lib user proposes makes sense or not, or whether someone else will come later and try to correct it to something that I yet again have no way to check myself.

I'm sure there's a way to use a 3rd party lib in a TS codebase without the lib being written in TS or having types explicitly exported.

I think I'll only add TS types here when I learn it in the future and then I'll just rewrite the whole source in it.