Skip to content

Commit

Permalink
fix: generic type class Cache (hexojs/hexo-util#308)
Browse files Browse the repository at this point in the history
feat: add overload `get` method
  • Loading branch information
dimaslanjaka committed May 17, 2023
1 parent bf62f58 commit 817c8ea
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/hexo/locals.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Cache } from 'hexo-util';
import { HexoLocalsData } from './locals-d';


class Locals {
public cache: Cache<HexoLocalsData>;
public getters: Record<string, HexoLocalsData>;
Expand All @@ -11,6 +10,12 @@ class Locals {
this.getters = {};
}

get(name: 'posts'): HexoLocalsData;
get(name: 'pages'): HexoLocalsData;
get(name: 'categories'): HexoLocalsData;
get(name: 'data'): HexoLocalsData;
get(name: 'tags'): HexoLocalsData;
get(name: string): HexoLocalsData;
get(name: string) {
if (typeof name !== 'string') throw new TypeError('name must be a string!');

Expand Down

0 comments on commit 817c8ea

Please sign in to comment.