-
-
Save mtimbs/0eaf27df08cff8f4ca4303de60bf617b to your computer and use it in GitHub Desktop.
{ | |
"compilerOptions": { | |
// project options | |
"lib": [ | |
"ESNext", | |
"dom" | |
], // specifies which default set of type definitions to use ("DOM", "ES6", etc) | |
"outDir": "lib", // .js (as well as .d.ts, .js.map, etc.) files will be emitted into this directory., | |
"removeComments": true, // Strips all comments from TypeScript files when converting into JavaScript- you rarely read compiled code so this saves space | |
"target": "ES6", // Target environment. Most modern browsers support ES6, but you may want to set it to newer or older. (defaults to ES3) | |
// Module resolution | |
"baseUrl": "./", // Lets you set a base directory to resolve non-absolute module names. | |
"esModuleInterop": true, // fixes some issues TS originally had with the ES6 spec where TypeScript treats CommonJS/AMD/UMD modules similar to ES6 module | |
"moduleResolution": "node", // Pretty much always node for modern JS. Other option is "classic" | |
"paths": {}, // A series of entries which re-map imports to lookup locations relative to the baseUrl | |
// Source Map | |
"sourceMap": true, // enables the use of source maps for debuggers and error reporting etc | |
"sourceRoot": "/", // Specify the location where a debugger should locate TypeScript files instead of relative source locations. | |
// Strict Checks | |
"alwaysStrict": true, // Ensures that your files are parsed in the ECMAScript strict mode, and emit “use strict” for each source file. | |
"allowUnreachableCode": false, // pick up dead code paths | |
"noImplicitAny": true, // In some cases where no type annotations are present, TypeScript will fall back to a type of any for a variable when it cannot infer the type. | |
"strictNullChecks": true, // When strictNullChecks is true, null and undefined have their own distinct types and you’ll get a type error if you try to use them where a concrete value is expected. | |
// Linter Checks | |
"noImplicitReturns": true, | |
"noUncheckedIndexedAccess": true, // accessing index must always check for undefined | |
"noUnusedLocals": true, // Report errors on unused local variables. | |
"noUnusedParameters": true // Report errors on unused parameters in functions | |
}, | |
"include": ["./**/*.ts"], | |
"exclude": [ | |
"node_modules/**/*" | |
] | |
} |
Some thoughts.
"removeComments": true, // Strips all comments from TypeScript files when converting into JavaScript- you rarely read compiled code so this saves space
Reading compiled code is pretty common, mainly when using a debugger and trying to set breakpoints on code in node_modules
.
I'd leave this as false
particularly if you are publishing a library. Whatever disk space you save setting it to true is unimportant. Leave it to your bundler to minify your code if you need it.
Some thoughts.
"removeComments": true, // Strips all comments from TypeScript files when converting into JavaScript- you rarely read compiled code so this saves space
Reading compiled code is pretty common, mainly when using a debugger and trying to set breakpoints on code in
node_modules
. I'd leave this asfalse
particularly if you are publishing a library. Whatever disk space you save setting it to true is unimportant. Leave it to your bundler to minify your code if you need it.
Yeah YMMV but I typically minify my compiled code with esbuild or webpack etc - even on the server. So everything is kind of unreadable (shipping sourcemaps helps stack traces etc). Thankfully a very intuitive setting so easy to understand how to change to suit your needs
Can I ask a question related to this?
You just did
nice work. thanks for sharing.
Good series