Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of undefined (reading 'has') #204

Open
Bae360 opened this issue Feb 14, 2025 · 1 comment
Open

Cannot read properties of undefined (reading 'has') #204

Bae360 opened this issue Feb 14, 2025 · 1 comment

Comments

@Bae360
Copy link

Bae360 commented Feb 14, 2025

Astro
after running
$ pnpm astro add @inox-tools/request-nanostores
the following error occurs on line 21
[ERROR] Cannot read properties of undefined (reading 'has')

\node_modules.pnpm@[email protected][email protected][email protected]\node_modules@inox-tools\request-nanostores\src\runtime\server.ts

import type { ReadableAtom } from 'nanostores';
import { getState } from '@it-astro:state';

const STATE_NAMESPACE = '@inox-tools/request-nanostores';

type Stores = Map<string, any>;

function getAtomStore(): Stores {
	return getState(STATE_NAMESPACE, new Map()) as Stores;
}

export const shared = <A extends ReadableAtom<any>>(name: string, store: A): A => {
	const baseValue = store.value;

	Object.defineProperty(store, 'value', {
		configurable: false,
		enumerable: true,
		get() {
			const store = getAtomStore();
			if (!store.has(name)) {
				store.set(name, structuredClone(baseValue));
			}
			return store.get(name);
		},
		set(value) {
			const store = getAtomStore();
			store.set(name, value);
		},
	});

	return store;
};

and Cannot find module '@it-astro:state' or its corresponding type declarations.ts(2307)

I have also ran
pnpm astro add @inox-tools/request-state

@Fryuni
Copy link
Owner

Fryuni commented Feb 20, 2025

Hey @Bae360. Can you provide a reproduction example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants