Skip to content

Commit

Permalink
fix(types): expose TypeCast types (#2425)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wellwelwel authored Feb 1, 2024
1 parent 5b44bf9 commit 336a7f1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
17 changes: 16 additions & 1 deletion typings/mysql/lib/parsers/index.d.ts
Original file line number Diff line number Diff line change
@@ -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,
};
8 changes: 4 additions & 4 deletions typings/mysql/lib/parsers/typeCast.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
type Geometry = {
export type Geometry = {
x: number;
y: number;
};

type Type = {
export type Type = {
type:
| 'DECIMAL'
| 'TINY'
Expand Down Expand Up @@ -38,7 +38,7 @@ type Type = {
| 'GEOMETRY';
};

type Field = Type & {
export type Field = Type & {
length: number;
db: string;
table: string;
Expand All @@ -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;
21 changes: 8 additions & 13 deletions typings/mysql/lib/protocol/packets/Field.d.ts
Original file line number Diff line number Diff line change
@@ -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 };

0 comments on commit 336a7f1

Please sign in to comment.