mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-31 11:07:32 +08:00
Merge pull request #25911 from KevinRamharak/master
added type definitions for NPM package module-alias
This commit is contained in:
47
types/module-alias/index.d.ts
vendored
Normal file
47
types/module-alias/index.d.ts
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// Type definitions for module-alias 2.0
|
||||
// Project: https://github.com/ilearnio/module-alias/
|
||||
// Definitions by: Kevin Ramharak <https://github.com/KevinRamharak>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/
|
||||
|
||||
export = init;
|
||||
|
||||
/**
|
||||
* Import aliases from package.json
|
||||
*/
|
||||
declare function init(options?: string | init.Options): void;
|
||||
|
||||
/**
|
||||
* Exported functoins
|
||||
*/
|
||||
declare namespace init {
|
||||
function isPathMatchesAlias(path: string, alias: string): boolean;
|
||||
|
||||
/**
|
||||
* Register a custom modules directory
|
||||
*/
|
||||
function addPath(path: string): void;
|
||||
|
||||
/**
|
||||
* Register a single alias
|
||||
*/
|
||||
function addAlias(alias: string, path: string): void;
|
||||
|
||||
/**
|
||||
* Register mutliple aliases
|
||||
*/
|
||||
function 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
|
||||
*/
|
||||
function reset(): void;
|
||||
|
||||
/**
|
||||
* module intialis options type
|
||||
*/
|
||||
interface Options {
|
||||
base: string;
|
||||
}
|
||||
}
|
||||
12
types/module-alias/module-alias-tests.ts
Normal file
12
types/module-alias/module-alias-tests.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import moduleAlias = require('module-alias');
|
||||
|
||||
moduleAlias('path'); // $ExpectType void
|
||||
moduleAlias({ base : 'path' }); // $ExpectType void
|
||||
|
||||
moduleAlias.isPathMatchesAlias('./path', '@alias'); // $ExpectType boolean
|
||||
|
||||
moduleAlias.addPath('path'); // $ExpectType void
|
||||
moduleAlias.addAliases({ alias : 'path', anotherAlias : 'anotherPath' }); // $ExpectType void
|
||||
moduleAlias.addAlias('@alias', 'somePath'); // $ExpectType void
|
||||
|
||||
moduleAlias.reset(); // $ExpectType void
|
||||
23
types/module-alias/tsconfig.json
Normal file
23
types/module-alias/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"module-alias-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/module-alias/tslint.json
Normal file
1
types/module-alias/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user