TS conformance: pilot per-node *.types baseline parity
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- csharp, typescript
Direzione di ricerca
Inizia con tests/conformance/SharpTS.TypeScriptConformance/TypeScriptConformanceRunner.cs e con i test completati del parser/resolver della Fase 1, quindi esamina TypeMap.cs, SourceDocument.cs, SpanTable.cs e TypeInfoDeclarationRenderer.cs. Esegui il progetto esplicito di conformità TypeScript per stabilire la baseline attuale. Il lavoro è concluso quando il pilot fisso produce osservazioni strutturate di SharpTS, le confronta con le baseline *.types fissate, segnala la copertura non supportata o mancante e documenta i propri risultati indipendenti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Follow-up to the completed diagnostic-parity campaign in #1281. Reactivated after the original deferral gates were cleared: the pinned lib.*.d.ts graph is loaded, the checker exposes expression types through TypeMap, source spans are retained, deterministic TypeScript type rendering exists for declaration emit, and the language server now has checker-backed semantic infrastructure.
Goal
Add a small, trustworthy *.types conformance track that compares SharpTS's per-node inferred types with the pinned TypeScript compiler's committed tests/baselines/reference/*.types files.
The existing diagnostics track answers “did both compilers report the same (line, TSnnnn) errors?” This track answers the complementary question: “when both compilers accept the program, did SharpTS infer the same types?” It should expose silent widening, narrowing, generic-inference, conditional-type, overload-return, and accidental-any divergences.
This issue deliberately covers *.types only. TypeScript's *.symbols baselines exercise a distinct binding/member/alias surface and should be planned separately after the type-query path is proven.
Evidence and starting point
At the pinned TypeScript v6.0.3 revision (050880ce59e30b356b686bd3144efe24f875ebc8):
- The upstream tree contains 14,016 tracked
*.typesbaseline files, including harness-configuration variants. - The committed SharpTS diagnostic subset is now 534/534
Pass. Of those 534 tests, 531 have at least one matching upstream*.typesbaseline family by basename; selecting the compatible configured variant remains part of Phase 1. - All eleven specifically named pilot candidates below are diagnostic
Passand have a plain upstream*.typesbaseline at the pin. - TypeScript's
TypeWriterWalkervisits expressions, identifiers, and declaration names in AST preorder; it skips most type-only nodes, queriesgetTypeAtLocation, and renders with a non-truncating type printer. - Upstream type baselines interleave source text with observations such as
>expression : inferred typeand an underline line.
Relevant SharpTS seams:
tests/conformance/SharpTS.TypeScriptConformance/TypeScriptConformanceRunner.cs— metadata, virtual multi-file program construction, directive mapping, resolver setup, checker execution, and target-specific baseline selection.src/SharpTS/TypeSystem/TypeMap.cs— resolved types keyed by expression identity.src/SharpTS/Parsing/SourceDocument.cs/SpanTable.cs— source ownership and spans.src/SharpTS/Parsing/Visitors/AstVisitorBase.cs— exhaustive AST traversal.src/SharpTS/Declaration/TypeInfoDeclarationRenderer.cs— deterministic TypeScript syntax rendering, currently declaration-oriented and internal.src/SharpTS/TypeSystem/BindingIndex.cs— checker-owned token/declaration identities; useful later for*.symbols, but not part of this issue.
Current status (2026-08-29)
Phase 1 is implemented and validated in the current worktree; the change is not yet committed or merged. It adds a shared deterministic resolver for .errors.txt and .types, a source-backed TypesBaselineParser, checked-in fixtures, focused parser/resolver tests, and pinned-corpus integration coverage.
At the pinned revision, all 518 configuration-compatible .types baselines among the 534 diagnostic-pass tests resolve and parse successfully. Sixteen tests correctly produce NoBaseline: three have no basename-matching .types family, and thirteen expose only target/module variants outside the runner's selected configuration. The explicit TypeScript conformance project passes all 384 test methods, including the unchanged 534/534 diagnostic aggregate.
Phases 2–6 remain unimplemented. The existing executable conformance track remains diagnostics-only; Phase 1 intentionally does not produce or compare SharpTS type observations yet.
Design decisions
- Use a fixed pilot, not the whole corpus. Start with diagnostic-passing tests so type mismatches identify silent semantic differences rather than duplicating known diagnostic failures.
- Keep type conformance separate from diagnostic conformance. Do not change the meaning or closed vocabulary of
baselines/interpreted.txt, which is an external contract consumed bysharpts-www. - Compare structured observations, not raw files. Parse the upstream baseline into observations and compare those with observations produced from SharpTS nodes. Raw text equality would conflate source echo formatting, underlines, and semantic type differences.
- Do not normalize away semantics. Normalization may cover documented presentation-only equivalents, but must not erase alias preservation, literal widening, union constituents, optionality, overload selection, or
any/unknown/neverdifferences. - Make unsupported coverage visible. Missing node types and unsupported render shapes are measured outcomes, not silently skipped observations.
- Build a reusable type-query/display surface. The production API should be usable by a later general TypeScript hover feature, but adding LSP hover is not part of this issue.
Implementation plan
Phase 1 — Parse and resolve upstream *.types baselines
- Add a
TypesBaselineParserthat reads file sections and produces ordered observations containing at least virtual filename, source line, source text, occurrence ordinal, expected type text, and optional underline metadata. - Cover single-file,
@filenamemulti-file, repeated identical source text, nested observations on one source line, blank lines, and types containing:/;/braces. - Generalize the existing target/configuration-aware baseline resolver so
.errors.txtand.typesselect the same configured variant instead of developing two naming algorithms. - Treat a missing upstream
*.typesfile asNoBaseline, distinct from parser or harness failure. - Add parser/resolver unit tests using small checked-in fixtures modeled on the pinned upstream format.
Phase 2 — Expose types for the node categories TypeScript measures
- Retain the
TypeMapreturned byTypeChecker.CheckModulesin the conformance program result instead of discarding it. - Add a checker-owned query index for source-backed declaration/name tokens that are not expressions. Keep expression storage compatible with existing compiler/interpreter consumers.
- Populate the query index at the semantic resolution points for:
- variable and parameter declarations/usages;
- function, class, interface, enum, namespace, and type-alias names where SharpTS has a resolved value/type;
- property/member names when the containing access or declaration has a resolved member type;
- type-alias declaration names using the evaluated alias body, matching upstream's useful expansion behavior.
- Never invent types for parse-recovery or synthetic nodes. Hidden/no-source nodes must remain absent and be reported as coverage gaps when upstream contains an observation.
- Add focused checker tests proving shadowed names, nested scopes, class value-vs-instance meaning, property accesses, aliases, and recovered programs return the intended source-node type.
Phase 3 — Add a stable conformance display renderer
- Extract/generalize
TypeInfoDeclarationRendererinto a deterministicTypeInfodisplay service shared by declaration emit and conformance. Avoid duplicating two large type switches. - Add an explicit conformance display mode for TypeScript-compatible choices such as literal preservation, alias expansion where requested, union/intersection ordering, overload display, anonymous object shapes, type parameters, conditional/mapped/indexed-access types, and recursion/cycle handling.
- Make formatting culture-invariant and non-truncating.
- Return a typed
UnsupportedTypeDisplayresult for shapes that cannot yet be represented; do not degrade them toanyorToString(). - Add golden unit tests for every currently supported
TypeInfofamily and targeted tests for known presentation differences fromtsc.
Phase 4 — Produce SharpTS observations in compatible order
- Add a dedicated source-order/preorder walker modeled on the pinned TypeScript
TypeWriterWalkerselection rules: expressions, identifiers, and declaration names; skip type-only nodes except evaluated type-alias names. - Use each
ParsedModule'sSourceDocumentandSpanTableto retain virtual filename, source text, and stable ordering. Parent expressions must precede their contained expressions when upstream does the same. - Define an observation match key that survives harmless AST-shape differences while remaining unambiguous: virtual file + source line/span text + occurrence ordinal. Report ambiguous keys as harness errors rather than guessing.
- Classify differences as
TypeTextMismatch,MissingSharpTSObservation,ExtraSharpTSObservation,UnsupportedSharpTSType, orHarnessError. - Provide a readable failure diff and an environment switch analogous to
SHARPTS_TSCONFORMANCE_DUMP_FAILURESfor dumping full expected/actual observations.
Phase 5 — Add the pilot runner and independent committed baseline
- Refactor shared metadata/program construction out of
TypeScriptConformanceRunnerso diagnostics and type runners use identical virtual files, directives, libraries, resolver behavior, decorator mode, strictness options, and multi-file roots. - Add
TypeScriptTypesConformanceRunnerand a dedicatedconfig/types-subset.jsoncontaining explicit tests only. - Start with a diverse 10–12 test cohort drawn from the current 531-test diagnostic-pass/
*.types-baseline candidate pool, including:es2019/globalThisTypeIndexAccess.tses2021/logicalAssignment/logicalAssignment9.tstypes/conditional/inferTypes1.tstypes/conditional/inferTypesWithExtends2.tstypes/keyof/keyofIntersection.tstypes/literal/literalTypes1.tstypes/typeRelationships/assignmentCompatibility/intersectionIncludingPropFromGlobalAugmentation.tstypes/typeRelationships/subtypesAndSuperTypes/stringLiteralTypeIsSubtypeOfString.tstypes/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts- one library-surface test such as
es2017/es2017DateAPIs.ts - one bigint test such as
es2020/constructBigint.ts - one well-known-symbol/property-access test with a diagnostic
Pass
- Commit a separate, versioned
baselines/types.txtaggregate with a documented vocabulary such asPass,Mismatch,Unsupported,NoBaseline, andHarnessError. - Give the type baseline its own update switch (for example
SHARPTS_TSTYPES_UPDATE_BASELINE=1) and regression rules. APass -> anything elsetransition must fail; intentional baseline changes must be reviewed rather than absorbed. - Do not add the new vocabulary to
baselines/interpreted.txtor silently change the website's diagnostics aggregation.
Phase 6 — Triage and document the pilot
- Run the cohort against the pinned TypeScript revision and publish counts for matches, semantic mismatches, display-only mismatches, missing observations, and unsupported display shapes.
- For each mismatch, determine whether the first fix belongs in inference/checking, node coverage, or rendering. Add focused core tests before changing the aggregate baseline.
- Document the
.typestrack, configuration, update workflow, bucket meanings, pinned-revision requirement, and the distinction between semantic and display parity in the conformance README. - Publish the measured pilot result on this issue and link any coherent semantic follow-ups instead of expanding this issue into a general checker backlog.
Acceptance criteria
- The runner parses and compares upstream
.typesbaselines for single- and multi-file tests without invokingtscat test time. - The pilot cohort is fixed, documented, and uses the same compiler options/resolver world as diagnostic conformance.
- Expected and actual observations produce actionable structured diffs.
- Literal widening, union constituents, generic/conditional inference, and accidental
anydifferences remain observable. - Missing nodes and unsupported render shapes are never counted as passes or silently omitted.
-
baselines/types.txtis independent, versioned, deterministic, and regression-gated. - Existing diagnostic baseline output and its externally consumed format remain unchanged.
- Core tests and the explicit TypeScript conformance project pass; no Test262 baseline regression is introduced.
- The issue closes with a measured pilot report and separately filed follow-ups for semantic clusters worth implementing.
Validation
dotnet test tests/SharpTS.Tests/SharpTS.Tests.csproj -c Release
dotnet test tests/conformance/SharpTS.TypeScriptConformance/SharpTS.TypeScriptConformance.csproj -c Release
Also verify deterministic output with two consecutive type-baseline generations producing no diff.
Out of scope
- TypeScript
*.symbolsbaselines; file a separate issue after the type pilot establishes the common observation/baseline infrastructure. - JavaScript
*.jsemit baselines (#87). - Running
tscdynamically or regenerating Microsoft's reference files. - Full-corpus rollout in the first implementation.
- General TypeScript hover UI in
SharpTS.LanguageServer; this work should expose reusable APIs for that follow-up. - Changing TypeScript semantics intentionally documented as SharpTS product differences without an explicit project decision.
- Lingua principale
- C#
- Stelle
- 156
- Fork
- 4
- Merge medio
- 2h 32m
- PR unite (30g)
- 177
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nickna/SharpTS
-
LSP: verify the standalone editing contract and publish editor recipesForse già presa @nickna l’ha presa 1 giorno fa. Apertadocumentation enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
LSP: find checker-bound source class member referencesForse già presa @nickna l’ha presa 1 giorno fa. Apertaenhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
LSP: add full-mode call and constructor signature helpForse già presa @nickna l’ha presa 1 giorno fa. Apertaenhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
LSP: add full-mode lexical and member completion for live editingForse già presa @nickna l’ha presa 1 giorno fa. Apertaenhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 1/100
I maintainer di solito rispondono entro 1 giorno
-
LSP: add full-mode semantic hover for ordinary TypeScript symbolsForse già presa @nickna l’ha presa 1 giorno fa. Apertaenhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di nickna/SharpTS
Issue simili
-
[i18n] 安装实例完成后的成功提示未正确本地化Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
PCL-Community/PCL-CE#3658 ·
I maintainer di solito rispondono entro 1 giorno
-
Deploy & Patch-issues opprettes ikke: create-pnd-issues.yml har feilet hver uke siden 2025-09-08Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Altinn/altinn-auth#4359 ·
I maintainer di solito rispondono entro 1 giorno
-
アプリ: チャット 優先: 中 提案
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
yksr-melt/Meltype#243 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Workflows: a workflow stored with null conditions is skipped with an exception instead of runApertabug core
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
type/automation type/tech-debt
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno