Skip to content

Commit 7d85ce2

Browse files
Merge pull request #2473 from LestevMisha/types/export-ast-node-types
Export AST node types for accurate type guards
2 parents be7cbc7 + 664f794 commit 7d85ce2

1 file changed

Lines changed: 23 additions & 24 deletions

File tree

types.d.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -325,25 +325,25 @@ export interface Use {
325325
loc?: LocationRange;
326326
}
327327

328-
type KW_UNSIGNED = "UNSIGNED";
329-
type KW_ZEROFILL = "ZEROFILL";
328+
export type KW_UNSIGNED = "UNSIGNED";
329+
export type KW_ZEROFILL = "ZEROFILL";
330330

331-
type Timezone = ["WITHOUT" | "WITH", "TIME", "ZONE"];
331+
export type Timezone = ["WITHOUT" | "WITH", "TIME", "ZONE"];
332332

333-
type KeywordComment = {
333+
export type KeywordComment = {
334334
type: "comment";
335335
keyword: "comment";
336336
symbol?: "=";
337337
value: string;
338338
};
339339

340-
type CollateExpr = {
340+
export type CollateExpr = {
341341
type: "collate";
342342
symbol?: "=";
343343
value: string;
344344
};
345345

346-
type DataType = {
346+
export type DataType = {
347347
dataType: string;
348348
length?: number;
349349
parentheses?: true;
@@ -353,24 +353,23 @@ type DataType = {
353353
expr?: Expr | ExprList;
354354
};
355355

356-
type LiteralNotNull = {
356+
export type LiteralNotNull = {
357357
type: "not null";
358358
value: "not null";
359359
};
360360

361-
type LiteralNull = { type: "null"; value: null | "null" };
361+
export type LiteralNull = { type: "null"; value: null | "null" };
362+
export type LiteralNumeric = number | { type: "bigint"; value: string };
362363

363-
type LiteralNumeric = number | { type: "bigint"; value: string };
364-
365-
type ColumnConstraint = {
364+
export type ColumnConstraint = {
366365
default_val: {
367366
type: "default";
368367
value: any;
369368
};
370369
nullable: LiteralNotNull | LiteralNull;
371370
};
372371

373-
type ColumnDefinitionOptList = {
372+
export type ColumnDefinitionOptList = {
374373
nullable?: ColumnConstraint["nullable"];
375374
default_val?: ColumnConstraint["default_val"];
376375
auto_increment?: "auto_increment";
@@ -384,24 +383,24 @@ type ColumnDefinitionOptList = {
384383
character_set?: { type: "CHARACTER SET"; value: string; symbol?: "=" };
385384
};
386385

387-
type CreateColumnDefinition = {
386+
export type CreateColumnDefinition = {
388387
column: ColumnRef;
389388
definition: DataType;
390389
resource: "column";
391390
} & ColumnDefinitionOptList;
392391

393-
type IndexType = {
392+
export type IndexType = {
394393
keyword: "using";
395394
type: "btree" | "hash" | "gist" | "gin";
396395
};
397396

398-
type IndexOption = {
397+
export type IndexOption = {
399398
type: "key_block_size";
400399
symbol?: "=";
401400
expr: LiteralNumeric;
402401
};
403402

404-
type CreateIndexDefinition = {
403+
export type CreateIndexDefinition = {
405404
index?: string;
406405
definition: ColumnRef[];
407406
keyword: "index" | "key";
@@ -410,7 +409,7 @@ type CreateIndexDefinition = {
410409
index_options?: IndexOption[];
411410
};
412411

413-
type CreateFulltextSpatialIndexDefinition = {
412+
export type CreateFulltextSpatialIndexDefinition = {
414413
index?: string;
415414
definition: ColumnRef[];
416415
keyword?:
@@ -424,9 +423,9 @@ type CreateFulltextSpatialIndexDefinition = {
424423
resource: "index";
425424
};
426425

427-
type ConstraintName = { keyword: "constraint"; constraint: string };
426+
export type ConstraintName = { keyword: "constraint"; constraint: string };
428427

429-
type CreateConstraintPrimary = {
428+
export type CreateConstraintPrimary = {
430429
constraint?: ConstraintName["constraint"];
431430
definition: ColumnRef[];
432431
constraint_type: "primary key";
@@ -436,7 +435,7 @@ type CreateConstraintPrimary = {
436435
index_options?: IndexOption[];
437436
};
438437

439-
type CreateConstraintUnique = {
438+
export type CreateConstraintUnique = {
440439
constraint?: ConstraintName["constraint"];
441440
definition: ColumnRef[];
442441
constraint_type: "unique key" | "unique" | "unique index";
@@ -447,7 +446,7 @@ type CreateConstraintUnique = {
447446
index_options?: IndexOption[];
448447
};
449448

450-
type CreateConstraintForeign = {
449+
export type CreateConstraintForeign = {
451450
constraint?: ConstraintName["constraint"];
452451
definition: ColumnRef[];
453452
constraint_type: "FOREIGN KEY";
@@ -457,21 +456,21 @@ type CreateConstraintForeign = {
457456
reference_definition?: any;
458457
};
459458

460-
type CreateConstraintCheck = {
459+
export type CreateConstraintCheck = {
461460
constraint?: ConstraintName["constraint"];
462461
definition: any[];
463462
constraint_type: "check";
464463
keyword?: ConstraintName["keyword"];
465464
resource: "constraint";
466465
};
467466

468-
type CreateConstraintDefinition =
467+
export type CreateConstraintDefinition =
469468
| CreateConstraintPrimary
470469
| CreateConstraintUnique
471470
| CreateConstraintForeign
472471
| CreateConstraintCheck;
473472

474-
type CreateDefinition =
473+
export type CreateDefinition =
475474
| CreateColumnDefinition
476475
| CreateIndexDefinition
477476
| CreateFulltextSpatialIndexDefinition

0 commit comments

Comments
 (0)