te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - Ionic 3 - All imports are unused warning (even though they are being used) - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Ionic 3 - All imports are unused warning (even though they are being used) - Stack Overflow

programmeradmin2浏览0评论

I am getting the following error when trying to run a prod build using the following

ionic cordova build browser --prod

Getting lot of warnings in the terminal like

FormBuilder is declared but never used

Even though in my code I am importing it and using it e.g.

import { Validators, FormGroup, FormBuilder } from '@angular/forms';

public form: FormGroup;

constructor(
    private formBuilder: FormBuilder
  ) {

setForm(){
    this.form = this.formBuilder.group({
      password: ['', Validators.required],
      password2: ['', Validators.required]
    });
  }

Has anyone had a similar problem? My guess it would be something to do with an npm package update.

Any advice would be great.

Thanks!

I am getting the following error when trying to run a prod build using the following

ionic cordova build browser --prod

Getting lot of warnings in the terminal like

FormBuilder is declared but never used

Even though in my code I am importing it and using it e.g.

import { Validators, FormGroup, FormBuilder } from '@angular/forms';

public form: FormGroup;

constructor(
    private formBuilder: FormBuilder
  ) {

setForm(){
    this.form = this.formBuilder.group({
      password: ['', Validators.required],
      password2: ['', Validators.required]
    });
  }

Has anyone had a similar problem? My guess it would be something to do with an npm package update.

Any advice would be great.

Thanks!

Share Improve this question asked Jun 26, 2017 at 12:02 user2085143user2085143 4,2327 gold badges42 silver badges71 bronze badges 3
  • Remember that you should delete your node_modules folder after updating the project to Ionic3, then run npm install again. With the new CLI these warnings will be more aggressive, prepare yourself. – dlcardozo Commented Jun 26, 2017 at 14:37
  • Thanks for the response. I have deleted them and re-installed many times now. Updated to Ionic 3 a while back and didn't have this issue, only starting occurring recently. – user2085143 Commented Jun 26, 2017 at 15:30
  • I have the same issue, any help? – Eusthace Commented Jun 27, 2017 at 1:30
Add a ment  | 

3 Answers 3

Reset to default 10

Ionic 3.3.0 (2017-05-24) removed the usage of legacy file 'src/declarations.d.ts' as mentioned in the changelog. Removing 'declarations.d.ts' from the src/ folder fixes the unused imports warning.

For more info check out the GitHub issue.

I have the same issue and this is because tslint 5.0 changed how it checks unused variables.

You can suppress the warnings by changing the rules of the tslint.json file. I changed the "no-unused-variable" from true to false so it will look something like this:

{
  "rules": {
    "no-duplicate-variable": true,
    "no-unused-variable": [
      false
    ]
  },
  "rulesDirectory": [
    "node_modules/tslint-eslint-rules/dist/rules"
  ]
}

Of course this will suppress all warnings about unused variables but at anytime you can revert it to true to see if there are any other unused variables.

You can also add the following variable "noUnusedLocals": true to the tsconfig.json file:

{
  "pilerOptions": {
    "noUnusedLocals": true,
.
.
.
}

Just know that the "noUnusedLocals": true will throw errors instead of warnings though...

Hope this helps

Working form with my ionic 3 App:

import {FormBuilder, FormGroup, Validators  } from '@angular/forms';


@IonicPage()
@Component({
  selector: 'page-mobile-login',
  templateUrl: 'mobile-login.html',
})
export class MobileLoginPage {
    public loginForm:FormGroup;

    constructor(public navCtrl: NavController, 
      public navParams: NavParams,
      public formBuilder: FormBuilder) 
      {
          this.loginForm = formBuilder.group({
              mobile: ['', Validators.pose([Validators.required,Validators.pattern('[0-9 ]*'),
                Validators.maxLength(10),Validators.minLength(10)])]
            });
      }


}

Seems issue you are using another function setForm() in constructor.

mobile-login.html

<form [formGroup]="loginForm" (submit)="submitMobile()" novalidate>
  <ion-list padding-right padding-left>
    <ion-item no-padding>
      <ion-input formControlName="mobile" type="tel" 
        placeholder="Enter Mobile" minlength="10" maxlength="10"
        [class.invalid]="!loginForm.controls.mobile.valid && loginForm.controls.mobile.dirty">
      </ion-input>
    </ion-item>
    <ion-item no-padding class="error-message" 
      *ngIf="!loginForm.controls.mobile.valid && loginForm.controls.mobile.dirty">
      <p ion-text>
        Enter Valid Mobile Number
      </p>
    </ion-item>
  </ion-list>

    <ion-row responsive-sm padding-right padding-left>
      <ion-col class="otpbutton">
        <button color='navbarColor' class="bluebg" ion-button block icon-left type="submit" [disabled]="!loginForm.valid">
        <ion-icon name="phone-portrait"></ion-icon>
            Submit
        </button>
      </ion-col>
    </ion-row>
  </form>
发布评论

评论列表(0)

  1. 暂无评论