mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-27 17:38:11 +03:00
This is a long one. So, `instanceof` in Typescript is incredibly flimsy. There's a documented bug with what happens when you extend built-in classes, such as Error or Array. You can read more about it here: https://github.com/Microsoft/TypeScript/wiki/FAQ#why-doesnt-extending-built-ins-like-error-array-and-map-work However, this normally works fine. A previous commit moved some schemas from server/ to common/, our gameSpecific UGPT settings schemas. This caused them to break in an interesting way. For any schema recursive with a depth greater than 1, all errors would be ignored. Why on earth was this happening? Well Prudence passes errors up the stack with a "return Err" -> "if ret instanceof Err: return Err" kind of approach. This normally works fine. The real kicker here is that because server/ and common/ were on 0.9.7 and 0.9.8 respectively, the "Err" instance in question would actually be erased when ran at runtime. The "if ret instance of Err" would fail, because the Err would be from 0.9.7, not 0.9.8. This subtle difference in file results in catastrophic damage. In short. InstanceOf is a footgun. I hate it. Lets never do it again. Thanks.
43 lines
1002 B
JSON
43 lines
1002 B
JSON
// This is a base TSConfig for nice integration with IDEs such as VSCode.
|
|
// By default, VSCode reads `tsconfig.json` to know what it should typecheck
|
|
// in the editor. Since we want it to typecheck things like our tests, but
|
|
// we want to save disk space by not compiling them at runtime, we need two
|
|
// tsconfigs!
|
|
{
|
|
"extends": "../tsconfig.json",
|
|
"compilerOptions": {
|
|
"baseUrl": "src",
|
|
"outDir": "./js",
|
|
"target": "ES2020",
|
|
"lib": [
|
|
"ES2019",
|
|
// This is necessary because -- for some unknown reason -- the AWS SDK
|
|
// depends on the DOM. Do people even run the AWS SDK in the browser?
|
|
// I hope not.
|
|
// "DOM"
|
|
],
|
|
"typeRoots": [
|
|
"@types",
|
|
"node_modules/@types",
|
|
],
|
|
"paths": {
|
|
"tachi-common": [
|
|
"../../common/src"
|
|
],
|
|
"tachi-common/*": [
|
|
"../../common/src/*"
|
|
]
|
|
}
|
|
},
|
|
"ts-node": {
|
|
"require": [
|
|
"tsconfig-paths/register"
|
|
]
|
|
},
|
|
"include": [
|
|
"src/**/*.ts"
|
|
],
|
|
"exclude": [
|
|
"node_modules"
|
|
]
|
|
} |