typia 14.0.1 → 14.0.2
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/lib/transformers/NoTransformConfigurationError.js +19 -4
- package/lib/transformers/NoTransformConfigurationError.js.map +1 -1
- package/lib/transformers/NoTransformConfigurationError.mjs +12 -6
- package/lib/transformers/NoTransformConfigurationError.mjs.map +1 -1
- package/native/cmd/ttsc-typia/json_schema_nonsensible_intersection_diagnostic_test.go +80 -0
- package/package.json +3 -3
- package/src/transformers/NoTransformConfigurationError.ts +19 -4
|
@@ -6,13 +6,28 @@ function NoTransformConfigurationError(name) {
|
|
|
6
6
|
throw new Error([
|
|
7
7
|
`Error on typia.${name}(): no transform has been configured.`,
|
|
8
8
|
"",
|
|
9
|
-
|
|
9
|
+
[
|
|
10
|
+
"Build the project with `ttsc` (not stock `tsc`), run TypeScript",
|
|
11
|
+
"with `ttsx`, or configure `@ttsc/unplugin` for a bundler.",
|
|
12
|
+
"These toolchains discover typia's native transform automatically.",
|
|
13
|
+
].join(" "),
|
|
14
|
+
"",
|
|
15
|
+
[
|
|
16
|
+
"If `ttsc` is missing, install it with",
|
|
17
|
+
"`npm i -D ttsc typescript`.",
|
|
18
|
+
].join(" "),
|
|
10
19
|
"",
|
|
11
20
|
[
|
|
12
|
-
"If
|
|
13
|
-
"
|
|
14
|
-
"is wrong with your code.",
|
|
21
|
+
"If setup is already complete, run `npx ttsc --noEmit` to",
|
|
22
|
+
"surface the underlying TypeScript or typia transform error.",
|
|
15
23
|
].join(" "),
|
|
24
|
+
"",
|
|
25
|
+
[
|
|
26
|
+
"Stock `tsc`, `ts-node`, `tsx`, Babel, and SWC do not load",
|
|
27
|
+
"typia's transform on their own.",
|
|
28
|
+
].join(" "),
|
|
29
|
+
"",
|
|
30
|
+
"See https://typia.io/docs/setup for setup and bundler instructions.",
|
|
16
31
|
].join("\n"));
|
|
17
32
|
}
|
|
18
33
|
//# sourceMappingURL=NoTransformConfigurationError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoTransformConfigurationError.js","sourceRoot":"","sources":["../../src/transformers/NoTransformConfigurationError.ts"],"names":[],"mappings":";;;AAAA,gBAAgB;AAChB,uCAA8C,IAAY;IACxD,MAAM,IAAI,KAAK,CACb;QACE,kBAAkB,IAAI,uCAAuC;QAC7D,EAAE;QACF,
|
|
1
|
+
{"version":3,"file":"NoTransformConfigurationError.js","sourceRoot":"","sources":["../../src/transformers/NoTransformConfigurationError.ts"],"names":[],"mappings":";;;AAAA,gBAAgB;AAChB,uCAA8C,IAAY;IACxD,MAAM,IAAI,KAAK,CACb;QACE,kBAAkB,IAAI,uCAAuC;QAC7D,EAAE;QACF;YACE,iEAAiE;YACjE,2DAA2D;YAC3D,mEAAmE;SACpE,CAAC,IAAI,CAAC,GAAG,CAAC;QACX,EAAE;QACF;YACE,uCAAuC;YACvC,6BAA6B;SAC9B,CAAC,IAAI,CAAC,GAAG,CAAC;QACX,EAAE;QACF;YACE,0DAA0D;YAC1D,6DAA6D;SAC9D,CAAC,IAAI,CAAC,GAAG,CAAC;QACX,EAAE;QACF;YACE,2DAA2D;YAC3D,iCAAiC;SAClC,CAAC,IAAI,CAAC,GAAG,CAAC;QACX,EAAE;QACF,qEAAqE;KACtE,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -4,13 +4,19 @@ function NoTransformConfigurationError(name) {
|
|
|
4
4
|
throw new Error([
|
|
5
5
|
`Error on typia.${name}(): no transform has been configured.`,
|
|
6
6
|
"",
|
|
7
|
-
"Read and follow https://typia.io/docs/setup please.",
|
|
8
|
-
"",
|
|
9
7
|
[
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
].join(" ")
|
|
8
|
+
"Build the project with `ttsc` (not stock `tsc`), run TypeScript",
|
|
9
|
+
"with `ttsx`, or configure `@ttsc/unplugin` for a bundler.",
|
|
10
|
+
"These toolchains discover typia's native transform automatically."
|
|
11
|
+
].join(" "),
|
|
12
|
+
"",
|
|
13
|
+
["If `ttsc` is missing, install it with", "`npm i -D ttsc typescript`."].join(" "),
|
|
14
|
+
"",
|
|
15
|
+
["If setup is already complete, run `npx ttsc --noEmit` to", "surface the underlying TypeScript or typia transform error."].join(" "),
|
|
16
|
+
"",
|
|
17
|
+
["Stock `tsc`, `ts-node`, `tsx`, Babel, and SWC do not load", "typia's transform on their own."].join(" "),
|
|
18
|
+
"",
|
|
19
|
+
"See https://typia.io/docs/setup for setup and bundler instructions."
|
|
14
20
|
].join("\n"));
|
|
15
21
|
}
|
|
16
22
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoTransformConfigurationError.mjs","names":[],"sources":["../../src/transformers/NoTransformConfigurationError.ts"],"sourcesContent":["/** @internal */\nexport function NoTransformConfigurationError(name: string): never {\n throw new Error(\n [\n `Error on typia.${name}(): no transform has been configured.`,\n \"\",\n \"
|
|
1
|
+
{"version":3,"file":"NoTransformConfigurationError.mjs","names":[],"sources":["../../src/transformers/NoTransformConfigurationError.ts"],"sourcesContent":["/** @internal */\nexport function NoTransformConfigurationError(name: string): never {\n throw new Error(\n [\n `Error on typia.${name}(): no transform has been configured.`,\n \"\",\n [\n \"Build the project with `ttsc` (not stock `tsc`), run TypeScript\",\n \"with `ttsx`, or configure `@ttsc/unplugin` for a bundler.\",\n \"These toolchains discover typia's native transform automatically.\",\n ].join(\" \"),\n \"\",\n [\n \"If `ttsc` is missing, install it with\",\n \"`npm i -D ttsc typescript`.\",\n ].join(\" \"),\n \"\",\n [\n \"If setup is already complete, run `npx ttsc --noEmit` to\",\n \"surface the underlying TypeScript or typia transform error.\",\n ].join(\" \"),\n \"\",\n [\n \"Stock `tsc`, `ts-node`, `tsx`, Babel, and SWC do not load\",\n \"typia's transform on their own.\",\n ].join(\" \"),\n \"\",\n \"See https://typia.io/docs/setup for setup and bundler instructions.\",\n ].join(\"\\n\"),\n );\n}\n"],"mappings":";;AACA,SAAgB,8BAA8B,MAAqB;CACjE,MAAM,IAAI,MACR;EACE,kBAAkB,KAAK;EACvB;EACA;GACE;GACA;GACA;EACF,CAAC,CAAC,KAAK,GAAG;EACV;EACA,CACE,yCACA,6BACF,CAAC,CAAC,KAAK,GAAG;EACV;EACA,CACE,4DACA,6DACF,CAAC,CAAC,KAAK,GAAG;EACV;EACA,CACE,6DACA,iCACF,CAAC,CAAC,KAAK,GAAG;EACV;EACA;CACF,CAAC,CAAC,KAAK,IAAI,CACb;AACF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"os"
|
|
5
|
+
"path/filepath"
|
|
6
|
+
"strings"
|
|
7
|
+
"testing"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// TestJSONSchemaNonsensibleIntersectionDiagnostic verifies that ttsc reports
|
|
11
|
+
// the transform-time cause behind issue #2373.
|
|
12
|
+
//
|
|
13
|
+
// The runtime fallback cannot inspect a TypeScript type after transformation
|
|
14
|
+
// has been skipped. This regression therefore compiles the reporter's exact
|
|
15
|
+
// `Date & string` property through the real typia package and preserves the
|
|
16
|
+
// actionable native diagnostic at its actual compiler boundary.
|
|
17
|
+
//
|
|
18
|
+
// 1. Compile a `typia.json.schema` call for the nonsensible intersection.
|
|
19
|
+
// 2. Require the API diagnostic, property path, and intersection reason.
|
|
20
|
+
func TestJSONSchemaNonsensibleIntersectionDiagnostic(t *testing.T) {
|
|
21
|
+
project := jsonSchemaNonsensibleIntersectionDiagnosticProject(t)
|
|
22
|
+
stdout, stderr, code := ttscTypiaTestCapture(func() int {
|
|
23
|
+
return runTransform([]string{
|
|
24
|
+
"--cwd", project,
|
|
25
|
+
"--tsconfig", "tsconfig.json",
|
|
26
|
+
"--file", "src/main.ts",
|
|
27
|
+
"--output", "js",
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
if code != 3 {
|
|
31
|
+
t.Fatalf("expected transform diagnostic exit code 3, got %d\nstdout:\n%s\nstderr:\n%s", code, stdout, stderr)
|
|
32
|
+
}
|
|
33
|
+
for _, expected := range []string{
|
|
34
|
+
"error TS(typia.json.schema):",
|
|
35
|
+
"ProblematicType.test",
|
|
36
|
+
"nonsensible intersection",
|
|
37
|
+
} {
|
|
38
|
+
if !strings.Contains(stderr, expected) {
|
|
39
|
+
t.Fatalf("expected stderr to contain %q, got:\n%s", expected, stderr)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
func jsonSchemaNonsensibleIntersectionDiagnosticProject(t *testing.T) string {
|
|
45
|
+
t.Helper()
|
|
46
|
+
root := ttscTypiaTestRepoRoot(t)
|
|
47
|
+
base := filepath.Join(root, "packages", "typia", "native", ".tmp-ttsc-typia-tests")
|
|
48
|
+
if err := os.MkdirAll(base, 0o755); err != nil {
|
|
49
|
+
t.Fatalf("create fixture base: %v", err)
|
|
50
|
+
}
|
|
51
|
+
project, err := os.MkdirTemp(base, "json-schema-nonsensible-intersection-")
|
|
52
|
+
if err != nil {
|
|
53
|
+
t.Fatalf("create fixture project: %v", err)
|
|
54
|
+
}
|
|
55
|
+
t.Cleanup(func() {
|
|
56
|
+
if err := os.RemoveAll(project); err != nil {
|
|
57
|
+
t.Errorf("remove fixture project: %v", err)
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
src := filepath.Join(project, "src")
|
|
61
|
+
if err := os.MkdirAll(src, 0o755); err != nil {
|
|
62
|
+
t.Fatalf("create fixture src: %v", err)
|
|
63
|
+
}
|
|
64
|
+
if err := os.WriteFile(filepath.Join(project, "tsconfig.json"), []byte(atomicIntersectionSchemaTSConfig), 0o644); err != nil {
|
|
65
|
+
t.Fatalf("write tsconfig: %v", err)
|
|
66
|
+
}
|
|
67
|
+
if err := os.WriteFile(filepath.Join(src, "main.ts"), []byte(jsonSchemaNonsensibleIntersectionDiagnosticSource), 0o644); err != nil {
|
|
68
|
+
t.Fatalf("write source: %v", err)
|
|
69
|
+
}
|
|
70
|
+
return project
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const jsonSchemaNonsensibleIntersectionDiagnosticSource = `import typia from "typia";
|
|
74
|
+
|
|
75
|
+
type ProblematicType = {
|
|
76
|
+
test: Date & string;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const schema = typia.json.schema<ProblematicType>();
|
|
80
|
+
`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typia",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.2",
|
|
4
4
|
"description": "Superfast runtime validators with only one line",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"homepage": "https://typia.io",
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"randexp": "^0.5.3",
|
|
46
|
-
"@typia/interface": "^14.0.
|
|
47
|
-
"@typia/utils": "^14.0.
|
|
46
|
+
"@typia/interface": "^14.0.2",
|
|
47
|
+
"@typia/utils": "^14.0.2"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"ttsc": ">=0.19.2"
|
|
@@ -4,13 +4,28 @@ export function NoTransformConfigurationError(name: string): never {
|
|
|
4
4
|
[
|
|
5
5
|
`Error on typia.${name}(): no transform has been configured.`,
|
|
6
6
|
"",
|
|
7
|
-
|
|
7
|
+
[
|
|
8
|
+
"Build the project with `ttsc` (not stock `tsc`), run TypeScript",
|
|
9
|
+
"with `ttsx`, or configure `@ttsc/unplugin` for a bundler.",
|
|
10
|
+
"These toolchains discover typia's native transform automatically.",
|
|
11
|
+
].join(" "),
|
|
12
|
+
"",
|
|
13
|
+
[
|
|
14
|
+
"If `ttsc` is missing, install it with",
|
|
15
|
+
"`npm i -D ttsc typescript`.",
|
|
16
|
+
].join(" "),
|
|
8
17
|
"",
|
|
9
18
|
[
|
|
10
|
-
"If
|
|
11
|
-
"
|
|
12
|
-
"is wrong with your code.",
|
|
19
|
+
"If setup is already complete, run `npx ttsc --noEmit` to",
|
|
20
|
+
"surface the underlying TypeScript or typia transform error.",
|
|
13
21
|
].join(" "),
|
|
22
|
+
"",
|
|
23
|
+
[
|
|
24
|
+
"Stock `tsc`, `ts-node`, `tsx`, Babel, and SWC do not load",
|
|
25
|
+
"typia's transform on their own.",
|
|
26
|
+
].join(" "),
|
|
27
|
+
"",
|
|
28
|
+
"See https://typia.io/docs/setup for setup and bundler instructions.",
|
|
14
29
|
].join("\n"),
|
|
15
30
|
);
|
|
16
31
|
}
|