Can I 'target' typescript to latest es?


#1

I am not a expert nor newbie to nativescript.
But still have problems to read tsconfig.json.

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "esnext",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "noEmitHelpers": false,
        "noEmitOnError": true,
        "sourceMap": false,
        "noImplicitReturns": true,
        "lib": [
            "es6",
            "dom"
        ],
        "baseUrl": ".",
        "paths": {
            "*": [
                "./node_modules/tns-core-modules/*",
                "./node_modules/*"
            ]
        }
    },
    "exclude": [
        "node_modules",
        "platforms"
    ]
}

target: “esnext” means I can use latest es?
It works for android but when I run it on ios which doesn’t like async and wait, it crushed.
I don’t want to target back to es5, there are so many wonderful stuff I would like to use from es6 and es7.
After looking through github, all solutions point to ‘íf you use typescript, you are able to use async…’.
Is there a comprehensive solution to use es6, es7 in nativescipt.
Last sincere suggestion, can ns provide an instruction about tsconfig and other setting files?


#2

You may still use asyc/await even when you target for ES5. Not only async/await but you can copy any typescript helpers to your global name space as described in this blog.

Android uses V8 engine and iOS uses the JavaScriptCore comes with the system. So you want want to make sure the features are supported in both platforms before moving your target to ES6.


#3

Thanks for your reply. I am using typescript 2.7.2. And I target to esnext which I assume should be targeted to the latest ‘accepted’ version. It works fine so far. More than async/await, there are so many other features I needed from above es6.