TypeStrong / tsify

Browserify plugin for compiling TypeScript
344 stars 75 forks source link

Failing to parse expression with null coalescing #287

Closed sotrh closed 2 years ago

sotrh commented 2 years ago

I have a typescript file that I'm trying to add to an existing project that uses browserify, and I've run into a snag where tsify won't parse the following statement.

const config = {
    color: material.color,
    envMap,
    ...(material.userData?.triplanarData ?? {})
};

It things the ? is the start of a ternary expression. How do I get tsify to parse null coalescing expressions? Here is my build script:

var browserify = require('browserify')
var babelify = require('babelify')
var tsify = require('tsify');

browserify()
    .add('src/app/scripts/main.ts')
    .plugin(tsify, { target: 'es6' })
    .transform(babelify, { extensions: [ '.js', '.jsx', '.ts', '.tsx' ] })
    .bundle()
    .on('error', function (error) { console.error(error) })
    .pipe(process.stdout)
sotrh commented 2 years ago

Turns out the project was using an older version of typescript. Upgrading fixed the issue.