简体   繁体   English

Typescript 不使用 JS 函数(Typeof)

[英]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:我正在尝试在 Angular 打字稿中执行一段 JS 代码,它不是我的代码,情况是 Angular 之外的代码运行良好,一旦进入编译器,我就会遇到很多错误,其中我无法解决这个问题:

在此处输入图片说明

(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我不知道为什么它不捕获或定义或全局,typescript 应该是 JS 的扩展,所有 js 代码都应该工作

The terminal give me that mistake:终端给了我那个错误:

在此处输入图片说明

But the @types has been installed and i have this at tsconfig.json:但是@types 已经安装,我在 tsconfig.json 有这个:

在此处输入图片说明

TypeScript doesn't know what these things are. TypeScript 不知道这些东西是什么。 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:如果需要,您可以添加类型而不是any

declare define: any;
declare global: any; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM