The ScrollTimeline constructor (https://developer.mozilla.org/en-US/docs/Web/API/ScrollTimeline/ScrollTimeline) is relatively new, and I'd like to use it in a project, but TypeScript says it doesn't know what it is. I figure either something isn't up to date with the latest JavaScript constructors, or experimental constructors are never included in something... I'm not really sure where to go from here. How can I do a new ScrollTimeline() in React?
#Where to get the types for an experimental JS constructor?
5 messages · Page 1 of 1 (latest)
if the types don't yet exist in lib.dom for the latest target (ESNext), then you'll have to write the declarations yourself. https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html is probably the thing to read if you don't know how to do that (you'd be declaring global types instead of types for a specific package, but i think that's covered in there too)
i think most of the built-in DOM typings are generated from WebIDL definitions in the specifications or something like that. i don't know what the whole toolchain looks like, but they're updated via PRs like this
not sure if there's source material that you could use to generate the types yourself so you don't have to write them by hand
Thanks!