NAlexP
NAlexP

Reputation: 183

Typescript syntax dosn't seem to get compiled

The ! character doesn't seem to be recognized when trying to compile the file.

enter image description here

If I do not use it, I get these errors(for context, not really important, I believe):

enter image description here

Point is, if I want to avoid those errors, I have to either use the non null assertion operator ! or to test whether or not these objects are null before using them.

Code runs like a charm using tests to verify the objects are not null, but for some reason, when trying to use the !, I get that Unexpected token error. Any clue how that could be fixed?

I have added

module.exports = {
  module:{
    rules:[
      {test: /\.ts$/, use: 'ts-loader'}
    ]
  }
};

to my wepback.config.js and now, I'm getting an Error:cannot find module 'typescript', Require stack: error.

enter image description here

Upvotes: 1

Views: 240

Answers (1)

NAlexP
NAlexP

Reputation: 183

npm install typescript --save-dev fixed the problem. I'm still courious why my globally installed typescript module(npm -i -g typescript) didn't work, though.

Upvotes: 1

Related Questions