mirror of
https://github.com/jbranchaud/til
synced 2026-01-18 06:28:02 +00:00
Compare commits
2 Commits
a61a22f707
...
5e68fb8c64
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e68fb8c64 | ||
|
|
a83ce7cc10 |
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1376 TILs and counting..._
|
||||
_1378 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -291,6 +291,7 @@ _1376 TILs and counting..._
|
||||
- [Include Or Exclude Remaining Patch Changes](git/include-or-exclude-remaining-patch-changes.md)
|
||||
- [Include Some Stats In Your Git Log](git/include-some-stats-in-your-git-log.md)
|
||||
- [Intent To Add](git/intent-to-add.md)
|
||||
- [Interactively Checkout Specific Files From A Stash](git/interactively-checkout-specific-files-from-a-stash.md)
|
||||
- [Interactively Unstage Changes](git/interactively-unstage-changes.md)
|
||||
- [Keep File Locally With `git rm`](git/keep-file-locally-with-git-rm.md)
|
||||
- [Last Commit A File Appeared In](git/last-commit-a-file-appeared-in.md)
|
||||
@@ -1278,6 +1279,7 @@ _1376 TILs and counting..._
|
||||
- [Interfaces With The Same Name Are Merged](typescript/interfaces-with-the-same-name-are-merged.md)
|
||||
- [Narrow The Type Of An Array To Its Values](typescript/narrow-the-type-of-an-array-to-its-values.md)
|
||||
- [Re-Export An Imported Type](typescript/re-export-an-imported-type.md)
|
||||
- [Set Path Alias For Cleaner Imports](typescript/set-path-alias-for-cleaner-imports.md)
|
||||
- [Type Narrowing With Const VS Let Strings](typescript/type-narrowing-with-const-vs-let-strings.md)
|
||||
- [Type Narrowing With Similarly Shaped Objects](typescript/type-narrowing-with-similarly-shaped-objects.md)
|
||||
- [Type Promise Results With The Awaited Type](typescript/type-promise-results-with-the-awaited-type.md)
|
||||
|
||||
18
git/interactively-checkout-specific-files-from-a-stash.md
Normal file
18
git/interactively-checkout-specific-files-from-a-stash.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Interactively Checkout Specific Files From A Stash
|
||||
|
||||
This command will prompt you with a list of the stashes in your current git
|
||||
repo. Once you select one of them from the interactive fzf prompt, you will
|
||||
then be prompted with another fzf prompt, this second one allow multi-select.
|
||||
From there you can tab select the files you want to checkout. Once you've
|
||||
marked the ones you want, hit enter and those files will be checked out to your
|
||||
index.
|
||||
|
||||
```bash
|
||||
git stash show --name-only $(
|
||||
git stash list \
|
||||
| fzf --height=20% --reverse \
|
||||
| sed 's/:.*//'
|
||||
) \
|
||||
| fzf --height=20% --multi --sync \
|
||||
| xargs -I {} sh -c 'git checkout stash@{0} -- {}'
|
||||
```
|
||||
41
typescript/set-path-alias-for-cleaner-imports.md
Normal file
41
typescript/set-path-alias-for-cleaner-imports.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Set Path Alias For Cleaner Imports
|
||||
|
||||
In the `tsconfig.json` file of a TypeScript project, there are a bunch of
|
||||
compiler options that you can specify. One of those compiler options is
|
||||
`paths`. This is an object that can map path aliases to directories in your
|
||||
project.
|
||||
|
||||
In projects where nested files are importing modules from other parts of the
|
||||
file tree, you can end up with cluttered imports like this:
|
||||
|
||||
```typescript
|
||||
import { prisma } from '../../server/db.server'
|
||||
import { List } from '../../components/list'
|
||||
```
|
||||
|
||||
By setting a path alias in your `tsconfig.json` file, like so, you can tidy
|
||||
these up:
|
||||
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"~/*": ["./app/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Now I can write any import such that it anchors to the `app` directory with
|
||||
`~`.
|
||||
|
||||
```typescript
|
||||
import { prisma } from '~/server/db.server'
|
||||
import { List } from '~/components/list'
|
||||
```
|
||||
|
||||
I prefer a single path alias if I can get away with it, but you can [add
|
||||
several](https://learn.saleor.io/setup/typescript-path-aliases/) to suit your
|
||||
project if you'd like.
|
||||
|
||||
[source](https://www.typescriptlang.org/tsconfig#paths)
|
||||
Reference in New Issue
Block a user