S
SolidJS•10mo ago
gsoutz

solid primitives storage is bug

I can't set value 0 number what is this. Secondly please fix the types in documentation like this asdf = (props) { } What is this props default type add that to documentation examples it's 2024 you still don't have types....
23 Replies
<Alterion.Dev>
<Alterion.Dev>•10mo ago
Where exactly are you seeing docs without types @gsoutz if you want things to change, you'll have to take the time to help us understand what the issue is, rather than do a drive-by complaint.
gsoutz
gsoutzOP•10mo ago
everywhere, just read it it's obvious
<Alterion.Dev>
<Alterion.Dev>•10mo ago
You'll unfortunately have to be a bit more precise. The reference guide has plenty of type docs. The tutorial, however, does not mix in typescript, as it's not obligatory to use solidjs with it Adding the layer of typescript complexity forced into every part of the beginners guide would actually force out people with an even harder and significant learning curve. And, to be fair, props is an object with the keys being your attributes, and the values you send it, I'm not sure how it would be typed? If you understand objects in typescript, it should be relatively obvious
gsoutz
gsoutzOP•10mo ago
bro instead of sending wall of text, just fix this and send a PR. fine I will stick to 🤪
<Alterion.Dev>
<Alterion.Dev>•10mo ago
Well if you can't dialog like an adult, we're not going to keep this conversation going. There's nothing we can do for you if you're going to stick with this attitude.
davedbase
davedbase•10mo ago
Yeah, I was going to suggest that being a nicer might get you a bit further ahead. Just friendly advice
<Alterion.Dev>
<Alterion.Dev>•10mo ago
Besides the Typescript question you had, the "can't set the value 0 number" doesn't really hold true? What exactly can't you set to 0? Because obviously, signals can be set to 0. And obviously I can pass props that are 0, that works fine.
export default function Counter(props: { start: number }) {
const [count, setCount] = createSignal(props.start);
return (
<button class="increment" onClick={() => setCount(count() + 1)}>
Clicks: {count()}
</button>
);
}
export default function Counter(props: { start: number }) {
const [count, setCount] = createSignal(props.start);
return (
<button class="increment" onClick={() => setCount(count() + 1)}>
Clicks: {count()}
</button>
);
}
and called with <Counter start={0} /> , again from the basic example, works perfectly well. So if you still want help, you're going to have to go beyond the "bro it's broke" level of question.
gsoutz
gsoutzOP•10mo ago
ok let me give you a hint, I am not going to contribute further to this project. What do you think this line does> https://github.com/solidjs-community/solid-primitives/blob/main/packages/storage/src/persisted.ts#L171... And props is here untyped.
import { createContext } from "solid-js";

const MyContext = createContext()

export const Provider = (props) => {
return (
<MyContext.Provider>
{props.children}
</MyContext.Provider>
)
}
import { createContext } from "solid-js";

const MyContext = createContext()

export const Provider = (props) => {
return (
<MyContext.Provider>
{props.children}
</MyContext.Provider>
)
}
GitHub
solid-primitives/packages/storage/src/persisted.ts at main · solidj...
A library of high-quality primitives that extend SolidJS reactivity. - solidjs-community/solid-primitives
<Alterion.Dev>
<Alterion.Dev>•10mo ago
You mean the children? You can easily type this with JSX.Element , as per https://docs.solidjs.com/reference/component-apis/children What you pointed to wasn't the docs. It's solid-primitive, part of the ecosystem, but it's not part of the official core code, or docs, it's community-provided
gsoutz
gsoutzOP•10mo ago
Sorry for the confusion, my link is about storage bug. Second thing is about solid docs. Two separete things here.
<Alterion.Dev>
<Alterion.Dev>•10mo ago
If you want community-provided things to get better, it's up to you to PR it, so you can go do that if you want? "props is untyped" because props is just an object. A Record<string, V> if you will. As for "storage bug", again, just pointing to source code saying it's not working isn't helpful, you have to actually demonstrate a bug in your own code, so that a developer might be able to reproduce it. Open an issue in https://github.com/solidjs-community/solid-primitives/issues, perhaps that would yield better results
<Alterion.Dev>
<Alterion.Dev>•10mo ago
there's even some really nice github features you can leverage to make that easier
No description
gsoutz
gsoutzOP•10mo ago
Ok.
<Alterion.Dev>
<Alterion.Dev>•10mo ago
Please try to be less dismissive of the effort of all your peers, and be less aggressive towards people trying to help you, in the future. It goes a lot smoother that way. Most people don't like to be angrily talked to in that way, I'm sure you don't either, and I don't know why you think this is appropriate behaviour towards others.
gsoutz
gsoutzOP•10mo ago
I said please didn't I. bringing software with fundamental bugs in it makes everyone mad.
<Alterion.Dev>
<Alterion.Dev>•10mo ago
Anger is understandable, but it doesn't meant you need to be passive aggressive, and condescending, when you bring up issues. "this makes me angry and I'm pissed off" is perfectly fine. "bro just figure it out here's a hint" isn't, really. I would appreciate if other people not involved with this question wouldn't butt in with commentary. This isn't your business. There. De-escalation is part of a mod's tasks after all :iara_hugs_eri:
gsoutz
gsoutzOP•10mo ago
It was your tone of making suggestive remarks like justifying the problem with long text isn't very constructive either. Solid is advertised to be fully typed but you think adding correct typing to examples is not right.
davedbase
davedbase•10mo ago
Frustration is acceptable, attitude and condescension isn't (on anyone's part for that matter)
<Alterion.Dev>
<Alterion.Dev>•10mo ago
That's certainly an argument to be made but if you can't bother having a conversation where you read an explanation or a counter point, the discussion is going to be pretty one-sided. I did address your point, and offer a solution for you - it's a thing you'd have to do equally in any framework. I have to type props in react myself too, solidjs isn't any different. And as a specific example, this is a really common (and simple) pattern to use:
type CounterProps = {
start: number;
}

export default function Counter(props: CounterProps) {
const [count, setCount] = createSignal(props.start);
return (
<button class="increment" onClick={() => setCount(count() + 1)}>
Clicks: {count()}
</button>
);
}
type CounterProps = {
start: number;
}

export default function Counter(props: CounterProps) {
const [count, setCount] = createSignal(props.start);
return (
<button class="increment" onClick={() => setCount(count() + 1)}>
Clicks: {count()}
</button>
);
}
This look exactly like how I do it in react. And to expand on that, in terms of children, you'd do like the reference says, as linked above, with this example:
"use client";
import { JSX, createSignal } from "solid-js";
import "./Counter.css";

type CounterProps = {
start: number;
children: JSX.Element;
}

export default function Counter(props: CounterProps) {
const [count, setCount] = createSignal(props.start);
return (
<button class="increment" onClick={() => setCount(count() + 1)}>
Clicks: {count()}
{props.children}
</button>
);
}
"use client";
import { JSX, createSignal } from "solid-js";
import "./Counter.css";

type CounterProps = {
start: number;
children: JSX.Element;
}

export default function Counter(props: CounterProps) {
const [count, setCount] = createSignal(props.start);
return (
<button class="increment" onClick={() => setCount(count() + 1)}>
Clicks: {count()}
{props.children}
</button>
);
}
Now if you want to counter that with more anger, condescension, or arguments about how we're lazy but you're not, there's no point in continuing any sort of conversation with you. Take that as a warning for any future interaction you might want to have in this server.
gsoutz
gsoutzOP•10mo ago
Ok your second example has the type that declares children as JSX.Element never mentioned anywhere in the docs. Thanks for bringing that up, people can reference this post in the future to learn that at least.
Brendonovich
Brendonovich•10mo ago
it's also in the dedicated typescript guide https://www.solidjs.com/guides/typescript
<Alterion.Dev>
<Alterion.Dev>•10mo ago
Every page in the reference section of the docs (and, to be precise, these are the new docs, that are still in development, so that might be part of the confusion) has the types at least at the top of the reference page
Want results from more Discord servers?
Add your server