Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TypeScript v5.7 update. #1415

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
},
"[mdx]": {
"editor.wordWrap": "on"
}
},
"typescript.tsdk": "node_modules\\typescript\\lib"
}
4 changes: 2 additions & 2 deletions benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
"suppress-warnings": "^1.0.2",
"tgrid": "^0.10.0",
"ts-node": "^10.9.1",
"ts-patch": "^3.2.0",
"ts-patch": "^3.3.0",
"tstl": "^3.0.0",
"typescript": "~5.6.3",
"typescript": "~5.7.2",
"uuid": "^8.3.2",
"zod": "^3.19.1"
},
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typia",
"version": "7.0.1",
"version": "7.0.2",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -41,16 +41,16 @@
},
"homepage": "https://typia.io",
"dependencies": {
"@samchon/openapi": "^2.0.0",
"@samchon/openapi": "^2.0.1",
"commander": "^10.0.0",
"comment-json": "^4.2.3",
"inquirer": "^8.2.5",
"package-manager-detector": "^0.2.0",
"randexp": "^0.5.3"
},
"peerDependencies": {
"typescript": ">=4.8.0 <5.7.0",
"@samchon/openapi": ">=2.0.0 <3.0.0"
"typescript": ">=4.8.0 <5.8.0",
"@samchon/openapi": ">=2.0.1 <3.0.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^26.0.1",
Expand All @@ -68,7 +68,7 @@
"rollup": "^4.18.0",
"suppress-warnings": "^1.0.2",
"ts-node": "^10.9.2",
"typescript": "~5.6.3"
"typescript": "~5.7.2"
},
"stackblitz": {
"startCommand": "npm install && npm run test"
Expand Down
5 changes: 3 additions & 2 deletions packages/typescript-json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
![Typia Logo](https://typia.io/logo.png)

[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/typia/blob/master/LICENSE)
[![npm version](https://img.shields.io/npm/v/typia.svg)](https://www.npmjs.com/package/typia)
[![Downloads](https://img.shields.io/npm/dm/typia.svg)](https://www.npmjs.com/package/typia)
[![NPM Version](https://img.shields.io/npm/v/typia.svg)](https://www.npmjs.com/package/typia)
[![NPM Downloads](https://img.shields.io/npm/dm/typia.svg)](https://www.npmjs.com/package/typia)
[![Build Status](https://github.com/samchon/typia/workflows/build/badge.svg)](https://github.com/samchon/typia/actions?query=workflow%3Abuild)
[![Guide Documents](https://img.shields.io/badge/guide-documents-forestgreen)](https://typia.io/docs/)
[![Gurubase](https://img.shields.io/badge/Gurubase-Ask%20Typia%20Guru-006BFF)](https://gurubase.io/g/typia)
[![Discord Badge](https://img.shields.io/badge/discord-samchon-d91965?style=flat&labelColor=5866f2&logo=discord&logoColor=white&link=https://discord.gg/E94XhzrUCZ)](https://discord.gg/E94XhzrUCZ)

```typescript
// RUNTIME VALIDATORS
Expand Down
8 changes: 4 additions & 4 deletions packages/typescript-json/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-json",
"version": "7.0.0-dev.20241202-3",
"version": "7.0.2-dev.20241205",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -37,11 +37,11 @@
},
"homepage": "https://typia.io",
"dependencies": {
"typia": "7.0.0-dev.20241202-3"
"typia": "7.0.2-dev.20241205"
},
"peerDependencies": {
"typescript": ">=4.8.0 <5.7.0",
"@samchon/openapi": ">=2.0.0 <3.0.0"
"typescript": ">=4.8.0 <5.8.0",
"@samchon/openapi": ">=2.0.1 <3.0.0"
},
"stackblitz": {
"startCommand": "npm install && npm run test"
Expand Down
31 changes: 17 additions & 14 deletions src/executable/TypiaPatchWizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,23 @@ export namespace TypiaPatchWizard {
};

export const patch = async (): Promise<void> => {
const location: string = require.resolve("typescript/lib/tsc.js");
const content: string = await fs.promises.readFile(location, "utf8");
if (content.indexOf(FROM_WITH_COMMENT) !== -1)
await fs.promises.writeFile(
location,
content.replace(FROM_WITH_COMMENT, TO_WITH_COMMENT),
"utf8",
);
else if (content.indexOf(FROM_ONLY) !== -1)
await fs.promises.writeFile(
location,
content.replace(FROM_ONLY, TO_ONLY),
"utf8",
);
for (const file of ["tsc.js", "_tsc.js"])
try {
const location: string = require.resolve(`typescript/lib/${file}`);
const content: string = await fs.promises.readFile(location, "utf8");
if (content.indexOf(FROM_WITH_COMMENT) !== -1)
await fs.promises.writeFile(
location,
content.replace(FROM_WITH_COMMENT, TO_WITH_COMMENT),
"utf8",
);
else if (content.indexOf(FROM_ONLY) !== -1)
await fs.promises.writeFile(
location,
content.replace(FROM_ONLY, TO_ONLY),
"utf8",
);
} catch {}
};
}

Expand Down
19 changes: 10 additions & 9 deletions src/factories/internal/metadata/iterate_metadata_native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import { IMetadataIteratorProps } from "./IMetadataIteratorProps";
export const iterate_metadata_native = (
props: IMetadataIteratorProps,
): boolean => {
const name: string = TypeFactory.getFullName({
checker: props.checker,
type: props.type,
symbol: props.type.getSymbol(),
});
const name: string =
TypeFactory.getFullName({
checker: props.checker,
type: props.type,
symbol: props.type.getSymbol(),
}).split("<")?.[0] ?? "";
const simple: IClassInfo | undefined = SIMPLES.get(name);
if (
simple !== undefined &&
Expand Down Expand Up @@ -72,7 +73,7 @@ const validate = (props: {
});
return (
returnType !== null &&
props.checker.typeToString(returnType) === method.return
props.checker.typeToString(returnType).split("<")?.[0] === method.return
);
}) &&
(props.info.properties ?? []).every((property) => {
Expand All @@ -82,7 +83,7 @@ const validate = (props: {
: undefined;
return (
propType !== undefined &&
props.checker.typeToString(propType) === property.type
props.checker.typeToString(propType).split("<")?.[0] === property.type
);
});

Expand Down Expand Up @@ -187,9 +188,9 @@ const SIMPLES: Map<string, IClassInfo> = new Map([
className,
{
methods: [
{ name: "arrayBuffer", return: "Promise<ArrayBuffer>" },
{ name: "arrayBuffer", return: "Promise" },
{ name: "slice", return: "Blob" },
{ name: "text", return: "Promise<string>" },
{ name: "text", return: "Promise" },
],
properties: [
{ name: "size", type: "number" },
Expand Down
7 changes: 7 additions & 0 deletions src/programmers/json/JsonAssertParseProgrammer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ts from "typescript";

import { IdentifierFactory } from "../../factories/IdentifierFactory";
import { JsonMetadataFactory } from "../../factories/JsonMetadataFactory";
import { StatementFactory } from "../../factories/StatementFactory";
import { TypeFactory } from "../../factories/TypeFactory";

Expand All @@ -19,6 +20,12 @@ export namespace JsonAssertParseProgrammer {
name: string | undefined;
init: ts.Expression | undefined;
}): FeatureProgrammer.IDecomposed => {
JsonMetadataFactory.analyze({
method: props.functor.method,
checker: props.context.checker,
transformer: props.context.transformer,
type: props.type,
});
const assert: FeatureProgrammer.IDecomposed = AssertProgrammer.decompose({
...props,
context: {
Expand Down
4 changes: 2 additions & 2 deletions test-error/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"homepage": "https://github.com/samchon/typia#readme",
"devDependencies": {
"rimraf": "^5.0.5",
"ts-patch": "^3.2.0",
"typescript": "~5.6.3"
"ts-patch": "^3.3.0",
"typescript": "~5.7.2"
},
"dependencies": {
"typia": "../"
Expand Down
6 changes: 3 additions & 3 deletions test-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
"homepage": "https://github.com/samchon/typia#readme",
"devDependencies": {
"@types/cli": "^0.11.25",
"@types/node": "^20.9.4",
"ts-patch": "^3.2.0",
"typescript": "~5.6.3"
"@types/node": "^22.10.1",
"ts-patch": "^3.3.0",
"typescript": "~5.7.2"
},
"dependencies": {
"typia": "../"
Expand Down
13 changes: 13 additions & 0 deletions test-esm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,17 @@ console.log(
typia.is<boolean>(true),
typia.assert<string>("something"),
typia.json.stringify<number>(3),
typia.protobuf.message<{
value: number;
binary: Uint8Array;
}>(),
typia.llm.schema<
{
/**
* Primary Key.
*/
id: string;
},
"gemini"
>(),
);
4 changes: 2 additions & 2 deletions test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"ts-node": "^10.9.2",
"ts-patch": "^3.2.1",
"typescript": "~5.6.3"
"ts-patch": "^3.3.0",
"typescript": "~5.7.2"
},
"dependencies": {
"cli": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/llm.application/3.0/ArrayAny.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/llm.application/3.0/ArrayHierarchical.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/llm.application/3.0/ArrayMatrix.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/llm.application/3.0/ArrayRecursive.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/llm.application/3.0/ArrayRepeatedUnion.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/llm.application/3.0/ArraySimple.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/llm.application/3.0/ArrayUnion.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/llm.application/3.0/AtomicUnion.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/llm.application/3.0/ClassGetter.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/llm.application/3.0/ClassMethod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": "3.0",
"options": {
"constraint": false,
"constraint": true,
"recursive": 3,
"separate": null
},
Expand Down
Loading
Loading