Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:flow-typed/flow-typed into main
- Loading branch information
Showing
6 changed files
with
586 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
definitions/npm/module-alias_v2.x.x/flow_v0.83.x-/module-alias_v2.x.x.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
|}; | ||
} |
81 changes: 81 additions & 0 deletions
81
definitions/npm/module-alias_v2.x.x/flow_v0.83.x-/test_module-alias_v2.x.x.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
}); |
Oops, something went wrong.