ts-brand no longer passing tsc 3.9.7 and higher
benallfree opened this issue · comments
$ git clone git clone git@github.com:kourge/ts-brand.git
$ cd ts-brand
$ tsc --version
Version 4.2.4
$ tsc
src/index.ts:44:42 - error TS2536: Type '"__witness__"' cannot be used to index type 'B'.
44 export type BaseOf<B extends AnyBrand> = B['__witness__'];
~~~~~~~~~~~~~~~
Or paste src/index.ts into the typescript playground
AnyBrand is inferred as any, other attributes are directly discarded.
To solve the problem, change the first argument of AnyBrand.
// Language service says Newtype = any
type NewType = any & {someKey: 'someValue'};
// Try this:
type AnyBrand = Brand<unknown, any>;