-
Hey ✌️ I am facing an issue when it comes to type elimination, mainly to distinguish between a export const isPrivateKey = (key: openpgp.Key | openpgp.Subkey) => {
if (key instanceof openpgp.PrivateKey || key instanceof openpgp.PublicKey) {
return key.isPrivate();
}
return key.mainKey.isPrivate();
} The above wouldn't work since we did not eliminate Are there any other approaches that would be appropriate here? Do you suggest that we tweak |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Hey @alichry , ...
if (key instanceof Subkey) {
return key.mainKey.isPrivate();
}
return key.isPrivate();
} Also, |
Beta Was this translation helpful? Give feedback.
Hey @alichry ,
Wouldn't checking for
Subkey
explicitly work in your use case? e.g.Also,
readKeys
returnsPublicKey[]
, so downcasting is only needed if you need aPrivateKey
(whether we should keep exportingKey
as a type is a valid question though)