Skip to content

Commit

Permalink
Upgraded to Typescript 1.6, fixed errors that were caused by the more…
Browse files Browse the repository at this point in the history
… constrained object type inspections.
  • Loading branch information
zakhenry committed Sep 17, 2015
1 parent 7c2101c commit a83ae5c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 18 deletions.
12 changes: 9 additions & 3 deletions app/src/common/models/abstractModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ namespace common.models {

export interface IModel{
getAttributes(includeUnderscoredKeys?:boolean):Object;
setExists(exists:boolean):void;
exists():boolean;
}

export interface IModelClass{
new(data?:any, exists?:boolean):IModel;
}

export interface IModelFactory{
(data:any, exists?:boolean):IModel;
}

export class AbstractModel implements IModel {
export abstract class AbstractModel implements IModel {

protected _nestedEntityMap;
private _exists:boolean;
Expand Down Expand Up @@ -47,7 +53,7 @@ namespace common.models {
*/
protected hydrateNested(data:any, exists:boolean){

_.forIn(this._nestedEntityMap, (model:typeof AbstractModel, nestedKey:string) => {
_.forIn(this._nestedEntityMap, (model:IModelClass, nestedKey:string) => {

//if the nested map is not defined with a leading _ prepend one
if (!_.startsWith(nestedKey, '_')){
Expand Down Expand Up @@ -77,7 +83,7 @@ namespace common.models {
* @returns {common.models.AbstractModel}
* @param exists
*/
private hydrateModel(data:any, Model:typeof AbstractModel, exists:boolean){
private hydrateModel(data:any, Model:IModelClass, exists:boolean){

let model = new Model(data);
model.setExists(exists);
Expand Down
4 changes: 2 additions & 2 deletions app/src/common/models/user/userModel.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace common.models {

export class UserMock{

private static getMockData():global.IUserData {
public static getMockData():global.IUserData {

let seededChance = new Chance(Math.random());

Expand All @@ -11,7 +11,7 @@ namespace common.models {
email:seededChance.email(),
firstName:seededChance.first(),
lastName:seededChance.last(),
emailConfirmed:seededChance.date(),
emailConfirmed: moment(seededChance.date()).toISOString(),
country:seededChance.country(),
avatarImgUrl:seededChance.url(),
regionCode: seededChance.pick(['uk', 'us', 'gb']),
Expand Down
12 changes: 1 addition & 11 deletions app/src/common/models/user/userModel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@ namespace common.models {

describe('User Model', () => {

let userData:global.IUserData = {
userId:seededChance.guid(),
email:seededChance.email(),
firstName:seededChance.first(),
lastName:seededChance.last(),
emailConfirmed:seededChance.date(),
country:seededChance.country(),
avatarImgUrl:seededChance.url(),
userType: seededChance.pick(User.userTypes),
_socialLogins:(<common.models.UserSocialLogin[]>[])
};
let userData:global.IUserData = UserMock.getMockData();

it('should instantiate a new user', () => {

Expand Down
2 changes: 1 addition & 1 deletion app/src/common/models/user/userSocialLoginModel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module common.models {

export class UserSocialLogin extends AbstractModel {
export class UserSocialLogin extends AbstractModel implements global.ISocialLogin {

public static googleType = 'google';
public static facebookType = 'facebook';
Expand Down
1 change: 1 addition & 0 deletions app/src/common/services/image/imageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace common.services.image {

export interface ICloudinaryFileUploadConfig extends ng.angularFileUpload.IFileUploadConfig {
fields: ICloudinaryUploadRequest;
sendFieldsAs: string;
}

export interface IImageNotification {
Expand Down
12 changes: 12 additions & 0 deletions app/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,24 @@ declare namespace global {
password: string;
}

export interface ISocialLogin {
userId:string;
provider:string;
token:string;
}

export interface IUserData extends NgJwtAuth.IUser {
_self?:string;
userId:string;
firstName:string; //make compulsory
lastName:string; //make compulsory
userType?:string;
emailConfirmed?:string;
avatarImgUrl?:string;
country?:string;
regionCode?:string;
_userCredential? : IUserCredential;
_socialLogins? : ISocialLogin[];
}

export interface IRootScope extends ng.IRootScopeService {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@
"selenium-webdriver": "^2.45.1",
"sinon": "^1.15.4",
"tsd": "^0.6.3",
"typescript": "^1.5.3"
"typescript": "^1.6"
}
}

0 comments on commit a83ae5c

Please sign in to comment.