diff --git a/definitions/npm/module-alias_v2.x.x/flow_v0.83.x-/module-alias_v2.x.x.js b/definitions/npm/module-alias_v2.x.x/flow_v0.83.x-/module-alias_v2.x.x.js new file mode 100644 index 0000000000..e8bbf38be3 --- /dev/null +++ b/definitions/npm/module-alias_v2.x.x/flow_v0.83.x-/module-alias_v2.x.x.js @@ -0,0 +1,34 @@ +declare module 'module-alias' { + /** + * module intialis options type + */ + declare export type Options = {| + base: string, + |}; + + declare module.exports: {| + /** + * Import aliases from package.json + */ + (options?: string | Options): void, + isPathMatchesAlias(path: string, alias: string): boolean, + /** + * Register a custom modules directory + */ + addPath(path: string): void, + /** + * Register a single alias + */ + addAlias(alias: string, path: string): void, + /** + * Register multiple aliases + */ + addAliases(aliases: { [alias: string]: string }): void, + /** + * Reset any changes maded (resets all registered aliases + * and custom module directories) + * The function is undocumented and for testing purposes only + */ + reset(): void, + |}; +} diff --git a/definitions/npm/module-alias_v2.x.x/flow_v0.83.x-/test_module-alias_v2.x.x.js b/definitions/npm/module-alias_v2.x.x/flow_v0.83.x-/test_module-alias_v2.x.x.js new file mode 100644 index 0000000000..0e04923290 --- /dev/null +++ b/definitions/npm/module-alias_v2.x.x/flow_v0.83.x-/test_module-alias_v2.x.x.js @@ -0,0 +1,81 @@ +// @flow +import { describe, test } from 'flow-typed-test'; +import moduleAlias from 'module-alias'; + +describe('module-alias', () => { + test('default', () => { + (moduleAlias(): void); + moduleAlias('test'); + moduleAlias({ + base: 'test', + }); + + // $FlowExpectedError[incompatible-cast] + (moduleAlias(): string); + // $FlowExpectedError[incompatible-call] + moduleAlias(123); + // $FlowExpectedError[incompatible-call] + moduleAlias({}); + // $FlowExpectedError[incompatible-call] + moduleAlias({ foo: 'bar' }); + }); + + test('isPathMatchesAlias', () => { + (moduleAlias.isPathMatchesAlias('test', 'test'): boolean); + + // $FlowExpectedError[incompatible-call] + moduleAlias.isPathMatchesAlias(); + // $FlowExpectedError[incompatible-call] + moduleAlias.isPathMatchesAlias(123); + // $FlowExpectedError[incompatible-call] + moduleAlias.isPathMatchesAlias('test', 123); + // $FlowExpectedError[incompatible-cast] + (moduleAlias.isPathMatchesAlias('test', 'test'): string); + }); + + test('addPath', () => { + (moduleAlias.addPath('test'): void); + + // $FlowExpectedError[incompatible-call] + moduleAlias.addPath(); + // $FlowExpectedError[incompatible-call] + moduleAlias.addPath(123); + // $FlowExpectedError[incompatible-cast] + (moduleAlias.addPath('test'): string); + }); + + test('addAlias', () => { + (moduleAlias.addAlias('test', 'test'): void); + + // $FlowExpectedError[incompatible-call] + moduleAlias.addAlias(); + // $FlowExpectedError[incompatible-call] + moduleAlias.addAlias(123); + // $FlowExpectedError[incompatible-call] + moduleAlias.addAlias('test', 123); + // $FlowExpectedError[incompatible-cast] + (moduleAlias.addAlias('test', 'test'): string); + }); + + test('addAliases', () => { + (moduleAlias.addAliases({ foo: 'bar' }): void); + + // $FlowExpectedError[incompatible-call] + moduleAlias.addAliases(); + // $FlowExpectedError[incompatible-call] + moduleAlias.addAliases(123); + // $FlowExpectedError[incompatible-call] + moduleAlias.addAliases({ foo: 123 }); + // $FlowExpectedError[incompatible-cast] + (moduleAlias.addAliases({ foo: 'bar' }): string); + }); + + test('reset', () => { + (moduleAlias.reset(): void); + + // $FlowExpectedError[extra-arg] + moduleAlias.reset(123); + // $FlowExpectedError[incompatible-cast] + (moduleAlias.reset(): string); + }); +});