mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add @types/feather-route-matcher (#36572)
This commit is contained in:
parent
ed7ba80316
commit
c2aed2dcf2
15
types/feather-route-matcher/feather-route-matcher-tests.ts
Normal file
15
types/feather-route-matcher/feather-route-matcher-tests.ts
Normal 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
22
types/feather-route-matcher/index.d.ts
vendored
Normal 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 };
|
||||
23
types/feather-route-matcher/tsconfig.json
Normal file
23
types/feather-route-matcher/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
1
types/feather-route-matcher/tslint.json
Normal file
1
types/feather-route-matcher/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user