LeaVerou / stretchy

Form element autosizing, the way it should be
https://stretchy.verou.me/
Other
1.27k stars 87 forks source link

Type definitions #46

Open plungingChode opened 1 year ago

plungingChode commented 1 year ago

I'd like to add type definitions for the library to DefinitelyTyped, but unfortunaltely the active global property is preventing that: https://github.com/LeaVerou/stretchy/blob/68bc05935f43cb76b6ebdf8a217b0eea1ab733ed/src/stretchy.js#L135

Since in TypeScript type definition files all exported variables are treated as read-only, and cannot be reassigned. Would it be possbile to convert this to a function? For example:

let active = true;

function setActive(isActive) {
    active = isActive;
}

This way the library could be (more easily) usable in TypeScript projects. You can see my current type definition implementation here.