Skip to content

Commit

Permalink
Set noImplicitOveride: true in tsconfig (#1147)
Browse files Browse the repository at this point in the history
This matches the default in Deno 2.0 and makes sense for us to use given
how much we use inheritance.
  • Loading branch information
scotttrinh authored Dec 11, 2024
1 parent efbbcfa commit 90389b0
Show file tree
Hide file tree
Showing 20 changed files with 167 additions and 153 deletions.
14 changes: 9 additions & 5 deletions packages/driver/genErrors.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const __filename = new URL("", import.meta.url).pathname;
mappingBuf.nl();
mappingBuf.code(copy);
mappingBuf.nl();
mappingBuf.code('import {ErrorType} from "./base";');
mappingBuf.code('import type { ErrorType } from "./base";');
mappingBuf.code('import * as errors from "./index";');
mappingBuf.nl();
mappingBuf.nl();
Expand All @@ -96,9 +96,13 @@ const __filename = new URL("", import.meta.url).pathname;
let line = `export class ${err} extends ${base} `;
line += `{\n`;
if (tag_items.length > 0) {
line += ` protected static tags = {${tag_items.join(", ")}}\n`;
line += ` override protected static tags = {${tag_items.join(", ")}}\n`;
}
if (base !== "EdgeDBError") {
line += ` override get code(): number {\n return ${code};\n }\n`;
} else {
line += ` get code(): number {\n return ${code};\n }\n`;
}
line += ` get code(): number {\n return ${code};\n }\n`;
line += `}`;

errorsBuf.code(line);
Expand All @@ -112,6 +116,6 @@ const __filename = new URL("", import.meta.url).pathname;
const errors_ts = prettier.format(errorsBuf.render(), prettierOptions);
const mapping_ts = prettier.format(mappingBuf.render(), prettierOptions);

fs.writeFileSync(path.join(__dirname, "./src/errors/index.ts"), errors_ts);
fs.writeFileSync(path.join(__dirname, "./src/errors/map.ts"), mapping_ts);
fs.writeFileSync(path.join(__dirname, "./src/errors/index.ts"), await errors_ts);
fs.writeFileSync(path.join(__dirname, "./src/errors/map.ts"), await mapping_ts);
})();
2 changes: 1 addition & 1 deletion packages/driver/src/codecs/boolean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { type ICodec, ScalarCodec } from "./ifaces";
import { InvalidArgumentError } from "../errors";

export class BoolCodec extends ScalarCodec implements ICodec {
tsType = "boolean";
override tsType = "boolean";

encode(buf: WriteBuffer, object: any): void {
const typeOf = typeof object;
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/codecs/bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { type ICodec, ScalarCodec } from "./ifaces";
import { InvalidArgumentError } from "../errors";

export class BytesCodec extends ScalarCodec implements ICodec {
tsType = "Uint8Array";
override tsType = "Uint8Array";

encode(buf: WriteBuffer, object: any): void {
if (!(object instanceof Uint8Array)) {
Expand Down
26 changes: 13 additions & 13 deletions packages/driver/src/codecs/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const TIMESHIFT = 946684800000;
const DATESHIFT_ORD = ymd2ord(2000, 1, 1);

export class DateTimeCodec extends ScalarCodec implements ICodec {
tsType = "Date";
override tsType = "Date";

encode(buf: WriteBuffer, object: unknown): void {
if (!(object instanceof Date)) {
Expand All @@ -66,8 +66,8 @@ export class DateTimeCodec extends ScalarCodec implements ICodec {
}

export class LocalDateTimeCodec extends ScalarCodec implements ICodec {
tsType = "LocalDateTime";
tsModule = "edgedb";
override tsType = "LocalDateTime";
override tsModule = "edgedb";

encode(buf: WriteBuffer, object: unknown): void {
if (!(object instanceof LocalDateTime)) {
Expand Down Expand Up @@ -123,8 +123,8 @@ export class LocalDateTimeCodec extends ScalarCodec implements ICodec {
}

export class LocalDateCodec extends ScalarCodec implements ICodec {
tsType = "LocalDate";
tsModule = "edgedb";
override tsType = "LocalDate";
override tsModule = "edgedb";
encode(buf: WriteBuffer, object: unknown): void {
if (!(object instanceof LocalDate)) {
throw new InvalidArgumentError(
Expand All @@ -142,8 +142,8 @@ export class LocalDateCodec extends ScalarCodec implements ICodec {
}

export class LocalTimeCodec extends ScalarCodec implements ICodec {
tsType = "LocalTime";
tsModule = "edgedb";
override tsType = "LocalTime";
override tsModule = "edgedb";
encode(buf: WriteBuffer, object: unknown): void {
if (!(object instanceof LocalTime)) {
throw new InvalidArgumentError(
Expand Down Expand Up @@ -199,8 +199,8 @@ export function checkValidEdgeDBDuration(duration: Duration): null | string {
}

export class DurationCodec extends ScalarCodec implements ICodec {
tsType = "Duration";
tsModule = "edgedb";
override tsType = "Duration";
override tsModule = "edgedb";
encode(buf: WriteBuffer, object: unknown): void {
if (!(object instanceof Duration)) {
throw new InvalidArgumentError(
Expand Down Expand Up @@ -283,8 +283,8 @@ export class DurationCodec extends ScalarCodec implements ICodec {
}

export class RelativeDurationCodec extends ScalarCodec implements ICodec {
tsType = "RelativeDuration";
tsModule = "edgedb";
override tsType = "RelativeDuration";
override tsModule = "edgedb";
encode(buf: WriteBuffer, object: unknown): void {
if (!(object instanceof RelativeDuration)) {
throw new InvalidArgumentError(`
Expand Down Expand Up @@ -350,8 +350,8 @@ export class RelativeDurationCodec extends ScalarCodec implements ICodec {
}

export class DateDurationCodec extends ScalarCodec implements ICodec {
tsType = "DateDuration";
tsModule = "edgedb";
override tsType = "DateDuration";
override tsModule = "edgedb";
encode(buf: WriteBuffer, object: unknown): void {
if (!(object instanceof DateDuration)) {
throw new InvalidArgumentError(`
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/codecs/ifaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export abstract class ScalarCodec extends Codec {
readonly tsType: string = "unknown";
readonly tsModule: string | null = null;

getKnownTypeName(): string {
override getKnownTypeName(): string {
if (this.typeName) {
return this.typeName;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/driver/src/codecs/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { type ICodec, ScalarCodec } from "./ifaces";
import { InvalidArgumentError, ProtocolError } from "../errors";

export class JSONCodec extends ScalarCodec implements ICodec {
tsType = "unknown";
override tsType = "unknown";

readonly jsonFormat: number | null = 1;

Expand Down Expand Up @@ -68,7 +68,7 @@ export class JSONCodec extends ScalarCodec implements ICodec {
}

export class PgTextJSONCodec extends JSONCodec {
readonly jsonFormat = null;
override readonly jsonFormat = null;
}

export class JSONStringCodec extends ScalarCodec implements ICodec {
Expand Down Expand Up @@ -101,5 +101,5 @@ export class JSONStringCodec extends ScalarCodec implements ICodec {
}

export class PgTextJSONStringCodec extends JSONStringCodec {
readonly jsonFormat = null;
override readonly jsonFormat = null;
}
4 changes: 2 additions & 2 deletions packages/driver/src/codecs/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { ConfigMemory } from "../datatypes/memory";
import { InvalidArgumentError } from "../errors";

export class ConfigMemoryCodec extends ScalarCodec implements ICodec {
tsType = "ConfigMemory";
tsModule = "edgedb";
override tsType = "ConfigMemory";
override tsModule = "edgedb";

encode(buf: WriteBuffer, object: any): void {
if (!(object instanceof ConfigMemory)) {
Expand Down
10 changes: 5 additions & 5 deletions packages/driver/src/codecs/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { type ICodec, ScalarCodec } from "./ifaces";
import { InvalidArgumentError } from "../errors";

export class Int64Codec extends ScalarCodec implements ICodec {
tsType = "number";
override tsType = "number";
encode(buf: WriteBuffer, object: any): void {
if (typeof object !== "number") {
throw new InvalidArgumentError(`a number was expected, got "${object}"`);
Expand Down Expand Up @@ -50,7 +50,7 @@ export class Int64BigintCodec extends ScalarCodec implements ICodec {
}

export class Int32Codec extends ScalarCodec implements ICodec {
tsType = "number";
override tsType = "number";
encode(buf: WriteBuffer, object: any): void {
if (typeof object !== "number") {
throw new InvalidArgumentError(`a number was expected, got "${object}"`);
Expand All @@ -65,7 +65,7 @@ export class Int32Codec extends ScalarCodec implements ICodec {
}

export class Int16Codec extends ScalarCodec implements ICodec {
tsType = "number";
override tsType = "number";
encode(buf: WriteBuffer, object: any): void {
if (typeof object !== "number") {
throw new InvalidArgumentError(`a number was expected, got "${object}"`);
Expand All @@ -80,7 +80,7 @@ export class Int16Codec extends ScalarCodec implements ICodec {
}

export class Float32Codec extends ScalarCodec implements ICodec {
tsType = "number";
override tsType = "number";
encode(buf: WriteBuffer, object: any): void {
if (typeof object !== "number") {
throw new InvalidArgumentError(`a number was expected, got "${object}"`);
Expand All @@ -95,7 +95,7 @@ export class Float32Codec extends ScalarCodec implements ICodec {
}

export class Float64Codec extends ScalarCodec implements ICodec {
tsType = "number";
override tsType = "number";
encode(buf: WriteBuffer, object: any): void {
if (typeof object !== "number") {
throw new InvalidArgumentError(`a number was expected, got "${object}"`);
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/codecs/numerics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const NUMERIC_POS = 0x0000;
const NUMERIC_NEG = 0x4000;

export class BigIntCodec extends ScalarCodec implements ICodec {
tsType = "bigint";
override tsType = "bigint";

encode(buf: WriteBuffer, object: any): void {
if (typeof object !== "bigint") {
Expand Down Expand Up @@ -73,7 +73,7 @@ export class BigIntCodec extends ScalarCodec implements ICodec {
}

export class DecimalStringCodec extends ScalarCodec implements ICodec {
tsType = "string";
override tsType = "string";

encode(buf: WriteBuffer, object: any): void {
if (typeof object !== "string") {
Expand Down
10 changes: 5 additions & 5 deletions packages/driver/src/codecs/pgvector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { SparseVector } from "../datatypes/pgvector";
export const PG_VECTOR_MAX_DIM = (1 << 16) - 1;

export class PgVectorCodec extends ScalarCodec implements ICodec {
readonly tsType = "Float32Array";
override readonly tsType = "Float32Array";

encode(buf: WriteBuffer, object: any): void {
if (!(object instanceof Float32Array || Array.isArray(object))) {
Expand Down Expand Up @@ -87,8 +87,8 @@ export class PgVectorCodec extends ScalarCodec implements ICodec {
}

export class PgVectorHalfVecCodec extends ScalarCodec implements ICodec {
readonly tsType = "Float16Array";
readonly tsModule = "edgedb";
override readonly tsType = "Float16Array";
override readonly tsModule = "edgedb";

encode(buf: WriteBuffer, object: any): void {
if (!(isFloat16Array(object) || Array.isArray(object))) {
Expand Down Expand Up @@ -154,8 +154,8 @@ export class PgVectorHalfVecCodec extends ScalarCodec implements ICodec {
}

export class PgVectorSparseVecCodec extends ScalarCodec implements ICodec {
readonly tsType = "SparseVector";
readonly tsModule = "edgedb";
override readonly tsType = "SparseVector";
override readonly tsModule = "edgedb";

encode(buf: WriteBuffer, object: any): void {
if (!(object instanceof SparseVector)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/codecs/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { type ICodec, ScalarCodec } from "./ifaces";
import { InvalidArgumentError } from "../errors";

export class StrCodec extends ScalarCodec implements ICodec {
tsType = "string";
override tsType = "string";

encode(buf: WriteBuffer, object: any): void {
if (typeof object !== "string") {
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/codecs/uuid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function UUIDBufferFromString(uuid: string): Uint8Array {
}

export class UUIDCodec extends ScalarCodec implements ICodec {
tsType = "string";
override tsType = "string";

encode(buf: WriteBuffer, object: any): void {
if (typeof object === "string") {
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/datatypes/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export class LocalDateTime extends LocalDate {
return localTimeInstances.get(this)!.nanosecond;
}

toString(): string {
override toString(): string {
return `${super.toString()}T${localTimeInstances.get(this)!.toString()}`;
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/errors/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class EdgeDBError extends Error {
this._message = message ?? "";
}

get message() {
override get message() {
return (
this._message +
(this._query && this._attrs
Expand All @@ -31,7 +31,7 @@ export class EdgeDBError extends Error {
);
}

get name(): string {
override get name(): string {
return this.constructor.name;
}

Expand Down
Loading

0 comments on commit 90389b0

Please sign in to comment.