0

In this case my question is Svelte Native specific. I want to build an app using Svelte Native and the TypeScript error that I am getting is for using props on Svelte components in the template (.svelte) files, something like this:

Svelte Native TypeScript Error

But this error only occurs with certain components, not all of them. I have this declared in 'types' folder:

declare module '*.svelte' { export { SvelteComponent as default }; }

But it doesn't help.

One similar issue is with using on:event prop with one RadListView component from Native Script:

Native Script TypeScript Error

Technically everything is working fine, it's just annoying to keep on seeing that. How can I get rid of these error? Is anybody else facing this issue? Thanks.

f.bele
  • 207
  • 2
  • 13
  • The type of the `actionBarHidden` prop is `boolean | undefined`, but you passed a string to it. Try: `` – Lin Du Jul 10 '23 at 09:43
  • @lin-du I am aware of what was the error, but I didn't know how to resolve it. User H.B. explained that in his answer below. – f.bele Jul 10 '23 at 13:26

1 Answers1

1

"true" is string. Either use the flag shorthand or set it via {...}

<page actionBarHidden />
<page actionBarHidden={true} />
H.B.
  • 166,899
  • 29
  • 327
  • 400
  • @h-b I wasn't aware one can pass values with primitive types like this to a prop. Good to know! I'm still learning. I have edited/updated my question as I have forgotten to add one another on:event prop that is throwing the similar error. Could you take a look if this kind of error is also resolvable? – f.bele Jul 10 '23 at 13:25
  • That error claims that the event does not exist, at least according to the types, so either it really does not exist or the type definitions are wrong or incompatible with the version of Svelte tooling used. Cannot say more, given that I have not used said component/library. Also, do *not* screenshot code, it's inaccessible and cannot be copied. Insert the code formatted as such, add errors as quotes and maybe point out where in the code it appears. – H.B. Jul 10 '23 at 14:15
  • @h-b Thank you for your swift answers and help. Is it possible that get rid of the errors by defining own types? If so, do you have any suggestion how I could do it? Thanks. I'll put errors also in writing so the code can be copied and programmatically read. – f.bele Jul 11 '23 at 15:42
  • You can define types, but that is a completely separate issue. Comments are not meant for answering questions, there also should already be answers elsewhere, e.g. [here](https://stackoverflow.com/q/64131176/546730). The namespaces and names changed over time, so I am not sure what the correct one is right now, it's also version dependent. – H.B. Jul 11 '23 at 15:51