草庐IT

grunt-typescript

全部标签

javascript - grunt 没有在 phantom 上运行 QUnit 测试

我有一个repository它与travis集成在一起。我有QUnit测试,我想从grunt/node服务器端和AMD(requirejs)运行。这是我的AMDinit.js的来源:(function(){require.config({baseUrl:"../src"});require(["../test/suites/basic",'../test/qunit-extend','qunit'],function(BasicTests){QUnit.config.autoload=false;QUnit.config.autostart=false;BasicTests.run()

javascript - Console.log 在使用 grunt 服务器的 Qunit 测试中不起作用

我正在创建在grunt服务器上运行的Qunit测试。在测试中,当我尝试使用“console.log”将一些输出记录到控制台时,它不会在控制台中打印任何内容。目前我只能使用OK来执行断言。请提供您的意见。 最佳答案 如果您在grunt中使用qunit任务,则需要使用--debug(即grunttest--debug)启动任务。然后,您将看到幻影日志以下列格式打印出您的控制台日志:[D]["phantomjs","console","MIXPANELPEOPLEREQUEST(QUEUED,PENDINGIDENTIFY):"]Seed

javascript - 如何将 grunt 任务的 feed 输出提供给另一个 grunt 任务?

我不确定grunt是否可以做到这一点。我有两个要运行的繁重任务。第一个任务是创建一个模拟帖子,第二个是运行penthouse任务来内联css。欢迎任何骇人听闻的方式。这是我在WordPress中创建博文时必须运行的exec任务。exec:{create_mock:{cmd:'cd~/MyProjects/project/vip-quickstart&&vagrantssh-c\'sh/srv/www/wp-content/themes/vip/the-theme/bin/mock-post.sh\'',callback:function(err,stdout,stderr){grunt

javascript - es6 模块到 commonjs,在 node harmony 标志下使用 typescript

我在--harmony标志下使用带有Node的TypeScript(1.6),所以我想将es6模块语法转换为commonjs。据我所知,我无法使用TypeScript1.6执行此操作。如果我将目标设置为es6,并将模块设置为commonjs,我会收到TypeScript错误-Cannotcompilemodulesinto'commonjs','amd','system'or'umd'whentargeting'ES6'orhigher.为什么TypeScript不能编译成带有ES6目标的commonjs?我想很多人都想这样做,因为Node还不支持ES6模块。我原以为新的moduleR

javascript - TypeScript 处理接口(interface)和类中多余属性的方式不同

我最近在TypeScript中偶然发现了这种奇怪的(imo)行为。在编译期间,只有当预期变量的类型是接口(interface)且接口(interface)没有必填字段时,它才会提示过多的属性。链接到TypeScriptPlayground#1:http://goo.gl/rnsLjdinterfaceIAnimal{name?:string;}classAnimalimplementsIAnimal{}varx:IAnimal={bar:true};//Objectliteralmayonlyspecifyknownproperties,and'bar'doesnotexistinty

javascript - 使用类将 JSON 对象转换为 typescript 类型变量的正确方法?

这是我正在尝试做的一个更简单的例子:exportclassPerson{id:Number;name:String;}exportclassPersonForm{//Thisline:default:Person={name:"Guy"};//Givesthefollowingerror://Error:(25,5)TS2322:Type'{name:string;}'isnotassignabletotype'Person'.//Property'id'ismissingintype'{name:string;}'.//Itried{name:"Guy"}butitgivesthes

javascript - 缺少 grunt 必需的配置属性

设置一个新项目,该项目将包含多个我想从任务文件加载的grunt任务。在运行我的第一个任务“核心”(应该为网站构建核心CSS)时,我遇到了一个我似乎无法解决的错误。一直在谷歌搜索,但没有找到这个具体问题。相同错误消息的任何问题通常是由于OP的拼写错误或花括号放错地方造成的。不确定这里的情况,但也许其他人看到了我显然没有看到的东西。Gruntfile.jsmodule.exports=function(grunt){grunt.initConfig({pkg:require('./package.json')});grunt.loadTasks('grunt-tasks');};grunt

javascript - 在 typescript 中获取函数名称

我正在寻找一种方法来获取传入参数的函数名称console.clear();classA{test(){}testCall(fnc:Function){console.log(fnc.name);//iwantitdisplaytestherenotemptyconsole.log(fnc);}}vara=newA();a.testCall(a.test);你可以在jsbin中查看http://jsbin.com/loluhu/edit?js,console 最佳答案 我发现这是typescript中的一个错误你可以在这里找到解决方案

javascript - TypeScript 可更新和枚举引用

我有一个用JavaScript编写的外部SDK,我正在使用它。这些模块之一,Blob是可更新的,但也公开了一个枚举FooEnum(成员Bar和Baz).在JavaScript中使用此SDK的代码如下:constblobInstance=newSdk.Blob();constfooType=Sdk.Blob.FooEnum.Baz;我现在正在尝试编写一个接口(interface),我可以将此SDK转换到该接口(interface),以提供一些类型安全性。这是我到目前为止所得到的:interfaceBlobInterface{}enumFoo{Bar,Baz}interfaceSdk{Bl

javascript - 如何在 Vue.js - Nuxt - TypeScript 应用程序中访问路由参数?

我正在构建一个基于NuxtTypeScriptStarter的网站模板。我在我的页面文件夹中创建了一个动态路由的页面_id.vue,我想在我的TS类中访问该id属性。我可以通过编写{{$route.params.id}}在我的模板中访问它,但是当我尝试在类中引用$route时,我得到一个错误:errorTS2304:Cannotfindname'$route'. 最佳答案 作为一个简单的解决方案,尝试从vue-router导入路由,如下所示:importComponentfrom"vue-class-component"import