Add @types/feather-route-matcher (#36572)

This commit is contained in:
Evgeniy 2019-07-01 23:14:20 +05:00 committed by Ryan Cavanaugh
parent ed7ba80316
commit c2aed2dcf2
4 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,15 @@
import createMatcher from 'feather-route-matcher';
const matcher = createMatcher({
'/': 33,
'/number-13': 13,
'/number/:num': 199,
});
const numberOfPage: number = matcher('/').page;
const matchedURL: string = matcher('/').url;
const params: {} | null = matcher('/number/34').params;
const knownParams = matcher('/number/24').params as { num: string };
const extractedNum: string = knownParams.num;

22
types/feather-route-matcher/index.d.ts vendored Normal file
View File

@ -0,0 +1,22 @@
// Type definitions for feather-route-matcher 3.1
// Project: https://github.com/henrikjoreteg/feather-route-matcher
// Definitions by: Eugeny Schibrikov <https://github.com/sHooKDT>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface RouteConfig<T> {
[path: string]: T;
}
interface Match<T> {
page: T;
url: string;
params: { [key: string]: string } | null;
}
interface Matcher<T> {
(path: string): Match<T>;
}
declare function createMatcher<T>(config: RouteConfig<T>): Matcher<T>;
export { createMatcher as default };

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"feather-route-matcher-tests.ts"
]
}

View File

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