[英]How to disable tslint for an unused import in Angular
我有一個小項目。 我想創建一個為此而構建的產品。 我使用了這個命令:
ng build --prod
但它拋出了一些構建錯誤。 所以我問了我的技術負責人,她告訴我添加這個導入:
import ResizeObserver from 'resize-observer-polyfill'
在此之后構建成功,但現在文件沒有通過 linting 測試。 由於導入未在此代碼中的其他任何地方使用。 我收到此錯誤:
錯誤:C:/Users/320035648/Angular/pinc-insights-ui/src/app/app.module.ts:29:1 - 此行上的所有導入均未使用。 在列出的文件中發現 Lint 錯誤。
所以我在導入之前添加了這一行:
/* tslint: disable: no-unused-variable */
但我仍然遇到同樣的錯誤。 請幫我。
如果您不使用ResizeObserver
,因此只使用庫導入副作用,為什么不簡單地以這種方式導入庫:
import 'resize-observer-polyfill'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.