0
votes

Typescript not compiling external class - protractor test.

I am trying to use external typescript classes, which i published as a npm package, into my protracter test, which is also in typescript. Im compiling typescript with gulp. Everything was working fine, when I had the class in the same project as my test, but now that I'm trying to use it via node_modules as a package, I get errors.

At run time, I get Unexpected token error. It looks like typescript is not compiling. Is it a typings error? Do I need to generate types for my package?


import { Helper } from './src/helper';
       ^
SyntaxError: Unexpected token {

package file system

  • e2e/src/helper

  • index.ts

  • package.json

  • tsconfig.json


index.ts

import { Helper } from './src/helper';
export { Helper };

package.json

  "name": "my-project",
  "main": "index.ts",
  "types": "index.d.ts",
  "version": "0.0.1",

tsconfig.json

{
    "compilerOptions": {
        "outDir": "lib",
        "rootDir": ".",
        "target": "es5",
        "module": "commonjs",
        "declaration": true,
        "types": [
        ]
    }
}

TEST

Protractor test file, where I'm trying to use the external class, which has been imported into node_modules

test.ts

import { Helper } from 'my-project';

describe(' Test Description' , () => {

    let helper: Helper;

before(async () => {
    helper = new Helper();
});

running this test gives me error - SyntaxError: Unexpected token {
1

1 Answers

0
votes
import { Helper } from 'my-project';

describe(' Test Description' , () => {

    let helper: Helper;

    before(async () => {
        helper = new Helper();
    });
}); //- сlosing tag