You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're using TypeScript with JS file checking enabled in our project. What that means is that TypeScript will check JS files for JSDoc definitions and interpret them as types. scrollbooster's index file contains JSDocs definitions:
When I try to create a new ScrollBooster instance with the same options as suggested in the README.md like this:
new ScrollBooster({
viewport: document.querySelector('.viewport'),
scrollMode: 'transform'
});
... TypeScript complains about missing parameters:
TS2345: Argument of type '{ viewport: HTMLElement; scrollMode: string; }' is not assignable to parameter of type '{ viewport: Element; content: Element; direction: string; pointerMode: string; scrollMode: string; bounce: boolean; bounceForce: number; friction: number; textSelection: boolean; ... 5 more ...; shouldScroll: Function; }'.
Type '{ viewport: HTMLElement; scrollMode: string; }' is missing the following properties from type '{ viewport: Element; content: Element; direction: string; pointerMode: string; scrollMode: string; bounce: boolean; bounceForce: number; friction: number; textSelection: boolean; ... 5 more ...; shouldScroll: Function; }': content, direction, pointerMode, bounce, and 9 more.
We're using TypeScript with JS file checking enabled in our project. What that means is that TypeScript will check JS files for JSDoc definitions and interpret them as types.
scrollbooster
'sindex
file contains JSDocs definitions:When I try to create a new
ScrollBooster
instance with the same options as suggested in theREADME.md
like this:... TypeScript complains about missing parameters:
That's because in the JSDocs comments of ScrollBooster's
index
file, non-essential parameters are not marked as optional. In JSDocs, you can mark parameters as optional by wrapping the parameter name in brackets ( [] ). When I do that for all the non-essential parameters, TypeScript stops complaining and my example works 🎉 .@ilyashubin I wanted to open a PR, but I can't seem to create a branch for this repo.
The text was updated successfully, but these errors were encountered: