mattpocock / mattpocock/ts-error-translator
Error: Cannot read properties of undefined (reading 'filter')
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.5k
- Forks
- 92
- PR merge metrics
- No merged PRs in 30d
Description
Description
Encountered an unhandled TypeError during the execution of updateDiagnostics function in the TypeScript error translator extension for VSCode. The error suggests an issue with reading properties of an undefined object, specifically when attempting to filter diagnostics.
Error Details
- Type: TypeError
- Message: Cannot read properties of undefined (reading 'filter')
- Location:
updateDiagnosticsfunction at/Users/jobayerhossain/.vscode/extensions/mattpocock.ts-error-translator-0.10.1/out/extension.jsline 61730:36 - Handled: No
Stack Trace
TypeError: Cannot read properties of undefined (reading 'filter')
at /Users/jobayerhossain/.vscode/extensions/mattpocock.ts-error-translator-0.10.1/out/extension.js:61730:36
Code Snippet
try {
// Existing code that might throw an error
} catch (e) {
// Error handling
}
helperDiagnostics.set(
document2.uri,
uriStore[document2.uri.path].filter(tipHasNoDepsOrAllDepsCompleted).filter((tip) => !isTipComplete(tip.type)).map((tip) => {
const diagnostic = new vscode5.Diagnostic(
tip.range,
tip.type,
vscode5.DiagnosticSeverity.Information
);
diagnostic.source = "total-typescript";
return diagnostic;
})
);
Potential Issue
The error appears to be related to the assumption that uriStore[document2.uri.path] is always defined and can be filtered. This may not be the case, leading to the TypeError when attempting to call .filter() on an undefined object.
Steps to Reproduce
- Install the TypeScript error translator extension (version 0.10.1) in VSCode.
- Trigger the
updateDiagnosticsfunction under conditions that lead touriStore[document2.uri.path]being undefined.
Expected Behavior
updateDiagnostics should handle cases where uriStore[document2.uri.path] is undefined, avoiding any TypeErrors related to calling .filter() on undefined.
Actual Behavior
The application throws a TypeError when it attempts to filter on an undefined object within the updateDiagnostics function.
Environment
- Node Version: v18.15.0
- macOS Version: 14.0
- Architecture: arm64
- Environment: production
- Error Level: error
- Error Mechanism: onunhandledrejection
- OS: macOS 14.0
- Runtime: Node v18.15.0
- Release: 1.32.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the updateDiagnostics function in out/extension.js around line 61730 and inspect how uriStore is populated and accessed for document2.uri.path. Reproduce the undefined-store case described in the issue, then verify that updateDiagnostics no longer throws when that entry is missing and that diagnostics still update for defined entries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100