Initialize the AST-based False Positive Detector
Optionalconfig: ASTFalsePositiveDetectorConfigOptional configuration options
Clear all registered aliases (reset to defaults)
Filter false positives from diagnostics using AST context
This method processes TypeScript diagnostics and separates genuine errors from false positives based on AST context analysis.
Algorithm:
Performance:
Array of ts-morph diagnostics to filter
SourceFile for AST context
Result with genuine errors and filtered false positives
const diagnostics = sourceFile.getPreEmitDiagnostics();
const result = detector.filterDiagnostics(diagnostics, sourceFile);
console.info(`Genuine: ${result.genuine.length}`);
console.info(`False positives: ${result.falsePositives.length}`);
console.info('Filtered by context:', result.filteredByContext);
Get all registered path alias prefixes
Set of alias prefixes
AST-based False Positive Detector
Detects and filters false positive syntax errors using AST context instead of regex pattern matching. More accurate and equally fast as string-based approach. Works directly on ts-morph
Diagnosticobjects; AST-based alternative to FalsePositiveDetector.filterFalsePositives.Key Advantages over String-based Detector:
Use Cases
Constructor Parameters with "import" keyword
Super Calls with "import" variables
Multiple Decorators
Path Aliases in Imports
Example