2017-09-22 2 views
0
  • tslintおよびtypescriptを初めて使用しています。
  • このエラーを修正しようとしています。
  • あなたはそれを修正する方法を教えてもらえますか?
  • 私はいくつかの調査をしましたが、解決策を見つけることができませんでした。
  • 以下のコードを提供してください。

(no-typeof-undefined)app/components/sports.ts:typeof x === 'undefined'比較は避けてください。好みのx ==未定義またはX ===未定義:!typeof演算hen.waterFox = "未定義"tslintはエラーを生成しますが、機能は正常に動作します。

fever(hen, health): any { 
     let sky = "waterFoxDiplay"; 
     let extensionType = { 
     ".pdf": "pdfFox", 

     }; 
     let captain = hen.waterName.captainOf("."); 

     sky = extensionType[hen.waterName.slice(captain).toLowerCase()]; 
     if (typeof hen.waterFox != "undefined" && hen.waterFox != "") { 
     sky = hen.waterFox; 
     } 
     if (typeof sky === "undefined") { 
     sky = "newJokeFox"; 
     } 
     let kendotxtMenu = ""; 
     if (hen.isMobileJoke == true) //isMobileJokeUploaded 
     { 
     kendotxtMenu = "waterFoxDiplay"; 
     } 
     if (hen.isMobileJoke == true && hen.MobileJokeID <= 0) //isMobileJokeUploaded 
     { 

     } 
     return "<span onclick=\"window.open('" + hen.waterName + "', 'popup', 'width=800,height=600,scrollbars=yes,resizable=no')\" class='" + sky + " displayInlineBlock " + kendotxtMenu + "'></span> <ul class='fileTypeHolder' id='fileTypeFoxs' style='display: none;'><li class='fileTypeHolderTitle'>Mobile water Type</li><li><span class='waterFox displayInlineBlock' (click)='browseFileType(Joke)'></span></li> <li><span class='xlsFox displayInlineBlock' (click)='browseFileType('xls')'></span></li> <li><span class='pptFox displayInlineBlock'(click)='browseFileType('ppt')'></span></li> <li><span class='pdfFox displayInlineBlock' (click)='browseFileType('pdf')'></span></li><li><span class='newJokeFox displayInlineBlock' (click)='browseFileType('newJoke')'></span></li><li><span class='mailFox displayInlineBlock' (click)='browseFileType('mail')'></span></li><li class='fileTypeHolderCloseBtn'> <button id='CloseBtn' class='commonBtn'>Close</button></ul>"; 
    } 

答えて

1

を変更し、次のコードブロック

if (typeof hen.waterFox != "undefined" && hen.waterFox != "") { 
     sky = hen.waterFox; 
    } 
     if (typeof sky === "undefined") { 
     sky = "newJokeFox"; 
    } 

if (hen.waterFox !== undefined && hen.waterFox != "") { 
     sky = hen.waterFox; 
    } 
     if (sky === undefined) { 
     sky = "newJokeFox"; 
    } 
+0

へお返事ありがとうございました...私は別のエラーが発生しています...任意のアイデア?メソッド名feverのメソッド名が/^[a-z] [\ w \ d] + $ /:fever –

+0

と一致しない場合は、feverメソッド名を 'setFever'や' getFever'や 'calculateFever'などに変更してみてください。すべてのルールをここで読んでください。 https://github.com/Microsoft/tslint-microsoft-contrib – Thusitha

+0

オペレーター –

関連する問題