lvin
lvin3y ago

types not inferred from npm packages

im importing deepSignal an npm package with ts support however non of the returned types are inferred, i tested the same package in nodejs and it works there
2 Replies
lvin
lvinOP3y ago
import { effect } from "@preact/signals";
import { deepSignal } from "npm:@deepsignal/preact";
type UserNameStore = {
first: string;
last: string;
};

const getInitialUserNameStore = (): UserNameStore => {
const storedUserStore = localStorage.getItem("USER_NAME_STORE_KEY");
return storedUserStore
? JSON.parse(storedUserStore)
: { first: "", last: "" };
};

const userStore = deepSignal({
name: getInitialUserNameStore(),
email: "",
});

effect(() =>
localStorage.setItem(
"USER_NAME_STORE_KEY",
JSON.stringify(userStore.name.value)
)
);
import { effect } from "@preact/signals";
import { deepSignal } from "npm:@deepsignal/preact";
type UserNameStore = {
first: string;
last: string;
};

const getInitialUserNameStore = (): UserNameStore => {
const storedUserStore = localStorage.getItem("USER_NAME_STORE_KEY");
return storedUserStore
? JSON.parse(storedUserStore)
: { first: "", last: "" };
};

const userStore = deepSignal({
name: getInitialUserNameStore(),
email: "",
});

effect(() =>
localStorage.setItem(
"USER_NAME_STORE_KEY",
JSON.stringify(userStore.name.value)
)
);
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?