Improve TypeScript type definition for stores
Closed this issue · 3 comments
albertms10 commented
Is your feature request related to a problem? Please describe.
The stores
function from @sapper/app
has an unknown
return type, although there is a known object returning some predefined values such as preloading
, page
, session
, as seen in the Sapper Docs.
<script>
import { stores } from '@sapper/app';
const { preloading, page, session } = stores(); // => `unknown`, destructured items are `any`
const delayedPreloading = derived(
preloading,
(currentPreloading, set) => { // as preloading is treated as `any`, TypeScript cannot infer types for fn parameters
// ...
}
);
// ...
</script>
Describe the solution you'd like
Adding types for these stores would improve DX.
Describe alternatives you've considered
Just ignore TypeScript warning about the any
type in use cases.
TheComputerM commented
Can I try to fix this issue and open a PR?
albertms10 commented
Of course!