Hey :)
I want to simply override the type that's returned by my custom bigints' .toString() method, so it:
a) does not allow a radix
b) returns my custom string type
Setup:
type MarkedBigInt<M extends symbol> = bigint & { readonly m: M } & { toString(): MarkedString<M>; };
type MarkedString<M extends symbol> = string & { readonly m: M };
Usage:
declare const brand: unique symbol;
type Assert<T extends true> = T
type IsMarkedString<V> = V extends MarkedString<typeof brand> ? true : false;
const string0 = "1234" as MarkedString<typeof brand>;
type assert_working = Assert<IsMarkedString<typeof string0>>;
const id = 1234n as MarkedBigInt<typeof brand>;
const string1 = id.toString();
type test = Assert<IsMarkedString<typeof string1>>;