Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): expose TypeCast types #2425

Merged
merged 4 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 };
Loading