mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Merge pull request #14725 from shiftkey/keytar-may-return-nulls
[keytar] correct return types for signatures
This commit is contained in:
12
keytar/index.d.ts
vendored
12
keytar/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for keytar 3.0.0
|
||||
// Type definitions for keytar 3.0.2
|
||||
// Project: http://atom.github.io/node-keytar/
|
||||
// Definitions by: Milan Burda <https://github.com/miniak/>
|
||||
// Definitions by: Milan Burda <https://github.com/miniak/>, Brendan Forster <https://github.com/shiftkey/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*
|
||||
* @returns the string password or null on failures.
|
||||
*/
|
||||
export declare function getPassword(service: string, account: string): string;
|
||||
export declare function getPassword(service: string, account: string): string | null;
|
||||
|
||||
/**
|
||||
* Add the password for the service and account to the keychain.
|
||||
@@ -31,9 +31,9 @@ export declare function addPassword(service: string, account: string, password:
|
||||
* @param service The string service name.
|
||||
* @param account The string account name.
|
||||
*
|
||||
* @returns the string password or null on failures.
|
||||
* @returns true on success, false on failure
|
||||
*/
|
||||
export declare function deletePassword(service: string, account: string): string;
|
||||
export declare function deletePassword(service: string, account: string): boolean;
|
||||
|
||||
/**
|
||||
* Replace the password for the service and account in the keychain.
|
||||
@@ -56,4 +56,4 @@ export declare function replacePassword(service: string, account: string, passwo
|
||||
*
|
||||
* @returns the string password or null on failures.
|
||||
*/
|
||||
export declare function findPassword(service: string): string;
|
||||
export declare function findPassword(service: string): string | null;
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
|
||||
import keytar = require('keytar');
|
||||
|
||||
keytar.addPassword('keytar-tests', 'username', 'password');
|
||||
keytar.deletePassword('keytar-tests', 'username');
|
||||
keytar.findPassword('keytar-tests');
|
||||
keytar.getPassword('keytar-tests', 'username');
|
||||
keytar.replacePassword('keytar-tests', 'username', 'password');
|
||||
let success: boolean = false;
|
||||
|
||||
success = keytar.addPassword('keytar-tests', 'username', 'password');
|
||||
success = keytar.deletePassword('keytar-tests', 'username');
|
||||
success = keytar.replacePassword('keytar-tests', 'username', 'password');
|
||||
|
||||
let password: string = '';
|
||||
|
||||
password = keytar.findPassword('keytar-tests');
|
||||
password = keytar.getPassword('keytar-tests', 'username');
|
||||
|
||||
Reference in New Issue
Block a user