2020. 8. 4.Get list of globally installed packages
npm:
npm list -g --depth 0
npm list -g --depth 0
yarn:
yarn global list --depth 0
yarn global list --depth 0
2020. 8. 3."Type aliases can only be used in TypeScript files.ts(8008)" in .js files
vscode가 flow type 정의에 .ts
가 아닌데 타입 머시기가 있다고 깝치는 에러. settings.json
에 아래를 추가한다.
"javascript.validate.enable": false
"javascript.validate.enable": false
2020. 8. 2.symlinks
path 의 alias 라고 생각하면 쉽다.
ln -s /PATH/TO/ORIGINAL /PATH/TO/LINK
ln -s /PATH/TO/ORIGINAL /PATH/TO/LINK
2020. 7. 31.Declaring Global Variables in TypeScript
daum 주소검색등 window
에 뭔가 끼워넣는 외부 기능 사용시, window.someApi
등으로 호출하게 될 때가 있는데, TS에서 당연히 Property 'someApi' does not exist on type 'Window & typeof globalThis'.
라고 뭐라고 한다. 요걸 해결하기 위해 보통은:
(window as any).someApi
(window as any).someApi
혹은
(<any>window).someApi
(<any>window).someApi
를 쓰라고 하는데 아래가 더 나은 것 같다.
declare global {
interface Window {
someApi: any; // 혹시 타입 정의를 제공해준다면 somApiType
}
}
declare global {
interface Window {
someApi: any; // 혹시 타입 정의를 제공해준다면 somApiType
}
}
요게 되는 것은 interface는 merging이 되기 때문.
Ref.
https://mariusschulz.com/blog/declaring-global-variables-in-typescript
2020. 7. 31.merging interfaces
interface Box {
height: number;
width: number;
}
interface Box {
scale: number;
}
let box: Box = {height: 5, width: 6, scale: 10};
interface Box {
height: number;
width: number;
}
interface Box {
scale: number;
}
let box: Box = {height: 5, width: 6, scale: 10};
https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces
2020. 7. 30.asdf nodejs
- asdf를 설치한다.
brew install asdf
brew install asdf
- gpg를 설치한다.
brew install gpg
brew install gpg
- asdf nodejs plugin을 설치한다.
asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
- nodejs release team의 gpg key를 추가한다.
bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'
bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'
nvm
등 사용중이던 vm이 있다면 호환성을 위해~/.asdfrc
에 아래를 추가한다.legacy_version_file = yes
legacy_version_file = yes
- 됫다.
how to uninstall node
2020. 7. 27.fix firefox color render
?
firefox의 컬러가 뭔가 좀 더 채도가 높게 렌더링 되는 경향이 있다.
- chrome

- safari

- firefox

요걸 없애려면?
!
- 일단 firefox의 주소창에
about:config
를 입력해 신비의 세계로 들어가서, - 신비의 세계 검색창에
color_management
를 쳐보면 아래와 같은 설정값들을 볼 수 있다. 이중에서, gfx.color_management.mode
를1
로 바꾼다.gfx.color_management.enablev4
를true
로 바꾼다.- 쨘
이것들이 뭐냐?
gfx.color_management.mode
:0
: Color management disabled.1
: Full color management.2
: Color management applied only to tagged images.
gfx.color_management.enablev4
:- 찾는 중
Refs
2020. 7. 24.fix eslint no-undef errors by jest globs
?

!
// .eslintrc.js
...
env: {
jest: true
}
...
// .eslintrc.js
...
env: {
jest: true
}
...
2020. 7. 23.PR에 PR 날리기
gh pr create -R <USER_NAME>/<REPO_NAME> --base <ORIG_PR_BRANCH_NAME>
gh pr create -R <USER_NAME>/<REPO_NAME> --base <ORIG_PR_BRANCH_NAME>
2020. 7. 22.type argument default value
예를 들어, 첫번째 arg는 보통 string이고 두번째 arg는 보통 number인데 아닐 수도 있고 두번째 arg가 있을 수도 없을 수도 있는 함수의 타입을 정의한다면 아래와 같이 선언할 수 있을 것이다.
type ExampleFn<T, U> = (arg0: T, arg1?: U) => SomeReturnType;
type ExampleFn<T, U> = (arg0: T, arg1?: U) => SomeReturnType;
근데 쓸 때 마다 아래와 같이 하기는 매우 귀찮은 일이다.
const implmentedFn1: ExampleFn<string, number> = (val: string) => /* ... */
const implmentedFn1: ExampleFn<string, number> = (val: string) => /* ... */
그래서 ts는 type argument에도 default value를 정해놓을 수 있는데, 함수 default value랑 동일한 형태로, 아래와 같이 하면 된다.
type ExampleFn<T = string, U = number> = (arg0: T, arg1?: U) => SomeReturnType;
type ExampleFn<T = string, U = number> = (arg0: T, arg1?: U) => SomeReturnType;
이제부턴 굳이 명시할 필요가 생기지 않으면 그냥 편하게 쓸 수 있다.
const implmentedFn2: ExampleFn = (val: string) => /* ... */
const implmentedFn2: ExampleFn = (val: string) => /* ... */
그러고보니 아예 arg에 타입 어노테이션을 안해도 된다.
const implmentedFn3: ExampleFn = (val) => /* ... */
const implmentedFn3: ExampleFn = (val) => /* ... */