0

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

2
  • typeof is certainly available in Typescript. But it doesn't know anything about the varaibles define and global. How and where are they defined? Could you please post them to the question? Commented Mar 23, 2020 at 10:47
  • Please provide minimal reproducible repository which contains at least your tsconfig.json, package.json and project file which is screenshotted in question. Information provided in question is not helpful for answering the question. Accepted question will work but that denies the purpose of why would you even use Typescript in the first place... Commented Mar 23, 2020 at 10:54

1 Answer 1

1

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; 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.