Skip to content

Commit cf1fe47

Browse files
committed
fix(client): fix remaining TS errors
1 parent 9ae9fb5 commit cf1fe47

File tree

8 files changed

+27
-17
lines changed

8 files changed

+27
-17
lines changed

Diff for: templates/app/client/app/account(auth)/account.module.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import { NgModule } from '@angular/core';
22
import { FormsModule } from '@angular/forms';
33
import { BrowserModule } from '@angular/platform-browser';
4-
<%_ if (filters.uirouter) { -%>
4+
<%_ if(filters.uirouter) { -%>
55
import { UIRouterModule } from 'ui-router-ng2';<% } %>
6-
<%_ if (filters.ngroute) { -%>
6+
<%_ if(filters.ngroute) { -%>
77
import { RouterModule, Routes } from '@angular/router';<% } %>
88
<%_ if(filters.oauth) { -%>
99
import { DirectivesModule } from '../../components/directives.module';<% } %>
1010

11-
import { STATES } from './account.routes';
11+
<%_ if(filters.uirouter) { -%>
12+
import { STATES } from './account.routes';<% } %>
1213

1314
import { LoginComponent } from './login/login.component';
1415
import { SettingsComponent } from './settings/settings.component';
1516
import { SignupComponent } from './signup/signup.component';
1617

17-
<%_ if (filters.ngroute) { -%>
18+
<%_ if(filters.ngroute) { -%>
1819
const accountRoutes: Routes = [{
1920
path: 'login',
2021
component: LoginComponent,
@@ -31,11 +32,11 @@ const accountRoutes: Routes = [{
3132
imports: [
3233
FormsModule,
3334
BrowserModule,
34-
<%_ if (filters.uirouter) { -%>
35+
<%_ if(filters.uirouter) { -%>
3536
UIRouterModule.forChild({
3637
states: STATES,
3738
}),<% } %>
38-
<%_ if (filters.ngroute) { -%>
39+
<%_ if(filters.ngroute) { -%>
3940
RouterModule.forChild(accountRoutes),<% } %>
4041
<%_ if(filters.oauth) { -%>
4142
DirectivesModule,<% } %>

Diff for: templates/app/client/app/account(auth)/signup/signup.component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class SignupComponent {
5656
})
5757
.then(() => {
5858
// Account created, redirect to home
59-
<% if(filters.ngroute) { %>this.$location.path('/');<% } -%>
59+
<% if(filters.ngroute) { %>this.Router.navigateByUrl('/home');<% } -%>
6060
<% if(filters.uirouter) { %>this.StateService.go('main');<% } -%>
6161
})
6262
.catch(err => {

Diff for: templates/app/client/app/admin(auth)/admin.module.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { AdminComponent } from './admin.component';
99

1010
<%_ if(filters.uirouter) { -%>
1111
import { STATES } from './admin.routes';<% } %>
12-
<%_ if (filters.ngroute) { -%>
12+
<%_ if(filters.ngroute) { -%>
1313
const adminRoutes: Routes = [{
1414
path: 'admin',
1515
component: AdminComponent,

Diff for: templates/app/client/app/main/main.component.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { SocketService } from '../../components/socket/socket.service';
99
styles: [require('./main.<%=styleExt%>')],
1010
})
1111
export class MainComponent implements OnInit<% if(filters.ws) { %>, OnDestroy<% } %> {
12+
Http;
1213
<%_ if(filters.ws) { -%>
1314
SocketService;<% } %>
1415
awesomeThings = [];

Diff for: templates/app/client/components/auth(auth)/auth.service.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ export class AuthService {
2222
_currentUser: User = new User();
2323
@Output() currentUserChanged = new EventEmitter(true);
2424
userRoles = constants.userRoles || [];
25+
Http;
26+
AuthHttp;
27+
UserService;
2528

2629
static parameters = [Http, AuthHttp, UserService];
2730
constructor(<%= private() %>http: Http, <%= private() %>authHttp: AuthHttp, <%= private() %>userService: UserService) {
@@ -31,6 +34,7 @@ export class AuthService {
3134

3235
if(localStorage.getItem('id_token')) {
3336
this.UserService.get().toPromise()
37+
.then(extractData)
3438
.then((user: User) => {
3539
this.currentUser = user;
3640
})
@@ -146,7 +150,7 @@ export class AuthService {
146150
* @param {Function} [callback] - function(user)
147151
* @return {Promise}
148152
*/
149-
getCurrentUser(callback?) {
153+
getCurrentUser(callback<% if(filters.ts) { %>?<% } %>) {
150154
safeCb(callback)(this.currentUser);
151155
return Promise.resolve(this.currentUser);
152156
}
@@ -185,7 +189,7 @@ export class AuthService {
185189
* @param {Function|*} [callback] - optional, function(is)
186190
* @return {Promise}
187191
*/
188-
isAdmin(callback?) {
192+
isAdmin(callback<% if(filters.ts) { %>?<% } %>) {
189193
return this.getCurrentUser().then(user => {
190194
var is = user.role === 'admin';
191195
safeCb(callback)(is);

Diff for: templates/app/client/components/auth(auth)/user.service.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ function handleError(err) {
2222

2323
@Injectable()
2424
export class UserService {
25+
AuthHttp;
26+
2527
static parameters = [AuthHttp];
2628
constructor(<%= private() %>authHttp: AuthHttp) {
2729
this.AuthHttp = authHttp;
@@ -32,7 +34,7 @@ export class UserService {
3234
.map((res:Response) => res.json())
3335
.catch(handleError);
3436
}
35-
get(user: UserType = {id: 'me'}): Observable<UserType> {
37+
get(user<% if(filters.ts) { %>: UserType<% } %> = {id: 'me'}): Observable<UserType> {
3638
return this.AuthHttp.get(`/api/users/${user.id || user._id}`)
3739
.map((res:Response) => res.json())
3840
.catch(handleError);

Diff for: templates/app/client/components/navbar/navbar.component.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ import { AuthService } from '../auth/auth.service';<% } %>
1212
})
1313
export class NavbarComponent {
1414
isCollapsed = true;
15-
isLoggedIn;
16-
isAdmin;
17-
currentUser = {};
1815
menu = [{
1916
title: 'Home',
2017
<% if(filters.uirouter) { %>'state': 'main'<% } else { %>'link': '/home'<% } %>,
2118
}];
19+
<%_ if(filters.ngroute) { -%>
20+
Router;<% } %>
2221
<%_ if(filters.auth) { -%>
22+
isAdmin;
23+
isLoggedIn;
24+
currentUser = {};
25+
AuthService;
2326

2427
static parameters = [AuthService<% if(filters.uirouter) { %>, StateService<% } else { %>, Router<% } %>];
2528
constructor(<%= private() %>authService: AuthService<% if(filters.uirouter) { %>, <%= private() %>stateService: StateService<% } else { %>, <%= private() %>router: Router<% } %>) {

Diff for: test/fixtures/.yo-rc.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"flow": false,
1919
"html": true,
2020
"sass": true,
21-
"uirouter": true,
21+
"ngroute": true,
2222
"bootstrap": true,
2323
"uibootstrap": true,
2424
"ws": true,
@@ -41,11 +41,10 @@
4141
"moduleName": "",
4242
"modulePrompt": true,
4343
"filters": [
44-
"uirouter",
44+
"ngroute",
4545
"mocha",
4646
"expect",
4747
"should",
48-
"uirouter",
4948
"es6",
5049
"webpack"
5150
],

0 commit comments

Comments
 (0)