typescript-tslint-plugin
全部标签 这个问题在这里已经有了答案:ShortcircuitArray.forEachlikecallingbreak(30个答案)关闭4年前。我想知道是否有更好的方法来执行此操作-看起来从foreach返回并没有从包含foreach循环的函数返回,这可能是C#开发人员的期望。只是想知道是否有更简洁的方法:example(){varforEachReturned;this.items.forEach(item=>{if(true){forEachReturned=true;return;}});if(forEachReturned){return;}//DostuffincaseforEach
我是maven和frontend-maven-plugin的新手。我知道我们可以将此代码添加到pom.xml以运行grunt,例如:com.github.eirslettfrontend-maven-plugintothelatestreleasedversionoffrontend-maven-plugin,likeinREADME.md-->@project.version@installnodeandnpminstall-node-and-npmv5.3.03.3.12npminstallnpminstallnpmrunbuildnpmrunbuildgruntbuildgrun
我有以下功能:lettemplateLoader=(onDidFinishLoad:Function,onDidFailLoad:Function)=>(url:string):Promise=>newPromise((resolve,reject)=>{mainWindow.loadURL(url);mainWindow.webContents.once('did-finish-load',()=>{onDidFinishLoad(resolve);});mainWindow.webContents.once('did-fail-load',(event,errorCode,erro
我想做什么我写了一个虚拟模块my-component,它基本上导出了一个类Something。我把它放在app/modules/中。现在我想使用app/app.js中的导入语法来访问它:import{Something}from'my-component';期望:根据我当前的Webpack配置(如下),我希望它能工作。实际:这会引发错误:ERRORin[default]//app/app.ts:1:26Cannotfindmodule'my-component/Something'.我尝试解决的问题我知道模块本身的定义是正确的,因为我可以使用相对路径导入它:import{Somethi
有React+TypeScript的应用,所有的组件类都要大写,有Component后缀,例如:exportclassFooBarComponentextendsReact.Component{...}应用程序被弹出create-react-application应用程序,即使用Webpack构建。如何强制组件命名与样式指南保持一致,至少对于组件类而言,当存在不一致时会在构建时抛出错误?我相信这不能单独使用TSLint/ESLint来实现。如果应该对TypeScript和JavaScript使用不同的方法,那么针对这两种语言的解决方案会很有帮助。 最佳答案
我需要应用哪个规则来强制导入语句中大括号之间的空格?即代替:import{IPostService}from'./api/IPostService';我要:import{IPostService}from'./api/IPostService'; 最佳答案 我认为这可能是您正在寻找的:"whitespace":[true,"check-module"]check-module-检查导入和导出语句中的空格。 关于javascript-TSLint,强制导入语句中括号之间的间距,我们在Sta
我们正在使用VisualStudio2017并且有两个独立的Web项目,它们应该共享一些用TypeScript编写的React组件。还可以共享JavaScript文件和CSS文件。为此,我们在VisualStudio中创建了一个共享项目。WhatisthedifferencebetweenaSharedProjectandaClassLibraryinVisualStudio2015?目前该项目只有一个包含此信息的文件。exportconstTypes={Type1:'1',Type2:'2',Type3:'3'}为了测试,我可以像这样引用它,VisualStudio将找到该文件:im
我将Webpack与插件一起使用html-webpack-plugin.基于环境变量,我想注入(inject)标签进入最后index.html文件。我该怎么做? 最佳答案 您可以定义自己的模板。在WritingYourOwnTemplates中简要提到了它您可以将任何您想要的选项传递给它,并在带有htmlWebpackPlugin.options的模板中使用它们:htmlWebpackPlugin.options:theoptionshashthatwaspassedtotheplugin.Inadditiontotheoption
我正在尝试在typescript中使用chai。Chai的javascript示例显示为:varshould=require('chai').should();我下载了类型定义:tsdinstallchai...引用文件,尝试导入///importshould=require('chai').should();我得到:errorTS1005:';'expected...知道怎么做吗? 最佳答案 import{should}from'chai';should(); 关于javascript
我正在尝试使用d3.js库和TypeScript绘制饼图。我有以下代码:"usestrict";moduleChart{exportclasschart{privatechart:d3.Selection;privatewidth:number;privateheight:number;privateradius:number;privatedonutWidth:number;privatedataset:{label:string,count:number}[];privatecolor:d3.scale.Ordinal;constructor(container:any){this