mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
Fix client compilation error in base64()
Context : The base64 function tries using the btoa function and falls back to using Buffer if btoa is not available. Problem : In the context of a dom, you have btoa, and you may not necessarily have Buffer, and in the case the fallback branch creates a compilation error "TS2591: Cannot find name 'Buffer'." Solution : Add a @ts-ignore in the fallback branch because we will always have either btoa or Buffer available in the forseable future.
This commit is contained in:
parent
aae6306a5a
commit
21d0e116e7
@ -2,6 +2,7 @@ function base64(str: string): string {
|
||||
try {
|
||||
return btoa(str);
|
||||
} catch (err) {
|
||||
// @ts-ignore
|
||||
return Buffer.from(str).toString('base64');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user