typia 15.4.1 → 15.5.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 -2
- package/lib/transform.d.ts +3 -1
- package/lib/transform.js +4 -1
- package/lib/transform.js.map +1 -1
- package/lib/transform.mjs +5 -2
- package/lib/transform.mjs.map +1 -1
- package/native/cmd/ttsc-typia/build.go +185 -125
- package/native/cmd/ttsc-typia/build_no_emit_preserves_analysis_options_test.go +50 -43
- package/native/cmd/ttsc-typia/check.go +92 -0
- package/native/cmd/ttsc-typia/check_serve.go +318 -0
- package/native/cmd/ttsc-typia/check_serve_matches_cold_check_test.go +234 -0
- package/native/cmd/ttsc-typia/check_serve_reloads_with_program_plugin_test.go +56 -0
- package/native/cmd/ttsc-typia/check_transform_leaves_program_untouched_test.go +155 -0
- package/native/cmd/ttsc-typia/main.go +3 -0
- package/native/cmd/ttsc-typia/typia_check_loads_one_program_test.go +125 -0
- package/native/go.mod +2 -1
- package/package.json +5 -5
- package/src/transform.ts +4 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"path/filepath"
|
|
6
|
+
"testing"
|
|
7
|
+
|
|
8
|
+
"github.com/samchon/ttsc/packages/ttsc/driver"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
// TestCheckServeReloadsWithProgramPlugin verifies typia's resident check loads
|
|
12
|
+
// a fresh Program for every cycle while a linked ProgramPlugin is selected.
|
|
13
|
+
//
|
|
14
|
+
// typia's analysis reads the ASTs the linked program hooks produce, and such a
|
|
15
|
+
// hook rewrites them in place, so a kept Program would show the next cycle
|
|
16
|
+
// source an earlier cycle already rewrote.
|
|
17
|
+
//
|
|
18
|
+
// 1. Select buildObservationPlugin, a ProgramPlugin without CheckProgram, as
|
|
19
|
+
// linked manifest entry 0.
|
|
20
|
+
// 2. Answer a passing cycle, then a transform failure after an edit of a
|
|
21
|
+
// known source.
|
|
22
|
+
// 3. Require a new load and no update for each cycle, each answer equal to a
|
|
23
|
+
// cold check.
|
|
24
|
+
//
|
|
25
|
+
// @evidence contracts/testing.md#behavioral-verification check-serve cycles with a linked ProgramPlugin must report one more load and no update per cycle, never reused, and match cold `check` status and output; a kept Program fails the counters.
|
|
26
|
+
// @evidence contracts/testing.md#independent-expectations The residency rule (a mutating linked hook requires a fresh Program) fixes the counters; cold `check` of the same files is the oracle for the answers.
|
|
27
|
+
// @evidence contracts/testing.md#distinguishing-cases An edit of a known source would be an incremental update without the plugin, as TestCheckServeMatchesColdCheck asserts; here it must reload, and both a passing and a failing answer are compared.
|
|
28
|
+
// @evidence contracts/testing.md#execution-ownership The native Go runner discovers this unit test; the plugin is selected with t.Setenv and check-serve runs in a goroutine of the test process.
|
|
29
|
+
func TestCheckServeReloadsWithProgramPlugin(t *testing.T) {
|
|
30
|
+
root := checkServeProject(t)
|
|
31
|
+
main := filepath.Join(root, "src", "main.ts")
|
|
32
|
+
typiaCheckWrite(t, main, typiaCheckValidSource)
|
|
33
|
+
// buildObservationPlugin consumes this file on every application.
|
|
34
|
+
typiaCheckWrite(t, filepath.Join(root, "external.txt"), "consumed\n")
|
|
35
|
+
payload, _ := json.Marshal([]driver.PluginEntry{{Name: "observation-test", Stage: "transform", Config: map[string]any{"mode": "complete"}}})
|
|
36
|
+
t.Setenv(driver.LinkedPluginsEnv, string(payload))
|
|
37
|
+
args := []string{"--tsconfig=" + filepath.Join(root, "tsconfig.json"), "--cwd=" + root}
|
|
38
|
+
serve := startCheckServe(t, args)
|
|
39
|
+
|
|
40
|
+
first := serve.send(t, `{}`)
|
|
41
|
+
if first.Status != 0 || first.Telemetry.ProgramLoads != 1 || first.Telemetry.Reused {
|
|
42
|
+
t.Fatalf("first cycle = %#v", first)
|
|
43
|
+
}
|
|
44
|
+
checkServeAssertCold(t, args, first)
|
|
45
|
+
|
|
46
|
+
typiaCheckWrite(t, main, transformDiagnosticSource)
|
|
47
|
+
second := serve.send(t, checkServeChanged(t, main))
|
|
48
|
+
if second.Status != 3 || second.Telemetry.ProgramLoads != 2 ||
|
|
49
|
+
second.Telemetry.ProgramUpdates != 0 || second.Telemetry.Reused || !second.TypeScriptDiagnosticsReported {
|
|
50
|
+
t.Fatalf("edited cycle = %#v", second)
|
|
51
|
+
}
|
|
52
|
+
checkServeAssertCold(t, args, second)
|
|
53
|
+
if code := serve.stop(); code != 0 {
|
|
54
|
+
t.Fatalf("check-serve exited with %d after stdin closed", code)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"os"
|
|
6
|
+
"path/filepath"
|
|
7
|
+
"reflect"
|
|
8
|
+
"sync"
|
|
9
|
+
"testing"
|
|
10
|
+
|
|
11
|
+
shimast "github.com/microsoft/typescript-go/shim/ast"
|
|
12
|
+
shimprinter "github.com/microsoft/typescript-go/shim/printer"
|
|
13
|
+
"github.com/samchon/ttsc/packages/ttsc/driver"
|
|
14
|
+
nativecontext "github.com/samchon/typia/packages/typia/native/core/context"
|
|
15
|
+
schemametadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
|
|
16
|
+
nativetransform "github.com/samchon/typia/packages/typia/native/transform"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
// TestCheckTransformLeavesProgramUntouched verifies typia's analysis rewrites
|
|
20
|
+
// calls without writing into the Program's parsed ASTs.
|
|
21
|
+
//
|
|
22
|
+
// check-serve keeps a Program across watch cycles only because of this: the
|
|
23
|
+
// next cycle's UpdateProgram shares every unchanged file's tree, so a call an
|
|
24
|
+
// earlier cycle rewrote in place would be read as already transformed.
|
|
25
|
+
//
|
|
26
|
+
// 1. Load a noEmit Program whose sources nest typia calls inside a namespace,
|
|
27
|
+
// a class and a function, so their ancestors must be rebuilt.
|
|
28
|
+
// 2. Record every node's identity, kind, range, flags, parent and text.
|
|
29
|
+
// 3. Run the analysis, then the transformer directly, requiring a rewritten
|
|
30
|
+
// file in place of the parsed one.
|
|
31
|
+
// 4. Require the recorded trees unchanged, and require the same record to
|
|
32
|
+
// notice a linked-hook style in-place literal edit.
|
|
33
|
+
//
|
|
34
|
+
// @evidence contracts/testing.md#behavioral-verification analyzeTypiaProgram and nativetransform.Transform run over a loaded Program; the transformer must return a different SourceFile for the typia call while every parsed node keeps its pointer, kind, range, flags, parent and text.
|
|
35
|
+
// @evidence contracts/testing.md#independent-expectations The parse-time record taken before any transform is the oracle; the expected rewrite follows from the typia.is call, not from printed output.
|
|
36
|
+
// @evidence contracts/testing.md#distinguishing-cases A rewritten file and an untouched plain file are both recorded; the in-place literal edit is the negative twin proving the record detects mutation rather than passing vacuously.
|
|
37
|
+
// @evidence contracts/testing.md#execution-ownership The native Go runner discovers this unit test; it loads the fixture through the driver in process and starts no compiler subprocess.
|
|
38
|
+
func TestCheckTransformLeavesProgramUntouched(t *testing.T) {
|
|
39
|
+
project := checkUntouchedProject(t)
|
|
40
|
+
prog, diags, err := driver.LoadProgram(project, "tsconfig.json", driver.LoadProgramOptions{ForceNoEmit: true})
|
|
41
|
+
if err != nil || len(diags) != 0 {
|
|
42
|
+
t.Fatalf("load program: err=%v diagnostics=%#v", err, diags)
|
|
43
|
+
}
|
|
44
|
+
defer prog.Close()
|
|
45
|
+
files := map[string]*shimast.SourceFile{}
|
|
46
|
+
for _, name := range []string{"main.ts", "plain.ts"} {
|
|
47
|
+
// No linked hook is selected here, so this lookup changes nothing.
|
|
48
|
+
file := prog.SourceFile(filepath.ToSlash(filepath.Join(project, "src", name)))
|
|
49
|
+
if file == nil {
|
|
50
|
+
t.Fatalf("src/%s is not in the program", name)
|
|
51
|
+
}
|
|
52
|
+
files[name] = file
|
|
53
|
+
}
|
|
54
|
+
before := map[string][]checkUntouchedNode{}
|
|
55
|
+
for name, file := range files {
|
|
56
|
+
before[name] = checkUntouchedRecord(file)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
var errText bytes.Buffer
|
|
60
|
+
settings := buildSettings{cwd: project, tsconfig: "tsconfig.json", quiet: true, rewriteMode: "typia"}
|
|
61
|
+
if status := analyzeTypiaProgram(prog, settings, &errText, &errText); status != 0 {
|
|
62
|
+
t.Fatalf("analysis failed with %d:\n%s", status, errText.String())
|
|
63
|
+
}
|
|
64
|
+
registerTypiaDefaultLibraryClassifier(prog)
|
|
65
|
+
defer schemametadata.MetadataDefaultLibrary_release(prog.Checker)
|
|
66
|
+
rewritten := nativetransform.Transform(prog, &nativecontext.ITransformOptions{}, nativecontext.ITypiaContext_Extras{Shared: &sync.Map{}}, shimprinter.NewEmitContext())(files["main.ts"])
|
|
67
|
+
if rewritten == nil || rewritten == files["main.ts"] {
|
|
68
|
+
t.Fatal("the typia calls in src/main.ts must be rewritten into a new file")
|
|
69
|
+
}
|
|
70
|
+
for name, file := range files {
|
|
71
|
+
if after := checkUntouchedRecord(file); !reflect.DeepEqual(before[name], after) {
|
|
72
|
+
t.Fatalf("typia's analysis changed the parsed tree of src/%s", name)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
transformLinkedEditRewrite(files["plain.ts"].AsNode())
|
|
77
|
+
if reflect.DeepEqual(before["plain.ts"], checkUntouchedRecord(files["plain.ts"])) {
|
|
78
|
+
t.Fatal("the record must notice an in-place literal edit")
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// checkUntouchedNode is what an in-place edit of one parsed node can change.
|
|
83
|
+
type checkUntouchedNode struct {
|
|
84
|
+
node *shimast.Node
|
|
85
|
+
parent *shimast.Node
|
|
86
|
+
kind shimast.Kind
|
|
87
|
+
pos int
|
|
88
|
+
end int
|
|
89
|
+
flags shimast.NodeFlags
|
|
90
|
+
text string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
func checkUntouchedRecord(file *shimast.SourceFile) []checkUntouchedNode {
|
|
94
|
+
var nodes []checkUntouchedNode
|
|
95
|
+
var visit func(node *shimast.Node)
|
|
96
|
+
visit = func(node *shimast.Node) {
|
|
97
|
+
entry := checkUntouchedNode{node: node, parent: node.Parent, kind: node.Kind, pos: node.Pos(), end: node.End(), flags: node.Flags}
|
|
98
|
+
switch node.Kind {
|
|
99
|
+
case shimast.KindIdentifier, shimast.KindStringLiteral, shimast.KindNumericLiteral, shimast.KindNoSubstitutionTemplateLiteral:
|
|
100
|
+
entry.text = node.Text()
|
|
101
|
+
}
|
|
102
|
+
nodes = append(nodes, entry)
|
|
103
|
+
node.ForEachChild(func(child *shimast.Node) bool {
|
|
104
|
+
visit(child)
|
|
105
|
+
return false
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
visit(file.AsNode())
|
|
109
|
+
return nodes
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
func checkUntouchedProject(t *testing.T) string {
|
|
113
|
+
t.Helper()
|
|
114
|
+
project := t.TempDir()
|
|
115
|
+
if err := os.MkdirAll(filepath.Join(project, "src"), 0o755); err != nil {
|
|
116
|
+
t.Fatalf("mkdir fixture src: %v", err)
|
|
117
|
+
}
|
|
118
|
+
transformDiagnosticWriteTypiaStub(t, project)
|
|
119
|
+
files := map[string]string{
|
|
120
|
+
"tsconfig.json": `{
|
|
121
|
+
"compilerOptions": {
|
|
122
|
+
"target": "ES2022",
|
|
123
|
+
"module": "commonjs",
|
|
124
|
+
"moduleResolution": "bundler",
|
|
125
|
+
"ignoreDeprecations": "6.0",
|
|
126
|
+
"types": ["*"],
|
|
127
|
+
"strict": true,
|
|
128
|
+
"skipLibCheck": true,
|
|
129
|
+
"noEmit": true
|
|
130
|
+
},
|
|
131
|
+
"include": ["src"]
|
|
132
|
+
}
|
|
133
|
+
`,
|
|
134
|
+
filepath.Join("src", "main.ts"): `import typia from "typia";
|
|
135
|
+
export namespace Checks {
|
|
136
|
+
export class Value {
|
|
137
|
+
public static is(input: unknown): input is { value: number } {
|
|
138
|
+
return typia.is<{ value: number }>(input);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
export function named(input: unknown): input is { name: string } {
|
|
143
|
+
return typia.is<{ name: string }>(input);
|
|
144
|
+
}
|
|
145
|
+
`,
|
|
146
|
+
filepath.Join("src", "plain.ts"): `export const spec = "linked-pending";
|
|
147
|
+
`,
|
|
148
|
+
}
|
|
149
|
+
for name, text := range files {
|
|
150
|
+
if err := os.WriteFile(filepath.Join(project, name), []byte(text), 0o644); err != nil {
|
|
151
|
+
t.Fatalf("write %s: %v", name, err)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return project
|
|
155
|
+
}
|
|
@@ -45,6 +45,8 @@ func run(args []string) int {
|
|
|
45
45
|
return runTransform(args[1:])
|
|
46
46
|
case "check":
|
|
47
47
|
return runBuild(append([]string{"--noEmit"}, args[1:]...))
|
|
48
|
+
case "check-serve":
|
|
49
|
+
return runCheckServe(os.Stdin, stdout, args[1:])
|
|
48
50
|
case "-p", "--project":
|
|
49
51
|
if len(args) < 2 {
|
|
50
52
|
fmt.Fprintln(stderr, "ttsc-typia: -p/--project requires a path argument")
|
|
@@ -79,6 +81,7 @@ Usage:
|
|
|
79
81
|
Commands:
|
|
80
82
|
build Compile every .ts in a project and emit typia-rewritten .js.
|
|
81
83
|
check Run the analyzer without emitting.
|
|
84
|
+
check-serve Answer check requests over stdin/stdout from one resident program.
|
|
82
85
|
transform Emit a single file's typia-rewritten JS.
|
|
83
86
|
demo Run a backend smoke path.
|
|
84
87
|
version Print version, build info, and platform.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"os"
|
|
6
|
+
"path/filepath"
|
|
7
|
+
"strings"
|
|
8
|
+
"testing"
|
|
9
|
+
|
|
10
|
+
"github.com/samchon/ttsc/packages/ttsc/driver"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
// The driver pairs manifest entries with registrations by position, and Go
|
|
14
|
+
// runs package init functions in file-name order. This registration follows
|
|
15
|
+
// the ones in build_emit_hook_observations_test.go (entry 0) and
|
|
16
|
+
// transform_prints_files_rewritten_outside_typia_test.go (entry 1), so it
|
|
17
|
+
// answers manifest entry 2.
|
|
18
|
+
func init() { driver.RegisterPlugin(typiaCheckLoadProbe{}) }
|
|
19
|
+
|
|
20
|
+
// typiaCheckLoads counts driver.LoadProgram calls that selected the probe.
|
|
21
|
+
var typiaCheckLoads int
|
|
22
|
+
|
|
23
|
+
// typiaCheckValidSource is a source whose only typia call transforms cleanly.
|
|
24
|
+
const typiaCheckValidSource = `import typia from "typia";
|
|
25
|
+
export const isValue = (input: unknown): input is { value: number } =>
|
|
26
|
+
typia.is<{ value: number }>(input);
|
|
27
|
+
`
|
|
28
|
+
|
|
29
|
+
func typiaCheckWrite(t *testing.T, file, text string) {
|
|
30
|
+
t.Helper()
|
|
31
|
+
if err := os.MkdirAll(filepath.Dir(file), 0o755); err != nil {
|
|
32
|
+
t.Fatal(err)
|
|
33
|
+
}
|
|
34
|
+
if err := os.WriteFile(file, []byte(text), 0o644); err != nil {
|
|
35
|
+
t.Fatal(err)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// typiaCheckLoadProbe is a linked SourcePreamblePlugin contributing no text.
|
|
40
|
+
// LoadProgram asks every linked plugin for its preamble once per load, so the
|
|
41
|
+
// calls count Program loads.
|
|
42
|
+
type typiaCheckLoadProbe struct{}
|
|
43
|
+
|
|
44
|
+
func (typiaCheckLoadProbe) SourcePreamble(driver.PluginContext) (string, error) {
|
|
45
|
+
typiaCheckLoads++
|
|
46
|
+
return "", nil
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// TestTypiaCheckLoadsOneProgram verifies an analysis-only `check` answers from
|
|
50
|
+
// the one Program it loads, with the diagnostics and linked-hook outcome the
|
|
51
|
+
// emit lane would report.
|
|
52
|
+
//
|
|
53
|
+
// `check` used to load the project, diagnose it, then load it again with emit
|
|
54
|
+
// forced so typia's transformer could run inside the emit pipeline. The
|
|
55
|
+
// analysis now runs typia's transformer over the first Program, so it must
|
|
56
|
+
// still reach every file the emit lane transforms, including under
|
|
57
|
+
// emitDeclarationOnly, which the forced reload cleared, and still run the
|
|
58
|
+
// linked program hooks.
|
|
59
|
+
//
|
|
60
|
+
// 1. Select two linked ProgramPlugins and the load-counting probe.
|
|
61
|
+
// 2. Check a project with an invalid typia call, the same project under
|
|
62
|
+
// emitDeclarationOnly, a valid project and a failing linked hook.
|
|
63
|
+
// 3. Require one load each, the typia diagnostic, a clean pass and the hook's
|
|
64
|
+
// failure respectively.
|
|
65
|
+
//
|
|
66
|
+
// @evidence contracts/testing.md#behavioral-verification run("check") must report the typia diagnostic with its location, pass a valid project silently and surface a linked hook's error, each after exactly one LoadProgram; a forced-emit reload, a missed file or a skipped hook fails an assertion.
|
|
67
|
+
// @evidence contracts/testing.md#independent-expectations The authored generic typia.is call must fail at src/main.ts:3:9, the authored hook returns "authored hook failure", and one LoadProgram per invocation is the issue's acceptance criterion.
|
|
68
|
+
// @evidence contracts/testing.md#distinguishing-cases Invalid, emitDeclarationOnly-invalid, valid and hook-failure cases; the emitDeclarationOnly twin distinguishes a selection computed from the noEmit Program's own options, which would analyze nothing. Existing noEmit tests own manifest, verbose and allowImportingTsExtensions behavior.
|
|
69
|
+
// @evidence contracts/testing.md#execution-ownership The native Go runner discovers this unit test; linked plugins are selected with t.Setenv and the command runs in process through run.
|
|
70
|
+
func TestTypiaCheckLoadsOneProgram(t *testing.T) {
|
|
71
|
+
for _, tc := range []struct {
|
|
72
|
+
name string
|
|
73
|
+
declarationOnly bool
|
|
74
|
+
valid bool
|
|
75
|
+
hook string
|
|
76
|
+
status int
|
|
77
|
+
stderr string
|
|
78
|
+
}{
|
|
79
|
+
{name: "transform-failure", hook: "complete", status: 3, stderr: "src/main.ts:3:9 - error TS(typia.is):"},
|
|
80
|
+
{name: "declaration-only", declarationOnly: true, hook: "complete", status: 3, stderr: "src/main.ts:3:9 - error TS(typia.is):"},
|
|
81
|
+
{name: "valid", valid: true, hook: "complete", status: 0},
|
|
82
|
+
{name: "hook-failure", hook: "fail", status: 3, stderr: "ttsc-typia build: emit failed: authored hook failure"},
|
|
83
|
+
} {
|
|
84
|
+
t.Run(tc.name, func(t *testing.T) {
|
|
85
|
+
project := buildNoEmitDiagnosticProject(t, false)
|
|
86
|
+
if tc.declarationOnly {
|
|
87
|
+
config := filepath.Join(project, "tsconfig.json")
|
|
88
|
+
text, err := os.ReadFile(config)
|
|
89
|
+
if err != nil {
|
|
90
|
+
t.Fatal(err)
|
|
91
|
+
}
|
|
92
|
+
typiaCheckWrite(t, config, strings.Replace(string(text), `"declaration": true,`, `"declaration": true,
|
|
93
|
+
"emitDeclarationOnly": true,`, 1))
|
|
94
|
+
}
|
|
95
|
+
if tc.valid {
|
|
96
|
+
typiaCheckWrite(t, filepath.Join(project, "src", "main.ts"), typiaCheckValidSource)
|
|
97
|
+
}
|
|
98
|
+
typiaCheckWrite(t, filepath.Join(project, "external.txt"), "consumed\n")
|
|
99
|
+
payload, _ := json.Marshal([]driver.PluginEntry{
|
|
100
|
+
{Name: "observation-test", Stage: "transform", Config: map[string]any{"mode": tc.hook}},
|
|
101
|
+
{Name: "linked-edit", Stage: "transform", Config: map[string]any{}},
|
|
102
|
+
{Name: "load-probe", Stage: "transform", Config: map[string]any{}},
|
|
103
|
+
})
|
|
104
|
+
t.Setenv(driver.LinkedPluginsEnv, string(payload))
|
|
105
|
+
typiaCheckLoads = 0
|
|
106
|
+
out, errText, code := ttscTypiaTestCapture(func() int {
|
|
107
|
+
return run([]string{"check", "--cwd", project, "--tsconfig", "tsconfig.json"})
|
|
108
|
+
})
|
|
109
|
+
if code != tc.status || typiaCheckLoads != 1 {
|
|
110
|
+
t.Fatalf("check = %d after %d loads, want %d after one\nstdout=%s\nstderr=%s", code, typiaCheckLoads, tc.status, out, errText)
|
|
111
|
+
}
|
|
112
|
+
normalized := filepath.ToSlash(errText)
|
|
113
|
+
if tc.stderr == "" {
|
|
114
|
+
if strings.TrimSpace(out+errText) != "" {
|
|
115
|
+
t.Fatalf("a passing check printed output:\nstdout=%s\nstderr=%s", out, errText)
|
|
116
|
+
}
|
|
117
|
+
} else if !strings.Contains(normalized, tc.stderr) {
|
|
118
|
+
t.Fatalf("check lost %q:\n%s", tc.stderr, errText)
|
|
119
|
+
}
|
|
120
|
+
if tc.hook == "fail" && strings.Contains(normalized, "TS(typia") {
|
|
121
|
+
t.Fatalf("a failed linked hook must stop the analysis before typia runs:\n%s", errText)
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
}
|
package/native/go.mod
CHANGED
|
@@ -2,7 +2,8 @@ module github.com/samchon/typia/packages/typia/native
|
|
|
2
2
|
|
|
3
3
|
go 1.26
|
|
4
4
|
|
|
5
|
-
// The supported ttsc floor (>= 0.
|
|
5
|
+
// The supported ttsc floor (>= 0.38.0, including driver.NewSessionFromProgram
|
|
6
|
+
// and Session.Contains for the resident check-serve command)
|
|
6
7
|
// is enforced through typia's package.json peerDependency, not here: ttsc builds
|
|
7
8
|
// this plugin from source on the user's machine and its buildSourcePlugin
|
|
8
9
|
// generates `replace github.com/samchon/ttsc/packages/ttsc v0.0.0 =>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typia",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.5.0",
|
|
4
4
|
"description": "Superfast runtime validators with only one line",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"homepage": "https://typia.io",
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"randexp": "^0.5.3",
|
|
46
|
-
"@typia/interface": "^15.
|
|
47
|
-
"@typia/utils": "^15.
|
|
46
|
+
"@typia/interface": "^15.5.0",
|
|
47
|
+
"@typia/utils": "^15.5.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"ttsc": ">=0.
|
|
50
|
+
"ttsc": ">=0.38.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
|
53
53
|
"ttsc": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@types/node": "^25.3.0",
|
|
59
59
|
"rimraf": "^6.1.2",
|
|
60
60
|
"rolldown": "^1.1.5",
|
|
61
|
-
"ttsc": "^0.
|
|
61
|
+
"ttsc": "^0.38.0",
|
|
62
62
|
"typescript": "7.1.0-dev.20261020.3"
|
|
63
63
|
},
|
|
64
64
|
"sideEffects": false,
|
package/src/transform.ts
CHANGED
|
@@ -15,7 +15,9 @@ import type { ITtscPlugin, ITtscPluginFactoryContext } from "ttsc";
|
|
|
15
15
|
* and compiler-owned output provenance for ttsc's checked runtime reuse
|
|
16
16
|
* protocol. Its only variable reads outside ttsc's own namespace go through the
|
|
17
17
|
* program's recorded `Env`, so it declares `environmentInputs` and ttsc keys
|
|
18
|
-
* its outputs by the variables it read instead of the whole environment.
|
|
18
|
+
* its outputs by the variables it read instead of the whole environment. The
|
|
19
|
+
* host also answers `check-serve`, so it declares `residentCheck` and a `ttsc
|
|
20
|
+
* --noEmit --watch` keeps one typia process and its program across saves.
|
|
19
21
|
*
|
|
20
22
|
* @param context Plugin factory context of ttsc
|
|
21
23
|
*
|
|
@@ -44,6 +46,7 @@ export function createTtscPlugin(
|
|
|
44
46
|
emitObservations: true,
|
|
45
47
|
emitProvenance: true,
|
|
46
48
|
environmentInputs: true,
|
|
49
|
+
residentCheck: true,
|
|
47
50
|
},
|
|
48
51
|
};
|
|
49
52
|
}
|