ttsc 0.19.3 → 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 +276 -100
- 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_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 +208 -0
- package/internal/graph/graph.go +143 -5
- package/internal/graph/line_model.go +122 -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 +100 -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ttsc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "General-purpose TypeScript-Go compiler, runtime, plugin host, and LSP host.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"typescript": "^7.0.2"
|
|
36
36
|
},
|
|
37
37
|
"optionalDependencies": {
|
|
38
|
-
"@ttsc/linux-
|
|
39
|
-
"@ttsc/linux-
|
|
40
|
-
"@ttsc/
|
|
41
|
-
"@ttsc/darwin-
|
|
42
|
-
"@ttsc/win32-x64": "0.
|
|
43
|
-
"@ttsc/
|
|
44
|
-
"@ttsc/
|
|
38
|
+
"@ttsc/linux-arm64": "0.20.0",
|
|
39
|
+
"@ttsc/linux-x64": "0.20.0",
|
|
40
|
+
"@ttsc/darwin-arm64": "0.20.0",
|
|
41
|
+
"@ttsc/darwin-x64": "0.20.0",
|
|
42
|
+
"@ttsc/win32-x64": "0.20.0",
|
|
43
|
+
"@ttsc/win32-arm64": "0.20.0",
|
|
44
|
+
"@ttsc/linux-arm": "0.20.0"
|
|
45
45
|
},
|
|
46
46
|
"sideEffects": false,
|
|
47
47
|
"files": [
|
package/shim/ast/shim.go
CHANGED
|
@@ -279,6 +279,49 @@ func IsElementAccessExpression(node *Node) bool {
|
|
|
279
279
|
return innerast.IsElementAccessExpression(node)
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
// IsTokenKind reports whether kind represents a lexical syntax token.
|
|
283
|
+
func IsTokenKind(kind Kind) bool {
|
|
284
|
+
return innerast.IsTokenKind(kind)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// IsExpressionNode reports whether node has expression semantics in its
|
|
288
|
+
// enclosing syntax context.
|
|
289
|
+
func IsExpressionNode(node *Node) bool {
|
|
290
|
+
return innerast.IsExpressionNode(node)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// IsTypeDeclaration reports whether node declares a type-level symbol.
|
|
294
|
+
func IsTypeDeclaration(node *Node) bool {
|
|
295
|
+
return innerast.IsTypeDeclaration(node)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// IsTypeDeclarationName reports whether node is the name of a type-level
|
|
299
|
+
// declaration.
|
|
300
|
+
func IsTypeDeclarationName(node *Node) bool {
|
|
301
|
+
return innerast.IsTypeDeclarationName(node)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// IsBindingElement reports whether node is one element of a binding pattern.
|
|
305
|
+
func IsBindingElement(node *Node) bool {
|
|
306
|
+
return innerast.IsBindingElement(node)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// IsDeclaration reports whether node is a declaration syntax node.
|
|
310
|
+
func IsDeclaration(node *Node) bool {
|
|
311
|
+
return innerast.IsDeclaration(node)
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// IsDeclarationNameOrImportPropertyName reports whether node names a
|
|
315
|
+
// declaration or the property side of an import or export specifier.
|
|
316
|
+
func IsDeclarationNameOrImportPropertyName(node *Node) bool {
|
|
317
|
+
return innerast.IsDeclarationNameOrImportPropertyName(node)
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// IsBindingPattern reports whether node is an object or array binding pattern.
|
|
321
|
+
func IsBindingPattern(node *Node) bool {
|
|
322
|
+
return innerast.IsBindingPattern(node)
|
|
323
|
+
}
|
|
324
|
+
|
|
282
325
|
// GetSourceFileOfNode walks up the parent chain to return the SourceFile that
|
|
283
326
|
// owns the given node. Linked from the internal package via go:linkname because
|
|
284
327
|
// the function is unexported there.
|
|
@@ -286,9 +329,11 @@ func IsElementAccessExpression(node *Node) bool {
|
|
|
286
329
|
//go:linkname GetSourceFileOfNode github.com/microsoft/typescript-go/internal/ast.GetSourceFileOfNode
|
|
287
330
|
func GetSourceFileOfNode(node *innerast.Node) *innerast.SourceFile
|
|
288
331
|
|
|
289
|
-
// GetNodeAtPosition returns the deepest AST node whose range covers
|
|
290
|
-
// in file. When includeJSDoc is true the search descends into JSDoc
|
|
291
|
-
//
|
|
332
|
+
// GetNodeAtPosition returns the deepest non-token AST node whose range covers
|
|
333
|
+
// position in file. When includeJSDoc is true the search descends into JSDoc
|
|
334
|
+
// sub-trees. Cursor-facing callers that need the exact token should use
|
|
335
|
+
// astnav.GetTouchingToken instead. Linked from the internal package via
|
|
336
|
+
// go:linkname.
|
|
292
337
|
//
|
|
293
338
|
//go:linkname GetNodeAtPosition github.com/microsoft/typescript-go/internal/ast.GetNodeAtPosition
|
|
294
339
|
func GetNodeAtPosition(file *innerast.SourceFile, position int, includeJSDoc bool) *innerast.Node
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module github.com/microsoft/typescript-go/shim/astnav
|
|
2
|
+
|
|
3
|
+
go 1.26
|
|
4
|
+
|
|
5
|
+
require github.com/microsoft/typescript-go v0.0.0-20260429010842-56ab4af42157
|
|
6
|
+
|
|
7
|
+
require (
|
|
8
|
+
github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433 // indirect
|
|
9
|
+
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
|
10
|
+
github.com/zeebo/xxh3 v1.1.0 // indirect
|
|
11
|
+
golang.org/x/sync v0.20.0 // indirect
|
|
12
|
+
golang.org/x/sys v0.43.0 // indirect
|
|
13
|
+
golang.org/x/text v0.36.0 // indirect
|
|
14
|
+
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433 h1:vymEbVwYFP/L05h5TKQxvkXoKxNvTpjxYKdF1Nlwuao=
|
|
2
|
+
github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433/go.mod h1:tphK2c80bpPhMOI4v6bIc2xWywPfbqi1Z06+RcrMkDg=
|
|
3
|
+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
|
4
|
+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
|
5
|
+
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
|
6
|
+
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
|
7
|
+
github.com/microsoft/typescript-go v0.0.0-20260429010842-56ab4af42157 h1:llOMPhKDiQ+UEJiAaQuuWaJOTg5V7tNNTEf9JPWoYSY=
|
|
8
|
+
github.com/microsoft/typescript-go v0.0.0-20260429010842-56ab4af42157/go.mod h1:m8YA0PMC7ti0GW0RI05D6fEcjQeu98XVS+FWF+VDW2k=
|
|
9
|
+
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
|
|
10
|
+
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
|
|
11
|
+
github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
|
|
12
|
+
github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
|
|
13
|
+
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
|
14
|
+
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
|
15
|
+
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
|
|
16
|
+
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|
17
|
+
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
|
|
18
|
+
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
|
|
19
|
+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
|
20
|
+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Package astnav exposes cursor-position traversal helpers from TypeScript-Go.
|
|
2
|
+
package astnav
|
|
3
|
+
|
|
4
|
+
import (
|
|
5
|
+
"github.com/microsoft/typescript-go/internal/ast"
|
|
6
|
+
_ "github.com/microsoft/typescript-go/internal/astnav"
|
|
7
|
+
_ "unsafe"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// GetTouchingToken returns the token touching position in sourceFile. When
|
|
11
|
+
// position touches no token, it returns the enclosing non-token node instead;
|
|
12
|
+
// callers that require a token must check ast.IsTokenKind on the result kind.
|
|
13
|
+
//
|
|
14
|
+
//go:linkname GetTouchingToken github.com/microsoft/typescript-go/internal/astnav.GetTouchingToken
|
|
15
|
+
func GetTouchingToken(sourceFile *ast.SourceFile, position int) *ast.Node
|
package/shim/checker/shim.go
CHANGED
|
@@ -28,6 +28,106 @@ type ElementFlags = innerchecker.ElementFlags
|
|
|
28
28
|
type Program = innerchecker.Program
|
|
29
29
|
type Tracer = innerchecker.Tracer
|
|
30
30
|
|
|
31
|
+
//go:linkname checkerNewAnonymousType github.com/microsoft/typescript-go/internal/checker.(*Checker).newAnonymousType
|
|
32
|
+
func checkerNewAnonymousType(
|
|
33
|
+
recv *innerchecker.Checker,
|
|
34
|
+
symbol *innerast.Symbol,
|
|
35
|
+
members innerast.SymbolTable,
|
|
36
|
+
callSignatures []*innerchecker.Signature,
|
|
37
|
+
constructSignatures []*innerchecker.Signature,
|
|
38
|
+
indexInfos []*innerchecker.IndexInfo,
|
|
39
|
+
) *innerchecker.Type
|
|
40
|
+
|
|
41
|
+
//go:linkname checkerGetTargetSymbol github.com/microsoft/typescript-go/internal/checker.(*Checker).getTargetSymbol
|
|
42
|
+
func checkerGetTargetSymbol(recv *innerchecker.Checker, symbol *innerast.Symbol) *innerast.Symbol
|
|
43
|
+
|
|
44
|
+
//go:linkname checkerIsPrototypeProperty github.com/microsoft/typescript-go/internal/checker.isPrototypeProperty
|
|
45
|
+
func checkerIsPrototypeProperty(symbol *innerast.Symbol) bool
|
|
46
|
+
|
|
47
|
+
//go:linkname checkerArePropertiesAbstractOrInterface github.com/microsoft/typescript-go/internal/checker.(*Checker).arePropertiesAbstractOrInterface
|
|
48
|
+
func checkerArePropertiesAbstractOrInterface(
|
|
49
|
+
recv *innerchecker.Checker,
|
|
50
|
+
base *innerast.Symbol,
|
|
51
|
+
baseDeclarationFlags innerast.ModifierFlags,
|
|
52
|
+
) bool
|
|
53
|
+
|
|
54
|
+
// Checker_isPropertyAssignableTo asks the upstream assignability relater about
|
|
55
|
+
// exactly one source/target property pair. The anonymous types retain the
|
|
56
|
+
// original property symbols, so propertyRelatedTo still enforces instantiated
|
|
57
|
+
// generic types, overloads, optionality, and private/protected declaration
|
|
58
|
+
// origins without an unrelated sibling member participating in the result.
|
|
59
|
+
func Checker_isPropertyAssignableTo(
|
|
60
|
+
recv *innerchecker.Checker,
|
|
61
|
+
sourceProperty *innerast.Symbol,
|
|
62
|
+
targetProperty *innerast.Symbol,
|
|
63
|
+
) bool {
|
|
64
|
+
if recv == nil || sourceProperty == nil || targetProperty == nil ||
|
|
65
|
+
sourceProperty.Name == "" || sourceProperty.Name != targetProperty.Name {
|
|
66
|
+
return false
|
|
67
|
+
}
|
|
68
|
+
source := checkerNewAnonymousType(
|
|
69
|
+
recv,
|
|
70
|
+
nil,
|
|
71
|
+
innerast.SymbolTable{sourceProperty.Name: sourceProperty},
|
|
72
|
+
nil,
|
|
73
|
+
nil,
|
|
74
|
+
nil,
|
|
75
|
+
)
|
|
76
|
+
target := checkerNewAnonymousType(
|
|
77
|
+
recv,
|
|
78
|
+
nil,
|
|
79
|
+
innerast.SymbolTable{targetProperty.Name: targetProperty},
|
|
80
|
+
nil,
|
|
81
|
+
nil,
|
|
82
|
+
nil,
|
|
83
|
+
)
|
|
84
|
+
return source != nil && target != nil && recv.IsTypeAssignableTo(source, target)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Checker_isValidClassMemberOverridePair applies the class-only member-kind
|
|
88
|
+
// boundary from checkKindsOfPropertyMemberOverrides to one exact pair. Ordinary
|
|
89
|
+
// structural assignability permits more shapes than a class extends clause:
|
|
90
|
+
// notably a concrete property/accessor cannot be replaced by a method, while a
|
|
91
|
+
// base method may be replaced by a function-valued property.
|
|
92
|
+
func Checker_isValidClassMemberOverridePair(
|
|
93
|
+
recv *innerchecker.Checker,
|
|
94
|
+
derivedProperty *innerast.Symbol,
|
|
95
|
+
baseProperty *innerast.Symbol,
|
|
96
|
+
) bool {
|
|
97
|
+
if recv == nil || derivedProperty == nil || baseProperty == nil {
|
|
98
|
+
return false
|
|
99
|
+
}
|
|
100
|
+
derived := checkerGetTargetSymbol(recv, derivedProperty)
|
|
101
|
+
base := checkerGetTargetSymbol(recv, baseProperty)
|
|
102
|
+
if derived == nil || base == nil || derived == base {
|
|
103
|
+
return false
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
baseDeclarationFlags := innerchecker.GetDeclarationModifierFlagsFromSymbol(base)
|
|
107
|
+
basePropertyFlags := base.Flags & innerast.SymbolFlagsPropertyOrAccessor
|
|
108
|
+
derivedPropertyFlags := derived.Flags & innerast.SymbolFlagsPropertyOrAccessor
|
|
109
|
+
if basePropertyFlags != 0 && derivedPropertyFlags != 0 {
|
|
110
|
+
// A direct class base member cannot be a mapped property. The upstream
|
|
111
|
+
// mapped-property exception therefore has no member declaration this
|
|
112
|
+
// direct-pair API could publish; assignment declarations and abstract /
|
|
113
|
+
// interface members are the two applicable exceptions.
|
|
114
|
+
if derived.ValueDeclaration != nil && innerast.IsBinaryExpression(derived.ValueDeclaration) ||
|
|
115
|
+
checkerArePropertiesAbstractOrInterface(recv, base, baseDeclarationFlags) {
|
|
116
|
+
return true
|
|
117
|
+
}
|
|
118
|
+
overriddenInstanceProperty := basePropertyFlags != innerast.SymbolFlagsProperty &&
|
|
119
|
+
derivedPropertyFlags == innerast.SymbolFlagsProperty
|
|
120
|
+
overriddenInstanceAccessor := basePropertyFlags == innerast.SymbolFlagsProperty &&
|
|
121
|
+
derivedPropertyFlags != innerast.SymbolFlagsProperty
|
|
122
|
+
return !overriddenInstanceProperty && !overriddenInstanceAccessor
|
|
123
|
+
}
|
|
124
|
+
if checkerIsPrototypeProperty(base) {
|
|
125
|
+
return checkerIsPrototypeProperty(derived) ||
|
|
126
|
+
derived.Flags&innerast.SymbolFlagsProperty != 0
|
|
127
|
+
}
|
|
128
|
+
return false
|
|
129
|
+
}
|
|
130
|
+
|
|
31
131
|
// NewChecker creates a checker that owns its complete type graph for program.
|
|
32
132
|
// The returned mutex is the upstream checker-pool synchronization primitive;
|
|
33
133
|
// callers that share the checker must serialize access through it.
|
package/shim/core/shim.go
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// gen_shims:hand-maintained
|
|
2
|
+
//
|
|
1
3
|
// Package core re-exports the subset of typescript-go's internal/core types
|
|
2
4
|
// and constants that plugins and the ttsc driver need. It provides compiler
|
|
3
5
|
// options, script-kind discrimination, tri-state booleans, and text-range
|
|
@@ -13,6 +15,12 @@ type CompilerOptions = innercore.CompilerOptions
|
|
|
13
15
|
// JsxEmit is the parsed compilerOptions.jsx mode.
|
|
14
16
|
type JsxEmit = innercore.JsxEmit
|
|
15
17
|
|
|
18
|
+
// ModuleResolutionKind selects TypeScript-Go's module resolver.
|
|
19
|
+
type ModuleResolutionKind = innercore.ModuleResolutionKind
|
|
20
|
+
|
|
21
|
+
// ResolutionMode is the CommonJS or ESM lookup mode for one module use.
|
|
22
|
+
type ResolutionMode = innercore.ResolutionMode
|
|
23
|
+
|
|
16
24
|
// Tristate is a three-valued boolean: TSFalse, TSTrue, or TSUnknown. Used by
|
|
17
25
|
// CompilerOptions fields that can be explicitly unset.
|
|
18
26
|
type Tristate = innercore.Tristate
|
|
@@ -20,6 +28,10 @@ type Tristate = innercore.Tristate
|
|
|
20
28
|
// TextPos is a zero-based byte offset into a source file's text.
|
|
21
29
|
type TextPos = innercore.TextPos
|
|
22
30
|
|
|
31
|
+
// ECMALineStarts holds the byte offset of every source line the compiler
|
|
32
|
+
// recognizes under ECMAScript's line-terminator rules.
|
|
33
|
+
type ECMALineStarts = innercore.ECMALineStarts
|
|
34
|
+
|
|
23
35
|
// TextRange is a half-open [Pos, End) byte range inside a source file.
|
|
24
36
|
type TextRange = innercore.TextRange
|
|
25
37
|
|
|
@@ -48,6 +60,35 @@ const (
|
|
|
48
60
|
JsxEmitReact = innercore.JsxEmitReact
|
|
49
61
|
JsxEmitReactJSX = innercore.JsxEmitReactJSX
|
|
50
62
|
JsxEmitReactJSXDev = innercore.JsxEmitReactJSXDev
|
|
63
|
+
|
|
64
|
+
// ModuleKind* constants enumerate every configured output module format.
|
|
65
|
+
ModuleKindNone = innercore.ModuleKindNone
|
|
66
|
+
ModuleKindCommonJS = innercore.ModuleKindCommonJS
|
|
67
|
+
ModuleKindAMD = innercore.ModuleKindAMD
|
|
68
|
+
ModuleKindUMD = innercore.ModuleKindUMD
|
|
69
|
+
ModuleKindSystem = innercore.ModuleKindSystem
|
|
70
|
+
ModuleKindES2015 = innercore.ModuleKindES2015
|
|
71
|
+
ModuleKindES2020 = innercore.ModuleKindES2020
|
|
72
|
+
ModuleKindES2022 = innercore.ModuleKindES2022
|
|
73
|
+
ModuleKindESNext = innercore.ModuleKindESNext
|
|
74
|
+
ModuleKindNode16 = innercore.ModuleKindNode16
|
|
75
|
+
ModuleKindNode18 = innercore.ModuleKindNode18
|
|
76
|
+
ModuleKindNode20 = innercore.ModuleKindNode20
|
|
77
|
+
ModuleKindNodeNext = innercore.ModuleKindNodeNext
|
|
78
|
+
ModuleKindPreserve = innercore.ModuleKindPreserve
|
|
79
|
+
|
|
80
|
+
// ResolutionMode* constants classify a single module-specifier lookup.
|
|
81
|
+
ResolutionModeNone = innercore.ResolutionModeNone
|
|
82
|
+
ResolutionModeCommonJS = innercore.ResolutionModeCommonJS
|
|
83
|
+
ResolutionModeESM = innercore.ResolutionModeESM
|
|
84
|
+
|
|
85
|
+
// ModuleResolutionKind* constants enumerate every TypeScript-Go resolver.
|
|
86
|
+
ModuleResolutionKindUnknown = innercore.ModuleResolutionKindUnknown
|
|
87
|
+
ModuleResolutionKindClassic = innercore.ModuleResolutionKindClassic
|
|
88
|
+
ModuleResolutionKindNode10 = innercore.ModuleResolutionKindNode10
|
|
89
|
+
ModuleResolutionKindNode16 = innercore.ModuleResolutionKindNode16
|
|
90
|
+
ModuleResolutionKindNodeNext = innercore.ModuleResolutionKindNodeNext
|
|
91
|
+
ModuleResolutionKindBundler = innercore.ModuleResolutionKindBundler
|
|
51
92
|
)
|
|
52
93
|
|
|
53
94
|
// Version reports the TypeScript compiler version typescript-go implements, in
|
|
@@ -55,6 +96,12 @@ const (
|
|
|
55
96
|
// consumer can tell which checker resolved the facts it is reading.
|
|
56
97
|
func Version() string { return innercore.Version() }
|
|
57
98
|
|
|
99
|
+
// ComputeECMALineStarts applies the compiler's LF, CRLF, CR, LS, and PS line
|
|
100
|
+
// model to UTF-8 source text.
|
|
101
|
+
func ComputeECMALineStarts(text string) ECMALineStarts {
|
|
102
|
+
return innercore.ComputeECMALineStarts(text)
|
|
103
|
+
}
|
|
104
|
+
|
|
58
105
|
// NewTextRange constructs a closed/open [pos, end) text range.
|
|
59
106
|
func NewTextRange(pos, end int) TextRange { return innercore.NewTextRange(pos, end) }
|
|
60
107
|
|
|
@@ -12,7 +12,10 @@
|
|
|
12
12
|
package diagnosticwriter
|
|
13
13
|
|
|
14
14
|
import (
|
|
15
|
+
"cmp"
|
|
15
16
|
"io"
|
|
17
|
+
"slices"
|
|
18
|
+
"strings"
|
|
16
19
|
|
|
17
20
|
"github.com/microsoft/typescript-go/internal/ast"
|
|
18
21
|
"github.com/microsoft/typescript-go/internal/diagnostics"
|
|
@@ -166,7 +169,54 @@ func FormatMixedDiagnostics(
|
|
|
166
169
|
},
|
|
167
170
|
NewLine: "\n",
|
|
168
171
|
}
|
|
172
|
+
slices.SortFunc(all, compareMixedDiagnostics)
|
|
169
173
|
inner.FormatDiagnosticsWithColorAndContext(output, all, options)
|
|
170
174
|
inner.WriteErrorSummaryText(output, all, options)
|
|
171
175
|
return errors
|
|
172
176
|
}
|
|
177
|
+
|
|
178
|
+
// compareMixedDiagnostics imposes one deterministic source order on tsgo and
|
|
179
|
+
// lint diagnostics before the upstream renderer consumes them. The renderer
|
|
180
|
+
// intentionally writes its input order, while the two producers have separate
|
|
181
|
+
// collection paths; ordering here keeps neither producer's traversal visible
|
|
182
|
+
// in CLI output.
|
|
183
|
+
func compareMixedDiagnostics(a, b inner.Diagnostic) int {
|
|
184
|
+
if c := strings.Compare(mixedDiagnosticFileName(a), mixedDiagnosticFileName(b)); c != 0 {
|
|
185
|
+
return c
|
|
186
|
+
}
|
|
187
|
+
if c := cmp.Compare(a.Pos(), b.Pos()); c != 0 {
|
|
188
|
+
return c
|
|
189
|
+
}
|
|
190
|
+
if c := cmp.Compare(a.End(), b.End()); c != 0 {
|
|
191
|
+
return c
|
|
192
|
+
}
|
|
193
|
+
if c := cmp.Compare(a.Code(), b.Code()); c != 0 {
|
|
194
|
+
return c
|
|
195
|
+
}
|
|
196
|
+
if c := cmp.Compare(a.Category(), b.Category()); c != 0 {
|
|
197
|
+
return c
|
|
198
|
+
}
|
|
199
|
+
if c := strings.Compare(a.Localize(locale.Default), b.Localize(locale.Default)); c != 0 {
|
|
200
|
+
return c
|
|
201
|
+
}
|
|
202
|
+
if c := compareMixedDiagnosticLists(a.MessageChain(), b.MessageChain()); c != 0 {
|
|
203
|
+
return c
|
|
204
|
+
}
|
|
205
|
+
return compareMixedDiagnosticLists(a.RelatedInformation(), b.RelatedInformation())
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
func mixedDiagnosticFileName(d inner.Diagnostic) string {
|
|
209
|
+
if file := d.File(); file != nil {
|
|
210
|
+
return file.FileName()
|
|
211
|
+
}
|
|
212
|
+
return ""
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
func compareMixedDiagnosticLists(a, b []inner.Diagnostic) int {
|
|
216
|
+
for i := 0; i < len(a) && i < len(b); i++ {
|
|
217
|
+
if c := compareMixedDiagnostics(a[i], b[i]); c != 0 {
|
|
218
|
+
return c
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return cmp.Compare(len(a), len(b))
|
|
222
|
+
}
|
package/src/TtscCompiler.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { resolveProjectConfig } from "./compiler/internal/project/resolveProject
|
|
|
6
6
|
import { resolveBinary } from "./compiler/internal/resolveBinary";
|
|
7
7
|
import { createProcessDiagnostic } from "./compiler/internal/runBuild";
|
|
8
8
|
import { transformProjectInMemory } from "./compiler/internal/transformProjectInMemory";
|
|
9
|
+
import { assertSafeExplicitCacheDirectory } from "./internal/assertSafeExplicitCacheDirectory";
|
|
9
10
|
import { resolveCleanTargets } from "./plugin/internal/buildSourcePlugin";
|
|
10
11
|
import { loadProjectPlugins } from "./plugin/internal/loadProjectPlugins";
|
|
11
12
|
import type { ITtscCompilerContext } from "./structures/ITtscCompilerContext";
|
|
@@ -91,7 +92,9 @@ export class TtscCompiler {
|
|
|
91
92
|
* project-local caches. A user-provided `GOCACHE` is never removed. The cache
|
|
92
93
|
* location comes from this instance's `cacheDir` and environment
|
|
93
94
|
* (`TTSC_CACHE_DIR` / `TTSC_GO_CACHE_DIR`), defaulting to
|
|
94
|
-
* `<workspaceRoot>/node_modules/.cache/ttsc`.
|
|
95
|
+
* `<workspaceRoot>/node_modules/.cache/ttsc`. An explicit cache directory
|
|
96
|
+
* that equals or contains the project, or names a filesystem root, is
|
|
97
|
+
* rejected before any directory is removed.
|
|
95
98
|
*
|
|
96
99
|
* @returns Cache directories that were removed.
|
|
97
100
|
*/
|
|
@@ -103,6 +106,7 @@ export class TtscCompiler {
|
|
|
103
106
|
];
|
|
104
107
|
const explicitCacheDir = this.resolveCacheDir();
|
|
105
108
|
if (explicitCacheDir !== undefined) {
|
|
109
|
+
assertSafeExplicitCacheDirectory(projectRoot, explicitCacheDir);
|
|
106
110
|
// An explicit constructor `cacheDir` names the cache directory for this
|
|
107
111
|
// instance — exactly like `ttsc clean --cache-dir X` on the CLI — so
|
|
108
112
|
// remove it wholesale plus the legacy project-local caches. This keeps
|
package/src/TtscService.ts
CHANGED
|
@@ -4,6 +4,18 @@ import type { ResidentTransformProcess } from "./compiler/internal/residentTrans
|
|
|
4
4
|
import { startResidentTransform } from "./compiler/internal/startResidentTransform";
|
|
5
5
|
import type { ITtscCompilerContext } from "./structures/ITtscCompilerContext";
|
|
6
6
|
|
|
7
|
+
/** Construction controls for the resident transform request lifecycle. */
|
|
8
|
+
export interface TtscServiceOptions {
|
|
9
|
+
/** Maximum time one transform or update request may await the host's reply. */
|
|
10
|
+
requestTimeoutMs?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Per-call controls for a resident transform or update request. */
|
|
14
|
+
export interface TtscServiceRequestOptions {
|
|
15
|
+
/** Abort this call before it receives a reply. */
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}
|
|
18
|
+
|
|
7
19
|
/**
|
|
8
20
|
* Resident, incremental transform service for the `ttsc` TypeScript-Go
|
|
9
21
|
* pipeline.
|
|
@@ -37,14 +49,20 @@ export class TtscService {
|
|
|
37
49
|
* host. The context is the same shape {@link TtscCompiler} accepts; it is not
|
|
38
50
|
* replaceable per call.
|
|
39
51
|
*/
|
|
40
|
-
public constructor(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
public constructor(
|
|
53
|
+
context: ITtscCompilerContext = {},
|
|
54
|
+
options: TtscServiceOptions = {},
|
|
55
|
+
) {
|
|
56
|
+
const started = startResidentTransform(
|
|
57
|
+
{
|
|
58
|
+
...context,
|
|
59
|
+
env: context.env ? { ...context.env } : undefined,
|
|
60
|
+
plugins: Array.isArray(context.plugins)
|
|
61
|
+
? [...context.plugins]
|
|
62
|
+
: context.plugins,
|
|
63
|
+
},
|
|
64
|
+
options,
|
|
65
|
+
);
|
|
48
66
|
this.resident = started.process;
|
|
49
67
|
this.projectRoot = started.projectRoot;
|
|
50
68
|
}
|
|
@@ -57,10 +75,14 @@ export class TtscService {
|
|
|
57
75
|
* Rejects when the resident host failed to compile the project; the rejection
|
|
58
76
|
* carries the host's diagnostics so callers can surface a real build error.
|
|
59
77
|
*/
|
|
60
|
-
public async transformFile(
|
|
78
|
+
public async transformFile(
|
|
79
|
+
fileName: string,
|
|
80
|
+
options: TtscServiceRequestOptions = {},
|
|
81
|
+
): Promise<string | undefined> {
|
|
61
82
|
const reply = await this.resident.request(
|
|
62
83
|
{ file: this.absolutePath(fileName) },
|
|
63
84
|
"transform",
|
|
85
|
+
options,
|
|
64
86
|
);
|
|
65
87
|
// The resident client already validated the reply shape (boolean `found`,
|
|
66
88
|
// string `typescript` when found), so a malformed or wrong-shape reply
|
|
@@ -78,10 +100,15 @@ export class TtscService {
|
|
|
78
100
|
* did not compile and the previous transform is still in effect. A relative
|
|
79
101
|
* `fileName` is resolved against the project root.
|
|
80
102
|
*/
|
|
81
|
-
public async updateFile(
|
|
103
|
+
public async updateFile(
|
|
104
|
+
fileName: string,
|
|
105
|
+
content: string,
|
|
106
|
+
options: TtscServiceRequestOptions = {},
|
|
107
|
+
): Promise<boolean> {
|
|
82
108
|
const reply = await this.resident.request(
|
|
83
109
|
{ content, update: this.absolutePath(fileName) },
|
|
84
110
|
"update",
|
|
111
|
+
options,
|
|
85
112
|
);
|
|
86
113
|
// The resident client validated the reply carries a boolean `updated`, so a
|
|
87
114
|
// malformed or wrong-shape reply rejected instead of collapsing to `false`.
|