```Type 'RelinkHook<G>' is not assignable to type '<T extends EntryType>(source_item: LiveEntryTypes

Type 'RelinkHook<G>' is not assignable to type '<T extends EntryType>(source_item: LiveEntryTypes<T>, dest_reg: Registry, dest_cat: RegCat<T>) => LiveEntryTypes<T> | Promise<...> | null'.
Types of parameters 'source_item' and 'source_item' are incompatible.
Type 'LiveEntryTypes<T>' is not assignable to type 'LiveEntryTypes<G>'.
Type 'T' is not assignable to type 'G'.
'T' is assignable to the constraint of type 'G', but 'G' could be instantiated with a different subtype of constraint 'EntryType'.
Type 'EntryType' is not assignable to type 'G'.
'EntryType' is assignable to the constraint of type 'G', but 'G' could be instantiated with a different subtype of constraint 'EntryType'.ts(2322)
Type 'RelinkHook<G>' is not assignable to type '<T extends EntryType>(source_item: LiveEntryTypes<T>, dest_reg: Registry, dest_cat: RegCat<T>) => LiveEntryTypes<T> | Promise<...> | null'.
Types of parameters 'source_item' and 'source_item' are incompatible.
Type 'LiveEntryTypes<T>' is not assignable to type 'LiveEntryTypes<G>'.
Type 'T' is not assignable to type 'G'.
'T' is assignable to the constraint of type 'G', but 'G' could be instantiated with a different subtype of constraint 'EntryType'.
Type 'EntryType' is not assignable to type 'G'.
'EntryType' is assignable to the constraint of type 'G', but 'G' could be instantiated with a different subtype of constraint 'EntryType'.ts(2322)
8 Replies
WHITESPINE
WHITESPINEOP4y ago
This is without any other changes we've made
// Transfers a category. Returns a list of all the insinuated items
async function transfer_cat<G extends EntryType>(
type: G,
from: Registry,
to: Registry,
ctx: OpCtx
): Promise<RegEntry<G>[]> {
// Insinuate each item in the cat
invalidate_cached_pack_map(type);
let from_cat = from.get_cat(type);

let items: RegEntry<T>[] = [];

for (let item of await from_cat.list_live(ctx)) {
// Do the deed
let insinuated = await item.insinuate(to, null, {
relinker: quick_relinker<G>({
key_pairs: [["LID", "lid"], ["Name", "name"]]
})
});
items.push(insinuated as any);
// Transfers a category. Returns a list of all the insinuated items
async function transfer_cat<G extends EntryType>(
type: G,
from: Registry,
to: Registry,
ctx: OpCtx
): Promise<RegEntry<G>[]> {
// Insinuate each item in the cat
invalidate_cached_pack_map(type);
let from_cat = from.get_cat(type);

let items: RegEntry<T>[] = [];

for (let item of await from_cat.list_live(ctx)) {
// Do the deed
let insinuated = await item.insinuate(to, null, {
relinker: quick_relinker<G>({
key_pairs: [["LID", "lid"], ["Name", "name"]]
})
});
items.push(insinuated as any);
ignore the as any, it was just me trying things
LukeAbby
LukeAbby4y ago
TS Playground - An online editor for exploring TypeScript and JavaS...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
LukeAbby
LukeAbby4y ago
could you play with this until it breaks
WHITESPINE
WHITESPINEOP4y ago
sure
LukeAbby
LukeAbby4y ago
I instantiated let item = null as unknown as RegEntry<'foo'>; like this because I don't have a concrete definition of RegEntry basically
WHITESPINE
WHITESPINEOP4y ago
yeah reasonable shouldn't matter, we're not running it
LukeAbby
LukeAbby4y ago
yeah lying at compile time that it's of type RegEntry<'foo'> so I can use it I'm just not sure why this isn't reproducing your problem ...I swear if this is some enum stupidity I don't like enums in Typescript that is it's plenty fine normally
WHITESPINE
WHITESPINEOP4y ago
oh whoops

Did you find this page helpful?