From d6e34762d782f3b22d2982ccf3a32a5fdc54aa3e Mon Sep 17 00:00:00 2001 From: Valerie Date: Thu, 10 Jun 2021 01:40:10 -0400 Subject: [PATCH] updated some stuff --- package.json | 2 +- src/Serializable.ts | 9 +++++---- src/index.ts | 2 +- tsconfig.json | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 4debde2..2b0e33e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "frigid", - "version": "1.0.0", + "version": "1.0.4", "main": "out/index.js", "types": "out/index.d.ts", "license": "MIT", diff --git a/src/Serializable.ts b/src/Serializable.ts index 16ac141..244e2fb 100644 --- a/src/Serializable.ts +++ b/src/Serializable.ts @@ -152,18 +152,19 @@ export default class Serializable { async restore() {} static createFromDisk(filename: string, ...args: any[]) { - if(existsSync(filename)) { - const instance = this.deserialize(readFileSync(createFilepath(filename))); + const filepath = createFilepath(filename); + if(existsSync(filepath)) { + const instance = this.deserialize(readFileSync(filepath)); // TS is plain and simply wrong... symbols can be used to index object... // @ts-ignore - instance[Serializable.PERSIST_LOCATION] = createFilepath(filename); + instance[Serializable.PERSIST_LOCATION] = filepath; instance?.restore(); return instance; } else { const instance = new this(...args); // again... TS is wrong... // @ts-ignore - instance[Serializable.PERSIST_LOCATION] = createFilepath(filename); + instance[Serializable.PERSIST_LOCATION] = filepath; instance?.updateDisk(); return instance; } diff --git a/src/index.ts b/src/index.ts index 655f98a..94fa023 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1 @@ -export {default as Serializable} from './Serializable'; \ No newline at end of file +export {default as Serializable} from './Serializable.js'; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 1bd2c13..ef4f823 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,8 @@ "module": "ES2020", "moduleResolution": "Node", "outDir": "out", - "declaration": true + "declaration": true, + "allowSyntheticDefaultImports": true }, "include": [ "src/**/*.ts"