bootstrap-notify icon indicating copy to clipboard operation
bootstrap-notify copied to clipboard

notify.d.ts: offset as object missing in INotifySettings

Open KarolBuchta opened this issue 9 years ago • 4 comments

The boostrap-notify INotificationSettings is missing something, that can be used in js.

offset in the settings can also be an object:

offset?:{
  x? :number,
  y? :number
}

See: https://github.com/mouse0270/bootstrap-notify/blob/master/bootstrap-notify.js#L112, the object seems to be the default, is merged. Number is additionally checked.

KarolBuchta avatar Apr 04 '16 09:04 KarolBuchta

Hello is this a typescript thing? I am not sure what your issue is.

mouse0270 avatar Apr 04 '16 16:04 mouse0270

Hi, the problem is, that in javascript you can put an object as argument for offset, as well as a number. In typescript only number is available in the type definitions. This means i cannot compile typescript code using bootstrap notify if i want to use the object type as argument, meaning it's not possible to specify different values for x/y.

As far as i know you cannot specify both types for this argument, so the type :any would be the right choice here.

So the line 34 in notify.d.ts should be:

offset?: any;

instead of

offset?: number;

In that case both will be allowed.

KarolBuchta avatar Apr 05 '16 12:04 KarolBuchta

So basically I have to update that line to read any instead of number and this should resolve this issue?

mouse0270 avatar Apr 05 '16 15:04 mouse0270

Yes exactly. The only disadvantage is, that the IDE (VS or IntelliJ) won't tell you the expected type of this field. On the other hand that way one can use your API at least fully, which is more important i think.

KarolBuchta avatar Apr 05 '16 18:04 KarolBuchta