JedWatson / react-input-autosize

Auto-resizing input field for React
https://jedwatson.github.io/react-input-autosize
MIT License
768 stars 178 forks source link

Add TypeScript declaration file #94

Open ahstro opened 7 years ago

ahstro commented 7 years ago

Would be nice to have a TypeScript declaration file, so us TS folks don't get compile errors 😇

twobit commented 7 years ago

@ahstro I created one today, feel free to use it

JonathanMEdwards commented 6 years ago

Thanks @twobit but I can't get it to work. To get the declarations to be recognized at all I had to wrap them in a declare module 'react-input-autosize' { ... } But then I get the the type error: [ts] Type '{ type: "text"; className: string; spellCheck: false; value: ReactText; onChange: (ev: FormEvent<...' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly<{ children?: ReactNode; ...'. Type '{ type: "text"; className: string; spellCheck: false; value: ReactText; onChange: (ev: FormEvent<...' is not assignable to type 'Readonly'. Types of property 'value' are incompatible. Type 'ReactText' is not assignable to type 'string | undefined'. Type 'number' is not assignable to type 'string | undefined'.

ozluy commented 4 years ago

I just created a new NPM module which calculates width of text it works perfect with input and Typescript please check it out:

https://github.com/ozluy/calculate-text-width image

itayganor commented 4 years ago

You can use @types/react-input-autosize, but hey, it's always better for it to be included in the actual package :)