Today, after restarting my computer and launching visual studio code, I encountered an unfamiliar error that I've never seen before:
https://i.sstatic.net/z1vw5.png
I haven't made any changes to my project's code (confirmed by running git status
). It's unclear whether this issue emerged today or if it has been occurring unnoticed for some time. However, five days ago, these errors were not present, even though the problematic code has been in place longer than that. Here is the snippet causing the error:
} catch (e) {
if (typeof e === "string") {
throw new Error(
`...: ${e}`
);
} else {
e.message = `... ${e.message}`;
throw e;
}
}
When running tsc
or eslint
, no complaints are raised about this particular error. My preference is for vscode to identify issues in line with tsc/eslint rules rather than implementing its own type checking protocols. How can I resolve these discrepancies?
I'm unsure of what I need to rectify. Perhaps attaching my settings could shed some light on the situation:
user
{
"files.autoSave": "afterDelay",
"explorer.confirmDelete": false,
"security.workspace.trust.untrustedFiles": "open",
"explorer.confirmDragAndDrop": false,
"docker.showStartPage": false,
"editor.fontSize": 14,
"editor.renderWhitespace": "all",
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"typescript.tsserver.experimental.enableProjectDiagnostics": true
}
Although toggling
typescript.tsserver.experimental.enableProjectDiagnostics
had no impact on the error message.
workspace
{
"workbench.editorAssociations": {
"*.ipynb": "jupyter-notebook"
},
"notebook.cellToolbarLocation": {
"default": "right",
"jupyter-notebook": "left"
},
"python.formatting.provider": "black",
"eslint.workingDirectories": [
"./firebase/functions",
],
"eslint.format.enable": false,
"prettier.enable": true,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"typescript.format.semicolons": "insert",
"editor.detectIndentation": false,
"prettier.configPath": "firebase/functions/.prettierrc.json"
}
Below is a redacted version of my package.json file:
{
"name": "...",
"scripts": {
"lint": "eslint .",
"build": "tsc --build .",
"test": "npm run lint && npm run build && ...",
...
},
"engines": {
"node": "12"
},
"main": "lib/index.js",
"dependencies": {
"@firebase/testing": "^0.20.8",
"@types/child-process-promise": "^2.2.1",
"@types/follow-redirects": "^1.13.0",
"@types/node-fetch": "^2.5.7",
"@types/progress": "^2.0.5",
"@types/request": "^2.48.7",
"@types/uuid": "^8.3.0",
...
},
"devDependencies": {
"@types/mocha": "^9.0.0",
"@types/node": "^14.10.2",
"@typescript-eslint/eslint-plugin": "^4.28.5",
"@typescript-eslint/parser": "^4.28.5",
"eslint": "^7.31.0",
"firebase-functions-test": "^0.2.2",
"lodash": "^4.17.21",
"mocha": "^8.1.3",
"prettier": "^2.3.2",
"typescript": "^3.9.7"
...
},
"private": true
}
(The package.json file contains unrelated complexities, which I apologize for; they are part of the legacy system that I am actively working on enhancing).
Here is my tsconfig.json:
{
"compilerOptions": {
"rootDir": ".",
},
"files": [],
"references": [
{
"path": "./src"
},
{
"path": "./test"
},
]
}
Note that this file resides in ./firebase/functions
, not at the project root level.
Provided below is the
./firebase/functions/src/tsconfig.json
:
{
"compilerOptions": {
"module": "commonjs",
"outDir": "../lib",
"noImplicitReturns": true,
"noUnusedLocals": true,
"sourceMap": true,
"strict": true,
"lib": ["es2020", "dom"],
"target": "es2019",
"composite": true,
"allowSyntheticDefaultImports": true
},
"compileOnSave": true,
"types": ["node", ...],
"include": ["**/*.ts"]
}
Lastly, the contents of
./firebase/functions/test/tsconfig.json
are as follows:
{
"compilerOptions": {
"module": "commonjs",
"outDir": "../libtest",
"strict": false,
"composite": true,
"sourceMap": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
},
"include": [
"**/*.ts"
]
}
What steps should I take to align visual studio code's error reporting with that of my tsc and eslint setups - maintaining consistency without unnecessary deviations?