2 ms·
I wonder if a different approach could work: have something conceptually like the @types/ libraries for javascript (which add type definitions to packages that
by overgard 5y ago
I wonder if a different approach could work: have something conceptually like the @types/ libraries for javascript (which add type definitions to packages that don't have them). In this case, the @types are parsers to and from normalized json and schemas for each command. You need a new shell now, but it could be a simple layer on top of existing ones. Let's call it tbash. tbash will check each command to see if it's typed, and handle invoking the type conversions automatically, falling back to byte streams if there is no type. It would also handle raising errors.
I'm probably missing a lot of edge cases here, but I think it could work.
The main difference in this approach is the shell takes on most of the work, the commands themselves can remain unchanged. They just need an @typed wrapper and some indications of what types they can accept (typescripts structural typing could also give guidance here)