TobiasHennig / nativescript-toast

A NativeScript Toast Plugin for Android and iOS apps.
MIT License
67 stars 19 forks source link

Argument of type '"long"' is not assignable to parameter of type 'duration'. #28

Closed Taremeh closed 7 years ago

Taremeh commented 7 years ago

Hi, I tried to create a long Toast (as shown on the example page): Toast.makeText("Hello World", "long").show();

However, I get an error, when compiling it: error TS2345: Argument of type '"long"' is not assignable to parameter of type 'duration'.

I'm using Nativescript 2.5 (and newest TNS Android). I think there's something wrong with the declaration of the parameter 'duration'...

jericdeleon commented 7 years ago

Encountering this too

When trying Toast.makeText("Hello World", Toast.duration.long).show();

...this runtime error shows up: ERROR TypeError: Cannot read property 'long' of undefined

For now, I just edited nativescript-toast's index.d.ts to: export function makeText(text: string, duration?: string): Toast;

I'm guessing duration's type is at fault as Typescript enums are number based (quoted here), so the duration argument should be changed either to constant strings or string-safe Typescript enums (manual example here ; npm package implementation here)