question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bash Executable Types

See original GitHub issue

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.

  • Bash
  • Shellscript

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn’t be a breaking change in existing TypeScript/JavaScript code
  • This wouldn’t change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn’t a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript’s Design Goals.

⭐ 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.

type FileName = bash`
  find "$PWD"
`

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.

async function readFile(fileName: string) {
  // ...
}

After: Only real files can be read from the file system, now you can sleep at night

type FileName = bash`
  find "$PWD"
`

async function readFile(fileName: FileName) {
  // ...
}

💻 Use Cases

  • Type-safe file operations
  • Keeping your database in sync with your types
  • Running Docker inside TS so your types are reproducible
  • Fork bombing VSCode

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:107
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

26reactions
DanielRosenwassercommented, Jan 5, 2021

*checks date* I think you have confused 1/4/2021 and 4/1/2021 😅

13reactions
jamiebuildscommented, Jan 5, 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 $ date

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>
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

What types of executable files exist on Linux?
1 Answer 1 · a.out (which is currently on a stay of execution); · ELF; · FDPIC ELF (on ARM, MMU-less SuperH, and...
Read more >
Executable File Formats - FileInfo.com
Extension File Type Popularity .AHK AutoHotkey Script 4.3 .APK Android Package File 4.3 .JAR Java Archive 4.3
Read more >
Which are the Linux Executable Files, and How do We Create ...
Unlike Windows, Linux doesn't have the concept of file extension based executables. Any file can be executable – you just need to have...
Read more >
Executable Formats - Understanding the Linux Kernel ...
Linux supports many other different formats for executable files; in this way, it can run programs compiled for other operating systems, such as...
Read more >
Types of Executables | Linux.org
Executable and Linkable Format (ELF) – The most common and widely used Linux executable format is ELF. Most game systems and Unix systems...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found