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.
Add typings for nookies (DefinitelyTyped#29857)
* Add typings for nookies * Set strictFunctionTypes to true * Fix get function return type * Add semicolons
- Loading branch information
1 parent
5508e44
commit c76ce3b
Showing
4 changed files
with
54 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,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; |
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,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'); |
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,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" | ||
] | ||
} |
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" } |