์๋ฐฑ ๊ฐ์ ํ์ผ๊ณผ ์ฌ๋ฌ ๊ณ์ธต์ ์ค์ฒฉ๋ ํ์ ๋๋ ํฐ๋ฆฌ๊ฐ ์๋ ์ง์ฅ์์ VS Code๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค. ์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉ๋๋ ๋ฉ์๋์ ํธ์ถ ์๋ช ์ ๋ณ๊ฒฝํ๋ ๋ฑ ๋ง์ ํ์ผ์ ์์์ํค๋ ๋ณ๊ฒฝ ์์ ์ ์์ฃผ ์ํํฉ๋๋ค. ํ๋ก์ ํธ๋ ์์ ํ typescript์ด๊ธฐ ๋๋ฌธ์ "๋ฌธ์ " ๋ณด๊ธฐ๋ฅผ ์ด๊ณ ๋ด๊ฐ ์ฐ ํ์ผ์์ ๋ด ๋ณ๊ฒฝ์ผ๋ก ์ธํ ์ค๋ฅ ๋ฐ ๊ฒฝ๊ณ ๋ฅผ ๋ณผ ์ ์๋ ๊ฒ์ด ์ ์ฉํฉ๋๋ค. ๊ทธ๋ฌ๋ ํ๋ก์ ํธ์ ํฌ๊ธฐ ๋๋ฌธ์ ์ฌ์ ํ ํฐ๋ฏธ๋๋ก ์ด๋ํ์ฌ ๋ฌธ์ ๋ชฉ๋ก์ ๋ณด๋ ค๋ฉด ์์ฒด make ๋ช ๋ น์ ์คํํด์ผ ํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ ์ ์ฌ๋ฐ๋ฅธ ํ์ผ์์ ์ฌ๋ฐ๋ฅธ ์ค์ ๊ฒ์ํ์ฌ ํฐ๋ฏธ๋๊ณผ VS Code ์ฌ์ด์์ ์ฌ๋ฏธ์๋ ์ถค์ ์ถ์ด์ผ ํฉ๋๋ค.
๋ด๊ฐ ํ์ํ ๊ฒ์ "๋ฌธ์ " ๋ณด๊ธฐ์ ๋ด ํ๋ก์ ํธ์ ์ด๋ ค ์๊ณ ๋ซํ ๋ชจ๋ ํ์ผ์ ๋ํ ๋ชจ๋ ์ค๋ฅ์ ๊ฒฝ๊ณ ๋ฅผ ํ์ํ๋๋ก ์ง์ํ๋ ๋ฐฉ๋ฒ์ ๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ๋จ์ผ ๋ชฉ๋ก์์ ๋ชจ๋ ๋ฌธ์ ๋ฅผ ๋ณด๊ณ ๋น ๋ฅด๊ฒ ํด๋ฆญํ์ฌ ์์ ํ ์ ์์ต๋๋ค.
@waderyan ์ด๊ฒ์ TS ํ๊ณผ ๋ ผ์ํ ๋น๋ ์์ ์ ๋ํ ๊ธฐ๋ฅ ์์ฒญ์ ๋๋ค.
์ฐธ๊ณ ๋ก ์ฌ๊ธฐ์ ๋ฌธ์ ์ ๋ํ ๋งํฌ๊ฐ ์์ต๋๋ค - https://github.com/Microsoft/TypeScript/issues/11229
๊ธ์, ๋๋ ๋จ์ง "problemMatcher": "$tsc-watch"
(https://code.visualstudio.com/Docs/editor/tasks#_processing-task-output-with-problem-matcher ์ฐธ์กฐ)์ ๋ชจ๋ ์ค๋ฅ ๋ฐ ๊ฒฝ๊ณ ๊ฐ ๋ฌธ์ ๋ณด๊ธฐ์ ์ฌ๋ฐ๋ฅด๊ฒ ํ์๋ฉ๋๋ค. ์ด๋ฆฐ ํ์ผ์ ๋ณ๊ฒฝ ์ฌํญ์ด ์ธ์ด ์๋ฒ๋ก ์ธํด ์ฆ์ ๊ฐ์ง๋๊ธฐ โโ๋๋ฌธ์ ๊ฝค ์ข์ ์ํฌํ๋ก์ด์ง๋ง ์ ์ฅํ๋ฉด ์ฆ๋ถ ์ปดํ์ผ( tsc --watch
)์ด ํธ๋ฆฌ๊ฑฐ๋๋ฏ๋ก ์ฌ์ ํ ์๊ฐ์ด ๊ฑธ๋ฆฌ์ง๋ง ์ ์ฅ/์ ์ฅํ์ง ์์์ผ๋ก์จ ๋๊ธฐ ์๊ฐ์ ์ ์ดํ ์ ์์ต๋๋ค. ์์ง.
์ด๊ฒ์ ์ด๋ค ETA? ํด๋น ๊ธฐ๋ฅ์ ๋ํด ๋ง์ ๋ฌธ์ ๊ฐ ์ด๋ ธ๊ณ ๋ด๊ฐ ๋์น ๊ฒ์ด ์๋์ง ์๋์ง ํ์คํ์ง ์์ต๋๋ค. ์ค๋ง์ผ:
@maxime1992 ํ์
๋ด๊ฐ ๊นจ๋ซ์ง ๋ชปํ ๊ฒ์ VSCode์ ์๋ ์์ ์ธํ๋ผ๋ก ์ด ์์ ์ ์ํํ ์ ์๋ค๋ ๊ฒ์ ๋๋ค. ์ด๊ฒ์ task.json์ ์ถ๊ฐํ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค.
{
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": ["-w", "-p", "."],
"showOutput": "silent",
"isBackground": true,
"problemMatcher": "$tsc-watch"
}
๊ทธ๋ฐ ๋ค์ ์คํํ๊ธฐ๋ง ํ๋ฉด ๋ฌธ์ ๋ณด๊ธฐ์์ ์ ์ฒด ํ๋ก์ ํธ์ ๋ชจ๋ ์ค๋ฅ๋ฅผ ๋ณผ ์ ์์ต๋๋ค.
์ ์ด๊ฒ์ด ๋ ๋์ ๋๊ฒ ํ์๋์ง ์๋์ง ์ฝ๊ฐ ๋นํฉ์ค๋ฝ์ต๋๋ค. ๋งค์ฐ ์ ์ฉํ๊ณ ๋ฉ์ง๋๋ค.
@johnfn ํ๋ฅญํ ์๋ฃจ์ , ๊ฐ์ฌํฉ๋๋ค. ์์ ์ ์ ์ผํ ๋ชฉ์ ์ด ์ค๋ฅ๋ฅผ ํ์ํ๋ ๊ฒ์ด๋ผ๋ฉด "--noEmit" ์ธ์๋ฅผ ์ถ๊ฐํ ์๋ ์์ต๋๋ค.
{
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": ["-w", "-p", ".", "--noEmit"],
"showOutput": "silent",
"isBackground": true,
"problemMatcher": "$tsc-watch"
}
@kevinjreece iTerm์ Semantic History ๊ธฐ๋ฅ(https://www.iterm2.com/documentation-one-page.html)์ ์ฌ์ฉํ์ฌ "๋ด ๋จ๋ง๊ณผ VS Code ๊ฐ์ ํ๋์ค"๋ฅผ ๋ฐฉ์งํ ์ ์์ต๋๋ค. cmd๊ฐ ํ์ผ ์ด๋ฆ + ์ค ๋ฒํธ๋ฅผ ํด๋ฆญํ๋ฉด ์๋์ผ๋ก vscode์์ ํด๋น ์ค์ด ์ด๋ฆฝ๋๋ค!
ํค๋ณด๋ ๋จ์ถํค๋ก ๋ฌธ์ ํจ๋์์ ์ค๋ฅ๊ฐ ์๋ ํ์ผ์ ์ด ์ ์๋์ง ์๋ ์ฌ๋์ด ์์ต๋๊น? ์์ ์ ์คํํ ํ์๋ ๋ง์ฐ์ค์ ํค๋ณด๋๋ฅผ ๊ณ์ ์ ํํ๋ ๊ฒ์ ์ ๋ง ๊ณ ํต์ค๋ฝ์ต๋๋ค.
Ctrl+Shift+M
(๋๋ Cmd+Shift+M
)๋ฅผ ์ฌ์ฉํ์ฌ ๋ฌธ์ ํจ๋์ ์ด ์ ์์ต๋๋ค. ๋ฐ๋ก ๊ฐ๊ธฐ ํค ์๋์ "๋ฌธ์ ํ์"๊ฐ ์์ต๋๋ค. ๊ทธ๊ฒ ๋ฌด์จ ๋ป์ธ๊ฐ์?
์๋์, ์ด๋ ค ์๋์ง ์ฌ๋ถ์ ๊ด๊ณ์์ด ์ค๋ฅ๊ฐ ์๋ ๋ค์ ํ์ผ๋ก ์ด๋ํ๋ ๋ฐ๋ก ๊ฐ๊ธฐ๋ฅผ ์ํฉ๋๋ค.
๋๋ ๊ทธ๊ฒ์ ํ ํ์ฅ์ ์ฐพ๊ณ ์์์ง๋ง API๋ ๋จ๋จํ ์ ๊ฒจ ์๊ณ ๋ช ๋ น์ ๋ด๊ฐ ๋ณผ ์์๋ ๋ฐฉ์์ผ๋ก MarkerService (๋ฌธ์ ์ถ์ )์ ์ก์ธ์ค ํ ์ ์์ต๋๋ค.
์ ๊ฒ ์ด์. ๊ฝค ์ ์ฉํ ์ ์์ต๋๋ค. ์ผ๋ฐ์ ์ผ๋ก vscode์ Problems
์์ญ์ ๊ฐ์ ํ ๊ธฐํ๊ฐ ๋ง์ต๋๋ค.
์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ ์ฌ๋์ https://github.com/Microsoft/vscode/issues/34412์
๋๊น?
ํ์ ๋น๋ ๊ฐ์ ์ ํํ ๋์ผํ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ฉด ์ด๋ฅผ ๋ฌด์ํฉ๋๋ค.
๋๋ฒ๊ทธ ์์
์ tsc
๋ฅผ ์ฌ์ฉํ๋ ํธ๋ฆญ์ด ํญ์ ๊ฐ๋ฅํ ๊ฒ์ ์๋๋๋ค. ์๋ฅผ ๋ค์ด ์ฌ์ฉ์ ์ ์ Webpack ๋ก๋๊ฐ ์๋ Vue ํ๋ก์ ํธ์์ .vue ํ์ผ์ ์ฒ๋ฆฌํ ์ ์์ต๋๋ค( tsc
๋ ๊ธฐ๋ณธ์ ์ผ๋ก Vue ํ์ผ์ ๊ตฌ๋ฌธ ๋ถ์ํ ์ ์์ต๋๋ค. ).
๊ทธ๋ฌ๋ ํ๋ก์ ํธ๋ฅผ ๋ณด๊ณ VS Code ํฐ๋ฏธ๋๋ก ์ปดํ์ผํ๋ฉด ๋ชจ๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ ๋ฐฉ๋ฒ์ ์ฐพ์ ์ ์์ต๋๋ค.
์๋ฅผ ๋ค์ด ๋ค์ npm ์คํฌ๋ฆฝํธ๋ฅผ ์ํํ์ต๋๋ค.
"live-check": "webpack --config ./build/webpack.dev.conf.js -w --display none",
๊ทธ๋ฆฌ๊ณ "npm run live-check"๋ฅผ ํตํด VS ํฐ๋ฏธ๋๋ก ์คํํ๊ณ ๋ชจ๋ ์ค๋ฅ๊ฐ ์ค์๊ฐ์ผ๋ก ๋ฐ์ํฉ๋๋ค.
@johnfn ์ ์๋ฃจ์
์ ์ฌ์ฉ
์ถ๋ ฅ ํญ์์ ์คํ ์ค์ธ ์์
์ ๋ณผ ์ ์์ง๋ง ์ค๋ฅ๊ฐ ํ์๋์ง ์์ต๋๋ค.
task.json:
{
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": ["-w", "-p", ".", "--noEmit"],
"showOutput": "silent",
"isBackground": true,
"problemMatcher": "$tsc-watch"
}
tsconfig.json
{
"compilerOptions": {
/* Basic Options */
"target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "es2015", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
// "lib": [], /* Specify library files to be included in the compilation: */
"allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react-native", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./build", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"removeComments": false, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"strictNullChecks": true, /* Enable strict null checks. */
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
/* Source Map Options */
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
},
"include": [
"src/**/*",
"./node_modules/react-native-dev-kit/**/*"
],
"exclude": [
"__tests__",
"index.android.js",
"index.ios.js",
"build",
"local_history",
"node_modules"
]
}
๋ซํ ํ์ผ์์ ์ค๋ฅ๋ฅผ ๋ณผ ์ ์๋ ์ด์ ๋ ๋ฌด์์ ๋๊น(์ค๋ฅ๊ฐ ์๋ค๊ณ ํ์ ํฉ๋๋ค)?
๐
@apperside๊ฐ ๋งํ๋ฏ์ด .. ์์ ์ ํ์ผ์ด ๋ณ๊ฒฝ๋ ๊ฒฝ์ฐ์๋ง ์ค๋ฅ๋ฅผ ํ์ํฉ๋๋ค..
์ฌ์ด๋๋ฐ์ ์์ ๊ณต๊ฐ์ ์ค๋ฅ๊ฐ ํ์๋๋ ์๋ก์ด ๊ธฐ๋ฅ์ ์ฌ์ฉํ๋ฉด ๊ธฐ๋ณธ์ ์ผ๋ก ์๋ํ๋ ์ด ์์ ์ ๋ํด ํฌ๊ฒ ๊ฐ์ฌํ ๊ฒ์ ๋๋ค.
์ต์ ๋ฒ์ ์ vscode์์ ์์ ํ์์ด ์ฝ๊ฐ ๋ณ๊ฒฝ๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ ํ์์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
{
"label": "Monitor TS Errors",
"command": "./node_modules/.bin/tsc",
"type": "shell",
"args": ["--watch", "--project", "."],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"isBackground": true,
"problemMatcher": "$tsc-watch"
}
VSCode๋ฅผ ์ด ๋๋ง๋ค ์์ ์ ์์ํฉ๋๊น? ์๋๋ฉด ์๋์ผ๋ก ์คํ์ํค๋ ๋ฐฉ๋ฒ์ด ์๋์?
์ต์ ๋ฒ์ ์ VS ์ฝ๋๋ ํ์ผ๋น ์ค๋ฅ ์๋ฅผ ๋ณด์ฌ์ค๋๋ค.
์ด๊ฒ์ ๋นํ์ฑํํ๋ ค๋ฉด ์ด๋ป๊ฒ ํด์ผ ํฉ๋๊น?
// ํ์ผ ๋ฐ ํด๋์ ๋ํ ์ค๋ฅ ๋ฐ ๊ฒฝ๊ณ ๋ฅผ ํ์ํฉ๋๋ค.
"problems.decorations.enabled": ์ฐธ,
์ด๊ฒ์ false๋ก ์ค์ ํ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค. ;)
2018๋ 2์ 15์ผ ๋ชฉ์์ผ ์ค์ 1์ 36๋ถ์ pabloli [email protected]์์ ๋ค์๊ณผ ๊ฐ์ด ์ผ์ต๋๋ค.
์ด๊ฒ์ ๋นํ์ฑํํ๋ ค๋ฉด ์ด๋ป๊ฒ ํด์ผ ํฉ๋๊น?
โ
์ด ์ค๋ ๋์ ๊ฐ์ ํ๊ธฐ ๋๋ฌธ์ ์ด ๋ฉ์์ง๋ฅผ ๋ฐ๊ณ ์์ต๋๋ค.
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ณ GitHub์์ ํ์ธํ์ธ์.
https://github.com/Microsoft/vscode/issues/13953#issuecomment-365838054 ,
๋๋ ์ค๋ ๋ ์์๊ฑฐ
https://github.com/notifications/unsubscribe-auth/AAy0aayEHkVuxumJRuZz-mdWmBvBhdn9ks5tU9B2gaJpZM4KaH3J
.
์ด๊ฒ์ ๋ด๊ฐ ์ฌ์ฉํ๋ ๊ฒ์ ๋๋ค
{
"label": "TSCompileAll",
"type": "shell",
"command": "./node_modules/.bin/tsc --watch --noEmit --project .",
"problemMatcher": ["$tsc-watch"]
}
๋งค์ฐ ์ค์ํฉ๋๋ค. ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ค์ ํ๊ฑฐ๋ ์ต์ํ ์ค์ ์ผ๋ก ์ค์ ํ ์ ์๋์ง ๊ถ๊ธํฉ๋๋ค.
์์ ๊ณต๊ฐ์ด๋ ํ๋ก์ ํธ์์ ์ด ์์ ์ ์๋์ผ๋ก ์์ํ ์ ์์ต๋๊น?
๋๋ ์ด๊ฒ์ ์ฌ์ฉํ๋ค:
{
"version": "2.0.0",
"tasks": [
{
"label": "tsc watch",
"type": "shell",
"command": "./node_modules/.bin/tsc",
"isBackground": true,
"args": ["--watch", "--noEmit", "--project", "www"],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "never",
"echo": false,
"focus": false,
"panel": "dedicated"
},
"problemMatcher": "$tsc-watch"
}
]
}
์ด ํ์ฅ์ ์ฌ์ฉํ์ฌ ์์ ์ ์์ ์ ์คํํฉ๋๋ค. https://marketplace.visualstudio.com/items?itemName=yukidoi.blade-runner
ํ์ผ์ ๋ซ์ ๋ (๋ฌธ์ ํจ๋์์) ํ์ผ์ ์ค๋ฅ๋ฅผ ์ ์งํ๋ ๋ฐฉ๋ฒ์ ์์ง ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
ํ์ผ์ ๋ซ์ ํ ํจ๋์ ๋์ด๋ ๋ฌธ์ ๋ฅผ ์ ์งํ๋ ์ต์ ์ด ์์ผ๋ฉด ๋งค์ฐ ๋์์ด ๋ฉ๋๋ค.
๋๊ตฐ๊ฐ ์ด ๋ฌธ์ ์ ๋ํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ต๋๊น? ์ค๋ํ ํ๋ก์ ํธ์ ๊ฒฝ์ฐ ์ค๋ฅ๊ฐ ์๋์ง ํ์ธํ๊ธฐ ์ํด ๋ชจ๋ ํ์ผ์ ์ฌ๋ ๊ฒ์ ์๋นํ ๋ฒ๊ฑฐ๋ก์ธ ์ ์์ต๋๋ค.
ํ๋์ ๋ช ๋ น์ผ๋ก ๋ชจ๋ ํ์ผ์ ํ ๋ฒ์ ์ฌ๋ ๋ฐฉ๋ฒ์ด ์์ต๋๊น? ๊ทธ๊ฒ์ ๋์๊ฒ ์์ฉ ๊ฐ๋ฅํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ๋ ๊ฒ์ ๋๋ค.
@daarong ๋๋ ์ผ๋ฐ์ ์ผ๋ก ์ ์ฒด ํ๋ก์ ํธ๋ฅผ ํ์ธํ๊ธฐ ์ํด vscode๋ก ์ฝ๋ฉํ๋ ๋์ ํฐ๋ฏธ๋์์ eslint-watch๋ฅผ ์คํํฉ๋๋ค. vscode์ ๋ชจ๋ linting ์ ๋ณด๋ฅผ ๊ฐ์ง๊ณ ์๋ ๊ฒ๋งํผ ์ข์ง๋ ์์ง๋ง ํ๋ก์ ํธ์ ํ์ผ์ ์ค๋ฅ๊ฐ ์๋์ง ํ ๋์ ํ์ธํ๊ธฐ์๋ ๊ด์ฐฎ์ ๋์์ ๋๋ค.
๋๊ตฌ๋ ์ง Java ํ์ผ์ ๋ํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ต๋๊น?
์ด๋ ค ์๋ ํ์ผ์ ์ค๋ฅ๋ฟ๋ง ์๋๋ผ ๋ฌธ์ ํจ๋์์ ๋ชจ๋ ํ์ผ์ ๋ชจ๋ ์ค๋ฅ๋ฅผ ์ธ์ ๋ ์ง ๋ณด๊ณ ์ถ์ต๋๋ค.
์ง๊ธ ๋๋ดํ๋ ๊ฑฐ์ง? ์ฝ 2,000๊ฐ์ ํ์ผ์ด ์์ต๋๋ค. ๋ณดํธ๋ผ๊ธฐ ์ค๋ฅ๋ฅผ ๊ฒ์ํ๊ธฐ ์ํด ์๋์ผ๋ก ๋ชจ๋ ํ์ผ์ ์ด์ด์ผ ํฉ๋๊น???
vs ์ฝ๋์์ ts lint๋ฅผ ํธ๋ฆฌ๊ฑฐํ๋ ๋ฐฉ๋ฒ์ด ์์ต๋๊น? ๋๋ ์ ์๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค. tslint
๋ฅผ ์ฌ์ฉํ์ฌ ์ฝ์์ ํ์ํฉ๋๋ค.
VS Code๊ฐ src ํด๋์ ๋ชจ๋ ํ์ผ์์ ์ค๋ฅ(๊ตฌ๋ฌธ ๋ฐ ๋ฆฐํฐ)๋ฅผ ๊ฒ์ํ๋๋ก ํธ๋ฆฌ๊ฑฐํ ์ ์๋ค๋ฉด ์ข์ ๊ฒ์
๋๋ค.
์ฆ, src ํด๋์ ๋ชจ๋ ํ์ผ(ts)์ ๋์์ ์ฌ๋ ๋ฐฉ๋ฒ์ ๋ฌด์์
๋๊น?
node_modules์ ๊ฐ์ ๋ค๋ฅธ ํด๋์์ ๊ฒ์ํ์ง ๋ง์ญ์์ค. ... ํ๋กํ ์ฝ์ ๋ํด์๋ง. ๐
ํฌํจ/์ ์ธ ๊ฒฝ๋ก ์ต์
์ด ์ข์๊น์? ...
์ฝ ํ ๋ฌ ์ ์ ์์ ๊ณต๊ฐ ๋ทฐ์ด์์ ๋ด ํ์ผ ์์ ์์ ๋นจ๊ฐ์ ์์ด์ฝ์ด ์์์ต๋๋ค. ์ด์ ๊ทธ๋ค์ ์ฌ๋ผ์ก๊ณ ๋ด๊ฐ ์ด๋ป๊ฒ ํ๋์ง ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ์ ๋ฒ์ ์ VSCode๊ฐ ์๋ ๋ฐฉ์์ ๋ณ๊ฒฝํ๊ฑฐ๋ ์ด๋ฅผ ์ค๋จ์ํจ ํ์ฅ์ ์ค์นํ์ต๋๋ค. ๋ค์ ์๋์ํค๋ ๋ฐฉ๋ฒ? ๋๋ task.json์ ๋ํด ๋ค์ด๋ณธ ์ ๋ ์๊ณ ์ด์ ์ ์๋ํ๋ค๋ ์ฌ์ค์ด ์ด๊ฒ์ด ์ด์ ๊ธฐ๋ณธ ๋์์์ ์์ฌํฉ๋๋ค.
๋ค์์ 10์ด ์ด๋ด์ ๋ชจ๋ ๋ฌธ์ ๋ฅผ ๋ณผ ์ ์๋ ๋ฐฉ๋ฒ์ ๋๋ค.
๋น์ ์ ์ฝ๊ฐ์ ํธ๋ฆญ์ ์ฌ์ฉํฉ๋๋ค.
ํ์ผ์์ ๋ชจ๋ ๋ฐ๊พธ๊ธฐ ์ด๊ธฐ(Ctrl + Shift + H).
๋ฐ๊พธ๋ค ; ์ ํจ๊ป ;
๋ชจ๋ ๋ฐ๊พธ๊ธฐ๋ฅผ ๋๋ฅด์ญ์์ค. ๊ทธ๊ฒ ๋ค์ผ ์ด์ ๋ฌธ์ ๋ฅผ ํ์ธํ์ญ์์ค.
์ฌ๊ธฐ์์ ๋ชจ๋ ํ์ผ์๋ ์ ์ด๋ ํ๋์ ์ธ๋ฏธ์ฝ๋ก ์ด ์๋ค๊ณ ๊ฐ์ ํฉ๋๋ค. ๋ ํฐ ํ๋ก์ ํธ์ ๊ฒฝ์ฐ ๊ฒ์์ ์ธ๋ถํํ๋ผ๋ ๊ฒฝ๊ณ ๊ฐ ํ์๋๋ฉด ๋ชจ๋ ํ์ผ์ ๊ณตํต์ ์ด์ง๋ง ๋ง์ด ๋ํ๋์ง ์๋ ํญ๋ชฉ์ ์ ๋ ฅํ์ญ์์ค.
์ด์ ๋ํ ์ ๋ฐ์ดํธ๊ฐ ์์ต๋๊น? Ajay์ ๋จ์ถํค๋ ์๋ํ์ง๋ง ๋ค์ ํดํน๋ ๋๋์ ๋๋ค. ์ด๊ฒ์ VSC์ ๋ช ๋ฐฑํ๊ณ ์ฌ์ด ์น๋ฆฌ์ธ ๊ฒ ๊ฐ์ต๋๋ค. "๋ชจ๋ ์ค๋ฅ ํ์/์ด๋ฆฐ ํ์ผ์ ๋ํ ์ค๋ฅ ํ์" ์ค์์น๋ง ์์ผ๋ฉด ๋ฉ๋๋ค.
ํ์ผ ๋ณ๊ฒฝ ์ ์๋์ผ๋ก ๋ฐ์ํ๋ ๋์ ๋ ๋ค๋ฅธ ์๊ฐ์ ๋๋ค. ํ๋จ ํ์์ค์ ๋ฒํผ์ด ์๊ฑฐ๋ ๋ชจ๋ ํ์ผ์ ๊ฒ์ฌํ๋ ๋ช ์์ ์ผ๋ก ์คํํ ์ ์๋ ๋ช ๋ น์ด ์์ผ๋ฉด ์์ ํ ๊ด์ฐฎ์ ๊ฒ์ ๋๋ค.
๋ง์์, ๋ฌธ์ ๋ ์ด๋ ค์๋ ๋ชจ๋ ํ์ผ์ ๊ฒ์ฌํ๋ TS ์๋น์ค๋ฅผ ์กฐ์ ํ๋ ๊ฒ๊ณผ ๊ด๋ จ์ด ์๊ณ ๋ค๋ฅธ ํํธ์ผ๋ก ๋ซํ ์๊ณ ์ผ๋ฐ์ ์ผ๋ก ์๋์ผ๋ก ๊ฒ์ฌ๋์ง ์๋ ํ์ผ์ ๊ฒ์ฌํ๋ ๊ฒ๊ณผ ๊ด๋ จ์ด ์๋ค๊ณ ์๊ฐํฉ๋๋ค. ๋ง์ต๋๊น? ๋ฐ๋ผ์ ์ฌ์ด ์๋ฃจ์ ์ ๋ฌธ์ ์ฐฝ์์ ๋จ์ผ ์์ค์์ ๋ชจ๋ TS ๋ฌธ์ ๋ฅผ ์์ ํ๋๋ก ํ๋ ๊ฒ์ ๋๋ค. ๋ง์ต๋๊น?
vscode ํ(?)์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ง ๋ชปํ๋ ๊ฒ์ ๋ณด๊ณ ์ ์:
์ ๋์จ์ด๋ vscode ์์ ๋ฌธ์ ๋งค์ฒ๋ฅผ ํตํด ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ต๋๊น? ๊ทธ๋ฌ๋ฉด ๋ฌธ์ ์ฐฝ์ด ๋ฌด์์ ์ธ์ ํ์ํ๋์ง ์ค์ค๋ก ํ์ธํ ์ ์๊ธฐ ๋๋ฌธ์ ๋๊น? ๊ทธ๋ฐ ๋ค์ ์ด๋ป๊ฒ๋ vscode๊ฐ ํด๋น ๋ด์ฉ์ ํ์ํ์ง ๋ชปํ๋๋ก ๋นํ์ฑํํด์ผ ํฉ๋๊น? vscode ๊ฐ๋ฐ์๊ฐ ์ด์ ๊ฐ์ ์์ ์ด ๊ฐ๋ฅํ์ง ๋งํด ์ค ์ ์์ต๋๊น?
๊ทธ๋ฌ๋ ๋๋ ์ฌ์ ํ ์ด ๊ธฐ๋ณธ์ ์ธ ๊ฒ๋ค์ vscode ์์ฒด์์ ์ฒ๋ฆฌํด์ผ ํ๋ค๊ณ ์๊ฐํฉ๋๋ค. ํ์ผ์ ๋ซ์ ๋ TS ์ค๋ฅ๊ฐ ์ ์ ๋ก ํด๊ฒฐ๋๋ ๊ฒ๊ณผ๋ ๋ค๋ฆ ๋๋ค... TS ์๋ฒ๊ฐ ๋ชจ๋ ํ์ผ์ ์ด๊ฑฐ๋ ์ด์ง ์๊ณ ์ฒ๋ฆฌํ๋๋ก ํ๋ฉด ํธ๋ฆญ์ ์ํํด์ผ ํฉ๋๋ค. ๋ฌผ๋ก ์ ํ์ฌํญ์ด์ง๋ง ์ ํ์ฌํญ์ด์ด์ผ ํฉ๋๋ค.
์ด๊ฒ์ด ๊ฐ์ฅ ๋จผ์ ํด๊ฒฐํด์ผ ํ ๋ชจ๋ ๋ฌธ์ ์ค ๊ฐ์ฅ ์ค์ํ์ง ์์ ์ ์์ต๋๊น? IDE๋ ์์ ๋ ๋๊น์ง ์ค๋จ๋ฉ๋๋ค.
์ข์, ์ด๊ฒ์ ํดํค ์๋ฃจ์
์
๋๋ค.
์์
์ด $tsc-watch๋ฅผ ์ฌ์ฉํ๋๋ก ํ์ฌ @plievone ์ ์๋ฃจ์
์ ์ฌ์ฉํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ Visual Studio Code๊ฐ ์ด๋ฆด ๋๋ง๋ค ์์
์ ์คํํ๋ AutoLaunch์ ๊ฐ์ ํ๋ฌ๊ทธ์ธ์ ๊ฐ์ ธ์ต๋๋ค. (https://marketplace.visualstudio.com/items?itemName=philfontaine.autolaunch)
@mateuscb ์ ์ ์์ ํ์ฅํ๋ ค๋ฉด ํ์ผ ํ์๊ธฐ์ ์ปจํ ์คํธ ๋ฉ๋ด์์ ํน์ ํด๋๋ฅผ ๋ง์ฐ์ค ์ค๋ฅธ์ชฝ ๋ฒํผ์ผ๋ก ํด๋ฆญํ๊ณ "ํด๋์์ ๋ฌธ์ ์ฐพ๊ธฐ"๋ฅผ ์ํํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ์ฌ์ฉ์๋ ๋ฒ์ ๋ ์๋ ๊ฐ์ ๊ท ํ์ ๊ฒฐ์ ํฉ๋๋ค.
@ajayRaghav37 ์ ์์ ์ํํ์ง ๋ง์ญ์์ค. vscode๊ฐ ์ค๋จ๋ฉ๋๋ค.
์ ์ฅ, ์์ผ๋ก ๋ค์๋ ts ์ฝ๋๋ฅผ ์์ฑํ์ง ์์ ๊ฒ์
๋๋ค)
์ด๊ฒ์ด ์ธ์ ํ์ดํ๋ผ์ธ์ ํฌํจ๋ ๊ฒ์ธ์ง์ ๋ํ ์ ๋ฐ์ดํธ๋ ์์ด๋์ด๊ฐ ์์ต๋๊น? ์ด ๊ธฐ๋ฅ์ ์ฆ์ ์ฌ์ฉํ ์ ์์ผ๋ฉด ์ข์ ๊ฒ์ ๋๋ค.
ES-Lint๋ VS Code์ ์๋ก์ด ์์ ์ ๋์ ํ์ต๋๋ค. ์์ ๊ณต๊ฐ ์ค์ ์์ ํ์ฑํํด์ผ ํฉ๋๋ค.
"eslint.provideLintTask": true
ํฐ๋ฏธ๋ ๋ฉ๋ด๋ก ์ด๋ํ์ฌ ์์ ์คํ์ ์ ํํ ๋ค์
eslint: ์ ์ฒด ํด๋๋ฅผ ๋ฆฐํธํฉ๋๋ค.
ํฐ๋ฏธ๋์์ ๋ค์ ๋ช ๋ น์ ์คํํ์ฌ ๋๋ถ๋ถ์ ๋ฌธ์ ๋ฅผ ์๋์ผ๋ก ์์ ํ ์๋ ์์ต๋๋ค.
.\node_modules\.bin\eslint.cmd --fix .
์ฐธ์กฐ: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
์ฐ๋ฆฌ๋ ์ฌ์ ํ VS Code์์ ๋ฌธ์ ์ค์บ๋๋ฅผ ๊ธฐ๋ค๋ฆฌ๊ณ ์์ง๋ง eslint๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์ด๊ฒ์ ์ถฉ๋ถํ ์ข์ ๋์์ ๋๋ค.
์ค์ ๋ก ๋ ํฐ ํ๋ก์ ํธ์ ํ์ํ ๊ธฐ๋ฅ์ ๋๋ค. ์ ๋ฐ์ดํธ๊ฐ ์์ต๋๊น?
@ajayRaghav37 , eslint๊ฐ ํ์ดํ ์ค๋ฅ๋ฅผ ์ก์ ์ ์๋ ๊ฒ์ฒ๋ผ ๋ณด์ ๋๋ค. ๋จ์ง linting ๊ท์น์ผ ๋ฟ์ ๋๋ค:
https://github.com/typescript-eslint/typescript-eslint/issues/36#issuecomment -478820127
+1
์ด ์๋ก. ๋ํ ๋ด์ฅ TS ๊ฒ์ฌ ๋ฐ ๋ฆฐํธ๋ฅผ ๋นํ์ฑํํ๊ณ ๋น๋ ์์ ์ ๊ฒฐ๊ณผ๋ง ์ฌ์ฉํ๋ ๊ฒ์ด ๊ฐ๋ฅํด์ผ ํ๋ค๊ณ ์๊ฐํฉ๋๋ค.
+1
์ด์ ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด tsc --noEmit -w
๋ฅผ ์คํํฉ๋๋ค.
ํ์ง๋ง VSCode์ ts-server
๋ฅผ ๊ณต์ ํ๋ ๊ฒ์ด ๋ ์ข์ ๊ฒ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค.
๊ทธ๋ฐ๋ฐ ์ ๊ทธ๋ ๊ฒ ์ค๋ซ๋์ ์ํ๋์ง ์์์ต๋๊น?
์ฌ๊ธฐ TS ์ธ์ด ์๋ฒ์ ๋ํด ์ ์๋ ์ฌ๋์ด ์์ต๋๊น? LSP API์ ์ด๊ฒ์ IDE์ ์ ๋ฌํ ๋ฐฉ๋ฒ์ด ์์ต๋๊น? ์ด๊ฒ์ด ์ฑ๋ฅ ๋ฌธ์ ์ ๋๊น? ๋ถ๋ช ํ ์ฌ๋๋ค์ ์ด ๊ธฐ๋ฅ์ ๋ถ์กฑ์ ๋ํด ์ด์ ์ ์ด๋ฏ๋ก(์ ๋) ์ด ๊ธฐ๋ฅ์ด ๊ฒฐ์น์ ์ ํต๊ณผํ๋ ๋ฐ ์ปค๋ฎค๋ํฐ ๋์์ ๊ด์ฌ์ด ์์ ๊ฒ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค.
๊ทธ๋ฌ๋ ์ฌ๊ธฐ์ ๋ฌธ์ ๊ฐ VS Code ํ์ ์ธ๋ ฅ ๋ถ์กฑ์ธ ๊ฒฝ์ฐ์ ๋๋ค.
๋ฌธ์ ๊ฐ ๋ค๋ฅธ ๊ฒฝ์ฐ(VS Code ์ํคํ ์ฒ์ ๋ํ ๋ ํฐ ์ํฅ, LSP ๋ณ๊ฒฝ ํ์, ๋ถ๋ช ํํ ์ฑ๋ฅ ์ํฅ, UX ๊ณ ๋ ค ์ฌํญ) ์ด ์ฌ์ค์ ์๋ ๊ฒ์ ๊ฒ๋ณด๊ธฐ์ ๊ฐ๋จํด ๋ณด์ด๋ ์ด ๊ธฐ๋ฅ์ด ์ ๊ทธ๋ ๊ฒ ๋ง์ ์๊ฐ์ด ๊ฑธ๋ฆฌ๋์ง ์ค๋ช ํ๋ ๋ฐ ๋์์ด ๋ ๊ฒ์ ๋๋ค.
์ด ๋ฌธ์ ์ ๋ํ ์ฑ ์์ด Visual Studio Code ํ์ด ์๋๋ผ TypeScript ํ์ ์๋ค๋ ์ ์ ๋ํ ๋ค์ํ ์๊ฒฌ์ด ์์ต๋๋ค. ๊ทธ๋ฌ๋ ์ด๊ฒ์ VS Code์ ๋ด์ฅ๋ '@ts-check' ๊ธฐ๋ฅ์๋ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. 'tsc' ๋ช ๋ น์ ์คํํ๋ ์์ ์ ์ฌ์ฉํ๊ธฐ ์ํด ์ด ๊ฒ์๋ฌผ์์ ์ธ๊ธํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ tsc๊ฐ ์ค์น๋์ด ์์ง ์๊ธฐ ๋๋ฌธ์ ์๋ํ์ง ์์ต๋๋ค(์ ๋ @ts-check ๋ฐ jsdoc๋ง ์ฌ์ฉํ๊ณ ์์ต๋๋ค).
์ด์ ์๋ ์ค๋ฅ๋ฅผ ์ฐพ๊ธฐ ์ํด ํ๋ก์ ํธ์ ๋ชจ๋ ํ์ผ์ ํด๋ฆญํ๊ณค ํ์ต๋๋ค. ๊ทธ๊ฒ์ ์ง๋ฃจํ ์ผ์ด์์ง๋ง ์ ์ด๋ ํ์ผ์ ๋ซ์์ ๋ ์ฌ์ด๋ ๋ฐ์์ ๋ฌธ์ ๊ฐ ์ฌ๋ผ์ง์ง ์์์ต๋๋ค. ์ง๋ ๋ช ๋ฌ ๊ฐ์ ์ ๋ฐ์ดํธ ์ค ํ๋ ์ดํ์ ์ด ๋ฌธ์ ๊ฐ ๋์ ๋์์ต๋๋ค: #73153.
์ด๊ฒ์ด ๊ฐ์ฅ ๋จผ์ ํด๊ฒฐํด์ผ ํ ๋ชจ๋ ๋ฌธ์ ์ค ๊ฐ์ฅ ์ค์ํ์ง ์์ ์ ์์ต๋๊น? IDE๋ ์์ ๋ ๋๊น์ง ์ค๋จ๋ฉ๋๋ค.
๋๋ ๋์ํ๋ค.
์ธ์ ?
์์ 'ํ์ฉ๋' ์๋ฃจ์ ์ด ์๋ํ์ง๋ง ์ผ๋ถ ํ๋๋ ๋ ์ด์ ์ฌ์ฉ๋์ง ์์ต๋๋ค.
{
"label": "Watch TS Errors",
"type": "shell",
"command": "tsc",
"args": ["-w", "-p", ".", "--noEmit"],
"isBackground": true,
"problemMatcher": "$tsc-watch"
}
๋๋ฅผ ์ํด ์๋ํฉ๋๋ค.
๋ํ ์์ง ์์ ์ด ์๋ ๊ฒฝ์ฐ tasks.json ํ์ผ์ ๋ง๋๋ ๋ฐฉ๋ฒ์ https://code.visualstudio.com/docs/editor/tasks ๋ฅผ ์ฐธ์กฐ
์ด์ ๊ฐ์ ๋น๋ ์์
์ผ๋ก tsc
๋ฅผ ์คํํ ๋ VS Code์ ๋ด์ฅ TS ์๋ฒ๋ฅผ ๋นํ์ฑํํ ์ ์์ต๋๊น? ๋ด๊ฐ ๋ฌป๋ ์ด์ ๋ ๊ทธ๋ ์ง ์์ผ๋ฉด ๋ด์ฅ TS ์๋ฒ์ ์ค๋ฅ์ ์์
์ ์ค๋ฅ, ๋๋ก๋ ๋๊ธฐํ๋์ง ์๋ ๋ ๊ฐ์ง ์ค๋ฅ ์ธํธ๊ฐ ๋ฐ์ํ๊ธฐ ๋๋ฌธ์
๋๋ค.
IDE๊ฐ ์์๋์ด Typescript ํ๋ก์ ํธ ์์ ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๊ทธ๋์ ๋ฒ์ 1.28.2๋ฅผ ๊ณ ์ํ๊ณ ์ ๋ฐ์ดํธ๋ฅผ ๋นํ์ฑํํด์ผ ํฉ๋๋ค.
์ด์ํ์ง๋ง ์ด์ ์๋ ์ด๋ป๊ฒ๋ ์๋ํ์ต๋๋ค. ๋ฌด์จ ์ผ์ด์ผ? ๊ทธ๋ฆฌ๊ณ ์ธ์ ๋ค์ ์๋ํฉ๋๊น? ๋ฒ์จ 1๋ ์ด ์ง๋ฌ๋๋ฐ ๋ณํ์ ๊ธฐ๋ฏธ๊ฐ ๋ณด์ด์ง ์๋๊ตฐ์...
2019๋ 10์์ด๋ฉฐ ์ด๊ฒ์ ์ฌ์ ํ โโ๋๋์ ๋๋ค.
๋ค๋ฅธ IDE๊ฐ ์ ๊ณตํ๋ ๊ธฐ๋ฅ์ ๋ํด 3๋ .... NNNNICCCEEEEEEEEEEEEEE
๋ค๋ฅธ IDE๊ฐ ์ ๊ณตํ๋ ๊ธฐ๋ฅ์ ๋ํด 3๋ .... NNNNICCCEEEEEEEEEEEEEE
VSCode๋ IDE๊ฐ ์๋์ ๊ธฐ์ตํ์ญ์์ค. ๊ทธ๊ฒ์ Editor์ IDE ์ฌ์ด์ ์๋ ๊ฒ์
๋๋ค.
์ด์จ๋ , ๋๋ ๊ทธ๋ค์ด ๊ทธ๊ฒ์ํ๊ธฐ๋ฅผ ๋ฐ๋๋๋ค
๋ค๋ฅธ IDE๊ฐ ์ ๊ณตํ๋ ๊ธฐ๋ฅ์ ๋ํด 3๋ .... NNNNICCCEEEEEEEEEEEEEE
VSCode๋ IDE๊ฐ ์๋์ ๊ธฐ์ตํ์ญ์์ค. ๊ทธ๊ฒ์ Editor์ IDE ์ฌ์ด์ ์๋ ๊ฒ์ ๋๋ค.
์ด์จ๋ , ๋๋ ๊ทธ๋ค์ด ๊ทธ๊ฒ์ํ๊ธฐ๋ฅผ ๋ฐ๋๋๋ค
๋ฌด์จ ์๊ด์ด์ผ. ๊ทธ๋ฌ๋ ts ํ์ผ์ ํ์ธํ๊ธฐ ์ํด ๋น์ด๋จน์ ์์ ์ ์์ํ๊ณ ์คํํ ์๋ ์์ต๋๋ค.
์ ๊ณต๋ ๊ฐ์ด๋๋ ์์ ํ ์๋ก์ด ๋น์ด๋จน์ ํ๋ก๊ทธ๋๋ฐ ์ธ์ด๋ฅผ ๋ฐฐ์ฐ๋ ๊ฒ์ฒ๋ผ ๋ณด์
๋๋ค.
์ฐ๋ฆฌ๋ ์ผํ๊ณ ์์ฐํฉ๋๋ค. ๋๋ ts ํ์ผ์ IDE์์ ๊ฒ์ฌํ๋ ์คํฌ๋ฆฝํธ๋ฅผ ์ฌ๋ฆฌ๊ธฐ ์ํด ๋ชจ๋ ์นํฉ(๋ฐ ์ด์ ์ ์ฌํ ๋๊ตฌ)์ ๋ฐฐ์ฐ๋ ๋ฐ ๋ญ๋นํ ์๊ฐ์ด ์์ต๋๋ค. t๋ IDE์ ๋์ผํ ์์ฑ์๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ๋ง๋ ์ธ์ด๋ ์ง์ํฉ๋๋ค....
๋ฌด์จ ํ์๋ฆฌ
๋ฌด์จ ํ์๋ฆฌ
์ฝ๊ฐ์ ๊ด์ :
Microsoft๋ ์ผ๋ถ ์ํํธ์จ์ด๋ฅผ ๋ง๋ค์ด ๋ฌด๋ฃ๋ก ์ ๊ณตํ์ต๋๋ค.
์ด ์ํํธ์จ์ด๋ ๊ฐ์ฌํ๋ ์๋ฐฑ๋ง ๋ช
์ ์ฌ๋๋ค์๊ฒ ๋์์ด ๋ฉ๋๋ค.
Microsoft๋ ๊ทํ์๊ฒ ์ด ์ํํธ์จ์ด๋ฅผ ์ฌ์ฉํ๋๋ก ๊ฐ์ํ์ง ์์ต๋๋ค.
๋น์ ์ ๊ทธ๋ค์ด ์ด๋ก ์ ์ผ๋ก ํ ์ ์๋ ๊ฒ๋งํผ ์๋ฒฝํ์ง ์๊ธฐ ๋๋ฌธ์ ๋น์ ์๊ฒ ๋ฌด์ธ๊ฐ๋ฅผ ๋ฌด๋ฃ๋ก ์ ๊ณตํ๋ ๊ฒ์ ๋ํด ํ๋ฅผ ๋ ๋๋ค.
๋ํ ๊ทธ๋ ๋์ผํ "IDE"์ ์ธ์ด๋ฅผ ์ฌ์ฉํ๊ณ IDE๋ ์คํ ์์ค์ด๋ฉฐ pull ์์ฒญ์ ์๋ฝํฉ๋๋ค...
๋๋ ์ด๊ฒ์ ์ค๋ซ๋์ ์ง์ผ๋ณด์๊ณ ์ฌ์ ํ ์ค๋ฅ ๋ฐ ๊ฒฝ๊ณ ๋ฅผ ์ถ์ ํ๋ ๋ ๋์ ๋ฐฉ๋ฒ์ ๊ธฐ๋ค๋ฆฌ๊ณ ์์ผ๋ฉฐ ๊ณต๊ฐ ์ถ์ ์ดํ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
์ฆ, VS Code๋ ์์ฌํ ์ฌ์ง ์์ด JS/TS ๊ฐ๋ฐ์ ์ํ ์ต๊ณ ์ IDE์ ๋๋ค. ์ฌ์ง์ด Github์ ์ด์ด ๋ ๋ฒ์งธ๋ก ์ต๊ณ ์ MS ์ ํ์ผ ์๋ ์์ต๋๋ค. ๊ธฐ๋ฅ๊ณผ ์ฑ๋ฅ์ด ํ์คํ ๊ฐ์ ๋์์ผ๋ฉฐ ํ์ฅ ๊ธฐ๋ฅ์ ์์ฒญ๋ ์์ ์ ๋ฅผ ๋งค์ฐ ๊ธฐ์๊ฒ ํฉ๋๋ค. ์, ๋ฌธ์๊ฐ ๋ ๋์ ์ ์์ง๋ง ๋ชจ๋ ๊ธฐ์ ๋ฌธ์์ ๋ํด ๊ทธ๋ ๊ฒ ๋งํ ์ ์์ต๋๋ค.
VS Code ํ์ ๋ ๋์ ๋๊ตฌ์ ํตํฉ์ ์ ๊ณตํ๊ธฐ ์ํด ๋์์์ด ๋ ธ๋ ฅํ๊ณ ์๋ค๊ณ ํ์ ํฉ๋๋ค.
๊ทธ๋ฆฌ๊ณ ๋๋ ์ฐ๋ฆฌ๊ฐ ์ฌ์ ํ ์๋ก์ด ๊ธฐ๋ฅ์ ์๊ตฌํ๊ฑฐ๋ ์ ์คํ๊ฒ ์ด ๊ธฐ๋ฅ์ ๊ณ์ ์ฌ๋ฆด ์ ์๋ค๊ณ ๋ฏฟ์ต๋๋ค.
ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ถ๊ฐ - ์ด์ tsc -w์ ์ถ๋ ฅ์ ๋ชจ๋ํฐ๋งํ๊ธฐ ์ํด ๋ฏธ๋ฆฌ ๊ตฌ์ฑ๋ ์์ ์ด ์๋ ๊ฒ ๊ฐ์ต๋๋ค. Mac์์ ํฐ๋ฏธ๋ -> ์์ ๊ตฌ์ฑ... -> tsc: watch - tsconfig.json. ๊ทธ๋ฐ ๋ค์ ctrl+shift+B๋ฅผ ๋๋ฅด๊ณ ์์ ์ ์คํํฉ๋๋ค.
3๋ ํ... ์์์ด ์๋์?
๋๊ท๋ชจ ๋ฆฌํฉํ ๋ง ์ค. ์ํฅ์ ๋ฐ๋ ๋ชจ๋ ํ์ผ์ ๋ซ์ผ๋ฉด ๋ ์ด์ ๋ชจ๋ ์ค๋ฅ๊ฐ ํ์๋์ง ์๋๋ค๋ ๊ฒ์ ๊นจ๋ซ์ง ๋ชปํ์ต๋๋ค.
3๋ ์์ง ์ด๋ ค์์ต๋๋ค :๋์:
3๋ , ์์ง ์ด๋ ค์๋ค
์, ๋ฐ๋ณด์ ๋ฌด์์ downvotes.
๊ทธ๋์ ๋ ์ด๊ฑด ์ง์ฆ๋๋ ๋ฌธ์ ์ผ!!! ์ฌ๊ฐํ ๋น์ฆ๋์ค ํ๋ก์ ํธ์ ์๋ฐฑ ๊ฐ์ ํ์ผ์ด ์๋ค๋ ๊ฒ์ ์๊ณ ๊ณ์
จ์ต๋๊น?
๋ง์์ผ๋ก ์ด๋ป๊ฒ ๊ทธ๋ค์ ์ถ์ ํด์ผํฉ๋๊น?
์ฌ๋๋ค์ด IDE๋ฅผ ์ฌ์ฉํ๋ ๊ธฐ๋ณธ ๊ธฐ๋ฅ ์ค ํ๋์ ๋๋ค.....
๊ทธ๋ฆฌ๊ณ ์ด์ ๋ Visual Studio์ Intellisense์๋ ๋๋๋ก ์ ํ๋๋ ๊ฒ ๊ฐ์ต๋๋ค.
Btw ์์ ์ ์ต์ํ ์ด๋ฅผ ์ํํ๋ ๊ฒ์ผ๋ก ๋ณด์ด๋ฉฐ ts ํ์ผ์ ๊ฒฝ์ฐ ์ผ๋ถ ์ ์ด ์คํฌ๋ฆฝํธ๋ ์ฌ์ฉํ ์ ์๋ ๊ฒ ๊ฐ์ต๋๋ค. vscode์ ํ์ฅ ๊ด๋ฆฌ์์์ ๋ชจ๋ angular/typescript ํ์ฅ์ผ๋ก ์ค์น๋๋์ง ์ฌ๋ถ๋ ๋ชจ๋ฅด๊ฒ ์ง๋ง ์์ ๊ฒ์ ํ์์ค([์ฌ๊ธฐ]์ ํ์๋จ)(https://code.visualstudio.com)์์ ๊ฒ์ํ๋ฉด /docs/editor/tasks) ์ปดํ์ผํ ๋๋ง๋ค ํธ๋ฆญ์ ์ํํ๋ ์๊ณ ๋๋ ์ด์ ์ ์ฌํ ๊ฒ์ ๊ฒ์ํ ์ ์์ต๋๋ค(๋ค๋ฅธ ์์ ์ธ ์ผ๋ฐ ์ปดํ์ผ ํ๋ก์ธ์ค์ ํจ๊ป ์ํํ๋ ๊ฒ์ผ๋ก ๋ณด์).
๋๋ ์ด๊ฒ ๋๋ฌธ์ ๋ฌธ์ ํญ์ด ์ธ๋ชจ์๋ค๊ณ ์๊ฐํด์ ์ ๋ ์ฌ์ฉํ์ง ์๋๋ค. ๋์ ํฐ๋ฏธ๋์์ ์ค์ ๋ก ํ์ํ ๊ฒ์ ์ ๊ณตํ๋ ๋ช ๊ฐ์ง ๋ช
๋ น์ ์คํํฉ๋๋ค. ์๋ฅผ ๋ค์ด ํ๋ก์ ํธ์ ๋ํ ๋ชจ๋ ์ปดํ์ผ๋ฌ ์ค๋ฅ๊ฐ ์๋ ๊ฒฝ์ฐ tsc -w
ํฉ๋๋ค. ๋ด ํ๋ก์ ํธ์ ๋ชจ๋ ๋ฌธ์ ๋ฅผ ๋ณด๊ณ ์ถ๊ฑฐ๋ ์ ํ ๋ณด๊ณ ์ถ์ง ์์ต๋๋ค. ๋๋ ํ์ผ์ด ์ด๋ฆฌ๋ ๋ง๋ ์๊ดํ์ง ์์ต๋๋ค. ๊ทธ๊ฒ์ ๊ด๋ จ์ด ์์ต๋๋ค.
๊ธ์, ๋๊ตฐ๊ฐ๊ฐ Problems
ํญ์์ ์ด๋ฆฐ ํ์ผ์ ๋ํด์๋ง ์ค๋ฅ๋ฅผ ๋ณด๋ ๊ฒ์ด ๊ทธ๋ ๊ฒ ์ค์ํ๋ค๋ฉด ๊ทธ๋๋ก ๋์ญ์์ค.
๊ทธ๋ฌ๋ Visual Studio์์์ ๊ฐ์ด Build Output
์ ๊ฐ์ด ๋ค๋ฅธ ํญ์ ๋ง๋ค ์ ์์ต๋๊น?
์ด ํญ์ ์ปดํ์ผ๋ฌ์ ์ค๋ฅ ๋ฐ ๊ฒฝ๊ณ ๋ฅผ ๊ฐ๋จํ ํ ์ค ํ ์คํธ๋ก ํ์ํ๊ณ ์ด๋ฅผ ๋ ๋ฒ ํด๋ฆญํ๋ฉด ํ์ผ์ด ์ด๋ฆฌ๊ณ ์ค๋ฅ๊ฐ ์๋ ์ค์ ๋ฐ๋ก ์บ๋ฟ์ด ๋ฐฐ์น๋ฉ๋๋ค.
๋ํ F4
/ Shift-F4
๋ฐ๋ก ๊ฐ๊ธฐ๋ ๋ค์/์ด์ ์ค๋ฅ๋ก ์ด๋ํ๋ ๊ฒ์ด ์ข์ต๋๋ค(๊ทธ๋ฌ๋ ์ด๊ฒ์ ๊ทธ๋ ๊ฒ ์ค์ํ์ง ์์ต๋๋ค).
์ด ํญ์ ์์ ํ ์ง์ฐ๊ณ ํธ์งํ ๋๋ง๋ค ๋ค์ ์ฑ์ฐ์ญ์์ค. ๊ทธ๊ฒ์ผ๋ก ์ถฉ๋ถํ ๊ฒ์ ๋๋ค.
์๋๋ฉด ๋๊ตฐ๊ฐ๊ฐ ์ด์ ๋ํ ํ์ฅ์ ๋ง๋ค ์ ์์ต๋๊น?
๋ชจ๋ .ts ํ์ผ์ ์ด๋ ค๋ฉด "์ผ์นํ๋ ํ์ผ ์ด๊ธฐ" ํ์ฅ์๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค. ์ฑ๋ฅ์ด ์ฝ๊ฐ ๋ฌด๊ฒ์ง๋ง ์ ์ด๋ ์์ ์ ์๋ฃํฉ๋๋ค.
typescript ์ธ์ด ์๋ฒ๊ฐ ๋จ์ผ ์ค๋ ๋์ด๊ณ C#์ ์ปดํ์ผ๋ฌ์ฒ๋ผ ์๋ํ์ง ์๊ธฐ ๋๋ฌธ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค.
๊ฐ๋ ํ์ผ์ ์ด๊ณ # ๋ช
๋ น ํ๋ ํธ๋ฅผ ์ฌ์ฉํ์ฌ ์ด๋ฆ์ผ๋ก ์ ํ์ ์ฐพ์ผ๋ ค๊ณ ํ๋๋ฐ ์๋ฌด ์ผ๋ ์ผ์ด๋์ง ์๊ธฐ ๋๋ฌธ์ ์ฌ์ ํ ์ด ๊ธฐ๋ฅ์ ๊ธฐ๋ค๋ฆฌ๊ณ ์์ต๋๋ค. ๐
์ฃ์ง์์ ์ด๊ณ ์ถ์ ์ฌ๋๋ค์ ์ํด ๋ค์ VS Code ๋ด๋ถ์ ๋น๋๋ ์คํ์ ์ธ ํ๋ก์ ํธ ์ ์ฒด์ ์ค๋ฅ ๋ณด๊ณ ๋ฅผ ๊ฐ๋ฅํ๊ฒ ํ๋ "typescript.tsserver.experimental.enableProjectDiagnostics"
์ค์ ์ ๋์
ํฉ๋๋ค.
์ด๊ฒ์ ์์ฐ ์ค๋น๊ฐ ๋์ง ์์๋ค๋ ์ ์ ์ ์ํ์ญ์์ค! ๋๊ท๋ชจ ํ๋ก์ ํธ์ ๋ํ ์ฑ๋ฅ ๋ฌธ์ ๊ฐ ์๋ ค์ ธ ์์ผ๋ฉฐ ์ธํ ๋ฆฌ์ผ์ค๊ฐ ์์๋ ์ ์์ต๋๋ค.
์ด ์ค์ ์ ์ฌ์ฉํ๋ ๋์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ฉด ์ ๋ฌธ์ ๋ฅผ ์ด์ด์ฃผ์ธ์.
์ฃ์ง์์ ์ด๊ณ ์ถ์ ์ฌ๋๋ค์ ์ํด ๋ค์ VS Code ๋ด๋ถ์ ๋น๋๋ ์คํ์ ์ธ ํ๋ก์ ํธ ์ ์ฒด์ ์ค๋ฅ ๋ณด๊ณ ๋ฅผ ๊ฐ๋ฅํ๊ฒ ํ๋
"typescript.tsserver.experimental.enableProjectDiagnostics"
์ค์ ์ ๋์ ํฉ๋๋ค.์ด๊ฒ์ ์์ฐ ์ค๋น๊ฐ ๋์ง ์์๋ค๋ ์ ์ ์ ์ํ์ญ์์ค! ๋๊ท๋ชจ ํ๋ก์ ํธ์ ๋ํ ์ฑ๋ฅ ๋ฌธ์ ๊ฐ ์๋ ค์ ธ ์์ผ๋ฉฐ ์ธํ ๋ฆฌ์ผ์ค๊ฐ ์์๋ ์ ์์ต๋๋ค.
์ด ์ค์ ์ ์ฌ์ฉํ๋ ๋์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ฉด ์ ๋ฌธ์ ๋ฅผ ์ด์ด์ฃผ์ธ์.
์ํ์ด~
์ด ๊ธฐ๋ฅ์ ์งํ ์ํฉ์ ์ด๋์์ ํ์ธํ ์ ์์ต๋๊น? ์ค๋น๊ฐ ๋๋ฉด VS ์ฝ๋์ ํ์ค ๋ฒ์ ์ ์ถ๊ฐ๋๊ธฐ๋ฅผ ๊ฐ์ ํ ๊ธฐ๋ค๋ฆฌ๊ณ ์์ต๋๋ค.
์ฃ์ง์์ ์ด๊ณ ์ถ์ ์ฌ๋๋ค์ ์ํด ๋ค์ VS Code ๋ด๋ถ์ ๋น๋๋ ์คํ์ ์ธ ํ๋ก์ ํธ ์ ์ฒด์ ์ค๋ฅ ๋ณด๊ณ ๋ฅผ ๊ฐ๋ฅํ๊ฒ ํ๋
"typescript.tsserver.experimental.enableProjectDiagnostics"
์ค์ ์ ๋์ ํฉ๋๋ค.์ด๊ฒ์ ์์ฐ ์ค๋น๊ฐ ๋์ง ์์๋ค๋ ์ ์ ์ ์ํ์ญ์์ค! ๋๊ท๋ชจ ํ๋ก์ ํธ์ ๋ํ ์ฑ๋ฅ ๋ฌธ์ ๊ฐ ์๋ ค์ ธ ์์ผ๋ฉฐ ์ธํ ๋ฆฌ์ผ์ค๊ฐ ์์๋ ์ ์์ต๋๋ค.
์ด ์ค์ ์ ์ฌ์ฉํ๋ ๋์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ฉด ์ ๋ฌธ์ ๋ฅผ ์ด์ด์ฃผ์ธ์.
๋๋ผ์ด ์์ ์ ์ํด Visual Studio Code์ ๊ธฐ์ฌํ ๋ชจ๋ ๋ถ๋ค๊ป ๊ฐ์ฌ๋๋ฆฝ๋๋ค.
์ฃ์ง์์ ์ด๊ณ ์ถ์ ์ฌ๋๋ค์ ์ํด ๋ค์ VS Code ๋ด๋ถ์ ๋น๋๋ ์คํ์ ์ธ ํ๋ก์ ํธ ์ ์ฒด์ ์ค๋ฅ ๋ณด๊ณ ๋ฅผ ๊ฐ๋ฅํ๊ฒ ํ๋
"typescript.tsserver.experimental.enableProjectDiagnostics"
์ค์ ์ ๋์ ํฉ๋๋ค.
์ด๊ฒ์ ๋ค๋ฅธ ๋ฆฐํฐ์ ์ด๋ป๊ฒ ์๋ํฉ๋๊น?
๋ด๊ฐ ์ธ์ ๋ด๊ฐ ํ์ฑํ ๋ฌธ์ ํ์ด "typescript.tsserver.experimental.enableProjectDiagnostics"
, ํ์ดํ ์คํฌ๋ฆฝํธ์ ๋ฆฐํฐ์ ๊ฒฐ๊ตญ ํต๊ณผ์ ํ ๋ผ ๊ตฌ๋ฉ ์๋๋ก ์ด๋ node_modules
, ๋ฐฐํฌ ํ์ผ๊ณผ์์ ์ค๋ฅ์ ์๋ฐฑ์ ๊ตด์ฐฉํ๋ ๊ฒฝ์ฐ์๋ "exclude"
tsconfig.json
์๋ "node_modules"
๋ฉ๋๋ค. ์ด๊ฒ์ ๋๋ฒ๊น
ํ๋ ๋ฐฉ๋ฒ์ ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
๋ํ @vdh ์ ๋์ผํ ํจ๊ณผ๋ฅผ
๋ด eslint/ํธ์ง๊ธฐ ๊ตฌ์ฑ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"[javascript]": {
"editor.formatOnSave": false
},
"[javascriptreact]": {
"editor.formatOnSave": false
},
"[typescript]": {
"editor.formatOnSave": false
},
"[typescriptreact]": {
"editor.formatOnSave": false
},
"eslint.enable": true
๋น์ฆ๋์ค์ ์ฒซ ๋ฒ์งธ ์์๋ ๊ฒฝ๋ก์ node_modules๊ฐ ์๋ ๋ชจ๋ ํ์ผ์ด ์ต์ํ ์ ์ฅ ์ ์์ ์ ๋ํด ๋ฌด์๋์ด์ผ ํ๋ค๋ ๊ฒ์ ๋๋ค.
์ด๊ฒ์ ๋งค์ฐ ๋์ด ํ๊ฐ๋๋ ๊ธฐ๋ฅ์
๋๋ค.
@Martaver @vdh ์ ๊ฐ์ ๋์์
ํํฐ๋ฅผ ์ถ๊ฐํ์ฌ ์ง๊ธ์ "ํด๊ฒฐ"ํ์ต๋๋ค.
!*node_modules, !*.vscode
ํฐ๋ฏธ๋ ๋ณด๊ธฐ๋ก ์ด๋ํฉ๋๋ค. (์๊ฐ์ ์ผ๋ก๋ง ๋ค๋ฆ). ๋๊ตฐ๊ฐ๊ฐ ์ด๊ฒ์ ๊ฐ์ง๊ณ ๋ ธ๋ ๋ฐ ๊ด์ฌ์ด ์๋ ๊ฒฝ์ฐ.
@blackfan23 ์ ๋ฌ๊ทธ ๋ฐ์ ๋จผ์ง๋ฅผ ์ธ์ด ๊ฐ๋๋ผ๊ตฌ์ :D
@Martaver ๋์ํฉ๋๋ค. ๋ค์๊ณผ ๊ฐ์ ๊ฒ:
"typescript.tsserver.experimental.enableProjectDiagnostics.ignores": [
"**/node_modules/**"
]
์ด์์ ์ผ ๊ฒ์ ๋๋ค. ์ค์ ๋ก 0์ด ์๋ ํ๋ก์ ํธ์์ 1,000๊ฐ ์ด์์ ๋ฌธ์ ๋ฅผ ๋ณด๋ ๊ฒ์ ๋์ฐํฉ๋๋ค.
@blackfan23 node_modules
๊ธ๋ฝ์ผ๋ก ์ธํ ๊ณผ๋ํ CPU ๋ณ๋์ผ๋ก ์ธํด ์ต์
์ด ์๋๋๋ค.
@vdh tsconfig์์ skipLibCheck ๋ฅผ true๋ก ์ค์ ํ๊ณ "๋ฌธ์ " ํญ์ด node_modules์ ์ค๋ฅ ํ์๋ฅผ ์ค์งํ์ต๋๋ค.
๊ทธ๋ฌ๋ ์ด stackoverflow ์ค๋ ๋๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์ด ์ต์ ์ ์ผ๋ฉด ์ ํ ๊ฒ์ฌ๊ฐ ์ ํ๋ฉ๋๋ค. VS ์ฝ๋ ๋๋ ํ์ดํ์คํฌ๋ฆฝํธ ํ์ ๋๊ตฐ๊ฐ๊ฐ ์ด ์ต์ ์ ์ผค ๋์ ์ฅ๋จ์ ์ ์ค๋ช ํ ์ ์๋ค๋ฉด ๊ฐ์ฌํฉ๋๋ค.
@mjbvz
์ ์๋ํฉ๋๋ค! ๊ฐ์ฌ ํด์!
ํ๋์ ๋ช
๋ น์ผ๋ก ์ด๋ฌํ ์ค๋ฅ์ ๋ํด "๋ชจ๋ ์์ "์ ์คํํ ์ ์์ต๋๊น?
Typescript๊ฐ ์๋ ๋ค๋ฅธ ์ธ์ด๋ ์ด๋ป์ต๋๊น? ์๋ฅผ ๋ค์ด, ํ๋ก์ ํธ์ ์๋ฐฑ ๊ฐ์ PHP ํ์ผ์ด ์๊ณ ๊ฐ๋ณ ํ์ผ์ ๋ํด Intellephense ํ์ฅ์์ ๋ณด๊ณ ๋ ๋ฌธ์ ๋ฅผ ๋ณผ ์ ์์ง๋ง ์ค์ ๋ก ์ํ๋ ๊ฒ์ ์ ์ฒด ์์ ๊ณต๊ฐ์ ๋ํด ์ง๋จ์ ์คํํ๋ ๊ฒ์ ๋๋ค.
์, ์ด๊ฒ์ ๋ํ ESLint๊ฐ node_modules
("ESLint: ๊ตฌ์ฑ์ ๋ก๋ํ์ง ๋ชปํ์ต๋๋ค"๊ฐ ๊ฑฐ๊ธฐ์ ์๋ ๋๋ ํ ๋ฆฌ๋ฅผ ํธ๋กค๋งํ ๋)๋ก ๊ฐ์ ๊ธ๊ฐํ๋ฅผ ํ๋ ๋ฌธ์ ๋ฅผ ์ผ์ผํต๋๋ค. ์ด ๋ฒ๊ทธ๋ฅผ ๋ฆฐํฐ๋ณ๋ก ํจ์นํ๋ ค๊ณ ํ๋ ๋์ ๋ธ๋๋ฆฌ์คํธ ๋๋ ๋ฌด์ธ๊ฐ๊ฐ ํ์ํฉ๋๋ค.
node_modules๋ฅผ ์ ์ธํ๋ ๊ฒ์ no1 ์์ ์ฌํญ์ด ๋ ๊ฒ์ ๋๋ค :)
์ด๊ฒ์ ๋ถํ ์ด ๊ฐ๋ฅํ ๊ฒ์ฒ๋ผ ๋ณด์ด์ง๋ง - ๊ทํ์ ๋ง์ผ๋ฆฌ์ง๋ ๋ค๋ฅผ ์ ์์ผ๋ฉฐ ๋ฌผ๋ก ๋ณด์ฆ์ ์์ต๋๋ค.
package.json์ typescript 3.9.2๊ฐ ์๊ณ VSCode์ ์์ ๊ณต๊ฐ์์ ํด๋น ๋ฒ์ ์ ์ ํํ๋ค๋ฉด:
: ./patches/typescript+3.9.2.patch
diff --git a/node_modules/typescript/lib/tsserver.js b/node_modules/typescript/lib/tsserver.js
index 2b6f035..ac6c9b4 100644
--- a/node_modules/typescript/lib/tsserver.js
+++ b/node_modules/typescript/lib/tsserver.js
@@ -149353,7 +149353,7 @@ var ts;
return;
}
// No need to analyze lib.d.ts
- var fileNamesInProject = fileNames.filter(function (value) { return !ts.stringContains(value, "lib.d.ts"); }); // TODO: GH#18217
+ var fileNamesInProject = fileNames.filter(function (value) { return !ts.stringContains(value, "lib.d.ts") && !ts.stringContains(value, "node_modules"); }); // TODO: GH#18217
if (fileNamesInProject.length === 0) {
return;
}
npm install
๋๋ yarn
= ์ด์ต?
@mjbvz ๋๋ ์ด๊ฒ์ ํ์ฑํํ๋ ค๊ณ ์๋ํ๊ณ ๋๋ ๊ทธ๊ฒ์ ๋ ๋์ ๋น๊ตํ์ฌ "์ฝ๋ ๋์ฐ๋ฏธ(๋ ๋๋ฌ)" ํ๋ก์ธ์ค์์ ๊ฝค ๋์ CPU ์ฌ์ฉ๋์ ๋ด ๋๋ค. ์ด๊ฒ์ด ๊ด๋ จ์ด ์๋ ๊ฒ ๊ฐ์ต๋๊น(ํ๋ก์ธ์ค ์ด๋ฆ์ "๋ ๋๋ฌ"๋ ๊ทธ๋ ์ง ์๋ค๊ณ ์ ์ํ์ง๋ง ๋ช ๋ฒ ํ ๊ธํ์ต๋๋ค). ํ๋ก์ ํธ๋ ํฌ์ง ์์ต๋๋ค(https://github.com/Dart-Code/Dart-Code).
์์ํ ์ง์๋์ง๋ ์์ง๋ง MacBook ํฌ์ ์ถฉ๋ถํ ํ์ ์์ผ ์ง๊ธ ๋น์ฅ์ ์ผ๊ธฐ๋ณด๋ค๋ ๊บผ ๋์ ๊ฒ์ ๋๋ค.
์ง๊ธ๊น์ง์ ์ด๋ค ์กฐ์ฌ๊ฐ ๋ ์ด์ "typescript.tsserver.experimental.enableProjectDiagnostics"
ํญ์ ๋ชจ๋ ์ ๋ค์ด๋น ๋ด๋ถ์ ํ์ผ node_modules
, ๋ฆฐํฐ์ CONFIGS ์ค์ ์์ ์ฐ๋ฆฌ์ ๋ค์ํ ์๋๊ฐ ์คํจ์๋ ๋ถ๊ตฌํ๊ณ ํผํ๊ธฐ ์ํด node_modules
?
์ด ์ ์ฌ์ ์ผ๋ก ๋ฉ์ง ๊ธฐ๋ฅ์ ์์น ์๋ ํ์ผ ๋ฐ ๋๋ ํฐ๋ฆฌ๋ฅผ ๋ฐ๋ณตํ์ฌ ๋ฐ์ํ๋ ๊ณผ๋ํ CPU ๋ณ๋์ผ๋ก ์ธํด ์์ ํ ์ฃฝ๊ธฐ ๋๋ฌธ์ ์ค๋ง์ค๋ฝ์ต๋๋ค... ๐ข
PROBLEMS
ํจ๋์ ๋ํ๋๋ node_modules
TypeScript ์ค๋ฅ์ ํจ๊ป ์์์ ์ธ๊ธํ @vdh ์ ๋์ผํ ๋ฌธ์ ๋ฅผ PROBLEMS
๋ด๊ฐ ์ผ์ผํจ ๊ตฌ์ฑ ๋ฌธ์ .
๋ค์๊ณผ ๊ฐ์ ๋ค์ํ tsconfig.json
์ค์ ์ ์๋ํ์ต๋๋ค.
"exclude": ["node_modules", "./node_modules/*"],
๋ฌธ์ ๊ฐ ๋ณด์ด๋์ง ์๋์ง์ ํจํด์ด ์๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๋ด๊ฐ ์์ฌ๋๋ ๋ช ๊ฐ์ง ์ผ์ด ์ผ์ด๋๊ณ ์์์ ์ ์์ต๋๋ค.
์์ ์์ ์ ๋ํด ์์ ํ ํ์ ํ์ง ๋ชปํด์ ํผ๋์ค๋ฌ์ธ ์ ์์ต๋๋ค. ๊ด๋ จ์ด ์์ ์ ์๋ ๋ ๋ค๋ฅธ ์ผํ๋ฅผ ์ถ๊ฐํ๋ ๊ฒ๋ฟ์ ๋๋ค. ํ์ฌ ๋ฒ์ ์์ ์ฌ์ ํ ๋ฌธ์ ๋ฅผ ๋ณด๊ณ ์๋ ์ฌ๋์ด ๋ช ๋ช ์๋ค๋ฉด ์ ๋ฌธ์ ๋ฅผ ์ ์ถํ ๊ฐ์น๊ฐ ์์ต๋๋ค. ์์ง ํด๋ณด์ง ์์์ ํ์คํ์ง ์์ต๋๋ค.
๋๋ ๊ฐ์ ๋ฌธ์ ๊ฐ ์์๊ณ #90430์ ํด๊ฒฐ์ฑ ์ typescript-tslint-plugin ์ ์ฌ์ฉํ๋ ๊ฒ์ด์์ต๋๋ค.
@enko TSLint๋ 2019๋ ๋ถํฐ ESLint ๋ฅผ ์ํด ๋ ์ด์ ์ฌ์ฉ๋์ง ์์ผ๋ฉฐ ์ฌ์ฉ๋์ง ์๋ linter์ ๋ํ ํ๋ฌ๊ทธ์ธ์ ์นํธํ๋ ๊ฒ์ ์ด ๋ฌธ์ ์ ๋ํ ์ข์ ์๋ฃจ์ ์ด ์๋๋๋ค.
typescript.tsserver.experimental.enableProjectDiagnostics
๋ฅผ ๋นํ์ฑํํด์ผ ํ์ต๋๋ค.
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
๋งค์ฐ ๋๋ฆผ( ๋จ์ผ ํ์ผ์ ์ ์ฅํ๋ ๋ฐ 2๋ถ).
๋ํ ๋ํ๋๊ฑฐ๋ ์ฌ๋ผ์ง๋ node_modules์์ ์์์ TS ์ค๋ฅ๋ฅผ ๋ฐ๊ฒฌํ์ต๋๋ค.
์์
์์ applyTo
์ฌ๋ฐ๋ฅด๊ฒ ์ค์ ํ๋ฉด ์ค์ ๋ก ์๋ํ๋ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
ํ์ฌ ๋ณด๊ธฐ์ ์๋ ํ์ผ์ ๊ฒฝ์ฐ์๋ ์ปดํ์ผ์ ๊ด์ฐฐํ๊ณ ๋ฌธ์ ์ฐฝ์ ๋ฌธ์ ๋ฅผ ๋ณด๊ณ ํ๋ ์ ์ฒด ์์ ์์ ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
{
"version": "2.0.0",
"tasks": [
{
"label": "tsc watch",
"type": "shell",
"command": "tsc",
"isBackground": true,
"args": ["--build", "--watch"],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "never",
"echo": false,
"focus": false,
"panel": "dedicated"
},
"problemMatcher": {
"base": "$tsc-watch",
"applyTo": "allDocuments"
}
}
]
}
@samesfahani-tuplehealth ์ด ์์
์ด enableProjectDiagnostics
์ ์ด๋ป๊ฒ ์ง์ ์ ์ผ๋ก ๊ด๋ จ๋๋์ง ๋งํ๋๋ก ์๊ฒฌ์ ์์ ํ๊ฑฐ๋ ์์ ์ด ์๋ ์์ _ํด๊ฒฐ ๋ฐฉ๋ฒ_์ผ๋ก ์ ์์ด๋ผ๊ณ ๋ค์
@vdh ์ถฉ๋ถํ ์์ ํ์ต๋๋ค. ์ด ๋ฌธ์ ๊ฐ ํนํ enableProjectDiagnostics
์ ๋๋ผ๊ณ ์๊ฐํ์ง๋ ์์ง๋ง; ๋น๋ฉดํ ๋ฌธ์ ๋ ํ์ฌ ํ์๋์ง ์๋ ํ์ผ์ ๊ฒฝ์ฐ์๋ ์ ์ฒด ํ๋ก์ ํธ์์ ๋ฌธ์ ๋ฅผ ๋ณผ ์ ์๋ค๋ ๊ฒ์ด์์ต๋๋ค.
์์น ์๋ node_modules
์ค๋ฅ ๋ฌธ์ ์ ๊ด๋ จํ์ฌ ํน๋ณํ ๋
ผ์ํ๊ธฐ ์ํด ์ ๋ฌธ์ ๋ฅผ ๋ง๋ค์์ต๋๋ค. https://github.com/microsoft/vscode/issues/103539
@vhd / @martaver / @blackfan23 / @patroza / @jgoux / other ... ํด๋น ๋ฌธ์ ์ ๋ํ ๋จ์๋ฅผ ๋ ์ถ๊ฐํ ์ ์๋ค๋ฉด ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๋ฐ ๋์์ด ๋ ์ ์์ต๋๋ค.
@jgoux ์ ๊ฐ์ ๋ฌธ์ ๋ "source.fixAll.eslint": true
์์๋ ์๋ํ์ง ์์ต๋๋ค. - eslint๋ ์ด๋ ค ์๋ ํ์ผ๋ฟ๋ง ์๋๋ผ ํ๋ก์ ํธ์ ๋ชจ๋ ํ์ผ์ ํ์ธํ๊ธฐ ์์ํ๊ณ ๋ชจ๋ ๋จ์ผ ๋ณ๊ฒฝ์ ๋ํด ์ ์ฒด ํ๋ก์ ํธ๋ฅผ ๋ค์ ํ์ธํฉ๋๋ค. VSCode๊ฐ ๋ฉ์ถฅ๋๋ค. ๊ธฐ๋ณธ ESLint ๋์์ ์์ ํ๋ ์ด์ ๋ฅผ ๋ชจ๋ฅด์ง๋ง ์ค์ ๋ก๋ ์ฐจ๋จ์
๋๋ค.
"typescript.tsserver.experimental.enableProjectDiagnostics"๋ ์ค์ ๋ก ์์ ๋ฐ ๊ฐ์ ๋์ด์ผ ํฉ๋๋ค. ์ด๊ฒ์ ํ์ดํ์คํฌ๋ฆฝํธ๋ฅผ ์ด๋ฏธ ์๋ ๊ฒ๋ณด๋ค ํจ์ฌ ๋ ๊ฐ๋ ฅํ๊ฒ ๋ง๋ค ๊ฒ์ ๋๋ค.
@samesfahani-tuplehealth๊ฐ ๊ฒ์ํ ์๋ฃจ์ ์ ๋งค์ฐ ์ ์๋ํฉ๋๋ค. ์ด๊ฒ์ ๊ฐ์ ธ์จ ์ ํ์ ํ ํ์ผ์์ ๋ค๋ฅธ ํ์ผ๋ก ์ด๋ํ๊ณ ๊ฐ์ ธ์ค๊ธฐ๊ฐ ์ค๋จ๋ ๋ชจ๋ ์์น๋ฅผ ์ฐพ์์ผ ํ ๋ ์ค์ํฉ๋๋ค. CPU ์ฌ์ฉ๋ฅ ์ด ๋์ง๋ ์์ง๋ง ํ์ํ ๋ ์คํํ ์ ์์ต๋๋ค.
@phatmann ๊ทธ๊ฑด ํด๊ฒฐ ๋ฐฉ๋ฒ์ด์ง , _์๋_ ์ ๋๋ค. ๊ธฐ๋ฅ์ ๋ฌด์ํ๊ณ _์์ ํ ๋ค๋ฅธ ๊ธฐ๋ฅ_์ ๋์ ์ฌ์ฉํ๋ ๊ฒ์ ์ฑ๋ฅ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๋ฐฉ๋ฒ์ด _์๋๋๋ค_. ๋๋ ์ด๊ฒ์ ๋ํด ๋์ง๊ธด ๊ฒ์ ์ซ์ดํ์ง๋ง ์ด ํ๋ฅญํ์ง๋ง ์คํ์ ์ธ ๊ธฐ๋ฅ์ ์์ ํ๋ ๋ฐ ๊ด์ฌ์ ๋๋ ๋ง์ ์์์ ์ํ์ง ์์ต๋๋ค. ๊ฐ์น๊ฐ ์๋ ๊ด์ฌ์ ๋ฐ์ผ๋ฉด ๋งค์ฐ ์ ์ฉํ ๊ฒ์ด ๋ ์ ์์ต๋๋ค.
@Vdh ๋ฌผ๋ก ๋ง์ต๋๋ค. (์ค์ ๋ก ์์ ์ ๋ ๊ฐ๋จํ ๋ฒ์ ์ธ ๋ด์ฅ tsk:watch ์์ ์ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ๋ํด ๋๊ฐ์ด ์ ์๋ํฉ๋๋ค). ๋ด ํผ๋์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ๋๋ฌด ํจ๊ณผ์ ์ด๊ณ ํจ์จ์ ์ด์ด์ ์ด ๋ฌธ์ ์์ ์ธ๊ธ๋ ์ค์ ๊ธฐ๋ฅ์ด ํ์ํ์ง ์๋ค๊ณ ์๊ฐํฉ๋๋ค. ๋ด๊ฐ ๋ญ๊ฐ๋ฅผ ๋์น๊ณ ์์ต๋๊น?
@phatmann Typescript ๊ฐ์ ์์ ์ ์คํํ๊ณ ์ถ๋ค๋ฉด ์ด๋ฏธ ์คํํ ์ ์์ต๋๋ค. ์ด๊ฒ์ ๋จ์ง TS ๊ฒ์ฌ๋ฅผ ์คํ์ ๋ํ ์์ต๋๋ค. ๊ทธ๊ฒ์ ๋ชจ๋ ํ๋ก์ ํธ ํ์ผ์ VSCode์ ๋ชจ๋ ๊ฒ์ฌ๋ฅผ ์คํํฉ๋๋ค. Typescript, ESLint, CSpell ๋ฑ... ํ์ผ์ ์ฌ๋ ๊ฒ์ ์์๋๋ผ๋ ์ ์ฒด ํ๋ก์ ํธ์์ ์ค๋ฅ๋ฅผ ์ฐพ์ ์ ์๋ค๋ ์ฌ์ค์ ์ ๋ง ๊ฐ๋ ฅํ๊ณ ์ ์ฉํฉ๋๋ค(๋ชจ๋ ํ์ผ์์ ์๋์ผ๋ก ๊ฐ ๋ฆฐํฐ๋ฅผ ์คํํ์ง ์๊ณ ๋ ํฐ๋ฏธ๋์์ ์ธ๋ถ๋ก).
ํ์ฌ ์ ์ผํ ์ฃผ์ ๊ฒฐํจ์ node_modules
์ ๊ฐ์ด ์ผ๋ฐ์ ์ผ๋ก ๊ธ์ง๋ ํด๋๋ฅผ ํฌํจํ์ฌ ๋ง ๊ทธ๋๋ก ๋ชจ๋ ํ์ผ์ ์ง๋์น๊ฒ ์คํํ๋ค๋ ๊ฒ์
๋๋ค.
vscode๋ก ์ด๋ป๊ฒ ํด์ผํ ์ง ๊ฒ์ํ์ง๋ง ์ป์ ๊ฒ์ 4๋ ๋ฏธํด๊ฒฐ ๋ฌธ์ ... ๐ข
๋์ ์ผ๋ง์ด๊ณ ์ด๋๋ก ๋ณด๋ด์ผ ํฉ๋๊น?
node_modules๋ฅผ ์ค์บํ๋ ์ด ๊ธฐ๋ฅ์ CPU ๋ฌธ์ ๋ ๋ฌธ์ ๊ฐ ์๋ ๊ฒฝ์ฐ ๋ค์์ ํฌํจ tsconfig.json
์ด ์๋์ง ํ์ธํ์ญ์์ค.
"files": []
๊ทธ๋ ์ง ์์ผ๋ฉด ๊ธฐ๋ณธ๊ฐ์ tsconfig๊ฐ ํฌํจ๋ ํด๋ ๋๋ ๊ทธ ์๋์ ์๋ ๋ชจ๋ TypeScript ํ์ผ์ ํฌํจํ๋ ๊ฒ์ด๋ฏ๋ก ๋๋ฌด ๋ง์ ํ์ผ์ ๋ถ์ํ ์ ์์ต๋๋ค.
์ด ๊ธฐ๋ฅ์ ์์ฌ ์์ ๊ณต๊ฐ๊ณผ ๋ณตํฉ ์ ํ ์คํฌ๋ฆฝํธ "ํ๋ก์ ํธ"๋ฅผ ์ฌ์ฉํ๋ ๋๊ท๋ชจ ๋ชจ๋ ธ๋ ํฌ์์ ์ ์๋ํฉ๋๋ค.
ํ๋ฅญํ ์กฐ์ธ @dinofx. ๋ํ ๋ฌธ์์ ๋ฐ๋ผ files
๋์ include
๋ฐ exclude
์ฌ์ฉํ ์ ์์ต๋๋ค.
"include": ["src/**/*"],
"exclude": ["node_modules", "test/**/*"],
๋ง์ต๋๋ค. ํ์ง๋ง "ํฌํจ" ๊ธ๋ก๋ธ์ ์ผ์นํ์ง ์๋ ๊ฒ์ ์ ์ธํ ํ์๋ ์์ต๋๋ค.
"files": []
๋ "์์
๊ณต๊ฐ" tsconfig.json ํ์ผ(๋ง์ ๋ค๋ฅธ tsconfig.json ํ์ผ์ ์ฐธ์กฐํ๋ ํ์ผ)์ ๋ํด ๋ ๊ฐ๊ฒฐํฉ๋๋ค. ์ ๋ฌธ์ํ๋์ด ์์ง๋ ์์ง๋ง ํจํค์ง ๋ฐ ์์
๊ณต๊ฐ์ ๋ํ ๊ตฌ์ฑ ํ์ผ์ ์ด๋ฆ์ tsconfig.json
. ๊ทธ๋ ์ง ์์ผ๋ฉด ๋ง์ ๊ธฐ๋ฅ์ด ์ ๋๋ก ์๋ํ์ง ์์ต๋๋ค(์ด ๊ธฐ๋ฅ, ์ฐธ์กฐ ์ฐพ๊ธฐ, ๋ฆฌํฉํ ๋ง ๋ฑ).
ํ์ฅ๋ ๊ณต์ ๊ตฌ์ฑ์ ๊ฒฝ์ฐ tsconfig.browser.json
, tsconfig.node.json
๋ฑ๊ณผ ๊ฐ์ ์ด๋ฆ์ ์ง์ ํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ๊ทธ ์ด๋ฆ์ "files"
๋๋ "includes"
์ด๋ฏ๋ก ์๋ตํ ์ ์์ต๋๋ค.
@dinofx ํ์ผ ์ํ ๋ฌธ์ ๋ Typescript์๋ง ๊ตญํ๋์ง ์์ต๋๋ค. ๋ํ ๋ชจ๋ ์ฌ๋์ด ๋ชจ๋ ธ๋ ํฌ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ์๋๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ฃ์ง์์ ์ด๊ณ ์ถ์ ์ฌ๋๋ค์ ์ํด ๋ค์ VS Code ๋ด๋ถ์ ๋น๋๋ ์คํ์ ์ธ ํ๋ก์ ํธ ์ ์ฒด์ ์ค๋ฅ ๋ณด๊ณ ๋ฅผ ๊ฐ๋ฅํ๊ฒ ํ๋
"typescript.tsserver.experimental.enableProjectDiagnostics"
์ค์ ์ ๋์ ํฉ๋๋ค.์ด๊ฒ์ ์์ฐ ์ค๋น๊ฐ ๋์ง ์์๋ค๋ ์ ์ ์ ์ํ์ญ์์ค! ๋๊ท๋ชจ ํ๋ก์ ํธ์ ๋ํ ์ฑ๋ฅ ๋ฌธ์ ๊ฐ ์๋ ค์ ธ ์์ผ๋ฉฐ ์ธํ ๋ฆฌ์ผ์ค๊ฐ ์์๋ ์ ์์ต๋๋ค.
์ด ์ค์ ์ ์ฌ์ฉํ๋ ๋์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ฉด ์ ๋ฌธ์ ๋ฅผ ์ด์ด์ฃผ์ธ์.