IMHO, one of the strong benefit of using TypeScript for shell scripting is to get more static checks.
However, currently dax is using (strings: TemplateStringsArray, ...exprs: any[]): CommandBuilder type (source) for its primary API, which is $. Because of any in the type, we cannot detect incorrect arguments passed such as undefined or random incompatible objects.
import $ from 'dax-sh'
const myobj1 = {'hello': 'world'}
const myobj2 = undefined
// type check passes for the following, which is not desired.
await $`echo ${myobj1} ${myobj2}`
Proposed solution
I propose to stop using any in (strings: TemplateStringsArray, ...exprs: any[]): CommandBuilder by precisely model all the possible arguments.
Ok thanks, so the only way to emit error for the above case is to stop supporting objects with toString()....
I think this is actually a good change but it is a breaking change 😢
IMHO, one of the strong benefit of using TypeScript for shell scripting is to get more static checks.
However, currently dax is using
(strings: TemplateStringsArray, ...exprs: any[]): CommandBuilder
type (source) for its primary API, which is$
. Because ofany
in the type, we cannot detect incorrect arguments passed such asundefined
or random incompatible objects.Proposed solution
I propose to stop using
any
in(strings: TemplateStringsArray, ...exprs: any[]): CommandBuilder
by precisely model all the possible arguments.Related issues
await
is not detected by eslint-typescript and I proposed a fix there (https://github.com/typescript-eslint/typescript-eslint/pull/8758)