添加和使用自定义的js文件我有非常标准的角2应用程序与角CLI如何角2应用在打字稿组件
我希望能够使用自定义的js文件,它创建的。 简体版嘲笑看起来像:
'use strict';
var testingThing = testingThing || {};
testingThing.Client = function (name) {
var self = this;
console.log(name);
this.parseUri = function (str) {
console.log(str);
return str;
};
return this;
};
// Node environment module
if (typeof window === 'undefined') {
module.exports = testingThing;
}
我挣扎我如何使用它打字稿组件中。
我想这(或类似的,也尝试不同的东西)
export class TestService {
something: any;
constructor() {
this.something = new testingThing.Client();
var huh = this.something.new("test name");
testingThing.parseUri("testParse");
}
}
我试图生成打字它
declare namespace testingThing{
class Client {
new (name : string): /* testingThing.Client */ any;
}
function parseUri(str : any): any;
}
但后来我得到了在控制台的错误,那testingThing没有定义。
Cannot read property 'Client' of undefined
当我试图导入它时,它说testingThing不是一个模块。
我也加入到myCustom.js角cli.json
"scripts": [
"./myCustom.js"
],
我试过几个来自互联网不同的方法,所以我现在是完全的想法,我在做什么错。这是我对它的用法,我的打字定义,还是其他任何东西。
我希望答案是一种明显的人更多的用于前端编程,但我现在堆叠。