From 336a7f1259c63d2dfe070fe400b141e89255844e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Weslley=20Ara=C3=BAjo?= <46850407+wellwelwel@users.noreply.github.com> Date: Wed, 31 Jan 2024 22:06:55 -0300 Subject: [PATCH] fix(types): expose TypeCast types (#2425) * fix(types): expose TypeCast types * chore(refactor): resolve conflict for types with ambiguous name s * chore: lint fix * chore: refactor `TypeCastField` import for `Field` and deprecated description --- typings/mysql/lib/parsers/index.d.ts | 17 ++++++++++++++- typings/mysql/lib/parsers/typeCast.d.ts | 8 +++---- typings/mysql/lib/protocol/packets/Field.d.ts | 21 +++++++------------ 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/typings/mysql/lib/parsers/index.d.ts b/typings/mysql/lib/parsers/index.d.ts index 7f1d48e943..734c4d924b 100644 --- a/typings/mysql/lib/parsers/index.d.ts +++ b/typings/mysql/lib/parsers/index.d.ts @@ -1,3 +1,18 @@ import { setMaxParserCache, clearParserCache } from './ParserCache.js'; +import { + TypeCast, + Field as TypeCastField, + Geometry as TypeCastGeometry, + Next as TypeCastNext, + Type as TypeCastType, +} from './typeCast.js'; -export { setMaxParserCache, clearParserCache }; +export { + setMaxParserCache, + clearParserCache, + TypeCast, + TypeCastField, + TypeCastGeometry, + TypeCastNext, + TypeCastType, +}; diff --git a/typings/mysql/lib/parsers/typeCast.d.ts b/typings/mysql/lib/parsers/typeCast.d.ts index 0311bdb089..65bfaa8949 100644 --- a/typings/mysql/lib/parsers/typeCast.d.ts +++ b/typings/mysql/lib/parsers/typeCast.d.ts @@ -1,9 +1,9 @@ -type Geometry = { +export type Geometry = { x: number; y: number; }; -type Type = { +export type Type = { type: | 'DECIMAL' | 'TINY' @@ -38,7 +38,7 @@ type Type = { | 'GEOMETRY'; }; -type Field = Type & { +export type Field = Type & { length: number; db: string; table: string; @@ -48,6 +48,6 @@ type Field = Type & { geometry: () => Geometry | Geometry[] | null; }; -type Next = () => void; +export type Next = () => void; export type TypeCast = ((field: Field, next: Next) => any) | boolean; diff --git a/typings/mysql/lib/protocol/packets/Field.d.ts b/typings/mysql/lib/protocol/packets/Field.d.ts index dc9967b6cc..a8c1690622 100644 --- a/typings/mysql/lib/protocol/packets/Field.d.ts +++ b/typings/mysql/lib/protocol/packets/Field.d.ts @@ -1,15 +1,10 @@ -declare interface Field { - constructor: { - name: 'Field'; - }; - db: string; - table: string; - name: string; - type: string; - length: number; - string: () => any; - buffer: () => any; - geometry: () => any; -} +// TODO (major version): remove workaround for `Field` compatibility. +import { TypeCastField } from '../../../lib/parsers/index.js'; + +/** + * @deprecated + * `Field` is deprecated and might be removed in the future major release. Please use `TypeCastField` type instead. + */ +declare interface Field extends TypeCastField {} export { Field };