I use Svelte, which means writing console.log(...) in my component files will only ever log once per instance of the component. Which isnt ideal when you want to track your state.
Instead in svelte, you write $: console.log(...) which will log each time the state updates.
The issue is, I only want to write $: console.log(...) in *.svelte files, not in .js or .ts (or Vue/React files if I use them).
We could change the logFunction setting to be one of two types;
type TLogFunction = string | { [fileExt: string]: string }
This way, the "actual" log function to be used is just the result of;
function getActualLogFn(logFn: TLogFunction, fileExt: string): string {
if (typeof logFn === "string") return logFn;
return logFn[fileExt];
}
Which can then be used in the existing code without further changes.
While yes, $: console.log(...) will work in js, it would be a nice QOL update to not have to have the label in js files for svelte compatibility
EDIT: if you would like, I'd be happy to work on a PR for this for you
I use Svelte, which means writing
console.log(...)
in my component files will only ever log once per instance of the component. Which isnt ideal when you want to track your state. Instead in svelte, you write$: console.log(...)
which will log each time the state updates.The issue is, I only want to write
$: console.log(...)
in*.svelte
files, not in.js
or.ts
(or Vue/React files if I use them).We could change the
logFunction
setting to be one of two types;This way, the "actual" log function to be used is just the result of;
Which can then be used in the existing code without further changes.
While yes,
$: console.log(...)
will work in js, it would be a nice QOL update to not have to have the label in js files for svelte compatibilityEDIT: if you would like, I'd be happy to work on a PR for this for you