Skip to content

Commit

Permalink
Enable noImplicitOverride and moduleDetection; fix test type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
DallasHoff committed Aug 8, 2024
1 parent 00269dc commit 8031caa
Show file tree
Hide file tree
Showing 21 changed files with 37 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"src"
],
"scripts": {
"build": "tsc",
"build": "tsc --project tsconfig.build.json",
"test": "vitest",
"test:ui": "vitest --ui",
"format": "prettier . --write",
Expand Down
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ export class SQLocal {
};

if (message.type === 'data') {
data.rows = message.data[0].rows;
data.columns = message.data[0].columns;
data.rows = message.data[0]?.rows ?? [];
data.columns = message.data[0]?.columns ?? [];
}

return data;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/exec-on-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function execOnDb(
case 'run':
break;
case 'get':
statementData.rows = rows[0];
statementData.rows = rows[0] ?? [];
break;
case 'all':
default:
Expand Down
2 changes: 1 addition & 1 deletion test/batch.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { SQLocal } from '../src/index';
import { SQLocal } from '../src/index.js';

describe('batch', () => {
const { sql, batch } = new SQLocal('batch-test.sqlite3');
Expand Down
2 changes: 1 addition & 1 deletion test/create-callback-function.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { SQLocal } from '../src/index';
import { SQLocal } from '../src/index.js';

describe('createCallbackFunction', () => {
const { sql, createCallbackFunction } = new SQLocal(
Expand Down
2 changes: 1 addition & 1 deletion test/create-scalar-function.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { SQLocal } from '../src/index';
import { SQLocal } from '../src/index.js';

describe('createScalarFunction', () => {
const { sql, createScalarFunction } = new SQLocal(
Expand Down
2 changes: 1 addition & 1 deletion test/destroy.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { SQLocal } from '../src/index';
import { SQLocal } from '../src/index.js';

describe('destroy', () => {
const { sql, destroy } = new SQLocal('destroy-test.sqlite3');
Expand Down
4 changes: 2 additions & 2 deletions test/drizzle/driver.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { SQLocalDrizzle } from '../../src/drizzle';
import { SQLocalDrizzle } from '../../src/drizzle/index.js';
import { drizzle } from 'drizzle-orm/sqlite-proxy';
import { int, real, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { desc, eq, relations, sql as dsql } from 'drizzle-orm';
import { sleep } from '../test-utils/sleep';
import { sleep } from '../test-utils/sleep.js';

describe('drizzle driver', () => {
const { sql, driver, batchDriver, transaction } = new SQLocalDrizzle(
Expand Down
2 changes: 1 addition & 1 deletion test/get-database-file.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { SQLocal } from '../src/index';
import { SQLocal } from '../src/index.js';

describe('getDatabaseFile', () => {
const fileName = 'get-database-file-test.sqlite3';
Expand Down
2 changes: 1 addition & 1 deletion test/get-database-info.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it } from 'vitest';
import { SQLocal } from '../src/index';
import { SQLocal } from '../src/index.js';

describe('getDatabaseInfo', () => {
const { sql, getDatabaseInfo } = new SQLocal(
Expand Down
2 changes: 1 addition & 1 deletion test/init.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterAll, afterEach, beforeEach, describe, expect, it } from 'vitest';
import { SQLocal } from '../src/index';
import { SQLocal } from '../src/index.js';

describe('init', () => {
const databasePath = 'init-test.sqlite3';
Expand Down
7 changes: 4 additions & 3 deletions test/kysely/dialect.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { Generated, Kysely, ParseJSONResultsPlugin } from 'kysely';
import { Kysely, ParseJSONResultsPlugin } from 'kysely';
import type { Generated } from 'kysely';
import { jsonArrayFrom } from 'kysely/helpers/sqlite';
import { SQLocalKysely } from '../../src/kysely';
import { sleep } from '../test-utils/sleep';
import { SQLocalKysely } from '../../src/kysely/index.js';
import { sleep } from '../test-utils/sleep.js';

describe('kysely dialect', () => {
const { dialect, transaction } = new SQLocalKysely(
Expand Down
4 changes: 2 additions & 2 deletions test/kysely/migrations.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it } from 'vitest';
import { SQLocalKysely } from '../../src/kysely';
import { SQLocalKysely } from '../../src/kysely/index.js';
import { Kysely, Migrator } from 'kysely';

describe('kysely migrations', () => {
Expand All @@ -11,7 +11,7 @@ describe('kysely migrations', () => {
db,
provider: {
async getMigrations() {
const { migrations } = await import('./migrations/');
const { migrations } = await import('./migrations/index.js');
return migrations;
},
},
Expand Down
3 changes: 2 additions & 1 deletion test/kysely/migrations/2023-08-01.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Kysely, Migration } from 'kysely';
import { Kysely } from 'kysely';
import type { Migration } from 'kysely';

export const Migration20230801: Migration = {
async up(db: Kysely<any>) {
Expand Down
3 changes: 2 additions & 1 deletion test/kysely/migrations/2023-08-02.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Kysely, Migration } from 'kysely';
import { Kysely } from 'kysely';
import type { Migration } from 'kysely';

export const Migration20230802: Migration = {
async up(db: Kysely<any>) {
Expand Down
6 changes: 3 additions & 3 deletions test/kysely/migrations/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Migration } from 'kysely';
import { Migration20230801 } from './2023-08-01';
import { Migration20230802 } from './2023-08-02';
import type { Migration } from 'kysely';
import { Migration20230801 } from './2023-08-01.js';
import { Migration20230802 } from './2023-08-02.js';

export const migrations: Record<string, Migration> = {
'2023-08-02': Migration20230802,
Expand Down
2 changes: 1 addition & 1 deletion test/overwrite-database-file.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect, afterAll } from 'vitest';
import { SQLocal } from '../src/index';
import { SQLocal } from '../src/index.js';

describe('overwriteDatabaseFile', async () => {
const db1 = new SQLocal('overwrite-test-db1.sqlite3');
Expand Down
2 changes: 1 addition & 1 deletion test/sql.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { SQLocal } from '../src/index';
import { SQLocal } from '../src/index.js';

describe('sql', () => {
const { sql } = new SQLocal('sql-test.sqlite3');
Expand Down
4 changes: 2 additions & 2 deletions test/transaction.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { SQLocal } from '../src/index';
import { sleep } from './test-utils/sleep';
import { SQLocal } from '../src/index.js';
import { sleep } from './test-utils/sleep.js';

describe('transaction', () => {
const { sql, transaction } = new SQLocal('transaction-test.sqlite3');
Expand Down
4 changes: 4 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["test"]
}
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

/* Building */
"moduleResolution": "NodeNext",
"moduleDetection": "force",
"esModuleInterop": true,
"useDefineForClassFields": true,
"allowSyntheticDefaultImports": true,
Expand All @@ -21,8 +22,9 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"verbatimModuleSyntax": true
},
"include": ["src"],
"include": ["src", "test"],
"exclude": ["**/node_modules/**", "dist"]
}

0 comments on commit 8031caa

Please sign in to comment.