Skip to content

Commit e85f173

Browse files
committed
fix: tighten types and added cache hit attr for get item raw
1 parent bbcc8a8 commit e85f173

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/nuxt/src/runtime/plugins/storage.server.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ type MaybeInstrumentedDriver = Driver & {
2121
__sentry_instrumented__?: boolean;
2222
};
2323

24+
type DriverMethod = keyof Driver;
25+
2426
/**
2527
* Methods that should have a key argument.
2628
*/
27-
const KEYED_METHODS = new Set([
29+
const KEYED_METHODS = new Set<DriverMethod>([
2830
'hasItem',
2931
'getItem',
3032
'getItemRaw',
@@ -38,7 +40,7 @@ const KEYED_METHODS = new Set([
3840
/**
3941
* Methods that should have a attribute to indicate a cache hit.
4042
*/
41-
const CACHE_HIT_METHODS = new Set(['hasItem', 'getItem', 'getKeys']);
43+
const CACHE_HIT_METHODS = new Set<DriverMethod>(['hasItem', 'getItem', 'getItemRaw', 'getKeys']);
4244

4345
/**
4446
* Creates a Nitro plugin that instruments the storage driver.
@@ -85,7 +87,7 @@ function instrumentDriver(driver: MaybeInstrumentedDriver, mountBase: string): D
8587

8688
// List of driver methods to instrument
8789
// get/set/remove are aliases and already use their {method}Item methods
88-
const methodsToInstrument: (keyof Driver)[] = [
90+
const methodsToInstrument: DriverMethod[] = [
8991
'hasItem',
9092
'getItem',
9193
'getItemRaw',
@@ -120,7 +122,7 @@ function instrumentDriver(driver: MaybeInstrumentedDriver, mountBase: string): D
120122
*/
121123
function createMethodWrapper(
122124
original: (...args: unknown[]) => unknown,
123-
methodName: string,
125+
methodName: DriverMethod,
124126
driver: Driver,
125127
mountBase: string,
126128
): (...args: unknown[]) => unknown {

0 commit comments

Comments
 (0)