mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-07 23:37:35 +08:00
basic-auth: Make auth return value optional
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
|
||||
import {IncomingMessage} from 'http';
|
||||
import auth = require('basic-auth');
|
||||
|
||||
auth(null);
|
||||
const loginData = auth(undefined! as IncomingMessage);
|
||||
if (loginData) {
|
||||
const {name, pass} = loginData;
|
||||
}
|
||||
|
||||
3
types/basic-auth/index.d.ts
vendored
3
types/basic-auth/index.d.ts
vendored
@@ -7,7 +7,8 @@
|
||||
|
||||
import * as http from 'http';
|
||||
|
||||
declare function auth(req: http.IncomingMessage): auth.BasicAuthResult;
|
||||
// See https://github.com/jshttp/basic-auth/blob/v1.1.0/index.js#L49
|
||||
declare function auth(req: http.IncomingMessage): auth.BasicAuthResult | undefined;
|
||||
|
||||
declare namespace auth {
|
||||
interface BasicAuthResult {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
|
||||
Reference in New Issue
Block a user