-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bash Executable Types #42212
Comments
*checks date* I think you have confused 1/4/2021 and 4/1/2021 π |
There's another use case! A whole bunch of people need to be reminded to update their copyright year strings, now they can automate that reminder with type Year = bash`
date +"%Y"
`
type Copyright = `Copyright Β© ${Year} Company, Inc.`
function Footer() {
let copyright: Copyright = "Copyright Β© 2020 Company, Inc." // ERROR!!!! Happy 2021!!!
return <p>{copyright}</p>
} |
People have pointed out some valid security concerns with third-party dependencies using their own bash types to steal private company code. My advice is add a new entrypoint to your program which turns networking features off, thereby thwarting any and all hacking attempts that steal data. // safe-entry.ts
type main = bash`
nmcli networking off
node ./unsafe-entry.ts
nmcli networking on
` |
This all makes sense and has no downsides, but I'm trying to figure out why bash instead of Powershell |
Why use a specific scripting language that a user may or may not have, instead of, say, TypeScript? This could be generalized into compile-time TS execution, we already sorta have it for const enums, why not just expand it to include everything? Otherwise, this cannot possible be available everywhere anyways, ex: https://typescriptlang.org/play couldn't execute Bash :/ |
"bash" has fewer characters than "powershell" so users will save on file storage |
Users can call out to
To be clear, I would expect TypeScript to ship its own copy of Bash for security reasons (who knows what a bad actor may do to |
This is somewhat related to #39385, where @RyanCavanaugh wrote:
Just here the "user code" is bash, not TypeScript, and it's intended for types. |
aha see, therefore it is superior |
I have to admit that I completely missed the joke. |
Tagging "Out of Scope" but let's agree that tag actually means "Too powerful for mere mortals to wield" in this case |
(But to the people in this thread saying "why not define the type computation in TypeScript": I've very much toyed with the idea) |
This issue has been marked as "Out of Scope" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Suggestion
π Search Terms
List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
A hot new way of constructing types at build time using the worlds most universally beloved language: bash.
Using the
bash`...`
type you can now run entire bash programs inside of TypeScript.The bash template type constructor would create a union of every stdout line of the embedded bash program.
π Motivating Example
Before: Allows all sorts of strings, who knows if this will work at runtime.
After: Only real files can be read from the file system, now you can sleep at night
π» Use Cases
The text was updated successfully, but these errors were encountered: