Hi,
in the current 3.5.2 version, the constants for field types are defined as enum in file types/share.d.ts:
export enum Types {
DECIMAL = 'DECIMAL',
TINY = 'TINY',
...
}
However, when using Typescript, these constants are only available at compile time but not at runtime causing errors like the following when accessing e.g., Types.TINY:
TypeError: Cannot read properties of undefined (reading 'TINY')
I think the problem is caused by c8fbc69 with the change in types/share.d.ts from
export const enum Types {
...
}
to
export enum Types {
...
}
With the previous const definition, the enum values got inlined during compilation of package consumers from typescript to javascript (see typescript docs). Without the const keyword in the current version, there is no inlining and the mariadb package does not export the enum in its Javascript files.
In the Javascript files, the constants are defined in lib/const/field-type.js but with a slightly different name (all uppercase):
export const TYPES = typeNames;
Hence they cannot be used from Typescript-consumers of the package.
Hi,
in the current 3.5.2 version, the constants for field types are defined as enum in file
types/share.d.ts:However, when using Typescript, these constants are only available at compile time but not at runtime causing errors like the following when accessing e.g.,
Types.TINY:I think the problem is caused by c8fbc69 with the change in
types/share.d.tsfromto
With the previous
constdefinition, the enum values got inlined during compilation of package consumers from typescript to javascript (see typescript docs). Without theconstkeyword in the current version, there is no inlining and the mariadb package does not export the enum in its Javascript files.In the Javascript files, the constants are defined in
lib/const/field-type.jsbut with a slightly different name (all uppercase):export const TYPES = typeNames;Hence they cannot be used from Typescript-consumers of the package.