Open phil123456 opened 7 years ago
Uh, interesting, can I see code? Is that error from the linter or ts?
so with OnInit
[at-loader] Checking started in a separate process...
[at-loader] Checking finished with 1 errors
Error in bail mode: [at-loader] ./src/app/app.component.ts:1:32
TS6133: 'OnInit' is declared but never used.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.9.2
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
with OnInit commented
WARNING in ./src/app/app.component.ts
[31, 5]: Implement lifecycle hook interface OnInit for method ngOnInit in class AppComponent (https://goo.gl/w1Nwk3)
@ ./src/app/app.module.ts 20:22-48
@ ./src/main.ts
import { Component, ViewChild, /*OnInit*/ } from '@angular/core';
import { Router } from '@angular/router';
import { DialogComponent } from './components/dialog/dialog.component';
import { DataService } from './data/data.service';
import { UserSession } from './data/userSession.class';
@Component({
selector: 'my-catalog-backend',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
@ViewChild(DialogComponent) dialog: DialogComponent;
constructor(private dataService: DataService, private router: Router) {
}
ngOnInit() {
this.dataService.getUserSession().subscribe(
(userSession: UserSession) => {
if (userSession) {
this.router.navigate(['products' /*,1*/ ]);
} else {
this.router.navigate(['login']);
}
});
}
}
Super hard to read. Clean it up please, remove comments and stuff.
I think I've found it, you have imported OnInit interface declaration and also implemented its method, but your class does not use that interface. To fix it, just update your export class AppComponent
to export class AppComponent implements OnInit
and check if the error goes away.
Docs: https://www.typescriptlang.org/docs/handbook/interfaces.html
ok so apparently it gets triggered, but the ts files are not debugable even if I set breakpoints they are never reached I'll create a new thread for this, since it's a different issue
@phil123456 that's the normal behaviour of webpack. It's nothing to do with the angular-webpack stater kit.
Hi,
I get something very strange with this seed
TS6133: 'OnInit' is declared but never used.
but I got ngOnInit() in my code (that used to be working)
if I comment OnInit then it compiles but my ngOnInit are never called
tried to dig this in google but cant find anything
any idea ? am I missing something ?
thanks