Add typings for nookies (#29857)

* Add typings for nookies

* Set strictFunctionTypes to true

* Fix get function return type

* Add semicolons
This commit is contained in:
Andreas Bergqvist
2018-10-19 08:54:22 -07:00
committed by Sheetal Nandi
parent 5508e44eee
commit c76ce3bec0
4 changed files with 54 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
// Type definitions for nookies 1.1
// Project: https://github.com/maticzav/nookies#readme
// Definitions by: Andreas Bergqvist <https://github.com/andreasbergqvist>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import { NextContext } from 'next';
import { CookieParseOptions, CookieSerializeOptions } from 'cookie';
export function parseCookies(ctx: NextContext, options?: CookieParseOptions): { [key: string]: string };
export function setCookie(ctx: NextContext, name: string, value: string, options?: CookieSerializeOptions): void;
export function destroyCookie(ctx: NextContext, name: string): void;
declare const Nookies: {
set(ctx: NextContext, name: string, value: string, options?: CookieSerializeOptions): void;
get(ctx: NextContext, options?: CookieParseOptions): { [key: string]: string };
destroy(ctx: NextContext, name: string): void;
};
export default Nookies;
+9
View File
@@ -0,0 +1,9 @@
import nookies, { parseCookies, setCookie, destroyCookie } from 'nookies';
nookies.set({ pathname: '', query: {}, asPath: ''}, 'test-cookie', 'test-value');
nookies.get({ pathname: '', query: {}, asPath: ''});
nookies.destroy({ pathname: '', query: {}, asPath: ''}, 'test-cookie');
parseCookies({ pathname: '', query: {}, asPath: ''});
setCookie({ pathname: '', query: {}, asPath: ''}, 'test-cookie', 'test-value');
destroyCookie({ pathname: '', query: {}, asPath: ''}, 'test-cookie');
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"nookies-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }