Skip to content

Commit

Permalink
[Mobx-cookie] add a new type definition (DefinitelyTyped#29868)
Browse files Browse the repository at this point in the history
* feat: add type definition for mobx-cookie

* fix: update version and add strictFunctionTypes to satisfy the test
  • Loading branch information
t49tran authored and sheetalkamat committed Oct 19, 2018
1 parent 8fe8a7b commit 2093b5c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
17 changes: 17 additions & 0 deletions types/mobx-cookie/index.d.ts
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;
11 changes: 11 additions & 0 deletions types/mobx-cookie/mobx-cookie-tests.ts
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();
23 changes: 23 additions & 0 deletions types/mobx-cookie/tsconfig.json
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"
]
}
1 change: 1 addition & 0 deletions types/mobx-cookie/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

0 comments on commit 2093b5c

Please sign in to comment.