Given the following function declaration:
export function createStyleSheet<S extends StyleSheet>(stylesheet: S) {}
I want to add a second argument but keep the S
inferring from the first parameter, is it possible? I was thinking in something like:
export function createStyleSheet<P, S extends StyleSheet>(stylesheet: S) {}
But when I try to use it, it says that the function requires 2 arguments instead of one, also, I’m not sure it will still infer from the first parameter:
Why do I need this? The createStyleSheet
function returns an object with many other functions that it creates, one of these functions are the createSelector
, and, instead of declaring these functions with one argument, something like function createSelector<P>() {}
, I want to receive it once in the main function createStyleSheet
, so, instead of this:
export function createStyleSheet<S extends StyleSheet>(stylesheet: S) {
function createSelector<P>() {}
function createSomething<P>() {}
function createAnotherThing<P>() {}
function createAnyThing<P>() {}
}
I want this, where the argument P
is optional:
export function createStyleSheet<P, S extends StyleSheet>(stylesheet: S) {
function createSelector() {}
function createSomething() {}
function createAnotherThing() {}
function createAnyThing() {}
}
Does it makes sense? I really appreciate your help.