ttsc 0.19.2 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/cmd/graphdump/main.go +2 -4
- package/cmd/ttsc/filter.go +12 -4
- package/cmd/ttsc/filter_resolves_flag_names_case_insensitively_test.go +53 -0
- package/cmd/ttsc/flags_gen.go +3 -3
- package/cmd/ttscgraph/dump.go +5 -7
- package/cmd/ttscgraph/run_dump_emits_only_checker_verified_member_relations_test.go +118 -0
- package/cmd/ttscgraph/serve.go +58 -308
- package/cmd/ttscgraph/serve_session_keeps_base_url_fallback_unchanged_test.go +49 -0
- package/cmd/ttscgraph/serve_session_keeps_esm_directory_candidate_unchanged_test.go +61 -0
- package/cmd/ttscgraph/serve_session_keeps_exports_blocked_file_candidates_unchanged_test.go +64 -0
- package/cmd/ttscgraph/serve_session_keeps_inactive_conditional_export_unchanged_test.go +66 -0
- package/cmd/ttscgraph/serve_session_keeps_lower_priority_module_candidate_unchanged_test.go +67 -0
- package/cmd/ttscgraph/serve_session_keeps_lower_priority_paths_pattern_unchanged_test.go +58 -0
- package/cmd/ttscgraph/serve_session_keeps_nonlongest_root_dirs_candidate_unchanged_test.go +54 -0
- package/cmd/ttscgraph/serve_session_reloads_commonjs_package_entry_for_esm_test.go +50 -0
- package/cmd/ttscgraph/serve_session_reloads_module_suffix_candidate_test.go +41 -0
- package/cmd/ttscgraph/serve_session_reloads_superseding_module_candidates_test.go +216 -0
- package/cmd/ttscgraph/serve_session_retries_failed_dump_test.go +103 -0
- package/driver/graph.go +12 -6
- package/driver/lsp.go +30 -0
- package/driver/program.go +37 -1
- package/driver/resolution_candidates.go +819 -0
- package/driver/windowsjunction/windowsjunction.go +40 -0
- package/go.mod +2 -0
- package/internal/graph/build.go +45 -11
- package/internal/graph/dump.go +312 -108
- package/internal/graph/dump_checkout_paths_are_stable_test.go +210 -0
- package/internal/graph/dump_diagnostics_ride_the_generation_that_built_it_test.go +9 -3
- package/internal/graph/dump_paths.go +172 -0
- package/internal/graph/dump_paths_are_portable_and_injective_test.go +93 -0
- package/internal/graph/dump_schema_version_matches_the_typescript_client_test.go +1 -1
- package/internal/graph/dump_uses_ecma_line_terminators_test.go +87 -0
- package/internal/graph/duplicate_variable_object_members_keep_first_declaration_test.go +61 -0
- package/internal/graph/edges.go +220 -5
- package/internal/graph/enum_members_carry_their_names_on_the_enum_node_test.go +131 -0
- package/internal/graph/graph.go +177 -5
- package/internal/graph/line_model.go +122 -0
- package/internal/graph/literals.go +175 -0
- package/internal/graph/literals_are_absent_when_the_type_admits_more_than_it_can_name_test.go +74 -0
- package/internal/graph/literals_cover_enum_members_the_graph_has_no_nodes_for_test.go +79 -0
- package/internal/graph/literals_do_not_depend_on_declaration_line_wrapping_test.go +84 -0
- package/internal/graph/literals_render_every_value_in_typescript_source_form_test.go +77 -0
- package/internal/graph/literals_resolve_through_alias_indirection_test.go +64 -0
- package/internal/graph/member_relation_edges_follow_checker_validity_test.go +85 -0
- package/internal/graph/member_relation_edges_preserve_checker_boundaries_test.go +191 -0
- package/internal/graph/member_relation_edges_reject_checker_invalid_pairs_test.go +119 -0
- package/internal/graph/node_ids_preserve_hash_bearing_components_test.go +41 -0
- package/internal/graph/node_modifiers_emit_union_strings_test.go +4 -1
- package/internal/graph/object_literal_members_ride_on_the_snapshot_test.go +192 -0
- package/internal/graph/object_member_signatures_preserve_literal_whitespace_test.go +67 -0
- package/internal/graph/object_members.go +229 -0
- package/internal/graph/provenance.go +88 -30
- package/internal/graph/source_texts_cover_every_resident_program_source_test.go +73 -0
- package/internal/graphsymbols/position_helpers_follow_ecma_line_terminators_test.go +66 -0
- package/internal/graphsymbols/provider.go +26 -91
- package/internal/lspserver/lsp_clean_didopen_refreshes_compiler_state_test.go +144 -0
- package/internal/lspserver/lsp_completion.go +109 -0
- package/internal/lspserver/lsp_completion_gate_never_refuses_a_matching_line_test.go +50 -0
- package/internal/lspserver/lsp_completion_hints_longest_trigger_wins_test.go +149 -0
- package/internal/lspserver/lsp_completion_hints_nearest_trigger_wins_test.go +37 -0
- package/internal/lspserver/lsp_completion_merges_into_upstream_response_test.go +149 -0
- package/internal/lspserver/lsp_completion_nearest_hint_replaces_nearest_filter_test.go +43 -0
- package/internal/lspserver/lsp_completion_preserves_completion_list_extensions_test.go +99 -0
- package/internal/lspserver/lsp_completion_refuses_hints_inside_a_string_literal_test.go +69 -0
- package/internal/lspserver/lsp_completion_replaces_full_filter_in_rank_order_test.go +85 -0
- package/internal/lspserver/lsp_completion_request.go +455 -0
- package/internal/lspserver/lsp_completion_scope.go +530 -0
- package/internal/lspserver/lsp_completion_scope_bench_test.go +41 -0
- package/internal/lspserver/lsp_completion_scope_classifies_regex_statement_and_operator_boundaries_test.go +39 -0
- package/internal/lspserver/lsp_completion_scope_ignores_jsdoc_bytes_in_literals_test.go +108 -0
- package/internal/lspserver/lsp_completion_scope_refuses_regex_hints_test.go +52 -0
- package/internal/lspserver/lsp_completion_trigger_uses_last_rune_test.go +24 -0
- package/internal/lspserver/lsp_deleted_watched_file_withdraws_plugin_diagnostics_test.go +110 -0
- package/internal/lspserver/lsp_didsave_keeps_the_incremental_changed_uri_path_test.go +78 -0
- package/internal/lspserver/lsp_hints_absence_is_not_an_error_test.go +46 -0
- package/internal/lspserver/lsp_hints_refresh_coalesces_concurrent_requests_test.go +82 -0
- package/internal/lspserver/lsp_hints_refresh_ignores_a_superseded_generation_test.go +40 -0
- package/internal/lspserver/lsp_hints_refresh_keeps_each_producer_isolated_test.go +64 -0
- package/internal/lspserver/lsp_hints_refresh_replaces_the_session_snapshot_test.go +66 -0
- package/internal/lspserver/lsp_hints_refresh_scheduled_by_editor_events_test.go +90 -0
- package/internal/lspserver/lsp_hints_refresh_serves_completion_while_running_test.go +91 -0
- package/internal/lspserver/lsp_index_byte_from_bounds_its_search_start_test.go +38 -0
- package/internal/lspserver/lsp_initialize_constrains_position_encoding_to_utf16_test.go +205 -0
- package/internal/lspserver/lsp_late_completion_trigger_is_reported_once_test.go +105 -0
- package/internal/lspserver/lsp_native_completion_hints_decode_flat_lint_wire_test.go +66 -0
- package/internal/lspserver/lsp_native_completion_hints_grouped_compatibility_boundary_test.go +60 -0
- package/internal/lspserver/lsp_native_plugin_source.go +315 -2
- package/internal/lspserver/lsp_native_resident.go +304 -0
- package/internal/lspserver/lsp_plugin.go +85 -8
- package/internal/lspserver/lsp_plugin_completion_resolve_stays_local_test.go +82 -0
- package/internal/lspserver/lsp_position_conversions_span_astral_and_combining_runes_test.go +119 -0
- package/internal/lspserver/lsp_proxy.go +601 -9
- package/internal/lspserver/lsp_refresh.go +70 -0
- package/internal/lspserver/lsp_resident_falls_back_when_serve_unsupported_test.go +43 -0
- package/internal/lspserver/lsp_resident_maps_verb_args_test.go +34 -0
- package/internal/lspserver/lsp_server.go +13 -1
- package/internal/lspserver/lsp_watched_file_changes_reach_compiler_caches_test.go +172 -0
- package/lib/TtscCompiler.d.ts +3 -1
- package/lib/TtscCompiler.js +5 -1
- package/lib/TtscCompiler.js.map +1 -1
- package/lib/TtscService.d.ts +13 -3
- package/lib/TtscService.js +6 -6
- package/lib/TtscService.js.map +1 -1
- package/lib/compiler/internal/project/readConfigJson.d.ts +30 -0
- package/lib/compiler/internal/project/readConfigJson.js +208 -0
- package/lib/compiler/internal/project/readConfigJson.js.map +1 -0
- package/lib/compiler/internal/project/readProjectConfig.js +53 -149
- package/lib/compiler/internal/project/readProjectConfig.js.map +1 -1
- package/lib/compiler/internal/residentTransformProcess.d.ts +15 -2
- package/lib/compiler/internal/residentTransformProcess.js +159 -39
- package/lib/compiler/internal/residentTransformProcess.js.map +1 -1
- package/lib/compiler/internal/runBuild.d.ts +6 -0
- package/lib/compiler/internal/runBuild.js +143 -44
- package/lib/compiler/internal/runBuild.js.map +1 -1
- package/lib/compiler/internal/startResidentTransform.d.ts +5 -1
- package/lib/compiler/internal/startResidentTransform.js +3 -1
- package/lib/compiler/internal/startResidentTransform.js.map +1 -1
- package/lib/compiler/internal/transformProjectInMemory.js +12 -2
- package/lib/compiler/internal/transformProjectInMemory.js.map +1 -1
- package/lib/flags/parser.d.ts +19 -0
- package/lib/flags/parser.js +78 -36
- package/lib/flags/parser.js.map +1 -1
- package/lib/flags/schema.d.ts +49 -11
- package/lib/flags/schema.js +94 -22
- package/lib/flags/schema.js.map +1 -1
- package/lib/internal/assertSafeExplicitCacheDirectory.d.ts +5 -0
- package/lib/internal/assertSafeExplicitCacheDirectory.js +26 -0
- package/lib/internal/assertSafeExplicitCacheDirectory.js.map +1 -0
- package/lib/launcher/internal/runTtsc.js +107 -69
- package/lib/launcher/internal/runTtsc.js.map +1 -1
- package/lib/launcher/internal/runTtsx.js +28 -41
- package/lib/launcher/internal/runTtsx.js.map +1 -1
- package/lib/launcher/internal/runtimeHooks.d.ts +15 -0
- package/lib/launcher/internal/runtimeHooks.js +18 -1
- package/lib/launcher/internal/runtimeHooks.js.map +1 -1
- package/lib/launcher/internal/watchTopology.d.ts +43 -0
- package/lib/launcher/internal/watchTopology.js +360 -0
- package/lib/launcher/internal/watchTopology.js.map +1 -0
- package/lib/plugin/internal/buildSourcePlugin.d.ts +14 -3
- package/lib/plugin/internal/buildSourcePlugin.js +247 -61
- package/lib/plugin/internal/buildSourcePlugin.js.map +1 -1
- package/lib/plugin/internal/loadProjectPlugins.js +63 -2
- package/lib/plugin/internal/loadProjectPlugins.js.map +1 -1
- package/lib/structures/ITtscCompilerTransformation.d.ts +16 -0
- package/lib/structures/internal/ITtscParsedProjectConfig.d.ts +2 -0
- package/package.json +8 -8
- package/shim/ast/shim.go +48 -3
- package/shim/astnav/go.mod +14 -0
- package/shim/astnav/go.sum +20 -0
- package/shim/astnav/shim.go +15 -0
- package/shim/checker/shim.go +113 -0
- package/shim/core/shim.go +47 -0
- package/shim/diagnosticwriter/lint.go +50 -0
- package/src/TtscCompiler.ts +5 -1
- package/src/TtscService.ts +37 -10
- package/src/compiler/internal/project/readConfigJson.ts +209 -0
- package/src/compiler/internal/project/readProjectConfig.ts +62 -158
- package/src/compiler/internal/residentTransformProcess.ts +197 -39
- package/src/compiler/internal/runBuild.ts +169 -47
- package/src/compiler/internal/startResidentTransform.ts +12 -1
- package/src/compiler/internal/transformProjectInMemory.ts +12 -1
- package/src/flags/parser.ts +113 -42
- package/src/flags/schema.ts +113 -31
- package/src/internal/assertSafeExplicitCacheDirectory.ts +29 -0
- package/src/launcher/internal/runTtsc.ts +117 -68
- package/src/launcher/internal/runTtsx.ts +29 -44
- package/src/launcher/internal/runtimeHooks.ts +30 -2
- package/src/launcher/internal/watchTopology.ts +466 -0
- package/src/plugin/internal/buildSourcePlugin.ts +326 -64
- package/src/plugin/internal/loadProjectPlugins.ts +80 -2
- package/src/structures/ITtscCompilerTransformation.ts +17 -0
- package/src/structures/internal/ITtscParsedProjectConfig.ts +2 -0
- package/tools/shim_audit/baseline.json +0 -3
- package/tools/shim_audit/main.go +42 -14
- package/tools/shim_audit/shim_dir_coverage_test.go +25 -0
- package/utility/flags_gen.go +3 -3
- package/utility/host.go +9 -3
package/driver/graph.go
CHANGED
|
@@ -30,14 +30,19 @@ const bundledScheme = "bundled:///"
|
|
|
30
30
|
// declaration files, script files, global augmentations, `typeRoots`
|
|
31
31
|
// entries). A change to any of them can affect every file.
|
|
32
32
|
// - Configs lists the project tsconfig followed by its `extends` ancestry.
|
|
33
|
+
// - Candidates maps each importing file to the resolution probes that precede
|
|
34
|
+
// its selected module target. They are a separate class from resolved
|
|
35
|
+
// edges: a probe's file appearing or changing can change an unchanged
|
|
36
|
+
// import's meaning.
|
|
33
37
|
//
|
|
34
38
|
// Keys and values use the same convention as the envelope's `typescript`
|
|
35
39
|
// map: project-relative slash paths, falling back to slash-normalized
|
|
36
40
|
// absolute paths outside the project root (see TransformOutputKey).
|
|
37
41
|
type TransformGraph struct {
|
|
38
|
-
Edges
|
|
39
|
-
Globals
|
|
40
|
-
Configs
|
|
42
|
+
Edges map[string][]string `json:"edges"`
|
|
43
|
+
Globals []string `json:"globals"`
|
|
44
|
+
Configs []string `json:"configs"`
|
|
45
|
+
Candidates map[string][]string `json:"candidates,omitempty"`
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
// NewTransformGraph computes the reference graph of a loaded program, keyed
|
|
@@ -50,9 +55,10 @@ func NewTransformGraph(prog *Program, cwd string) *TransformGraph {
|
|
|
50
55
|
return nil
|
|
51
56
|
}
|
|
52
57
|
graph := &TransformGraph{
|
|
53
|
-
Edges:
|
|
54
|
-
Globals:
|
|
55
|
-
Configs:
|
|
58
|
+
Edges: map[string][]string{},
|
|
59
|
+
Globals: []string{},
|
|
60
|
+
Configs: []string{},
|
|
61
|
+
Candidates: SupersedingModuleCandidates(prog, cwd),
|
|
56
62
|
}
|
|
57
63
|
for _, file := range prog.TSProgram.SourceFiles() {
|
|
58
64
|
fileName := file.FileName()
|
package/driver/lsp.go
CHANGED
|
@@ -55,6 +55,12 @@ type LSPProjectDiagnostics = lspserver.LSPProjectDiagnostics
|
|
|
55
55
|
// LSPDiagnosticsResult separates document and project plugin diagnostics.
|
|
56
56
|
type LSPDiagnosticsResult = lspserver.LSPDiagnosticsResult
|
|
57
57
|
|
|
58
|
+
// LSPCompletionHint is the driver-level alias for lspserver.LSPCompletionHint.
|
|
59
|
+
type LSPCompletionHint = lspserver.LSPCompletionHint
|
|
60
|
+
|
|
61
|
+
// LSPCompletionItem is the driver-level alias for lspserver.LSPCompletionItem.
|
|
62
|
+
type LSPCompletionItem = lspserver.LSPCompletionItem
|
|
63
|
+
|
|
58
64
|
// LSPSymbolKind is the driver-level alias for lspserver.LSPSymbolKind.
|
|
59
65
|
type LSPSymbolKind = lspserver.LSPSymbolKind
|
|
60
66
|
|
|
@@ -74,6 +80,30 @@ type SymbolProvider = lspserver.SymbolProvider
|
|
|
74
80
|
// diagnostics, code actions, and workspace commands to the LSP proxy.
|
|
75
81
|
type PluginSource = lspserver.PluginSource
|
|
76
82
|
|
|
83
|
+
// CompletionHintSource is the optional extension a PluginSource implements to
|
|
84
|
+
// contribute editor completion hints to the LSP proxy.
|
|
85
|
+
type CompletionHintSource interface {
|
|
86
|
+
CompletionHints() []LSPCompletionHint
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// CompletionHintRefresher is the optional extension a CompletionHintSource
|
|
90
|
+
// implements when its corpus can change during a session. The proxy calls it
|
|
91
|
+
// after a saved document, a configuration change, or a watched-file change, and
|
|
92
|
+
// expects the call to return immediately: the source owns the scheduling and the
|
|
93
|
+
// staleness rules, and completion keeps reading the previous corpus until the
|
|
94
|
+
// new one is stored.
|
|
95
|
+
type CompletionHintRefresher interface {
|
|
96
|
+
RefreshCompletionHints()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// CompletionHintObserverSource is the optional extension a CompletionHintSource
|
|
100
|
+
// implements to tell the proxy that a refresh finished. The proxy uses it to
|
|
101
|
+
// detect a completion trigger character that appeared after the initialize
|
|
102
|
+
// response was already sent.
|
|
103
|
+
type CompletionHintObserverSource interface {
|
|
104
|
+
SetCompletionHintsObserver(observer func())
|
|
105
|
+
}
|
|
106
|
+
|
|
77
107
|
// NullPluginSource is the driver-level alias for lspserver.NullPluginSource.
|
|
78
108
|
type NullPluginSource = lspserver.NullPluginSource
|
|
79
109
|
|
package/driver/program.go
CHANGED
|
@@ -101,6 +101,9 @@ func (p *Program) SourceFile(filename string) *ast.SourceFile {
|
|
|
101
101
|
if p == nil || p.TSProgram == nil {
|
|
102
102
|
return nil
|
|
103
103
|
}
|
|
104
|
+
// Discarded on purpose: an accessor returning a source file has no channel
|
|
105
|
+
// for an apply failure, and growing one would ripple through every caller.
|
|
106
|
+
// `Diagnostics` reports it, and the emit path checks the error directly.
|
|
104
107
|
_ = p.ApplyLinkedPlugins()
|
|
105
108
|
normalized := filepath.ToSlash(filename)
|
|
106
109
|
for _, file := range p.TSProgram.SourceFiles() {
|
|
@@ -513,6 +516,7 @@ func ApplySourcePreamble(text string, preamble string) string {
|
|
|
513
516
|
// SourceFiles exposes the program's user-authored source files (declaration
|
|
514
517
|
// files filtered out).
|
|
515
518
|
func (p *Program) SourceFiles() []*ast.SourceFile {
|
|
519
|
+
// Discarded on purpose; see SourceFile. `Diagnostics` carries the failure.
|
|
516
520
|
_ = p.ApplyLinkedPlugins()
|
|
517
521
|
return p.sourceFilesRaw()
|
|
518
522
|
}
|
|
@@ -563,6 +567,38 @@ func (p *Program) Diagnostics() []Diagnostic {
|
|
|
563
567
|
if p == nil || p.TSProgram == nil {
|
|
564
568
|
return []Diagnostic{{Message: "driver: nil program"}}
|
|
565
569
|
}
|
|
570
|
+
// A linked ProgramPlugin that failed to apply is reported here, ahead of the
|
|
571
|
+
// compiler's own findings, because every other consumer of this program is
|
|
572
|
+
// then looking at a tree the plugin did not transform.
|
|
573
|
+
//
|
|
574
|
+
// `SourceFile`, `SourceFiles`, and the graph builder all run the apply and
|
|
575
|
+
// discard its error — they have no channel of their own and are not the place
|
|
576
|
+
// to grow one. The emit path checks it directly and fails the build, so this
|
|
577
|
+
// is the read-only half of the same fact: `ttscgraph` used to describe the
|
|
578
|
+
// untransformed program with nothing to say about it, while `ttsc build` on
|
|
579
|
+
// the same project reported the failure.
|
|
580
|
+
//
|
|
581
|
+
// The cached outcome is read, never forced. Calling `ApplyLinkedPlugins`
|
|
582
|
+
// here would move WHEN the apply happens: diagnostics would then be computed
|
|
583
|
+
// against the mutated tree, whose nodes carry positions that need not map
|
|
584
|
+
// into the original source text, and the diagnostic writer walks that text to
|
|
585
|
+
// render context. It panics on the mismatch.
|
|
586
|
+
//
|
|
587
|
+
// Reading the cache costs nothing and is enough for the consumers this is
|
|
588
|
+
// for: `SourceTexts` and `SourceFiles` run the apply, and both graph entry
|
|
589
|
+
// points call them before asking for diagnostics. A caller that has not
|
|
590
|
+
// applied yet has nothing to report, which is correct — the plugins have not
|
|
591
|
+
// failed, they have not run.
|
|
592
|
+
//
|
|
593
|
+
// `driver: nil program` above is the precedent for a driver-level entry with
|
|
594
|
+
// no file or code.
|
|
595
|
+
var out []Diagnostic
|
|
596
|
+
if p.pluginsApplied && p.pluginsApplyErr != nil {
|
|
597
|
+
out = append(out, Diagnostic{
|
|
598
|
+
Severity: SeverityError,
|
|
599
|
+
Message: "driver: linked plugins failed to apply: " + p.pluginsApplyErr.Error(),
|
|
600
|
+
})
|
|
601
|
+
}
|
|
566
602
|
ctx := context.Background()
|
|
567
603
|
raw := shimcompiler.GetDiagnosticsOfAnyProgram(
|
|
568
604
|
ctx,
|
|
@@ -573,7 +609,7 @@ func (p *Program) Diagnostics() []Diagnostic {
|
|
|
573
609
|
p.TSProgram.GetSemanticDiagnostics,
|
|
574
610
|
)
|
|
575
611
|
raw = filterDiagnostics(raw)
|
|
576
|
-
return convertDiagnostics(shimcompiler.SortAndDeduplicateDiagnostics(raw))
|
|
612
|
+
return append(out, convertDiagnostics(shimcompiler.SortAndDeduplicateDiagnostics(raw))...)
|
|
577
613
|
}
|
|
578
614
|
|
|
579
615
|
// filterDiagnostics removes diagnostics that are false positives in ttsc's
|