elver
elver

Reputation: 111

Typescript does not use JS functions (Typeof)

I am trying to execute a JS code in the Angular typescript, it is a code that is not mine, the case is that the code outside Angular works perfectly, once inside the compiler I get many errors, among them I cannot solve this:

enter image description here

(function (global, factory) {
    console.log("Adminlscn.js en uso");
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
    typeof define === 'function' && define.amd ? define(['exports'], factory) :
    (global = global || self, factory(global.adminlte = {}));
  }(this, (function (exports) { 'use strict';....

I don't know why it doesn't catch or define or global, typescript is supposed to be an extension of JS, all js code should work

The terminal give me that mistake:

enter image description here

But the @types has been installed and i have this at tsconfig.json:

enter image description here

Upvotes: 0

Views: 103

Answers (1)

Poul Kruijt
Poul Kruijt

Reputation: 71911

TypeScript doesn't know what these things are. You need to declare them for the compiler. Add this above the function, so that the compiler doesn't complain anymore. You can add typings instead of any if you want:

declare define: any;
declare global: any; 

Upvotes: 1

Related Questions