scarf
scarf
DDeno
Created by scarf on 5/22/2024 in #help
type checking `.js` files using `d.ts` files
would it be possible to type check javascript files using d.ts files?
// add.js
/// <reference types="./add.d.ts" />
const add = (a) => a + 1
// add.js
/// <reference types="./add.d.ts" />
const add = (a) => a + 1
// add.d.ts
export declare const add: (a: number) => number
// add.d.ts
export declare const add: (a: number) => number
importing add from add.js from consumer will type check but
1 replies
DDeno
Created by scarf on 12/12/2023 in #help
deno info depth
No description
5 replies
DDeno
Created by scarf on 10/17/2023 in #help
rust ffi buffer overflow
hi, do i have to null-terminate array when using rust ffi? i'm getting buffer overflows.
#[no_mangle]
pub extern "C" fn play(path: *const u8) {
let path = unsafe {
assert!(!path.is_null());

std::ffi::CStr::from_ptr(path as *const i8)
};
let path = path.to_str().unwrap();
println!("path: {path}");
}
#[no_mangle]
pub extern "C" fn play(path: *const u8) {
let path = unsafe {
assert!(!path.is_null());

std::ffi::CStr::from_ptr(path as *const i8)
};
let path = path.to_str().unwrap();
println!("path: {path}");
}
const lib = "./audio/target/debug/libaudio.so"
const dylib = Deno.dlopen(lib, { "play": { parameters: ["buffer"], result: "void" } } as const)

const encoded = new TextEncoder().encode("path")

dylib.symbols.play(encoded)
const lib = "./audio/target/debug/libaudio.so"
const dylib = Deno.dlopen(lib, { "play": { parameters: ["buffer"], result: "void" } } as const)

const encoded = new TextEncoder().encode("path")

dylib.symbols.play(encoded)
$ deno run -A --unstable --allow-ffi audio.ts
thread '<unnamed>' panicked at src/lib.rs:29:30:
called `Result::unwrap()` on an `Err` value: Utf8Error { valid_up_to: 3, error_len: Some(1) }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
$ deno run -A --unstable --allow-ffi audio.ts
thread '<unnamed>' panicked at src/lib.rs:29:30:
called `Result::unwrap()` on an `Err` value: Utf8Error { valid_up_to: 3, error_len: Some(1) }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
4 replies
DDeno
Created by scarf on 8/7/2023 in #help
restrict path applied for import maps
No description
1 replies
DDeno
Created by scarf on 7/1/2023 in #help
how to import svg in vite without type errors?
5 replies
DDeno
Created by scarf on 5/8/2023 in #help
embed typescript playground to web page
5 replies
DDeno
Created by scarf on 4/28/2023 in #help
how to cancel test watch
on linux. ran deno test -A --watch tools/json_tools/examples/*.ts and ctrl+c does not seems to work. had to force-quit terminal to stop it.
3 replies