diff --git a/deploy/internal/ReplicaPublisher.ts b/deploy/internal/ReplicaPublisher.ts index 54e4ad5f24..c9063487bc 100644 --- a/deploy/internal/ReplicaPublisher.ts +++ b/deploy/internal/ReplicaPublisher.ts @@ -4,25 +4,24 @@ import fs from "fs"; export namespace ReplicaPublisher { export function replica(tag: string): void { // PREPARE DIRECTORY - if (fs.existsSync(PACKAGES)) cp.execSync(`rimraf ${PACKAGES}`); - fs.mkdirSync(PACKAGES); - fs.mkdirSync(typia); + if (fs.existsSync(LEGACY)) cp.execSync(`rimraf ${LEGACY}`); + fs.mkdirSync(LEGACY); // COPY ESSENTIAL FILES for (const file of ["package.json", "LICENSE", "tsconfig.json"]) - fs.copyFileSync(`${ROOT}/${file}`, `${typia}/${file}`); + fs.copyFileSync(`${ROOT}/${file}`, `${LEGACY}/${file}`); readme(); // CREATE RE-EXPORT FILES - fs.mkdirSync(`${typia}/src`); - link(LIB, `${typia}/src`); + fs.mkdirSync(`${LEGACY}/src`); + link(LIB, `${LEGACY}/src`); // CHANGE PACKAGE.JSON CONTENT pack(); // DO BUILD & PUBLISH try { - cp.execSync("npx tsc", { cwd: typia }); + cp.execSync("npx tsc", { cwd: LEGACY }); } catch {} console.log("publish typescript-json (replica)"); @@ -32,7 +31,7 @@ export namespace ReplicaPublisher { function readme(): void { const content: string = fs.readFileSync(`${ROOT}/README.md`, "utf8"); fs.writeFileSync( - `${typia}/README.md`, + `${LEGACY}/README.md`, "> ## Deprecated\n" + "> `typescript-json` has been renamed to [`typia`](https://github.com/samchon/typia)" + "\n\n" + @@ -72,7 +71,7 @@ export namespace ReplicaPublisher { function pack(): void { const pack: any = JSON.parse( - fs.readFileSync(`${typia}/package.json`, "utf8"), + fs.readFileSync(`${LEGACY}/package.json`, "utf8"), ); pack.name = "typescript-json"; @@ -84,7 +83,7 @@ export namespace ReplicaPublisher { delete pack.bin; fs.writeFileSync( - `${typia}/package.json`, + `${LEGACY}/package.json`, JSON.stringify(pack, null, 2), "utf8", ); @@ -93,13 +92,12 @@ export namespace ReplicaPublisher { function publish(command: string): void { try { cp.execSync(command, { - cwd: typia, + cwd: LEGACY, }); } catch {} } } const ROOT: string = __dirname + "/../.."; -const PACKAGES: string = ROOT + "/packages"; -const typia: string = PACKAGES + "/typescript-json"; +const LEGACY: string = ROOT + "/packages/typescript-json"; const LIB = `${__dirname}/../../lib`; diff --git a/package.json b/package.json index 9eb2e2bafb..0c028e3b01 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typia", - "version": "5.3.0-dev.20231122", + "version": "5.3.0-dev.20231126-2", "description": "Superfast runtime validators with only one line", "main": "lib/index.js", "typings": "lib/index.d.ts", diff --git a/packages/benchmark/package.json b/packages/benchmark/package.json index 6c847f5a43..48892ea695 100644 --- a/packages/benchmark/package.json +++ b/packages/benchmark/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "rimraf bin && tsc", "build:actions": "rimraf bin && tsc -p tsconfig.actions.json", - "prepare": "ts-patch install", + "prepare": "ts-patch install && typia patch", "prettier": "prettier ./src/**/*.ts --write", "start": "node bin", "template": "ts-node src/template && npm run prettier && npm run build" @@ -73,6 +73,6 @@ "suppress-warnings": "^1.0.2", "tstl": "^2.5.13", "uuid": "^9.0.1", - "typia": "D:\\github\\samchon\\typia\\typia-5.3.0-dev.20231122.tgz" + "typia": "D:\\github\\samchon\\typia\\typia-5.3.0-dev.20231126-2.tgz" } } \ No newline at end of file diff --git a/packages/errors/package.json b/packages/errors/package.json index 50ff2e944c..45189cf6dc 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -6,7 +6,7 @@ "main": "index.js", "scripts": { "build": "rimraf bin && tsc", - "prepare": "ts-patch install", + "prepare": "ts-patch install && typia patch", "prettier": "prettier ./src/**/*.ts --write", "setup": "node build/setup.js", "start": "node index" @@ -29,9 +29,9 @@ "devDependencies": { "rimraf": "^5.0.5", "ts-patch": "^3.0.2", - "typescript": "5.2.2" + "typescript": "^5.3.2" }, "dependencies": { - "typia": "D:\\github\\samchon\\typia\\typia-5.3.0-dev.20231122.tgz" + "typia": "D:\\github\\samchon\\typia\\typia-5.3.0-dev.20231126-2.tgz" } } \ No newline at end of file diff --git a/packages/test/package.json b/packages/test/package.json index 2f229861a7..84d5c102f9 100644 --- a/packages/test/package.json +++ b/packages/test/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "rimraf bin && tsc", "build:actions": "rimraf bin && tsc -p tsconfig.actions.json", - "prepare": "ts-patch install", + "prepare": "ts-patch install && typia patch", "prettier": "prettier ./src/**/*.ts --write", "setup": "node build/setup.js", "start": "node bin", @@ -36,7 +36,7 @@ "rimraf": "^5.0.5", "ts-node": "^10.9.1", "ts-patch": "^3.0.2", - "typescript": "5.2.2" + "typescript": "^5.3.2" }, "dependencies": { "cli": "^1.0.1", @@ -46,6 +46,6 @@ "suppress-warnings": "^1.0.2", "tstl": "^2.5.13", "uuid": "^9.0.1", - "typia": "D:\\github\\samchon\\typia\\typia-5.3.0-dev.20231122.tgz" + "typia": "D:\\github\\samchon\\typia\\typia-5.3.0-dev.20231126-2.tgz" } } \ No newline at end of file diff --git a/packages/typescript-json/package.json b/packages/typescript-json/package.json index 0c28c5f992..e8d3174b15 100644 --- a/packages/typescript-json/package.json +++ b/packages/typescript-json/package.json @@ -1,39 +1,23 @@ { "name": "typescript-json", - "version": "5.3.0-dev.20231122", + "version": "5.3.0-dev.20231126-2", "description": "Superfast runtime validators with only one line", "main": "lib/index.js", "typings": "lib/index.d.ts", "scripts": { - "benchmark": "npm run build:benchmark && node measure/benchmark", - "benchmark:generate": "ts-node benchmark/generate && npm run build:benchmark", - "test:generate": "npx ts-node src/executable/typia generate --input test/features --output test/generated/output --project test/tsconfig.json", - "test:template": "npx tsc && ts-node -P build/tsconfig.json build/test.ts", - "----------------------------------------------": "", + "test": "npm run package:tgz", + "-------------------------------------------------": "", "build": "rimraf lib && tsc --removeComments --declaration false && tsc --emitDeclarationOnly", - "build:test": "rimraf bin && tsc -p test/tsconfig.json", - "build:test:actions": "rimraf bin && tsc -p test/tsconfig.actions.json", - "build:test:issues": "rimraf bin && tsc -p test/tsconfig.issue.json", - "build:benchmark": "rimraf measure && tsc -p benchmark/tsconfig.json", - "build:test:errors": "rimraf errors/bin && tsc -p errors/tsconfig.json", - "build:test:prettier": "npm run build:test && prettier --write ./bin/**/*.js", "dev": "rimraf lib && tsc --watch", - "dev:test": "rimraf bin && tsc -p test/tsconfig.json --watch", "eslint": "eslint ./**/*.ts", "eslint:fix": "eslint ./**/*.ts --fix", - "prettier": "prettier --write ./**/*.ts", - "-----------------------------------------------": "", - "issue": "node test/issue", - "issue:generate": "ts-node src/executable/typia generate --input test/issues/generate/input --output test/issues/generate --project test/tsconfig.json", - "test": "node bin/test", - "test:errors": "node errors", - "test:manual": "node test/manual", + "prettier": "prettier src --write", "------------------------------------------------": "", - "package:latest": "ts-node build/publish.ts latest", - "package:next": "ts-node build/publish.ts next", - "package:patch": "ts-node build/publish.ts patch", - "package:deprecate": "npm deprecate typescript-json \"Renamed to typia\"", - "prepare": "ts-patch install" + "package:latest": "ts-node deploy latest", + "package:next": "ts-node deploy next", + "package:patch": "ts-node deploy patch", + "package:tgz": "ts-node deploy tgz", + "package:deprecate": "npm deprecate typescript-json \"Renamed to typia\"" }, "repository": { "type": "git", @@ -72,13 +56,13 @@ }, "homepage": "https://typia.io", "dependencies": { - "typia": "5.3.0-dev.20231122" + "typia": "5.3.0-dev.20231126-2" }, "peerDependencies": { - "typescript": ">=4.8.0 <5.3.0" + "typescript": ">=4.8.0 <5.4.0" }, "stackblitzs": { - "startCommand": "npm run prepare && npm run build:test:actions && npm run build:test && npm run test" + "startCommand": "npm install && npm run build && cd packages/test && npm install && npm run build:actions && npm start" }, "files": [ "LICENSE", diff --git a/src/executable/TypiaPatchWizard.ts b/src/executable/TypiaPatchWizard.ts new file mode 100644 index 0000000000..a023b5bb53 --- /dev/null +++ b/src/executable/TypiaPatchWizard.ts @@ -0,0 +1,31 @@ +import fs from "fs"; + +export namespace TypiaPatchWizard { + export const main = async (): Promise => { + console.log("----------------------------------------"); + console.log(" Typia Setup Wizard"); + console.log("----------------------------------------"); + console.log( + [ + `Since TypeScript v5.3 update, "tsc" no more parses JSDoc comments.`, + ``, + `Therefore, "typia" revives the JSDoc parsing feature by patching "tsc".`, + ``, + `This is a temporary feature of "typia", and it would be removed when "ts-patch" being updated.`, + ].join("\n"), + ); + + await patch(); + }; + + export const patch = async (): Promise => { + const location: string = require.resolve("typescript/lib/tsc.js"); + const content: string = await fs.promises.readFile(location, "utf8"); + if (content.indexOf(FROM) === -1) return; + + await fs.promises.writeFile(location, content.replace(FROM, TO), "utf8"); + }; +} + +const FROM = `var defaultJSDocParsingMode = 2 /* ParseForTypeErrors */`; +const TO = `var defaultJSDocParsingMode = 0 /* ParseAll */`; diff --git a/src/executable/TypiaSetupWizard.ts b/src/executable/TypiaSetupWizard.ts index 37045cbfb6..aedd2b6371 100644 --- a/src/executable/TypiaSetupWizard.ts +++ b/src/executable/TypiaSetupWizard.ts @@ -1,5 +1,6 @@ import fs from "fs"; +import { TypiaPatchWizard } from "./TypiaPatchWizard"; import { ArgumentParser } from "./setup/ArgumentParser"; import { CommandExecutor } from "./setup/CommandExecutor"; import { PackageManager } from "./setup/PackageManager"; @@ -23,7 +24,7 @@ export namespace TypiaSetupWizard { // INSTALL TYPESCRIPT COMPILERS pack.install({ dev: true, modulo: "ts-patch", version: "latest" }); pack.install({ dev: true, modulo: "ts-node", version: "latest" }); - pack.install({ dev: true, modulo: "typescript", version: "5.2.2" }); + pack.install({ dev: true, modulo: "typescript", version: "5.3.2" }); args.project ??= (() => { const runner: string = pack.manager === "npm" ? "npx" : pack.manager; CommandExecutor.run(`${runner} tsc --init`); @@ -38,9 +39,20 @@ export namespace TypiaSetupWizard { typeof data.scripts.prepare === "string" && data.scripts.prepare.trim().length ) { - if (data.scripts.prepare.indexOf("ts-patch install") === -1) + if ( + data.scripts.prepare.indexOf("ts-patch install") === -1 && + data.scripts.prepare.indexOf("typia patch") === -1 + ) + data.scripts.prepare = + "ts-patch install && typia patch && " + data.scripts.prepare; + else if (data.scripts.prepare.indexOf("ts-patch install") === -1) data.scripts.prepare = "ts-patch install && " + data.scripts.prepare; - } else data.scripts.prepare = "ts-patch install"; + else if (data.scripts.prepare.indexOf("typia patch") === -1) + data.scripts.prepare = data.scripts.prepare.replace( + "ts-patch install", + "ts-patch install && typia patch", + ); + } else data.scripts.prepare = "ts-patch install && typia patch"; // FOR OLDER VERSIONS if (typeof data.scripts.postinstall === "string") { @@ -53,6 +65,7 @@ export namespace TypiaSetupWizard { delete data.scripts.postinstall; } }); + await TypiaPatchWizard.patch(); CommandExecutor.run(`${pack.manager} run prepare`); // CONFIGURE TYPIA diff --git a/src/executable/typia.ts b/src/executable/typia.ts index e61956c423..bcdde5793a 100644 --- a/src/executable/typia.ts +++ b/src/executable/typia.ts @@ -34,6 +34,9 @@ const main = async (): Promise => { if (type === "setup") { const { TypiaSetupWizard } = await import("./TypiaSetupWizard"); await TypiaSetupWizard.setup(); + } else if (type === "patch") { + const { TypiaPatchWizard } = await import("./TypiaPatchWizard"); + await TypiaPatchWizard.main(); } else if (type === "generate") { try { await import("typescript"); diff --git a/src/transformers/FileTransformer.ts b/src/transformers/FileTransformer.ts index 7ab8867810..4dbca098b2 100644 --- a/src/transformers/FileTransformer.ts +++ b/src/transformers/FileTransformer.ts @@ -76,11 +76,11 @@ const checkJsDocParsingMode = new Singleton( key: "jsDocParsingMode", category: ts.DiagnosticCategory.Warning, message: [ - `Run "npx typia setup" or "npx ts-patch install" command again.`, + `Run "npx typia setup" or "npx typia patch" command again.`, ``, - `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.`, + `Since TypeScript v5.3 update, "tsc" no more parses JSDoc comments. Therefore, "typia" also cannot utilize those JSDoc comments too, and it damages on some features of "typia" like "comment tags" or "JSON schema" generator.`, ``, - `To solve this problem, run "npx typia setup" or "ts-patch install" command again to hack the TypeScript compiler to revive the JSDoc parsing.`, + `To solve this problem, run "npx typia setup" or "npx typia patch" command to hack the TypeScript compiler to revive the JSDoc parsing feature.`, ``, ` - reference: https://github.com/microsoft/TypeScript/pull/55739`, ].join("\n"), diff --git a/website/package-lock.json b/website/package-lock.json index e5e331c124..542d5d2cd1 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -20,7 +20,7 @@ "nextra-theme-docs": "latest", "react": "^18.2.0", "react-dom": "^18.2.0", - "typescript": "^5.3.0-beta" + "typescript": "^5.3.2" }, "devDependencies": { "@trivago/prettier-plugin-sort-imports": "^4.1.1", @@ -31,7 +31,7 @@ "prettier": "^2.8.8", "rimraf": "^5.0.0", "ts-node": "^10.9.1", - "typia": "^5.3.0-dev.20231117" + "typia": "^5.3.0-dev.20231126-2" } }, "node_modules/@babel/code-frame": { @@ -7630,9 +7630,9 @@ } }, "node_modules/typescript": { - "version": "5.3.0-beta", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.0-beta.tgz", - "integrity": "sha512-SiTeC1C8wAS6v2SD05iyfojeuIkUZIbb8suZz0d4BR+RErwpG+05iolat+VjM9hqXSrjb3xutEBzh4X3NJ7Jgw==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.2.tgz", + "integrity": "sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -7642,9 +7642,9 @@ } }, "node_modules/typia": { - "version": "5.3.0-dev.20231117", - "resolved": "https://registry.npmjs.org/typia/-/typia-5.3.0-dev.20231117.tgz", - "integrity": "sha512-u1oVVCq6t7t5ZSczawr1umHQtr5oiAhI49gP8N4TcOaolrWLQn/Vqd9CXC4q7L0igUBxfjyXrxnbEUZ55IgnJQ==", + "version": "5.3.0-dev.20231126-2", + "resolved": "https://registry.npmjs.org/typia/-/typia-5.3.0-dev.20231126-2.tgz", + "integrity": "sha512-MV8pZFHOol3eWYewhhg2ziGXybFDodPE7TvwW9Bi+sW+3dBEZcb75I6FhUMigzxY1SbyNmN+fcclIcyJqtDe+Q==", "dev": true, "dependencies": { "commander": "^10.0.0", @@ -7656,7 +7656,7 @@ "typia": "lib/executable/typia.js" }, "peerDependencies": { - "typescript": ">=4.8.0 <5.3.0" + "typescript": ">=4.8.0 <5.4.0" } }, "node_modules/typia/node_modules/commander": { diff --git a/website/package.json b/website/package.json index 6c844882d7..193a0da073 100644 --- a/website/package.json +++ b/website/package.json @@ -30,7 +30,7 @@ "nextra-theme-docs": "latest", "react": "^18.2.0", "react-dom": "^18.2.0", - "typescript": "^5.3.0-beta" + "typescript": "^5.3.2" }, "devDependencies": { "@trivago/prettier-plugin-sort-imports": "^4.1.1", @@ -41,6 +41,6 @@ "prettier": "^2.8.8", "rimraf": "^5.0.0", "ts-node": "^10.9.1", - "typia": "^5.3.0-dev.20231117" + "typia": "^5.3.0-dev.20231126-2" } } diff --git a/website/pages/docs/setup.mdx b/website/pages/docs/setup.mdx index e6c13bc385..d22f62f2e5 100644 --- a/website/pages/docs/setup.mdx +++ b/website/pages/docs/setup.mdx @@ -208,7 +208,7 @@ As `typia` generates optimal operation code through transformation, you've to co ```json filename="package.json" copy showLineNumbers {2-4} { "scripts": { - "prepare": "ts-patch install" + "prepare": "ts-patch install && typia patch" }, "dependencies": { "typia": "^4.1.8" @@ -246,6 +246,21 @@ Of course, you've to run the `npm run prepare` command after the configuration. For reference, [`ts-patch`](https://github.com/nonara/ts-patch) is an helper library of TypeScript compiler that supporting custom transformations by plugins. From now on, whenever you run `tsc` command, your `typia` function call statements would be transformed to the optimal operation codes in the compiled JavaScript files. +
+ + + + **`npx typia patch`** + + +Since TypeScript v5.3 update, `tsc` no more parses `JSDocComment`s. Therefore, `typia` also cannot utilize those `JSDocComment` related features too, especially ["Comment Tags"](./validators/tags/#comment-tags) and ["JSON schema generator"](./json/schema). + +The `npx typia patch` command has been developed to revive the `JSDocComment` parsing feature of `tsc`. It is temporary solution for the TypeScript v5.3 update instead of [`ts-patch`](https://github.com/nonara/ts-patch), and will be disabled after [`ts-patch`](https://github.com/nonara/ts-patch) starts supporting such TypeScript v5.3 update. + +Of course, if you don't use any ["Comment Tags"](./validators/tags/#comment-tags) and ["JSON schema generator"](./json/schema), you don't need to run `npx typia patch` command. This is not mandatory command, but just optional command. + + +