TypeScript `|` Combinator

I have the following code:
ceramic.did = new DID({
provider: threeID.getDidProvider(),
resolver: {
...get3IDResolver(ceramic), // returns a ResolverRegistry
...getKeyResolver(), // returns a ResolverRegistry
} as ResolverRegistry,
});
ceramic.did = new DID({
provider: threeID.getDidProvider(),
resolver: {
...get3IDResolver(ceramic), // returns a ResolverRegistry
...getKeyResolver(), // returns a ResolverRegistry
} as ResolverRegistry,
});
And, TypeScript is giving me the following error:
Type 'ResolverRegistry' is not assignable to type 'Resolver | ResolverRegistry | undefined'.
Type 'ResolverRegistry' is missing the following properties from type 'Resolver': registry, cache, resolvets(2322)
(property) resolver?: Resolver | ResolverRegistry | undefined
Type 'ResolverRegistry' is not assignable to type 'Resolver | ResolverRegistry | undefined'.
Type 'ResolverRegistry' is missing the following properties from type 'Resolver': registry, cache, resolvets(2322)
(property) resolver?: Resolver | ResolverRegistry | undefined
I thought that let pet: Cat | Dog means I can assign either a Cat or Dog to it. Is that not right?
1 Reply
dys 🐙
dys 🐙OP17mo ago
Nevermind. I think it might be complaining about the Resolver type within ResolverRegistry. There were two different versions of the library included. I set a "resolutions" for the more recent version in my package.json & TS is now happy.
Want results from more Discord servers?
Add your server