[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:
Duong Tran
2018-10-20 02:57:42 +11:00
committed by Sheetal Nandi
parent 8fe8a7bf58
commit 2093b5c036
4 changed files with 52 additions and 0 deletions

17
types/mobx-cookie/index.d.ts vendored Normal file
View 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;

View 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();

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",
"mobx-cookie-tests.ts"
]
}

View File

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