ECMAScript 6 (ES6) importing problems


I want to write my code fully in es6; however, I get some errors especially in importing models. For example:

import { Observable } from 'data/observable';

it will give me the following error

SyntaxError: Importing binding name ‘Observable’ is not found.

are there any flags or configurations that I need to do to fully utilize es6?

Error: trying to link invalid ‘this’ to a java object (async/await, importHelpers)
Error: trying to link invalid ‘this’ to a java object (async/await, importHelpers)

@ganas currently import statements are not supported inside the Android runtime. Extending native (Android) classes using ES6 syntax isn’t supported either. Other than that you should not be facing issues utilizing the other ES6 features to the fullest.

We’ll announce publicly when support for either is delivered in an official NativeScript release.

Unexpected token import

Thanks for clarifying. Yeah I got so confused cuz some ES6 syntax works while others don’t.


I am still using require statements to import things in NS Core with JS.
I don’t mind using require statements,
but I’m happy that I can write async functions now in NS.

believe it or not, by writing async function, just yesterday I reduced a function which used
promises, from 85 lines to just under 25 lines!

async functions really let you write cleaner code and avoid the promise chain hell.


Nice, what changes you made to enable ES7 to have Await/Async


In my .eslintrc file, I modified the parserOptions to this, to enable async functions (actually it works without that as well, but eslint will show squiggly line under your async keyword)

"parserOptions": {
        "ecmaVersion": 2017,
        "ecmaFeatures": {
            "impliedStrict": true


in the parserOptions, if you add sourceType: "module" it will let you write import statements,
but NS Core doesn’t recognise import keyword


Thanks bud, I will try it :slight_smile:


are you using NS Core with JS too?


Yes, its the way to go awesome vanilla javascript with awesome NativeScript :wink:


yay hi5!

Plain Awesome NativeScript <3


So I just gave it a go, and it worked like a charm

async function AreYouTalkingToMe() {
    console.log("I'm a Async");

async function WhoAreYou (args) {
    await AreYouTalkingToMe();
    console.log("Yey, nice meeting you Async, long Awaited");

Now I have some refactoring to do


Welcome to Async/Await awesomeness :slight_smile:


For Android, I didn’t face any problems; however, for iOS it threw the following error

Unexpected keyword 'function'

I tried installing babel core and babel/preset-env, and added correct .babelrc file but still no luck with iOS :frowning:


Strange. It didn’t throw any such error for me :thinking:


May i know the path for .eslintrc file ?


It is there in your project folder. If you have installed eslint.

If you have not installed eslint. Then you can directly start using async await


I have not used eslint , still I am getting ReferenceError: __awaiter is not defined. Below is my code

export async function doSignInRequest() {
    console.log("Making request ");

    await makeRequest();
    console.log("Requesting finished ");


export async function makeRequest() {
    console.log("Requesting : from here");


Are you using ns core?


Yes. I am using NS Core .


this is how my dev dependencies look

"devDependencies": {
        "babel-traverse": "6.4.5",
        "babel-types": "6.4.5",
        "babylon": "6.4.5",
        "eslint": "4.6.1",
        "lazy": "1.0.11",
        "nativescript-dev-sass": "1.3.2",
        "node-sass": "4.5.3"

in package.json