Skip to content

ts-loader 8.* unable to recognize class variables #1499

@DiscultDev

Description

@DiscultDev

Hi when I try to import my test.ts class it throws an error saying additional loader is needed for the class variable options(see blow)

Module parse failed: Unexpected token (3:11)
File was processed with these loaders:
 * ./node_modules/ts-loader/index.js
You may need an additional loader to handle the result of these loaders.
| import { EventEmitter } from "events";
| export class TestClass extends EventEmitter {
>     options;
|     constructor(data) {
|         super();

 @ ./src/backend/electron/electron.ts 5:0-50 37:25-36
 @ multi ./src/backend/electron/electron.ts

This is what I am getting from the console when trying to run the app.

Code example:

import { EventEmitter } from "events";

export class TestClass extends EventEmitter {
  options: object;

  constructor() {
    super();
    this.options = { 
       data: data
    };
  }
}

I am unsure why this is causing an issue.

Some extra info:

I am using this in conjunction with vuejs 2, electron and vuetify.
I had to download my ts-loader to 8 to support webpack 4.

if anymore information is needed I will provide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions