2016-09-01 88 views
5

當前我正在使用Ionic 2.0.0-beta.37。其中使用打字稿1.8.x。我試圖給我們帶有打字稿的D3版本4,但d3-v4-definitelytyped的打字稿使用Typescript 2.x.我收到編碼上的類型錯誤,並在d3-v4-definitelytyped repo上提出問題後,我瞭解到我需要在我的Ionic 2項目中使用TS 2.x。將Ionic 2移植到Typescript 2.0 RC

這是我得到的錯誤:

TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-axis/index.d.ts(150,30): Error TS1110: Type expected. 
TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-axis/index.d.ts(167,24): Error TS1110: Type expected. 
TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-axis/index.d.ts(173,55): Error TS1110: Type expected. 
TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-axis/index.d.ts(191,24): Error TS1110: Type expected. 
TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-brush/index.d.ts(30,37): Error TS1110: Type expected. 
TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-chord/index.d.ts(38,56): Error TS1110: Type expected. 
TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-chord/index.d.ts(39,25): Error TS1110: Type expected. 
TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-chord/index.d.ts(41,59): Error TS1110: Type expected. 

我看着package.json文件在我的主要離子目錄,我沒有看到一個typescript作爲依賴,所以我的數字,這是使用別的東西來定義版本。我看到:

  • 「離子,一飲而盡,browserify-打字稿」: 「2.0.0」
  • 「tslint離子規則」: 「^ 0.0.3」
  • 「tsify」:「0.16 .0"

於是我走進tslint-ionic-rules看到:

"devDependencies": { 
    "typescript": "^1.8.10" 
    } 

只是爲了嘗試我跑npm install [email protected]在安裝新版本node_modules看看我是否得到相同的錯誤。錯誤仍然存​​在。

有人可以提供關於如何做的指導嗎? RC最近在MFST Blog上公佈。

回答

0

在我開始之前,我還沒有完全解決問題,但我至少可以解釋我所嘗試過的。 確切的說我沒有在我的gulp.file使用皮棉,但我做了ionic2使用browserify通知,當你在看的離子,一飲而盡,browserify-打字稿模塊,你可以看到:

tsifyOptions:{ }

您可以使用它來設置您想要使用的TS的版本。

例子:

  1. 安裝打字稿2.x的本地
  2. 添加tsifyOptions:{}在構建任務

它應該是這個樣子:

gulp.task('build', ['clean'], function(done){ 
    runSequence(
    ['sass', 'html', 'fonts', 'scripts'], 
    function(){ 
     buildBrowserify({ 
     minify: isRelease, 
     browserifyOptions: { 
      debug: !isRelease 
     }, 
     uglifyOptions: { 
      mangle: false 
     }, 
     tsifyOptions: { 
      typescript: require('your typescript') 
     } 
     }).on('end', done); 
    } 
); 
}); 
+0

難道這項工作爲你? – inspired

+0

我成功地加載了Typescript 2.x,但後來遇到了其他問題.. –

+0

簡單而且簡單,您可以禁用tslint,從你的一to消失。畢竟tslint只是一個standarts的集合 – misha130