feat(cli): respect TypeScript suppression directives for import diagnostics#33280
Draft
ddevilz wants to merge 5 commits intodenoland:mainfrom
Draft
feat(cli): respect TypeScript suppression directives for import diagnostics#33280ddevilz wants to merge 5 commits intodenoland:mainfrom
ddevilz wants to merge 5 commits intodenoland:mainfrom
Conversation
…ostics This change adds support for @ts-ignore and @ts-expect-error directives for import-related diagnostics in the CLI type checker. Features: - Single-line and block comment support - Multi-line import handling - AST-based detection for accuracy - Parsed source caching for performance - Comprehensive test coverage Fixes denoland#32822
- Replace private HashMap<ModuleSpecifier, ParsedSource> on GraphWalker with a shared &ParsedSourceCache threaded from TypeChecker, eliminating redundant re-parsing of source files during type checking - Extract duplicated cache-lookup-parse-store logic into check_suppressed_at() - Add comment on item_start_line == 0 guard explaining u32 underflow prevention - Document @ts-expect-error / TS2578 limitation in is_resolution_suppressed - Add blank_line_gap integration spec test (comment + blank line → no suppression) - Remove tsgo_path and package_json_resolver from RequestNpmState (post-merge cleanup) - Add production/skip_types fields to NpmInstallerFactoryOptions (post-merge cleanup)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(cli): respect TypeScript suppression directives for import diagnostics
Fixes #32822
What
Respect TypeScript suppression directives (
@ts-ignoreand@ts-expect-error) for import-related diagnostics in the CLI type checker.Why
Previously, Deno's type checker ignored suppression comments for unresolved import errors, making it impossible to suppress known or intentional "module not found" diagnostics.
This behavior was inconsistent with developer expectations when using TypeScript suppression directives.
How
check_suppressed_at()helper function to centralize suppression checking logicis_resolution_suppressed()to use AST-based detection for accurate positioningGraphWalkerto check for suppression before pushing tomissing_diagnostics//) and block (/* */) comment formatsBehavior
Before
After
Also supports multi-line imports:
Features
// @ts-ignoreand// @ts-expect-error/* @ts-ignore */and/* @ts-expect-error */Design Notes
get_leading()to avoid false positives from inline comments on preceding statementsTesting
Comprehensive test suite covering all suppression scenarios
Tests include:
All tests pass in
x test-spec ts_ignore_importImplementation Details
cli/type_checker.rs,cli/factory.rsparsed_source_cachetoGraphWalkerfor efficient parsingcheck_suppressed_at()helper function to reduce code duplicationChecklist
./x fmtpasses./x lintpasses./x test-spec ts_ignore_importpasses// @ts-expect-erroror// @ts-ignorecomment #32822)AI Disclosure
I used AI assistance to help with implementation, test writing, and drafting this PR description.