From c39cb48528846b8e968ee70bf8ab8118cce46a83 Mon Sep 17 00:00:00 2001 From: Arthur Fiorette <47537704+arthurfiorette@users.noreply.github.com> Date: Sat, 25 May 2024 16:18:20 -0300 Subject: [PATCH 1/5] feat: remove ts-expose-internals (#1968) --- package.json | 1 - src/NodeParser/FunctionNodeParser.ts | 13 +++++-------- src/NodeParser/PromiseNodeParser.ts | 4 +++- src/NodeParser/TypeReferenceNodeParser.ts | 3 ++- src/SchemaGenerator.ts | 4 +++- src/Utils/symbolAtNode.ts | 3 ++- yarn.lock | 5 ----- 7 files changed, 15 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 32bc25d3a..71a932062 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,6 @@ "@types/jest": "^29.5.12", "@types/node": "^20.12.7", "@types/normalize-path": "^3.0.2", - "@types/ts-expose-internals": "npm:ts-expose-internals@^5.4.5", "ajv": "^8.12.0", "ajv-formats": "^3.0.1", "auto": "^11.1.6", diff --git a/src/NodeParser/FunctionNodeParser.ts b/src/NodeParser/FunctionNodeParser.ts index e31a666a9..7f5f06304 100644 --- a/src/NodeParser/FunctionNodeParser.ts +++ b/src/NodeParser/FunctionNodeParser.ts @@ -1,11 +1,11 @@ import ts from "typescript"; -import { SubNodeParser } from "../SubNodeParser.js"; -import { BaseType } from "../Type/BaseType.js"; +import type { SubNodeParser } from "../SubNodeParser.js"; +import type { BaseType } from "../Type/BaseType.js"; import { FunctionType } from "../Type/FunctionType.js"; -import { FunctionOptions } from "../Config.js"; +import type { FunctionOptions } from "../Config.js"; import { NeverType } from "../Type/NeverType.js"; import { DefinitionType } from "../Type/DefinitionType.js"; -import { Context, NodeParser } from "../NodeParser.js"; +import type { Context, NodeParser } from "../NodeParser.js"; import { ObjectProperty, ObjectType } from "../Type/ObjectType.js"; import { getKey } from "../Utils/nodeKey.js"; @@ -15,14 +15,11 @@ export class FunctionNodeParser implements SubNodeParser { protected functions: FunctionOptions, ) {} - public supportsNode(node: ts.TypeNode): boolean { + public supportsNode(node: ts.Node): boolean { return ( node.kind === ts.SyntaxKind.FunctionType || - // @ts-expect-error internals type bug node.kind === ts.SyntaxKind.FunctionExpression || - // @ts-expect-error internals type bug node.kind === ts.SyntaxKind.ArrowFunction || - // @ts-expect-error internals type bug node.kind === ts.SyntaxKind.FunctionDeclaration ); } diff --git a/src/NodeParser/PromiseNodeParser.ts b/src/NodeParser/PromiseNodeParser.ts index 08320bff0..484e13325 100644 --- a/src/NodeParser/PromiseNodeParser.ts +++ b/src/NodeParser/PromiseNodeParser.ts @@ -32,6 +32,7 @@ export class PromiseNodeParser implements SubNodeParser { const type = this.typeChecker.getTypeAtLocation(node); + //@ts-expect-error - internal typescript API const awaitedType = this.typeChecker.getAwaitedType(type); // ignores non awaitable types @@ -60,7 +61,8 @@ export class PromiseNodeParser implements SubNodeParser { context: Context, ): BaseType { const type = this.typeChecker.getTypeAtLocation(node); - const awaitedType = this.typeChecker.getAwaitedType(type)!; // supportsNode ensures this + //@ts-expect-error - internal typescript API + const awaitedType = this.typeChecker.getAwaitedType(type); const awaitedNode = this.typeChecker.typeToTypeNode(awaitedType, undefined, ts.NodeBuilderFlags.IgnoreErrors); if (!awaitedNode) { diff --git a/src/NodeParser/TypeReferenceNodeParser.ts b/src/NodeParser/TypeReferenceNodeParser.ts index f059ecc5d..14535a243 100644 --- a/src/NodeParser/TypeReferenceNodeParser.ts +++ b/src/NodeParser/TypeReferenceNodeParser.ts @@ -6,6 +6,7 @@ import { AnyType } from "../Type/AnyType.js"; import { ArrayType } from "../Type/ArrayType.js"; import type { BaseType } from "../Type/BaseType.js"; import { StringType } from "../Type/StringType.js"; +import { symbolAtNode } from "../Utils/symbolAtNode.js"; const invalidTypes: Record = { [ts.SyntaxKind.ModuleDeclaration]: true, @@ -28,7 +29,7 @@ export class TypeReferenceNodeParser implements SubNodeParser { // When the node doesn't have a valid source file, its position is -1, so we can't // search for a symbol based on its location. In that case, the ts.factory defines a symbol // property on the node itself. - (node.typeName as unknown as ts.Type).symbol; + symbolAtNode(node.typeName)!; if (typeSymbol.flags & ts.SymbolFlags.Alias) { const aliasedSymbol = this.typeChecker.getAliasedSymbol(typeSymbol); diff --git a/src/SchemaGenerator.ts b/src/SchemaGenerator.ts index c07a9e3e5..9ea6d2cf0 100644 --- a/src/SchemaGenerator.ts +++ b/src/SchemaGenerator.ts @@ -10,6 +10,7 @@ import type { TypeFormatter } from "./TypeFormatter.js"; import type { StringMap } from "./Utils/StringMap.js"; import { hasJsDocTag } from "./Utils/hasJsDocTag.js"; import { removeUnreachable } from "./Utils/removeUnreachable.js"; +import { symbolAtNode } from "./Utils/symbolAtNode.js"; export class SchemaGenerator { public constructor( @@ -262,6 +263,7 @@ export class SchemaGenerator { return false; } + //@ts-expect-error - internal typescript API return !!node.localSymbol?.exportSymbol; } @@ -270,6 +272,6 @@ export class SchemaGenerator { } protected getFullName(node: ts.Declaration, typeChecker: ts.TypeChecker): string { - return typeChecker.getFullyQualifiedName(node.symbol).replace(/".*"\./, ""); + return typeChecker.getFullyQualifiedName(symbolAtNode(node)!).replace(/".*"\./, ""); } } diff --git a/src/Utils/symbolAtNode.ts b/src/Utils/symbolAtNode.ts index 1a6988d2b..d55584c58 100644 --- a/src/Utils/symbolAtNode.ts +++ b/src/Utils/symbolAtNode.ts @@ -1,5 +1,6 @@ import type ts from "typescript"; export function symbolAtNode(node: ts.Node): ts.Symbol | undefined { - return (node as ts.Declaration).symbol; + //@ts-expect-error - internal typescript API + return node.symbol; } diff --git a/yarn.lock b/yarn.lock index 38ac61950..43153aab7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1976,11 +1976,6 @@ resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8" integrity sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw== -"@types/ts-expose-internals@npm:ts-expose-internals@^5.4.5": - version "5.4.5" - resolved "https://registry.yarnpkg.com/ts-expose-internals/-/ts-expose-internals-5.4.5.tgz#94da2b665627135ad1281d98af3ccb08cb4c1950" - integrity sha512-0HfRwjgSIOyuDlHzkFedMWU4aHWq9pu4MUKHgH75U+L76wCAtK5WB0rc/dAIhulMRcPUlcKONeiiR5Sxy/7XcA== - "@types/yargs-parser@*": version "21.0.3" resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.3.tgz#815e30b786d2e8f0dcd85fd5bcf5e1a04d008f15" From a1da3a2598188f5b920098f781a437aa3801be98 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 26 May 2024 11:02:03 +0000 Subject: [PATCH 2/5] chore(deps-dev): bump typescript-eslint from 7.8.0 to 7.10.0 (#1972) Bumps [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint) from 7.8.0 to 7.10.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v7.10.0/packages/typescript-eslint) --- updated-dependencies: - dependency-name: typescript-eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 122 +++++++++++++++++++++++++----------------------------- 1 file changed, 56 insertions(+), 66 deletions(-) diff --git a/yarn.lock b/yarn.lock index 43153aab7..43484bed3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1966,11 +1966,6 @@ resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.2.tgz#5950e50960793055845e956c427fc2b0d70c5239" integrity sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw== -"@types/semver@^7.5.8": - version "7.5.8" - resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e" - integrity sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ== - "@types/stack-utils@^2.0.0": version "2.0.3" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8" @@ -1988,64 +1983,62 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@7.8.0": - version "7.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.8.0.tgz#c78e309fe967cb4de05b85cdc876fb95f8e01b6f" - integrity sha512-gFTT+ezJmkwutUPmB0skOj3GZJtlEGnlssems4AjkVweUPGj7jRwwqg0Hhg7++kPGJqKtTYx+R05Ftww372aIg== +"@typescript-eslint/eslint-plugin@7.10.0": + version "7.10.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.10.0.tgz#07854a236f107bb45cbf4f62b89474cbea617f50" + integrity sha512-PzCr+a/KAef5ZawX7nbyNwBDtM1HdLIT53aSA2DDlxmxMngZ43O8SIePOeX8H5S+FHXeI6t97mTt/dDdzY4Fyw== dependencies: "@eslint-community/regexpp" "^4.10.0" - "@typescript-eslint/scope-manager" "7.8.0" - "@typescript-eslint/type-utils" "7.8.0" - "@typescript-eslint/utils" "7.8.0" - "@typescript-eslint/visitor-keys" "7.8.0" - debug "^4.3.4" + "@typescript-eslint/scope-manager" "7.10.0" + "@typescript-eslint/type-utils" "7.10.0" + "@typescript-eslint/utils" "7.10.0" + "@typescript-eslint/visitor-keys" "7.10.0" graphemer "^1.4.0" ignore "^5.3.1" natural-compare "^1.4.0" - semver "^7.6.0" ts-api-utils "^1.3.0" -"@typescript-eslint/parser@7.8.0": - version "7.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.8.0.tgz#1e1db30c8ab832caffee5f37e677dbcb9357ddc8" - integrity sha512-KgKQly1pv0l4ltcftP59uQZCi4HUYswCLbTqVZEJu7uLX8CTLyswqMLqLN+2QFz4jCptqWVV4SB7vdxcH2+0kQ== +"@typescript-eslint/parser@7.10.0": + version "7.10.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.10.0.tgz#e6ac1cba7bc0400a4459e7eb5b23115bd71accfb" + integrity sha512-2EjZMA0LUW5V5tGQiaa2Gys+nKdfrn2xiTIBLR4fxmPmVSvgPcKNW+AE/ln9k0A4zDUti0J/GZXMDupQoI+e1w== dependencies: - "@typescript-eslint/scope-manager" "7.8.0" - "@typescript-eslint/types" "7.8.0" - "@typescript-eslint/typescript-estree" "7.8.0" - "@typescript-eslint/visitor-keys" "7.8.0" + "@typescript-eslint/scope-manager" "7.10.0" + "@typescript-eslint/types" "7.10.0" + "@typescript-eslint/typescript-estree" "7.10.0" + "@typescript-eslint/visitor-keys" "7.10.0" debug "^4.3.4" -"@typescript-eslint/scope-manager@7.8.0": - version "7.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-7.8.0.tgz#bb19096d11ec6b87fb6640d921df19b813e02047" - integrity sha512-viEmZ1LmwsGcnr85gIq+FCYI7nO90DVbE37/ll51hjv9aG+YZMb4WDE2fyWpUR4O/UrhGRpYXK/XajcGTk2B8g== +"@typescript-eslint/scope-manager@7.10.0": + version "7.10.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-7.10.0.tgz#054a27b1090199337a39cf755f83d9f2ce26546b" + integrity sha512-7L01/K8W/VGl7noe2mgH0K7BE29Sq6KAbVmxurj8GGaPDZXPr8EEQ2seOeAS+mEV9DnzxBQB6ax6qQQ5C6P4xg== dependencies: - "@typescript-eslint/types" "7.8.0" - "@typescript-eslint/visitor-keys" "7.8.0" + "@typescript-eslint/types" "7.10.0" + "@typescript-eslint/visitor-keys" "7.10.0" -"@typescript-eslint/type-utils@7.8.0": - version "7.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-7.8.0.tgz#9de166f182a6e4d1c5da76e94880e91831e3e26f" - integrity sha512-H70R3AefQDQpz9mGv13Uhi121FNMh+WEaRqcXTX09YEDky21km4dV1ZXJIp8QjXc4ZaVkXVdohvWDzbnbHDS+A== +"@typescript-eslint/type-utils@7.10.0": + version "7.10.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-7.10.0.tgz#8a75accce851d0a331aa9331268ef64e9b300270" + integrity sha512-D7tS4WDkJWrVkuzgm90qYw9RdgBcrWmbbRkrLA4d7Pg3w0ttVGDsvYGV19SH8gPR5L7OtcN5J1hTtyenO9xE9g== dependencies: - "@typescript-eslint/typescript-estree" "7.8.0" - "@typescript-eslint/utils" "7.8.0" + "@typescript-eslint/typescript-estree" "7.10.0" + "@typescript-eslint/utils" "7.10.0" debug "^4.3.4" ts-api-utils "^1.3.0" -"@typescript-eslint/types@7.8.0": - version "7.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.8.0.tgz#1fd2577b3ad883b769546e2d1ef379f929a7091d" - integrity sha512-wf0peJ+ZGlcH+2ZS23aJbOv+ztjeeP8uQ9GgwMJGVLx/Nj9CJt17GWgWWoSmoRVKAX2X+7fzEnAjxdvK2gqCLw== +"@typescript-eslint/types@7.10.0": + version "7.10.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.10.0.tgz#da92309c97932a3a033762fd5faa8b067de84e3b" + integrity sha512-7fNj+Ya35aNyhuqrA1E/VayQX9Elwr8NKZ4WueClR3KwJ7Xx9jcCdOrLW04h51de/+gNbyFMs+IDxh5xIwfbNg== -"@typescript-eslint/typescript-estree@7.8.0": - version "7.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.8.0.tgz#b028a9226860b66e623c1ee55cc2464b95d2987c" - integrity sha512-5pfUCOwK5yjPaJQNy44prjCwtr981dO8Qo9J9PwYXZ0MosgAbfEMB008dJ5sNo3+/BN6ytBPuSvXUg9SAqB0dg== +"@typescript-eslint/typescript-estree@7.10.0": + version "7.10.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.10.0.tgz#6dcdc5de3149916a6a599fa89dde5c471b88b8bb" + integrity sha512-LXFnQJjL9XIcxeVfqmNj60YhatpRLt6UhdlFwAkjNc6jSUlK8zQOl1oktAP8PlWFzPQC1jny/8Bai3/HPuvN5g== dependencies: - "@typescript-eslint/types" "7.8.0" - "@typescript-eslint/visitor-keys" "7.8.0" + "@typescript-eslint/types" "7.10.0" + "@typescript-eslint/visitor-keys" "7.10.0" debug "^4.3.4" globby "^11.1.0" is-glob "^4.0.3" @@ -2053,25 +2046,22 @@ semver "^7.6.0" ts-api-utils "^1.3.0" -"@typescript-eslint/utils@7.8.0": - version "7.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.8.0.tgz#57a79f9c0c0740ead2f622e444cfaeeb9fd047cd" - integrity sha512-L0yFqOCflVqXxiZyXrDr80lnahQfSOfc9ELAAZ75sqicqp2i36kEZZGuUymHNFoYOqxRT05up760b4iGsl02nQ== +"@typescript-eslint/utils@7.10.0": + version "7.10.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.10.0.tgz#8ee43e5608c9f439524eaaea8de5b358b15c51b3" + integrity sha512-olzif1Fuo8R8m/qKkzJqT7qwy16CzPRWBvERS0uvyc+DHd8AKbO4Jb7kpAvVzMmZm8TrHnI7hvjN4I05zow+tg== dependencies: "@eslint-community/eslint-utils" "^4.4.0" - "@types/json-schema" "^7.0.15" - "@types/semver" "^7.5.8" - "@typescript-eslint/scope-manager" "7.8.0" - "@typescript-eslint/types" "7.8.0" - "@typescript-eslint/typescript-estree" "7.8.0" - semver "^7.6.0" + "@typescript-eslint/scope-manager" "7.10.0" + "@typescript-eslint/types" "7.10.0" + "@typescript-eslint/typescript-estree" "7.10.0" -"@typescript-eslint/visitor-keys@7.8.0": - version "7.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-7.8.0.tgz#7285aab991da8bee411a42edbd5db760d22fdd91" - integrity sha512-q4/gibTNBQNA0lGyYQCmWRS5D15n8rXh4QjK3KV+MBPlTYHpfBUT3D3PaPR/HeNiI9W6R7FvlkcGhNyAoP+caA== +"@typescript-eslint/visitor-keys@7.10.0": + version "7.10.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-7.10.0.tgz#2af2e91e73a75dd6b70b4486c48ae9d38a485a78" + integrity sha512-9ntIVgsi6gg6FIq9xjEO4VQJvwOqA3jaBFQJ/6TK5AvEup2+cECI6Fh7QiBxmfMHXU0V0J4RyPeOU1VDNzl9cg== dependencies: - "@typescript-eslint/types" "7.8.0" + "@typescript-eslint/types" "7.10.0" eslint-visitor-keys "^3.4.3" JSONStream@^1.0.4: @@ -6163,13 +6153,13 @@ typed-array-length@^1.0.6: possible-typed-array-names "^1.0.0" typescript-eslint@^7.7.1: - version "7.8.0" - resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-7.8.0.tgz#d2a73d4caac35d4d9825bfdfac06a9bf2ba175e4" - integrity sha512-sheFG+/D8N/L7gC3WT0Q8sB97Nm573Yfr+vZFzl/4nBdYcmviBPtwGSX9TJ7wpVg28ocerKVOt+k2eGmHzcgVA== + version "7.10.0" + resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-7.10.0.tgz#18637c414fcbf6ff1defac05b5c898c303a0ffed" + integrity sha512-thO8nyqptXdfWHQrMJJiJyftpW8aLmwRNs11xA8pSrXneoclFPstQZqXvDWuH1WNL4CHffqHvYUeCHTit6yfhQ== dependencies: - "@typescript-eslint/eslint-plugin" "7.8.0" - "@typescript-eslint/parser" "7.8.0" - "@typescript-eslint/utils" "7.8.0" + "@typescript-eslint/eslint-plugin" "7.10.0" + "@typescript-eslint/parser" "7.10.0" + "@typescript-eslint/utils" "7.10.0" typescript-memoize@^1.0.0-alpha.3: version "1.1.1" From 542cf5668fce058b0159162c7b8d58edf0d9e2c3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 26 May 2024 11:02:05 +0000 Subject: [PATCH 3/5] chore(deps-dev): bump ajv from 8.13.0 to 8.14.0 (#1971) Bumps [ajv](https://github.com/ajv-validator/ajv) from 8.13.0 to 8.14.0. - [Release notes](https://github.com/ajv-validator/ajv/releases) - [Commits](https://github.com/ajv-validator/ajv/compare/v8.13.0...v8.14.0) --- updated-dependencies: - dependency-name: ajv dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 43484bed3..6279a96ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2117,9 +2117,9 @@ ajv@^6.12.4: uri-js "^4.2.2" ajv@^8.0.0, ajv@^8.12.0: - version "8.13.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.13.0.tgz#a3939eaec9fb80d217ddf0c3376948c023f28c91" - integrity sha512-PRA911Blj99jR5RMeTunVbNXMF6Lp4vZXnk5GQjcnUWUTsrXtekg/pnmFFI2u/I36Y/2bITGS30GZCXei6uNkA== + version "8.14.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.14.0.tgz#f514ddfd4756abb200e1704414963620a625ebbb" + integrity sha512-oYs1UUtO97ZO2lJ4bwnWeQW8/zvOIQLGKcvPTsWmvc2SYgBb+upuNS5NxoLaMU4h8Ju3Nbj6Cq8mD2LQoqVKFA== dependencies: fast-deep-equal "^3.1.3" json-schema-traverse "^1.0.0" From 3dfb59b170e75f50ac87654e300d653fb92aaaf8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 26 May 2024 11:02:08 +0000 Subject: [PATCH 4/5] chore(deps-dev): bump eslint from 9.2.0 to 9.3.0 (#1970) Bumps [eslint](https://github.com/eslint/eslint) from 9.2.0 to 9.3.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v9.2.0...v9.3.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6279a96ad..6ad805328 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1317,10 +1317,10 @@ resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.10.0.tgz#548f6de556857c8bb73bbee70c35dc82a2e74d63" integrity sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA== -"@eslint/eslintrc@^3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-3.0.2.tgz#36180f8e85bf34d2fe3ccc2261e8e204a411ab4e" - integrity sha512-wV19ZEGEMAC1eHgrS7UQPqsdEiCIbTKTasEfcXAigzoXICcqZSjBZEHlZwNVvKg6UBCjSlos84XiLqsRJnIcIg== +"@eslint/eslintrc@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-3.1.0.tgz#dbd3482bfd91efa663cbe7aa1f506839868207b6" + integrity sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ== dependencies: ajv "^6.12.4" debug "^4.3.2" @@ -1332,12 +1332,7 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/js@9.2.0": - version "9.2.0" - resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.2.0.tgz#b0a9123e8e91a3d9a2eed3a04a6ed44fdab639aa" - integrity sha512-ESiIudvhoYni+MdsI8oD7skpprZ89qKocwRM2KEvhhBJ9nl5MRh7BXU5GTod7Mdygq+AUl+QzId6iWJKR/wABA== - -"@eslint/js@^9.1.1": +"@eslint/js@9.3.0", "@eslint/js@^9.1.1": version "9.3.0" resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.3.0.tgz#2e8f65c9c55227abc4845b1513c69c32c679d8fe" integrity sha512-niBqk8iwv96+yuTwjM6bWg8ovzAPF9qkICsGtcoa5/dmqcEMfdwNAX7+/OHcJHc7wj7XqPxH98oAHytFYlw6Sw== @@ -1361,10 +1356,10 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz#4a2868d75d6d6963e423bcf90b7fd1be343409d3" integrity sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA== -"@humanwhocodes/retry@^0.2.3": - version "0.2.3" - resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.2.3.tgz#c9aa036d1afa643f1250e83150f39efb3a15a631" - integrity sha512-X38nUbachlb01YMlvPFojKoiXq+LzZvuSce70KPMPdeM1Rj03k4dR7lDslhbqXn3Ang4EU3+EAmwEAsbrjHW3g== +"@humanwhocodes/retry@^0.3.0": + version "0.3.0" + resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.3.0.tgz#6d86b8cb322660f03d3f0aa94b99bdd8e172d570" + integrity sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew== "@hutson/parse-repository-url@^3.0.0": version "3.0.2" @@ -3276,17 +3271,17 @@ eslint-visitor-keys@^4.0.0: integrity sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw== eslint@^9.1.0: - version "9.2.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.2.0.tgz#0700ebc99528753315d78090876911d3cdbf19fe" - integrity sha512-0n/I88vZpCOzO+PQpt0lbsqmn9AsnsJAQseIqhZFI8ibQT0U1AkEKRxA3EVMos0BoHSXDQvCXY25TUjB5tr8Og== + version "9.3.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.3.0.tgz#36a96db84592618d6ed9074d677e92f4e58c08b9" + integrity sha512-5Iv4CsZW030lpUqHBapdPo3MJetAPtejVW8B84GIcIIv8+ohFaddXsrn1Gn8uD9ijDb+kcYKFUVmC8qG8B2ORQ== dependencies: "@eslint-community/eslint-utils" "^4.2.0" "@eslint-community/regexpp" "^4.6.1" - "@eslint/eslintrc" "^3.0.2" - "@eslint/js" "9.2.0" + "@eslint/eslintrc" "^3.1.0" + "@eslint/js" "9.3.0" "@humanwhocodes/config-array" "^0.13.0" "@humanwhocodes/module-importer" "^1.0.1" - "@humanwhocodes/retry" "^0.2.3" + "@humanwhocodes/retry" "^0.3.0" "@nodelib/fs.walk" "^1.2.8" ajv "^6.12.4" chalk "^4.0.0" From 2880903089ac89248dad93cd1d1e1d566c3c47bb Mon Sep 17 00:00:00 2001 From: Arthur Fiorette <47537704+arthurfiorette@users.noreply.github.com> Date: Mon, 27 May 2024 16:46:51 -0300 Subject: [PATCH 5/5] fix: revert back to commons js (#1975) * cjs * run npm pkg fix * lint * feat: eslint in mjs * feat: eslint in mjs v2 --- bin/ts-json-schema-generator.js | 4 +- eslint.config.js => eslint.config.mjs | 5 +- package.json | 81 ++++++++++++--------------- tsconfig.cjs.json | 12 ---- tsconfig.json | 4 +- 5 files changed, 45 insertions(+), 61 deletions(-) rename eslint.config.js => eslint.config.mjs (95%) delete mode 100644 tsconfig.cjs.json diff --git a/bin/ts-json-schema-generator.js b/bin/ts-json-schema-generator.js index 2177a3c7f..bfb576487 100755 --- a/bin/ts-json-schema-generator.js +++ b/bin/ts-json-schema-generator.js @@ -1,2 +1,4 @@ #!/usr/bin/env node -import("../dist/ts-json-schema-generator.js"); + +// eslint-disable-next-line @typescript-eslint/no-require-imports +require("../dist/ts-json-schema-generator.js"); diff --git a/eslint.config.js b/eslint.config.mjs similarity index 95% rename from eslint.config.js rename to eslint.config.mjs index 74c0e841a..58245e816 100644 --- a/eslint.config.js +++ b/eslint.config.mjs @@ -6,7 +6,7 @@ import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended" /** @type {import('@types/eslint').Linter.FlatConfig[]} */ export default tseslint.config( { - ignores: ["dist", "cjs", "build"], + ignores: ["dist", "cjs", "build", "eslint.config.mjs"], }, eslint.configs.recommended, { @@ -21,7 +21,7 @@ export default tseslint.config( ], extends: tseslint.configs.recommendedTypeChecked, languageOptions: { - sourceType: "module", + sourceType: "commonjs", parserOptions: { project: "tsconfig.eslint.json", tsconfigRootDir: import.meta.dirname, @@ -71,6 +71,7 @@ export default tseslint.config( languageOptions: { globals: { ...globals.jest, + ...globals.commonjs, }, }, }, diff --git a/package.json b/package.json index 71a932062..76483cf59 100644 --- a/package.json +++ b/package.json @@ -2,20 +2,18 @@ "name": "ts-json-schema-generator", "version": "2.0.0", "description": "Generate JSON schema from your Typescript sources", - "module": "dist/index.js", - "types": "dist/index.d.ts", - "type": "module", - "bin": { - "ts-json-schema-generator": "./bin/ts-json-schema-generator.js" - }, - "files": [ - "dist", - "cjs", - "src", - "factory", - "index.*", - "ts-json-schema-generator.*" + "keywords": [ + "ts", + "typescript", + "json", + "schema", + "jsonschema" ], + "repository": { + "type": "git", + "url": "git+https://github.com/vega/ts-json-schema-generator.git" + }, + "license": "MIT", "author": { "name": "Alexander Evtushenko", "email": "aevtushenko@xiag.ch" @@ -30,24 +28,32 @@ "email": "mooyoul@gmail.com" } ], - "repository": { - "type": "git", - "url": "https://github.com/vega/ts-json-schema-generator.git" + "type": "commonjs", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "bin": { + "ts-json-schema-generator": "bin/ts-json-schema-generator.js" }, - "license": "MIT", - "keywords": [ - "ts", - "typescript", - "json", - "schema", - "jsonschema" + "files": [ + "dist", + "src", + "factory", + "index.*", + "ts-json-schema-generator.*" ], - "engines": { - "node": ">=18.0.0" - }, - "exports": { - "import": "./dist/index.js", - "require": "./cjs/index.js" + "scripts": { + "build": "tsc", + "debug": "tsx --inspect-brk ts-json-schema-generator.ts", + "format": "eslint --fix", + "lint": "eslint", + "prepublishOnly": "yarn build", + "release": "yarn build && auto shipit", + "run": "tsx ts-json-schema-generator.ts", + "test": "jest test/ --verbose", + "test:coverage": "yarn jest test/ --collectCoverage=true", + "test:fast": "cross-env FAST_TEST=1 jest test/ --verbose", + "test:update": "cross-env UPDATE_SCHEMA=true yarn test:fast", + "watch": "tsc -w" }, "dependencies": { "@types/json-schema": "^7.0.15", @@ -87,20 +93,7 @@ "vega": "^5.28.0", "vega-lite": "^5.18.0" }, - "scripts": { - "prepublishOnly": "yarn build", - "build": "npm run build:cjs && npm run build:esm", - "build:cjs": "tsc -p tsconfig.cjs.json", - "build:esm": "tsc -p tsconfig.json", - "watch": "tsc -w", - "lint": "eslint", - "format": "eslint --fix", - "test": "jest test/ --verbose", - "test:fast": "cross-env FAST_TEST=1 jest test/ --verbose", - "test:coverage": "yarn jest test/ --collectCoverage=true", - "test:update": "cross-env UPDATE_SCHEMA=true yarn test:fast", - "debug": "tsx --inspect-brk ts-json-schema-generator.ts", - "run": "tsx ts-json-schema-generator.ts", - "release": "yarn build && auto shipit" + "engines": { + "node": ">=18.0.0" } } diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json deleted file mode 100644 index de02fb0c0..000000000 --- a/tsconfig.cjs.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "target": "ES2022", - "module": "CommonJS", - "moduleResolution": "Node", - "outDir": "cjs" - }, - "files": ["ts-json-schema-generator.ts", "index.ts"], - "include": ["src/**/*.ts", "factory/**/*.ts"], - "exclude": ["node_modules", "dist", "cjs"] -} diff --git a/tsconfig.json b/tsconfig.json index d0f20b4a0..d049d7d24 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "target": "ES2022", - "module": "NodeNext", - "moduleResolution": "Node16", + "module": "CommonJS", + "moduleResolution": "Node", "esModuleInterop": true, "isolatedModules": false, "experimentalDecorators": true,