草庐IT

gulp-typescript

全部标签

javascript - gulp-filter 没有正确过滤掉排除的文件

我正在尝试在一个项目中使用gulpjs而不是grunt。在我的代码上运行jsHint时,我试图使用gulp过滤器忽略vendor库。我的代码基于自述文件示例中的代码,但文件未被过滤。我正在运行Node0.10.26、gulp3.8.0和gulp过滤器0.4.1我正在尝试在包含许多其他JS文件目录的目录wcui/app/js上运行jshint,总共大约有120个js文件。我只想排除vendor目录。我的代码是这样的:vargulp=require('gulp');vargulpFilter=require('gulp-filter');varjshint=require('gulp-js

javascript - typescript : Type 'Promise<{}>' is not assignable to type 'Promise<void>'

我有以下功能: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

javascript - 无法使用 Webpack、Typescript、自定义模块目录找到模块

我想做什么我写了一个虚拟模块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

javascript - 使用 TypeScript 强制 React 组件命名

有React+TypeScript的应用,所有的组件类都要大写,有Component后缀,例如:exportclassFooBarComponentextendsReact.Component{...}应用程序被弹出create-react-application应用程序,即使用Webpack构建。如何强制组件命名与样式指南保持一致,至少对于组件类而言,当存在不一致时会在构建时抛出错误?我相信这不能单独使用TSLint/ESLint来实现。如果应该对TypeScript和JavaScript使用不同的方法,那么针对这两种语言的解决方案会很有帮助。 最佳答案

javascript - Visual Studio -> Shared TypeScript Library -> TS6059 文件 '' 不在 'rootDir' '' 下。 'rootDir' 应该包含所有源文件

我们正在使用VisualStudio2017并且有两个独立的Web项目,它们应该共享一些用TypeScript编写的React组件。还可以共享JavaScript文件和CSS文件。为此,我们在VisualStudio中创建了一个共享项目。WhatisthedifferencebetweenaSharedProjectandaClassLibraryinVisualStudio2015?目前该项目只有一个包含此信息的文件。exportconstTypes={Type1:'1',Type2:'2',Type3:'3'}为了测试,我可以像这样引用它,VisualStudio将找到该文件:im

javascript - 在 Typescript 中导入 Chai

我正在尝试在typescript中使用chai。Chai的javascript示例显示为:varshould=require('chai').should();我下载了类型定义:tsdinstallchai...引用文件,尝试导入///importshould=require('chai').should();我得到:errorTS1005:';'expected...知道怎么做吗? 最佳答案 import{should}from'chai';should(); 关于javascript

javascript - 使用 d3.js 和 TypeScript 绘制饼图时出现编译错误

我正在尝试使用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

javascript - typescript 的/** @class */有目的吗?

我正在学习typescript,我注意到编译后的javascript对每个类都有一个注释,如下所示:/**@class*/例子:varStudent=/**@class*/(function(){functionStudent(firstName,middleInitial,lastName){this.firstName=firstName;this.middleInitial=middleInitial;this.lastName=lastName;this.fullName=firstName+""+middleInitial+""+lastName;}returnStudent

javascript - Angular2 - 类型错误 : Cannot read property 'Id' of undefined in (Typescript)

我收到以下错误:angular2.dev.js:23925EXCEPTION:TypeError:Cannotreadproperty'Id'ofnullin[{{product.Id}}inProductEditComponent@0:68]抛出://Product-edit.component.ts:import{Component}from'angular2/core';import{IProduct}from'./product'import{ProductService}from'./product.service'import{RouteParams}from'angula

javascript - Typescript - 自执行匿名函数

如何使用类型脚本创建自执行的匿名函数?例如(function(){varsomeClass={}}.call(this));我想要一个内置的插件,它可能适用于Node.js,也适用于前端。 最佳答案 /***SelfexecutinganonymousfunctionusingTS.*/(()=>{//Whateverisherewillbeexecutedassoonasthescriptisloaded.console.log('executed')})();IwantabuiltapluginthatmayworkforNod