deno
033a720f - feat(check): type-check doc snippets with native tsc (--doc/--doc-only)

Commit
112 days ago
feat(check): type-check doc snippets with native tsc (--doc/--doc-only) Native `deno check` warned and ignored `--doc`/`--doc-only`; this brings back doctest type-checking. For each local root, snippets are extracted (reusing `extract_snippet_files`) into pseudo-files with the synthetic `<file>#<start>-<end>.<ext>` specifier, materialized next to their source (so their imports resolve) behind an RAII cleanup guard, and fed into the native pipeline as roots: original + snippets for `--doc`, snippets only for `--doc-only`. The injected base-module import (an absolute `file://` URL stock tsc can't resolve) is rewritten to a co-located relative path; tsc diagnostics are remapped from the on-disk path back to the `#start-end` display specifier. Also fixes a pre-existing sync-types bug this exercises: an `importMap` that lives in a different directory than deno.json had its local targets rebased from the wrong base, yielding spurious TS2307. Local targets are now rebased from the import map file's own directory onto the project root (a no-op in the common co-located case). Re-enables check/typecheck_doc_{success,failure,in_markdown,duplicate_identifiers}.
Author
Parents
Loading