makseo / ng2-sticky

Angular 2+ solution to make elements stick during scrolling.
https://domainlines.com
MIT License
91 stars 50 forks source link

Fix for "Argument of type 'null' is not assignable to parameter of type 'string | undefined'." #29

Closed ChrisMBarr closed 7 years ago

ChrisMBarr commented 7 years ago

In my project I have the "strictNullChecks": true, compiler option enabled, which produces this error:

ERROR in C:/my-project/node_modules/ng2-sticky-kit/src/ng2-sticky/ng2-sticky.ts (185,55): Argument of type 'null' is not assignable to parameter of type 'string | undefined'.

The code in question is where it calls window.getComputedStyle(element, null). That 2nd parameter is optional, meaning it's type is string | undefined in typescript, but null is being passed in which does not match the expected typedef. I believe you can simply change this line of code to window.getComputedStyle(element) to change no functionality and allow it to be compiled properly

According to the Mozilla documentation for getComputedStyle:

Prior to Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1), the [2nd] parameter was required. No other major browser required this parameter be specified if null. Gecko has been changed to match the behavior of other browsers.

sravenhorst commented 7 years ago

+1

makseo commented 7 years ago

Hi @chrismbarr , you will find your change in v4.1.1