Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
fix: retain backwards compat
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl committed Sep 10, 2018
1 parent 128b8a8 commit 39e58a1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/model/user-store-enhancer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as Mobx from 'mobx';
import * as Types from '../types';
import * as TypeScript from 'typescript';
import { UserStore } from './user-store';
import * as uuid from 'uuid';
import * as VM from 'vm';

const MemoryFilesystem = require('memory-fs');
Expand Down Expand Up @@ -193,10 +194,15 @@ export class UserStoreEnhancer {
public constructor(init: UserStoreEnhancerInit) {
this.id = init.id;
this.code = init.code;

if (!init) {
this.id = uuid.v4();
this.code = defaultCode;
}
}

public static from(serialized: Types.SerializedUserStoreEnhancer): UserStoreEnhancer {
return new UserStoreEnhancer(serialized);
return new UserStoreEnhancer(serialized || {});
}

public getApi(): string {
Expand Down

0 comments on commit 39e58a1

Please sign in to comment.