2013-07-30 65 views

回答

3

我有下面的代碼完全符合Definitely Typed的最新定義。

/// <reference path="node.d.ts" /> 
/// <reference path="jasmine.d.ts" /> 

var fs = jasmine.createSpyObj('fs', ['readfile']); 
var callback = jasmine.createSpy('callback'); 

var rek = require('rekuire'); 
var proxykuire = rek('proxykuire').proxykuire; 
var getMenuDataCommand = rek('GetMenuDataCommand'); 

describe('GetMenuDataCommand', function() { 
    var getMenuDataCommand; 
    var fs; 
    var callback; 

    beforeEach(function() { 
     fs = jasmine.createSpyObj('fs', ['readFile']); 
     callback = jasmine.createSpy('callback'); 

     var getMenuDataCommand = proxykuire('GetMenuDataCommand', { fs: fs }); 
     getMenuDataCommand = new getMenuDataCommand(); 
    }); 
}); 

唯一的區別(除非我輸入了錯誤的東西)是我的引用是更接近我的打字稿文件。我得到充分的智能感知,沒有錯誤。

WebStorm

我只是在WebStorm測試,它似乎並不支持打字稿0.9,這將是一個絆腳石,如果你使用WebStorm。 (它不承認boolean類型,並且沒有支持export = internal;)。

您可以使用舊版本的定義(從更新到TypeScript 0.9之前)讓您現在開始使用,然後在WebStorm獲得0.9語言支持時進行更新。

+0

你使用webstorm嗎? – Guy

+0

好吧,我不知道你在使用WebStorm - 添加了額外的部分。 – Fenton

+0

謝謝。我明白。 – Guy