#Type unexpectedly widens when used in interface

1 messages · Page 1 of 1 (latest)

green quest
#

so i have this MessageMetadata type.

export interface MessageMetadata<T> {
  readonly guard: Modding.Generic<StripMeta<T>, "guard">;
  readonly serializerMetadata: SerializerMetadata<T>;
}

when i do SerializerMetadata<u8> on it's own, i get the expected type (["u8"]) back. however, when i do MessageMetadata<u8> (which then makes serializerMetadata a SerializerMetadata<u8>), it evaluates the SerializerMetadata to ["f32"] (the default number type)

type X = SerializerMetadata<u8>; // ["u8"]
type Y = MessageMetadata<u8>["serializerMetadata"]; // ["f32"]

i've tried using type Fresh<T> = T extends infer U ? U : never, getting rid of the guard field to see if that affected it, passing the resolved type of SerializerMetadata<T> as a 2nd type parameter to MessageData, etc.

let me know if you would like full code to repro.

errant hinge
#

Yeah, a typescript playground reproduction of this would probably help

green quest
green quest
#

ok i literally cant repro it..... this is so weird

#

it works when i copy all types into a playground, but doesnt work in my project

#

it even works when i use MessageMetadata<T> in the same file its defined in, just not outside of that file

vagrant root
green quest
#

its definitely the same type, somehow the symbol keys are just lost somewhere down the line

#

something to do with exports/imports, i just decided to brand the types using a string key instead of a symbol key