Open
Description
I am wondering if it's possible to annotate setContext
calls such that the exposed variables are typed.
For example:
<!-- MyLogger.svelte -->
<script context="module">
import { setContext } from 'svelte';
/**
* Log something
* @type {(message: string) => void}
*/
function log(message) {
console.log(message);
}
setContext('my-logger', log);
</script>
My problem is that even though log
has type annotations, when someone gets the function via getContext('my-logger')
the type is unknown.
I wonder if there's a way to add type annotations to setContext
.
Metadata
Metadata
Assignees
Labels
No labels