when you use infer with a constraint that is a union type containing multi character strings TypeScript seems to prioritize character by character matching rather than trying to match the complete union members
here is how we can do workaround by checking if the string starts with any of the union members :)
type StartsWith<T extends string, U extends string> = T extends `${infer P}${string}`
? P extends U
? P
: never
: never;
type Z = GetPrefix<'[[Text', '[[' | '<<'>;
// "[["