Skip to content

feat(typescript): correct many typescripts errors fixes #2617 #2620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ export class Generator extends Base {
choices: ['CSS', 'Sass', 'Stylus', 'Less'],
filter: val => val.toLowerCase()
}, {
type: 'list',
name: 'router',
default: 1,
message: 'What Angular router would you like to use?',
choices: ['ngRoute', 'uiRouter'],
filter: val => val.toLowerCase()
}, {
// type: 'list',
// name: 'router',
// default: 1,
// message: 'What Angular router would you like to use?',
// choices: ['ngRoute', 'uiRouter'],
// filter: val => val.toLowerCase()
//}, {
type: 'confirm',
name: 'bootstrap',
message: 'Would you like to include Bootstrap?'
Expand All @@ -203,8 +203,9 @@ export class Generator extends Base {
this.filters[answers.stylesheet] = true;
insight.track('stylesheet', answers.stylesheet);

this.filters[answers.router] = true;
insight.track('router', answers.router);
//this.filters[answers.router] = true;
//insight.track('router', answers.router);
this.filters['ngroute'] = true;

this.filters.bootstrap = !!answers.bootstrap;
insight.track('bootstrap', !!answers.bootstrap);
Expand Down
20 changes: 10 additions & 10 deletions templates/app/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@
"@angularclass/match-control": "^2.0.0",
"reflect-metadata": "^0.1.3",
"rxjs": "^5.3.0",
"zone.js": "^0.7.2",
"@angular/common": "~2.4.9",
"@angular/compiler": "~2.4.9",
"@angular/core": "~2.4.9",
"@angular/forms": "~2.4.9",
"@angular/http": "~2.4.9",
"zone.js": "^0.8.4",
"@angular/common": "^4.3.3",
"@angular/compiler": "^4.3.3",
"@angular/core": "^4.3.3",
"@angular/forms": "^4.3.3",
"@angular/http": "^4.3.3",
"@angular/platform-browser": "^4.3.3",
"@angular/platform-browser-dynamic": "^4.3.3",
"@angular/router": "^4.3.3",
<%#"@angular/material": "^2.0.0-alpha.10",%>
"@angular/platform-browser": "~2.4.9",
"@angular/platform-browser-dynamic": "~2.4.9",
"@angular/router": "^3.4.7",
"@angularclass/hmr": "^1.2.1",
<%_ if(filters.ts) { -%>
"@types/core-js": "^0.9.41",
Expand All @@ -82,7 +82,7 @@
"@types/webpack": "^2.2.15",
<%_ } -%>
"angular2-universal": "2.1.0-rc.1",
"angular2-jwt": "^0.1.24",
"angular2-jwt": "^0.1.28",
<% if(filters.auth) { %>
"angular-validation-match": "^1.9.0",<% } %>
<% if(filters.uirouter) { %>
Expand Down
7 changes: 2 additions & 5 deletions templates/app/client/__index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!doctype html>
<html lang="en">
<head>
<base href="/">
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<base href="/">
<title>Angular Full-Stack Generator</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
Expand All @@ -25,9 +25,6 @@
ga('send', 'pageview');
</script>

<app>LOADING</app>
<navbar></navbar>
<% if (filters.ngroute) { %><div ng-view=""></div><% } %><% if (filters.uirouter) { %><div ui-view=""></div><% } %>
<footer></footer>
<app>Loading...</app>
</body>
</html>
23 changes: 19 additions & 4 deletions templates/app/client/app/account(auth)/account.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,29 @@ import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
<%_ if (filters.uirouter) { -%>
import { UIRouterModule } from 'ui-router-ng2';<% } %>
<%_ if (filters.ngroute) { -%><% } %>
<%_ if (filters.ngroute) { -%>
import { RouterModule, Routes } from '@angular/router';<% } %>
<%_ if(filters.oauth) { -%>
import { DirectivesModule } from '../../components/directives.module';<% } %>

import { STATES } from './account.routes';
//import { STATES } from './account.routes';

import { LoginComponent } from './login/login.component';
import { SignupComponent } from './signup/signup.component';
import { SettingsComponent } from './settings/settings.component';
import { SignupComponent } from './signup/signup.component';

<%_ if (filters.ngroute) { -%>
const accountRoutes: Routes = [{
path: 'login',
component: LoginComponent,
//data: { title: 'Home' }
}, {
path: 'settings',
component: SettingsComponent,
}, {
path: 'signup',
component: SignupComponent,
}];<% } %>

@NgModule({
imports: [
Expand All @@ -21,7 +35,8 @@ import { SettingsComponent } from './settings/settings.component';
UIRouterModule.forChild({
states: STATES,
}),<% } %>
<%_ if (filters.ngroute) { -%><% } %>
<%_ if (filters.ngroute) { -%>
RouterModule.forChild(accountRoutes),<% } %>
<%_ if(filters.oauth) { -%>
DirectivesModule,<% } %>
],
Expand Down
16 changes: 11 additions & 5 deletions templates/app/client/app/account(auth)/login/login.component.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Component } from '@angular/core';
<%_ if(filters.uirouter) { -%>
import { StateService } from 'ui-router-ng2';<% } %>
<%_ if(filters.ngroute) { -%><% } %>
<%_ if(filters.ngroute) { -%>
import { Router } from '@angular/router';<% } %>
import { AuthService } from '../../../components/auth/auth.service';

// @flow
Expand Down Expand Up @@ -33,14 +34,16 @@ export class LoginComponent {
errors = {login: undefined};
submitted = false;
AuthService;
Router;
<%_ if(filters.ngroute) { -%><% } %>
<%_ if(filters.uirouter) { -%>
StateService;<% } %>

static parameters = [AuthService, <% if(filters.ngroute) { %><% } else { %>StateService<% } %>];
constructor(_AuthService_: AuthService, <% if(filters.ngroute) { %><% } else { %>_StateService_: StateService<% } %>) {
static parameters = [AuthService, <% if(filters.ngroute) { %>Router<% } else { %>StateService<% } %>];
constructor(_AuthService_: AuthService, <% if(filters.ngroute) { %>router: Router<% } else { %>_StateService_: StateService<% } %>) {
this.AuthService = _AuthService_;
<%_ if(filters.ngroute) { -%><% } %>
<%_ if(filters.ngroute) { -%>
this.Router = router;<% } %>
<%_ if(filters.uirouter) { -%>
this.StateService = _StateService_;<% } %>
}
Expand All @@ -54,7 +57,10 @@ export class LoginComponent {
})
.then(() => {
// Logged in, redirect to home
this.StateService.go('main');
<%_ if(filters.ngroute) { -%>
this.Router.navigateByUrl('/home');<% } %>
<%_ if(filters.uirouter) { -%>
this.StateService.go('main');<% } %>
})
.catch(err => {
this.errors.login = err.message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ export class SettingsComponent {
changePassword(form) {
this.submitted = true;

if(form.$valid) {
this.AuthService.changePassword(this.user.oldPassword, this.user.newPassword)
.then(() => {
this.message = 'Password successfully changed.';
})
.catch(() => {
form.password.$setValidity('mongoose', false);
this.errors.other = 'Incorrect password';
this.message = '';
});
}
return this.AuthService.changePassword(this.user.oldPassword, this.user.newPassword)
.then(() => {
this.message = 'Password successfully changed.';
})
.catch(() => {
// form.password.$setValidity('mongoose', false);
this.errors.other = 'Incorrect password';
this.message = '';
});
}
}
20 changes: 9 additions & 11 deletions templates/app/client/app/account(auth)/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,31 @@ <h1>Change Password</h1>
<div class="form-group">
<label>Current Password</label>

<input type="password" name="password" class="form-control" [(ngModel)]="user.oldPassword" mongoose-error/>
<p class="help-block" [hidden]="!form.password.$error.mongoose">
{{ errors.other }}
<input type="password" name="password" class="form-control" [(ngModel)]="user.oldPassword" required #oldPassword="ngModel"/>
<p class="help-block" [hidden]="oldPassword.valid || !submitted">
Required
</p>
</div>

<div class="form-group">
<label>New Password</label>

<input type="password" name="newPassword" class="form-control" [(ngModel)]="user.newPassword"
ng-minlength="3"
required/>
<input type="password" name="newPassword" class="form-control" [(ngModel)]="user.newPassword" required #newPassword="ngModel"
minlength="3"/>
<p class="help-block"
[hidden]="!(form.newPassword.$error.minlength || form.newPassword.$error.required) || !(form.newPassword.$dirty || submitted)">
[hidden]="newPassword.valid || !submitted">
Password must be at least 3 characters.
</p>
</div>

<div class="form-group">
<label>Confirm New Password</label>

<input type="password" name="confirmPassword" class="form-control" [(ngModel)]="user.confirmPassword"
<input type="password" name="confirmPassword" class="form-control" [(ngModel)]="user.confirmPassword" required #confirmPassword="ngModel"
match="user.newPassword"
ng-minlength="3"
required=""/>
minlength="3"/>
<p class="help-block"
[hidden]="!form.confirmPassword.$error.match || !submitted">
[hidden]="confirmPassword.valid || !submitted">
Passwords must match.
</p>

Expand Down
20 changes: 11 additions & 9 deletions templates/app/client/app/account(auth)/signup/signup.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import { Component } from '@angular/core';
<%_ if(filters.uirouter) { -%>
import { StateService } from 'ui-router-ng2';<% } %>
<%_ if(filters.ngroute) { -%><% } %>
<%_ if(filters.ngroute) { -%>
import { Router } from '@angular/router';
<% } %>
import { AuthService } from '../../../components/auth/auth.service';
import {ANGULARCLASS_MATCH_CONTROL_DIRECTIVES} from '@angularclass/match-control';

<%_ if(filters.flow) { -%>
type User = {
Expand All @@ -21,8 +22,7 @@ interface User {

@Component({
selector: 'signup',
template: require('./signup.<%=templateExt%>'),
directives: [...ANGULARCLASS_MATCH_CONTROL_DIRECTIVES]
template: require('./signup.<%=templateExt%>')
})
export class SignupComponent {
user: User = {
Expand All @@ -33,14 +33,16 @@ export class SignupComponent {
errors = {};
submitted = false;
AuthService;
<%_ if(filters.ngroute) { -%><% } %>
<%_ if(filters.ngroute) { -%>
Router;<% } %>
<%_ if(filters.uirouter) { -%>
StateService;<% } %>

static parameters = [AuthService, <% if(filters.ngroute) { %><% } else { %>StateService<% } %>];
constructor(_AuthService_: AuthService, <% if(filters.ngroute) { %><% } else { %>_StateService_: StateService<% } %>) {
static parameters = [AuthService, <% if(filters.ngroute) { %>Router<% } else { %>StateService<% } %>];
constructor(_AuthService_: AuthService, <% if(filters.ngroute) { %>router: Router<% } else { %>_StateService_: StateService<% } %>) {
this.AuthService = _AuthService_;
<%_ if(filters.ngroute) { -%><% } -%>
<%_ if(filters.ngroute) { -%>
this.Router = router;<% } -%>
<%_ if(filters.uirouter) { -%>
this.StateService = _StateService_;<% } -%>
}
Expand All @@ -55,7 +57,7 @@ export class SignupComponent {
})
.then(() => {
// Account created, redirect to home
<% if(filters.ngroute) { %>this.$location.path('/');<% } -%>
<% if(filters.ngroute) { %>this.Router.navigateByUrl('/home');<% } -%>
<% if(filters.uirouter) { %>this.StateService.go('main');<% } -%>
})
.catch(err => {
Expand Down
2 changes: 1 addition & 1 deletion templates/app/client/app/admin(auth)/admin.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class AdminComponent {

<%_ } _%>
static parameters = [UserService];
constructor(userService: UserService) {
constructor(<%= private() %>userService: UserService) {
this.userService = userService;
// Use the user service to fetch all users
this.userService.query().subscribe(users => {
Expand Down
9 changes: 6 additions & 3 deletions templates/app/client/app/admin(auth)/admin.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ import { RouterModule, Routes } from '@angular/router';<% } %>

import { AdminComponent } from './admin.component';

<%_ if(filters.ngroute) { -%>
import { ROUTES } from './admin.routes';<% } %>
<%_ if(filters.uirouter) { -%>
import { STATES } from './admin.routes';<% } %>
<%_ if (filters.ngroute) { -%>
const adminRoutes: Routes = [{
path: 'admin',
component: AdminComponent,
}];<% } %>

@NgModule({
imports: [
BrowserModule,
<%_ if(filters.ngroute) { _%>
RouterModule.forChild(ROUTES),<% } %>
RouterModule.forChild(adminRoutes),<% } %>
<%_ if(filters.uirouter) { _%>
UIRouterModule.forChild({
states: STATES,
Expand Down
2 changes: 1 addition & 1 deletion templates/app/client/app/app.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Component } from '@angular/core';
@Component({
selector: 'app',
template: `<navbar></navbar>
<ui-view></ui-view>
<% if (filters.ngroute) { %><router-outlet></router-outlet><% } %><% if (filters.uirouter) { %><ui-view></ui-view><% } %>
<footer></footer>`
})
export class AppComponent {}
2 changes: 1 addition & 1 deletion templates/app/client/app/app.constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%_ if(filters.babel) { -%>
export default from '../../server/config/environment/shared';<% } %>
<%_ if(filters.ts) { -%>
import shared from '../../server/config/environment/shared';
import shared from '../../server/config/environment/shared.js';

export default shared;<% } %>
Loading