demo codes:
const cwd = (()=>{
if(typeof Deno !== 'undefined') return Deno.cwd();
if(typeof process !== 'undefined') return process.cwd();
if(typeof location !== 'undefined') return location.href;
return '';
})()
error: Cannot find name 'process'. deno-ts(2580)
tried:
declare global {
const Deno: { cwd: () => string };
const process: { cwd: () => string };
const location: { href: string };
}
error: Cannot redeclare block-scoped variable 'Deno'.deno-ts(2451)
What I want to do:
- when
Denoexist in type scope:- do nothing on Deno
- when
Denodoesn't exist:- Declare it
- repeat this on
processandlocation