Skip to content

Commit

Permalink
Merge pull request DefinitelyTyped#7696 from komarik0/master
Browse files Browse the repository at this point in the history
cannot declare variable of Umzug type
  • Loading branch information
horiuchi committed Jan 20, 2016
2 parents 180b37d + 67315b6 commit 7ac1530
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 102 deletions.
7 changes: 4 additions & 3 deletions umzug/umzug-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
/// <reference path="../sequelize/sequelize.d.ts" />
/// <reference path="../node/node.d.ts" />

import Umzug = require("umzug");
import Sequelize = require("sequelize");

import * as Umzug from "umzug";
import * as Sequelize from "sequelize";

var someVar:Umzug.Umzug;
var umzug = new Umzug({});
someVar = umzug;

umzug.up().then(function (result) {
// do something with the result
Expand Down
199 changes: 100 additions & 99 deletions umzug/umzug.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
/// <reference path="../sequelize/sequelize.d.ts" />

declare module "umzug" {
import Sequelize = require("sequelize");

import Sequelize = require("sequelize");
module umzug {

interface MigrationOptions {
interface MigrationOptions {

/*
* The params that gets passed to the migrations.
Expand All @@ -30,65 +31,65 @@ declare module "umzug" {
*/
wrap?: <T>( fn : T ) => T;

}
}

interface JSONStorageOptions {
interface JSONStorageOptions {

/**
* The path to the json storage.
* Defaults to process.cwd() + '/umzug.json';
*/
path?: string;

}

interface SequelizeStorageOptions {

/**
* The configured instance of Sequelize.
* Optional if `model` is passed.
*/
sequelize?: Sequelize.Sequelize;

/**
* The to be used Sequelize model.
* Must have column name matching `columnName` option
* Optional of `sequelize` is passed.
*/
model?: Sequelize.Model<any, any>;

/**
* The name of the to be used model.
* Defaults to 'SequelizeMeta'
*/
modelName?: string;

/**
* The name of table to create if `model` option is not supplied
* Defaults to `modelName`
*/
tableName?: string;

/**
* The name of table column holding migration name.
* Defaults to 'name'.
*/
columnName: string;

/**
* The type of the column holding migration name.
* Defaults to `Sequelize.STRING`
*/
columnType: Sequelize.DataTypeAbstract;

}

interface ExecuteOptions {
}

interface SequelizeStorageOptions {

/**
* The configured instance of Sequelize.
* Optional if `model` is passed.
*/
sequelize?: Sequelize.Sequelize;

/**
* The to be used Sequelize model.
* Must have column name matching `columnName` option
* Optional of `sequelize` is passed.
*/
model?: Sequelize.Model<any, any>;

/**
* The name of the to be used model.
* Defaults to 'SequelizeMeta'
*/
modelName?: string;

/**
* The name of table to create if `model` option is not supplied
* Defaults to `modelName`
*/
tableName?: string;

/**
* The name of table column holding migration name.
* Defaults to 'name'.
*/
columnName: string;

/**
* The type of the column holding migration name.
* Defaults to `Sequelize.STRING`
*/
columnType: Sequelize.DataTypeAbstract;

}

interface ExecuteOptions {
migrations?: Array<string>;
method?: string;
}
}

interface UmzugOptions {
interface UmzugOptions {

/**
* The storage.
Expand Down Expand Up @@ -122,67 +123,67 @@ declare module "umzug" {
*/
migrations? : MigrationOptions;

}

interface UpDownToOptions {

/**
* It is also possible to pass the name of a migration in order to
* just run the migrations from the current state to the passed
* migration name.
*/
to: string;

}
}

interface UpDownMigrationsOptions {
interface UpDownToOptions {

/**
* Running specific migrations while ignoring the right order, can be
* done like this:
*/
migrations: Array<string>;
/**
* It is also possible to pass the name of a migration in order to
* just run the migrations from the current state to the passed
* migration name.
*/
to: string;

}
}

class Umzug {
interface UpDownMigrationsOptions {

constructor(options?: UmzugOptions);
/**
* Running specific migrations while ignoring the right order, can be
* done like this:
*/
migrations: Array<string>;

/**
* The execute method is a general purpose function that runs for
* every specified migrations the respective function.
*/
execute(options? : ExecuteOptions) : Promise<Array<string>>;
}

/**
* You can get a list of pending/not yet executed migrations like this:
*/
pending() : Promise<Array<string>>;
interface Umzug {
/**
* The execute method is a general purpose function that runs for
* every specified migrations the respective function.
*/
execute(options? : ExecuteOptions) : Promise<Array<string>>;

/**
* You can get a list of already executed migrations like this:
*/
executed() : Promise<Array<string>>;
/**
* You can get a list of pending/not yet executed migrations like this:
*/
pending() : Promise<Array<string>>;

/**
* The up method can be used to execute all pending migrations.
*/
up(migration?: string) : Promise<string>;
up(migrations?: Array<string>) : Promise<Array<string>>;
up(options?: UpDownToOptions | UpDownMigrationsOptions ) : Promise<Array<string>>;
/**
* You can get a list of already executed migrations like this:
*/
executed() : Promise<Array<string>>;

/**
* The down method can be used to revert the last executed migration.
*/
down(migration?: string) : Promise<string>;
down(migrations?: Array<string>) : Promise<Array<string>>;
down(options?: UpDownToOptions | UpDownMigrationsOptions ) : Promise<Array<string>>;
/**
* The up method can be used to execute all pending migrations.
*/
up(migration?: string) : Promise<string>;
up(migrations?: Array<string>) : Promise<Array<string>>;
up(options?: UpDownToOptions | UpDownMigrationsOptions ) : Promise<Array<string>>;

}
/**
* The down method can be used to revert the last executed migration.
*/
down(migration?: string) : Promise<string>;
down(migrations?: Array<string>) : Promise<Array<string>>;
down(options?: UpDownToOptions | UpDownMigrationsOptions ) : Promise<Array<string>>;

var umzug : typeof Umzug;
}

export = umzug;
interface UmzugStatic {
new (options?: UmzugOptions) : Umzug;
}
}

var umzug : umzug.UmzugStatic;
export = umzug;
}

0 comments on commit 7ac1530

Please sign in to comment.