typescript-tslint-plugin
全部标签 是否可以包含jquery.d.ts并使用jQueryStatic类型?我需要类似的东西...protectedel:jQueryStatic;...无论我如何尝试,我都无法从https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/jquery导入jQueryStatic接口(interface)非常感谢。更新///errorTS2304:Cannotfindname'jQuery'.///import{jQuery}from'jquery';errorTS2305:Module'"jquery"'hasnoexpor
我在下面的代码中做错了什么?我正在尝试在我的类MyNumberList上扩展Array,然后尝试使用它。我看到的是似乎没有任何项目被添加到列表中。当我尝试访问列表元素时,我得到一个undefined。P.S我正在使用TypeScript1.8.2classMyNumberListextendsArray{constructor(...numbers:number[]){//lookslikethisisnotworkingsuper(...numbers);}}letstatusCodes:MyNumberList=newMyNumberList(10,20,30);console.l
我有一个具有以下属性的typescript类:exportclassapiAccount{private_balance:apiMoney;getbalance():apiMoney{returnthis._balance;}setbalance(value:apiMoney){this._balance=value;}private_currency:string;getcurrency():string{returnthis._currency;}setcurrency(value:string){this._currency=value;}...我需要为这个类创建一个空白实例:l
我在我的TypeScript(Ionic2/Angular2)项目中使用moment.js。继thispost,我现在想试用一个插件moment-duration-format我有npm包和类型定义,可以通过importas..使用。importmomentfrom'moment';...letduration=moment.duration(decimalHours,'hours');我现在想使用moment-duration-format我通过npminstallmoment-duration-format--save安装,然后通过npmi@types/moment-duratio
我正在尝试使用Karma、Jasmine和Webpack测试(覆盖)我的TypeScript应用程序。通过以下,我能够成功运行测试,但无法正确生成覆盖率。我正在使用karma-remap-coverage(https://github.com/sshev/karma-remap-coverage),它看起来很简单。它看起来好像发生了一些有趣的事情(而且我得到了某种覆盖率报告)但是在这里和那里进行了一些调整,数字发生了巨大变化,我永远无法真正加载源map。这是基本设置:我有一个src目录,其中包含10个.ts文件。目前只有一个有相应的.spec文件。spec文件非常简单,足以证明我可以运
我有一个这样的结构:structtTest{charfoo[1+1];charbar[64];};我有TypesScriptexportinterfacetTest{foo:string;bar:string;}有没有办法将[64]和[1+1]添加到类型中? 最佳答案 正如评论所说:js/ts不支持char类型,无法声明数组/字符串长度。不过,您可以使用setter强制执行:interfacetTest{foo:string;}classtTestImplementationimplementstTest{private_foo:s
我正在尝试使用TypeScript中先前设置的变量的值动态访问类的方法。类似的东西:classFoo{bar(){}}varmethodName="bar";varfooBar=newFoo();fooBar.methodName();//IwouldlikethistoresolvetofooBar.bar();例如,在PHP中我可以执行以下操作:classFoo{publicfunctionbar(){}}$methodName="bar";$fooBar=newFoo();$fooBar.$methodName();//resolvestofooBar.bar();谁知道这是否可
声明declaremodule"MyModule"{exportfunctionFoo(){...}exportfunctionBar(){...}}我只需要Foo某处,我应该如何导入它?import*asMyModulefrom"MyModule";MyModule.Foo();或import{Foo}from"MyModule";Foo()哪个比另一个好?以第一种方式导入所有导出是否有任何性能影响?我在发布问题之前阅读的一些引用资料:https://www.exratione.com/2015/12/es6-use-of-import-property-from-module-is
我的意图是有这样的目录结构:-/my-project/--/src/(hereareall.tsxfileslocated)--/dist/-index.html-/build/-bundle.js--/node_modules/--package.json--tsconfig.json--webpack.config.js所以,我想要我的index.html,它是在/dist子目录中手动创建的,在它里面我想要/buildsubdir,webpack制作的app.js所在的位置。我希望当我保存一些位于我的/src目录中的.tsx文件时,webpack会自动重建app.js并且webpa
我正在尝试使用taggedtemplateliteral带有typescript的ES5,但似乎typescript没有完全支持它。我有以下代码。classTemplateLiterals{age:number=24;name:'LukeSkywalker'privatetag(strings:string[],personExp,ageExp):string{varstr0=strings[0];//"that"varstr1=strings[1];//"isa"varageStr;if(ageExp>99){ageStr='centenarian';}else{ageStr='yo