mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
Merge branch 'basic-auth-return-value' of https://github.com/michael42/DefinitelyTyped into michael42-basic-auth-return-value
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
|
||||
import {IncomingMessage} from 'http';
|
||||
import auth = require('basic-auth');
|
||||
|
||||
auth(null);
|
||||
const loginData = auth(undefined! as IncomingMessage);
|
||||
if (loginData) {
|
||||
const {name, pass} = loginData;
|
||||
}
|
||||
|
||||
auth.parse('Basic QmFzaWM6QXV0aA==');
|
||||
const parsed = auth.parse('Basic QmFzaWM6QXV0aA==');
|
||||
if (parsed) {
|
||||
const {name, pass} = parsed;
|
||||
}
|
||||
|
||||
5
types/basic-auth/index.d.ts
vendored
5
types/basic-auth/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for basic-auth v1.1.0
|
||||
// Type definitions for basic-auth 1.1
|
||||
// Project: https://github.com/jshttp/basic-auth
|
||||
// Definitions by: Clément Bourgeois <https://github.com/moonpyk>, Vesa Poikajärvi <https://github.com/vesse>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -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": [
|
||||
"../"
|
||||
|
||||
1
types/basic-auth/tslint.json
Normal file
1
types/basic-auth/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user