forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mobx-cookie] add a new type definition (DefinitelyTyped#29868)
* feat: add type definition for mobx-cookie * fix: update version and add strictFunctionTypes to satisfy the test
- Loading branch information
1 parent
8fe8a7b
commit 2093b5c
Showing
4 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "extends": "dtslint/dt.json" } |