added type definitions for NPM package module-alias

This commit is contained in:
KevinRamharak
2018-05-21 10:52:33 +02:00
parent 7983861f3e
commit f316905e97
4 changed files with 71 additions and 0 deletions

44
types/module-alias/index.d.ts vendored Normal file
View File

@@ -0,0 +1,44 @@
// 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;
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;
}
}

View File

@@ -0,0 +1,3 @@
import * as moduleAlias from 'module-alias';
moduleAlias.isPathMatchesAlias('./path', '@alias'); // $ExpectType boolean

View 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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }