m4rc3l05
m4rc3l05
DDeno
Created by Kitura on 12/4/2024 in #help
To use @types/react, do I have to prefix all my React imports with // @deno-types ?
i belive currently we need to specify the deno-types comment https://github.com/denoland/deno/issues/27062
7 replies
DDeno
Created by Kitura on 12/4/2024 in #help
To use @types/react, do I have to prefix all my React imports with // @deno-types ?
no it does not it seems...
7 replies
DDeno
Created by Kitura on 12/4/2024 in #help
To use @types/react, do I have to prefix all my React imports with // @deno-types ?
i belive if you add npm:@types/react to the compilerOptions.types array it should type react imports
7 replies
DDeno
Created by w7a9q on 12/7/2024 in #help
Types for global variables
this should also pass the deno check command to typecheck your code
3 replies
DDeno
Created by w7a9q on 12/7/2024 in #help
Types for global variables
Hi. Try to create a new d.ts file like global.d.ts with the contents
// deno-lint-ignore no-var
declare var Args: Record<string, unknown>;
// deno-lint-ignore no-var
declare var Args: Record<string, unknown>;
Add a reference to this d.ts file in the compiler options in deno.json
{
//...
"compilerOptions": {
"types": ["./global.d.ts"]
},
//...
}
{
//...
"compilerOptions": {
"types": ["./global.d.ts"]
},
//...
}
You should be able to access Args from globalThis
3 replies
DDeno
Created by Ben on 12/10/2024 in #help
Which logger do you use?
using @std/log, still not stable yet but no complains so far
4 replies
DDeno
Created by m4rc3l05 on 10/11/2024 in #help
Deno v2 deno install not installing all dep files
8 replies
DDeno
Created by m4rc3l05 on 10/11/2024 in #help
Deno v2 deno install not installing all dep files
will do thx
8 replies
DDeno
Created by m4rc3l05 on 10/11/2024 in #help
Deno v2 deno install not installing all dep files
without --cached-only it does work, i get the downloading log and it finishes ok. it just feels weird that it has do download more stuff after a deno install has been issued, am i wrong on this assumption?
8 replies
DDeno
Created by banananas on 10/11/2024 in #help
Getting the width and height of an image
From a simple jsr search i got this package https://jsr.io/@retraigo/image-size
import { getImageInfo } from "jsr:@retraigo/image-size";

const imgData = getImageInfo(Deno.readFileSync("./image.png"));
console.log("x", imgData);
import { getImageInfo } from "jsr:@retraigo/image-size";

const imgData = getImageInfo(Deno.readFileSync("./image.png"));
console.log("x", imgData);
deno run -A --no-lock foo.ts
x { width: 200, height: 300, format: "png", shape: [Function: shape] }
deno run -A --no-lock foo.ts
x { width: 200, height: 300, format: "png", shape: [Function: shape] }
Do not know if we have a native way of doing this on deno...
5 replies
DDeno
Created by m4rc3l05 on 10/11/2024 in #help
Deno v2 deno install not installing all dep files
Another version of the above issue and a bit more weird i think is, i have this deno project:
{
...
"lock": {
"frozen": true
},
"imports": {
"@david/dax": "jsr:@david/dax@^0.42.0",
"@std/cli": "jsr:@std/cli@1.0.6",
"@std/path": "jsr:@std/path@^1.0.6",
"@std/yaml": "jsr:@std/yaml@1.0.5"
}
}
{
...
"lock": {
"frozen": true
},
"imports": {
"@david/dax": "jsr:@david/dax@^0.42.0",
"@std/cli": "jsr:@std/cli@1.0.6",
"@std/path": "jsr:@std/path@^1.0.6",
"@std/yaml": "jsr:@std/yaml@1.0.5"
}
}
Where if i run deno install && deno run --cached-only main.ts all goes well but if i do deno install && deno compile --cached-only main.ts i get the error
error: Specifier not found in cache: "https://jsr.io/@std/yaml/1.0.5/_type.ts", --cached-only is specified.
at https://jsr.io/@std/yaml/1.0.5/_loader_state.ts:40:37
error: Specifier not found in cache: "https://jsr.io/@std/yaml/1.0.5/_type.ts", --cached-only is specified.
at https://jsr.io/@std/yaml/1.0.5/_loader_state.ts:40:37
What could be triggering this inconsistencies? i am expecting that both deno run --cached-only and deno compile --cached only to be able to run successfully.
8 replies
DDeno
Created by m4rc3l05 on 9/21/2024 in #help
How to check if stdin is a file?
it is only a file if you do input redirection < deno.json
20 replies
DDeno
Created by m4rc3l05 on 9/21/2024 in #help
How to check if stdin is a file?
using this simple deno script that uses the deprecated methods/properties:
#!/usr/bin/env deno

console.log("isFile => ", Deno.fstatSync(Deno.stdin.rid).isFile);
#!/usr/bin/env deno

console.log("isFile => ", Deno.fstatSync(Deno.stdin.rid).isFile);
Here what i have:
./foo.ts
isFile => false
./foo.ts
isFile => false
echo "foo" | ./foo.ts
isFile => false
echo "foo" | ./foo.ts
isFile => false
./foo.ts < deno.json
isFile => true
./foo.ts < deno.json
isFile => true
20 replies
DDeno
Created by m4rc3l05 on 9/21/2024 in #help
How to check if stdin is a file?
Decided to use nodejs apis for this. thx everybody for you suggestions.
20 replies
DDeno
Created by m4rc3l05 on 9/21/2024 in #help
How to check if stdin is a file?
The idea would be to have what pino-pretty does but with deno apis, but then i noticed this issue with the deprecations and started to wonder how would i do it without nodejs apis for deno v2. So currently not possible then?
20 replies
DDeno
Created by m4rc3l05 on 9/21/2024 in #help
How to check if stdin is a file?
stdin.isTerminal() does not seem to be what i want, given the example from pino-pretty https://github.com/pinojs/pino-pretty/blob/master/bin.js#L86, they check if stdin is terminal and if stdin is a file and if both are false it means that we are piping to the script and we should do nothing on the first sigint and exit on the next one, allowing to wait for the process being piped to close before closing it self, as explained in https://github.com/pinojs/pino/pull/358#issuecomment-366185875 the stdin.isTerminal() answares the 2 point, but the 1 remain still remains, how do we check it in deno v2 without using deprecated methos? currently i am doing !Deno.stdin.isTerminal() && !Deno.fstatSync(Deno.stdin.rid).isFile bu this will not work for v2 right?
20 replies
DDeno
Created by m4rc3l05 on 9/21/2024 in #help
How to check if stdin is a file?
Hey, thx for the response, just tried but it only works if the contents of stdin is a filepath and it will not work for example if i execute the ts file like ./foo.js < deno.json for example.
20 replies