We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3a22b76 commit 4108465Copy full SHA for 4108465
src/db/file/repo.ts
@@ -97,7 +97,7 @@ export const createRepo = async (repo: Repo): Promise<Repo> => {
97
if (err) {
98
reject(err);
99
} else {
100
- resolve(doc ? toClass(doc, Repo.prototype) : null);
+ resolve(toClass(doc, Repo.prototype));
101
}
102
});
103
src/db/helper.ts
@@ -1,7 +1,7 @@
1
-export const toClass = function (obj: any, proto: any) {
2
- obj = JSON.parse(JSON.stringify(obj));
3
- obj.__proto__ = proto;
4
- return obj;
+export const toClass = function <T, U>(obj: T, proto: U): U {
+ const out = JSON.parse(JSON.stringify(obj));
+ out.__proto__ = proto;
+ return out as U;
5
};
6
7
export const trimTrailingDotGit = (str: string): string => {
0 commit comments