typia 5.3.0-dev.20231120 → 5.3.0-dev.20231122

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.
@@ -1,30 +1,38 @@
1
1
  import ts from "typescript";
2
2
 
3
+ import { Singleton } from "../utils/Singleton";
4
+
3
5
  import { IProject } from "./IProject";
4
6
  import { NodeTransformer } from "./NodeTransformer";
5
7
  import { TransformerError } from "./TransformerError";
6
8
 
7
9
  export namespace FileTransformer {
8
10
  export const transform =
9
- (project: Omit<IProject, "context">) =>
11
+ (environments: Omit<IProject, "context">) =>
10
12
  (context: ts.TransformationContext) =>
11
13
  (file: ts.SourceFile): ts.SourceFile => {
12
14
  if (file.isDeclarationFile) return file;
15
+
16
+ const project: IProject = {
17
+ ...environments,
18
+ context,
19
+ };
20
+ checkJsDocParsingMode.get(project, file);
21
+
13
22
  return ts.visitEachChild(
14
23
  file,
15
- (node) => iterate_node({ ...project, context })(context)(node),
24
+ (node) => iterate_node(project)(node),
16
25
  context,
17
26
  );
18
27
  };
19
28
 
20
29
  const iterate_node =
21
30
  (project: IProject) =>
22
- (context: ts.TransformationContext) =>
23
31
  (node: ts.Node): ts.Node =>
24
32
  ts.visitEachChild(
25
33
  try_transform_node(project)(node) ?? node,
26
- (child) => iterate_node(project)(context)(child),
27
- context,
34
+ (child) => iterate_node(project)(child),
35
+ project.context,
28
36
  );
29
37
 
30
38
  const try_transform_node =
@@ -55,3 +63,29 @@ const isTransformerError = (error: any): error is TransformerError =>
55
63
  error.constructor.name === "TransformerError" &&
56
64
  typeof error.code === "string" &&
57
65
  typeof error.message === "string";
66
+
67
+ const checkJsDocParsingMode = new Singleton(
68
+ (project: IProject, file: ts.SourceFile) => {
69
+ if (
70
+ typeof file.jsDocParsingMode === "number" &&
71
+ file.jsDocParsingMode !== 0
72
+ ) {
73
+ project.extras.addDiagnostic(
74
+ ts.createDiagnosticForNode(file, {
75
+ code: `(typia setup)` as any,
76
+ key: "jsDocParsingMode",
77
+ category: ts.DiagnosticCategory.Warning,
78
+ message: [
79
+ `Run "npx typia setup" or "npx ts-patch install" command again.`,
80
+ ``,
81
+ `Since TypeScript v5.3 update, "tsc" no more parses JSDoc comments. Therefore, "typia" also cannot utilize those JSDoc comments, and it would damage some features of "typia" like "comment tags" or "JSON schema" generator.`,
82
+ ``,
83
+ `To solve this problem, run "npx typia setup" or "ts-patch install" command again to hack the TypeScript compiler to revive the JSDoc parsing.`,
84
+ ``,
85
+ ` - reference: https://github.com/microsoft/TypeScript/pull/55739`,
86
+ ].join("\n"),
87
+ }),
88
+ );
89
+ }
90
+ },
91
+ );