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: export more ts type definitions #411

Merged
merged 1 commit into from
Nov 22, 2023
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@
"sql.js": "^1.8.0",
"sqlite3": "^5.0.2",
"ts-node": "^10.9.1",
"typescript": "^4.6.2"
"typescript": "^4.9.5"
}
}
7 changes: 1 addition & 6 deletions src/adapters/sequelize.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
Attributes, Literal, WhereConditions,
BoneOptions, ResultSet, Raw,
SetOptions, BeforeHooksType, AfterHooksType,
QueryOptions, OrderOptions, QueryResult, Values as CommonValues, BoneColumns, InstanceColumns, BoneCreateValues,
QueryOptions, OrderOptions, QueryResult, Values as CommonValues, BoneColumns, InstanceColumns, BoneCreateValues, Collection,
} from '../types/common';
import { AbstractBone } from '../types/abstract_bone';
import { Spell } from '../spell';
Expand Down Expand Up @@ -54,11 +54,6 @@ type ScopeOptions = {

type aggregators = 'count' | 'COUNT' | 'average' | 'AVERAGE' | 'minimum' | 'MINIMUM' | 'maximum' | 'MAXIMUM' | 'sum' | 'SUM';

export class Collection<T extends SequelizeBone> extends Array<T> {
save(): Promise<void>;
toJSON(): object[];
toObject(): object[];
}

export class SequelizeBone extends AbstractBone {

Expand Down
4 changes: 2 additions & 2 deletions src/bone.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class Bone extends AbstractBone {
static find<T extends typeof Bone>(this: T, whereConditions: WhereConditions<T>): Spell<T, Collection<InstanceType<T>>>;
static find<T extends typeof Bone>(this: T, whereConditions: string, ...values: Literal[]): Spell<T, Collection<InstanceType<T>>>;
static find<T extends typeof Bone>(this: T, primaryKey: number | number[] | bigint): Spell<T, Collection<InstanceType<T>>>;
static find<T extends typeof Bone>(this: T, ): Spell<T, Collection<InstanceType<T>>>;
static find<T extends typeof Bone>(this: T): Spell<T, Collection<InstanceType<T>>>;

/**
* SELECT rows LIMIT 1. Besides limiting the results to one rows, the type of the return value is different from {@link Bone.find} too. If no results were found, {@link Bone.findOne} returns null. If results were found, it returns the found record instead of wrapping them as a collection.
Expand All @@ -24,7 +24,7 @@ export default class Bone extends AbstractBone {
static findOne<T extends typeof Bone>(this: T, whereConditions: WhereConditions<T>): Spell<T, InstanceType<T> | null>;
static findOne<T extends typeof Bone>(this: T, whereConditions: string, ...values: Literal[]): Spell<T, InstanceType<T> | null>;
static findOne<T extends typeof Bone>(this: T, primaryKey: number | number[] | bigint): Spell<T, InstanceType<T> | null>;
static findOne<T extends typeof Bone>(this: T, ): Spell<T, InstanceType<T> | null>;
static findOne<T extends typeof Bone>(this: T): Spell<T, InstanceType<T> | null>;

static sum<T extends typeof Bone>(this: T, name?: BoneColumns<T>): Spell<T, ResultSet<T> | number>;
static sum<T extends typeof Bone>(this: T, name?: Raw): Spell<T, ResultSet<T> | number>;
Expand Down
6 changes: 3 additions & 3 deletions src/hint.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class IndexHint {
* })
*/
static build(hint: string | Array<string> | HintInterface, type?: INDEX_HINT_TYPE, scope?: INDEX_HINT_SCOPE): IndexHint;

/**
* Creates an instance of IndexHint.
* @param {Array<string> | string} index
Expand All @@ -77,7 +77,7 @@ export class IndexHint {
* @memberof IndexHint
*/
constructor(index: string, type?: INDEX_HINT_TYPE, scope?: INDEX_HINT_SCOPE);

set index(values: string | Array<string>);

get index(): Array<string>;
Expand Down Expand Up @@ -110,5 +110,5 @@ export class IndexHint {
}

export type CommonHintsArgs = string | HintInterface | Hint | IndexHint | {
[key in INDEX_HINT_SCOPE_TYPE]?: string | Array<string>
[key in INDEX_HINT_SCOPE_TYPE]?: string | Array<string>
};
22 changes: 6 additions & 16 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
import DataTypes, { DataType, AbstractDataType, LENGTH_VARIANTS } from './data_types';
import {
Hint, IndexHint, HintInterface,
INDEX_HINT_SCOPE_TYPE, INDEX_HINT_SCOPE, INDEX_HINT_TYPE
} from './hint';
import {
Literal, Validator,
Connection, QueryOptions, WhereConditions,
Raw, ColumnMeta, AttributeMeta,
BeforeHooksType, AfterHooksType, Collection,
GeneratorReturnType, Values, BoneCreateValues, BoneInstanceValues,
} from './types/common';
import { SpellMeta, Spell, SpellBookFormatResult } from './spell';
import Bone from './bone';
import { ConnectOptions, AbstractDriver } from './drivers';
import { QueryOptions, GeneratorReturnType, AttributeMeta, Connection, Literal, ColumnMeta, AfterHooksType, BeforeHooksType } from './types/common';
import Raw from './raw';

export {
LENGTH_VARIANTS as LENGTH_VARIANTS,
DataTypes, Literal, Validator, Connection, WhereConditions,
Hint, IndexHint, HintInterface, INDEX_HINT_SCOPE_TYPE, INDEX_HINT_SCOPE, INDEX_HINT_TYPE,
Bone, Raw, Collection,
SpellMeta, Spell, ColumnMeta, AttributeMeta, SpellBookFormatResult, Values, BoneCreateValues, BoneInstanceValues,
DataTypes, Bone
};

export * from './decorators';
export * from './drivers';
export * from './adapters/sequelize';
export * from './hint';
export * from './types/common';
export * from './spell';

interface InitOptions {
underscored?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/raw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default class Raw {
value: string;

// consumed in expr_formatter.js
type: string = 'raw';
type = 'raw';

constructor(value: string) {
if (typeof value !== 'string') {
Expand All @@ -18,4 +18,4 @@ export default class Raw {
static build(value: string) {
return new Raw(value);
}
};
}
Loading