Search code examples
typescriptvisual-studio-codenativescriptnativescript-vuevetur

NativeScript-Vue with Typescript in VSCode with Vetur: Alert with then giving Property 'then' does not exist on type 'void'


I'm using VSCode with Vetur. This is my code:

alert({
  title: 'Success!',
  message: 'Account created successfully',
  okButtonText: 'Okay'
  }).then(() => {
  console.log('Alert dialog closed!');
})

I get the error Property 'then' does not exist on type 'void' Vetur(2339)

I just follow the instructions in the docs here: https://nativescript-vue.org/en/docs/elements/dialogs/alert/

Any idea what's going on?


Solution

  • EDIT for Nativescript 7:

    import {Dialogs} from "@nativescript/core";
    

    then use

    Dialogs.alert({
      foo
    });
    

    or whatever you need from the Dialogs module.

    Original answer:

    Make sure to either

    import { alert } from 'tns-core-modules/ui/dialogs'
    

    edit: or (thanks ayudh)

    import { alert } from '@nativescript/core/ui/dialogs'