New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type 'WebStream<string>' is not assignable to type 'string'. #1546
Comments
Turn out I can just fixed it by install opengpp 5.3.1. |
I get the same error when upgrading from 5.10 to >=5.2.0 && <= 5.5.0. The error is probably due to the changes in this commit: const encrypted: string = await openpgp.encrypt({
message, // openpgp.Message<string>
encryptionKeys, // openpgp.PublicKey[]
signingKeys // openpgp.PrivateKey[]
}) |
Nevermind. Installing the latest version of Should be mentioned in the documentation or even in the release notes, as already addressed in #1502 (comment). |
Having to install an additional package like The reason it doesn't work is that This can be fixed by changing export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format?: 'armored' }): Promise<
T extends WebStream<infer X> ? WebStream<string> :
T extends NodeStream<infer X> ? NodeStream<string> :
string
>; to export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format?: 'armored' }): Promise<
T extends ReadableStream<unknown> ? (
T extends WebStream<unknown> ? WebStream<string> :
T extends NodeStream<unknown> ? NodeStream<string> :
string
) : string
>; As this check is done in several places, it may be good to define a new generic type of it, e.g.: type StreamOrSimple<MessageType, SimpleReturnType> = MessageType extends ReadableStream<unknown> ? (
MessageType extends WebStream<unknown> ? WebStream<SimpleReturnType> :
MessageType extends NodeStream<unknown> ? NodeStream<SimpleReturnType> :
SimpleReturnType
) : SimpleReturnType;
export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format?: 'armored' }): Promise<StreamOrSimple<T, string>>;
export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format: 'binary' }): Promise<StreamOrSimple<T, Uint8Array>>;
export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format: 'object' }): Promise<Message<T>>; Should I create a PR along those lines, @larabr? |
@rene-leanix please see this: #1720 (comment) , it should resolve TS issues with v5. |
@larabr, yes, installing It should still be preferable to adjust the typing to avoid the need to install |
Got the following error when running
tsc --noEmit
On openpgp version 5.3.0
I believe this is cause by the fact that in the package.json, it listed as devdependency instead of dependency !?
The text was updated successfully, but these errors were encountered: