Skip to content

Commit 7f0eca5

Browse files
authored
Merge pull request #2 from atuinsh/mkt/package
Update TS config and prepare script
2 parents 8e0b1eb + 6a498cd commit 7f0eca5

File tree

6 files changed

+17
-41
lines changed

6 files changed

+17
-41
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"prepare": "tsc"
1313
},
1414
"dependencies": {
15-
"tsx": "^4.19.2",
1615
"typescript": "^5.7.3"
1716
},
1817
"devDependencies": {
@@ -21,6 +20,7 @@
2120
"jest": "^29.7.0",
2221
"sqlite": "^5.1.1",
2322
"sqlite3": "^5.1.7",
24-
"ts-jest": "^29.2.5"
23+
"ts-jest": "^29.2.5",
24+
"tsx": "^4.19.2"
2525
}
2626
}

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/advanced-model.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ let postLoadCalled = false;
3434
lastUpdated: { encoder: dateEncoder }
3535
},
3636
{
37-
preSave: async (context, model) => {
37+
preSave: async (_context, model) => {
3838
preSaveCalled = true;
3939
return model;
4040
},
41-
postSave: async (context, model) => {
41+
postSave: async (_context, model) => {
4242
postSaveCalled = true;
4343
return model;
4444
},
45-
postLoad: async (context, model) => {
45+
postLoad: async (_context, model) => {
4646
postLoadCalled = true;
4747
return model;
4848
}
@@ -180,8 +180,8 @@ describe('Advanced Model Features', () => {
180180

181181
const allModels = await ComplexModel.all();
182182
expect(allModels.length).toBeGreaterThanOrEqual(2);
183-
expect(allModels[0].get("metadata")).toBeInstanceOf(Object);
184-
expect(allModels[0].get("lastUpdated")).toBeInstanceOf(Date);
183+
expect(allModels[0]?.get("metadata")).toBeInstanceOf(Object);
184+
expect(allModels[0]?.get("lastUpdated")).toBeInstanceOf(Date);
185185
expect(postLoadCalled).toBe(true);
186186
});
187187

@@ -196,7 +196,7 @@ describe('Advanced Model Features', () => {
196196

197197
const foundModel = await ComplexModel.getBy({ name: "Search Test" });
198198
expect(foundModel).not.toBeNull();
199-
expect(foundModel?.get("metadata").searchKey).toBe("findMe");
199+
expect(foundModel?.get("metadata")?.searchKey).toBe("findMe");
200200
expect(foundModel?.get("lastUpdated").getTime()).toBe(date.getTime());
201201
expect(postLoadCalled).toBe(true);
202202
});

test/model.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe('Model', () => {
120120

121121
const peopleAge45 = await Person.all({ age: 45 });
122122
expect(peopleAge45.length).toBeGreaterThan(0);
123-
expect(peopleAge45[0].get("age")).toBe(45);
123+
expect(peopleAge45[0]?.get("age")).toBe(45);
124124

125125
const personByName = await Person.getBy({ firstName: "David" });
126126
expect(personByName).not.toBeNull();

test/sqlite-adapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AdapterConfig, Model, ModelAttributes, WithId } from "../src";
1+
import { AdapterConfig, Model, ModelAttributes, WithId } from "../src/index";
22
import * as sqlite3 from "sqlite3";
33
import { Database, open } from "sqlite";
44

@@ -55,7 +55,7 @@ export function createSqliteAdapter<T extends ModelAttributes>(dbName: string, t
5555
bindValues = Object.values(matchOrQuery);
5656
}
5757
let res = await context.db.all<WithId<T>[]>(`SELECT * FROM ${tableName} ${whereClause}`, bindValues);
58-
return res.map(row => convertRowToCamelCase<WithId<T>>(row));
58+
return res.map((row: WithId<T>) => convertRowToCamelCase<WithId<T>>(row));
5959
}
6060

6161
async function get(context: Context, id: any) {

tsconfig.json

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,16 @@
44
],
55
"compilerOptions": {
66
/* Visit https://aka.ms/tsconfig to read more about this file */
7-
/* Projects */
8-
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
9-
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
10-
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
11-
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
12-
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
13-
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
14-
/* Language and Environment */
157
"target": "es2016",
168
"lib": [
179
"ES2015"
1810
],
19-
// "jsx": "preserve", /* Specify what JSX code is generated. */
2011
"experimentalDecorators": true,
2112
"emitDecoratorMetadata": true,
22-
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
23-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
24-
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
25-
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
26-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
27-
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
28-
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
29-
/* Modules */
30-
"module": "ESNext",
13+
"module": "ES6",
14+
"moduleResolution": "node",
3115
"rootDir": "./src",
32-
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
16+
// "moduleResolution": "nodenext",
3317
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
3418
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
3519
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
@@ -87,22 +71,14 @@
8771
"strictFunctionTypes": true,
8872
"strictBindCallApply": true,
8973
"strictPropertyInitialization": true,
90-
"strictBuiltinIteratorReturn": true,
9174
"noImplicitThis": true,
9275
"useUnknownInCatchVariables": true,
93-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
9476
"noUnusedLocals": true,
9577
"noUnusedParameters": true,
96-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
9778
"noImplicitReturns": true,
9879
"noFallthroughCasesInSwitch": true,
9980
"noUncheckedIndexedAccess": true,
10081
"noImplicitOverride": true,
101-
"noPropertyAccessFromIndexSignature": true,
102-
// "allowUnusedLabels": true,
103-
// "allowUnreachableCode": true,
104-
/* Completeness */
105-
// "skipDefaultLibCheck": true,
10682
"skipLibCheck": true
10783
}
10884
}

0 commit comments

Comments
 (0)