mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-06 06:19:58 +08:00
Merge pull request #3412 from m4cx/master
Values in localStorage are not only strings
This commit is contained in:
@@ -14,7 +14,7 @@ interface TestScope extends ng.IScope {
|
||||
|
||||
module ng.local.storage.tests {
|
||||
export class TestController {
|
||||
constructor($scope: TestScope, localStorageService: ng.local.storage.ILocalStorageService) {
|
||||
constructor($scope: TestScope, localStorageService: ng.local.storage.ILocalStorageService<string>) {
|
||||
// isSupported
|
||||
if (localStorageService.isSupported) {
|
||||
// do something
|
||||
@@ -72,4 +72,4 @@ app.config(function (localStorageServiceProvider: ng.local.storage.ILocalStorage
|
||||
.setNotify(true, true);
|
||||
});
|
||||
|
||||
app.controller('TestController', ng.local.storage.tests.TestController);
|
||||
app.controller('TestController', ng.local.storage.tests.TestController);
|
||||
|
||||
@@ -75,7 +75,7 @@ declare module ng.local.storage {
|
||||
|
||||
}
|
||||
|
||||
interface ILocalStorageService {
|
||||
interface ILocalStorageService<T> {
|
||||
/**
|
||||
* Checks if the browser support the current storage type(e.g: localStorage, sessionStorage).
|
||||
* Returns: Boolean
|
||||
@@ -92,14 +92,14 @@ declare module ng.local.storage {
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
set(key: string, value: string): boolean;
|
||||
set(key: string, value: T): boolean;
|
||||
/**
|
||||
* Directly get a value from local storage.
|
||||
* If local storage is not supported, use cookies instead.
|
||||
* Returns: value from local storage
|
||||
* @param key
|
||||
*/
|
||||
get(key: string): string;
|
||||
get(key: string): T;
|
||||
/**
|
||||
* Return array of keys for local storage, ignore keys that not owned.
|
||||
* Returns: value from local storage
|
||||
@@ -146,4 +146,4 @@ declare module ng.local.storage {
|
||||
*/
|
||||
cookie:ICookie;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user