TypeScript + Ionic + Cordova Plugin: Syntax Error import declarations may only appear at the top level of a module


#1

Hi,

I am new at meteor and ionic and try to combine them following the tutorial from here:
https://angular-meteor.com/tutorials/whatsapp2/meteor/setup

I added other plugins to the project and try to make a custom app.
The barcode-scanner plugin from ionic is written in js and uses an import statement.
When I try to use this plugin I get the error :

“Syntax Error import declarations may only appear at the top level of a module” (firefox)
or
"Uncaught SyntaxError: Unexpected token import" (chrome)

using.
import { BarcodeScanner } from ‘@ionic-native/barcode-scanner’;

I read that meteor is able to use non-top-level imports since 1.3. I am using METEOR@1.5 (.meteor/release).
Can someone please explain where the error lies? Does the typescript compiler create this error? How do I configure typescript to transpile wrong js files?

This seems to apply to other plugins as well. I tried also the ionic-native camera plugin.

Thanks


#2

Hi,

Were you able to resolve this issue?