mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-04 17:20:09 +00:00
[Mobx-cookie] add a new type definition (#29868)
* feat: add type definition for mobx-cookie * fix: update version and add strictFunctionTypes to satisfy the test
This commit is contained in:
committed by
Sheetal Nandi
parent
8fe8a7bf58
commit
2093b5c036
17
types/mobx-cookie/index.d.ts
vendored
Normal file
17
types/mobx-cookie/index.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// Type definitions for mobx-cookie 1.1
|
||||
// Project: https://github.com/will-stone/mobx-cookie#readme
|
||||
// Definitions by: Duong Tran <https://github.com/t49tran>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { CookieAttributes } from 'js-cookie';
|
||||
|
||||
declare class MobxCookie {
|
||||
constructor(name: string, options?: CookieAttributes);
|
||||
|
||||
get(): any;
|
||||
set(value: any, options?: CookieAttributes): void;
|
||||
remove(): void;
|
||||
}
|
||||
|
||||
export default MobxCookie;
|
||||
11
types/mobx-cookie/mobx-cookie-tests.ts
Normal file
11
types/mobx-cookie/mobx-cookie-tests.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import MobxCookie from 'mobx-cookie';
|
||||
|
||||
// Declare a reactive mobx cookie that last for 20 days
|
||||
const mobxCookie = new MobxCookie('TEST_MOBX_COOKIE', {expires: 20});
|
||||
|
||||
// Set a new value for the cookie that last for 10 days
|
||||
mobxCookie.set('MY_VALUE', {expires: 10});
|
||||
|
||||
const cookieValue = mobxCookie.get();
|
||||
|
||||
mobxCookie.remove();
|
||||
23
types/mobx-cookie/tsconfig.json
Normal file
23
types/mobx-cookie/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",
|
||||
"mobx-cookie-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/mobx-cookie/tslint.json
Normal file
1
types/mobx-cookie/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user