mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* [cookie-parser] finish incomplete typings * [cookie-parser] bump compiler version as suggested by travis output * [cookie-parser] revert compiler bump * [cookie-parser] restrict compiler version in failing packages * [cookie-parser] fix indentation
32 lines
771 B
TypeScript
32 lines
771 B
TypeScript
import express = require('express');
|
|
import cookieParser = require('cookie-parser');
|
|
|
|
const app = express();
|
|
app.use(cookieParser('optional secret string'));
|
|
|
|
let obj: object;
|
|
let str: string;
|
|
let notTrue: false;
|
|
let undef: undefined;
|
|
|
|
const res = cookieParser.JSONCookie('foo');
|
|
if (typeof res === 'undefined') {
|
|
undef = res;
|
|
} else {
|
|
obj = res;
|
|
}
|
|
|
|
const res2 = cookieParser.JSONCookies({foo: 'bar'});
|
|
const jsonRes: { foo?: object } = res2;
|
|
|
|
const res3 = cookieParser.signedCookie('', 'keyboard cat');
|
|
cookieParser.signedCookie('', ['keyboard', 'cat']);
|
|
if (typeof res3 === 'string') {
|
|
str = res3;
|
|
} else {
|
|
notTrue = res3;
|
|
}
|
|
|
|
const res4 = cookieParser.signedCookies({foo: 'bar'}, 'keyboard cat');
|
|
const signedCookieRes: { foo?: string | false } = res4;
|