diff --git a/.autorc.json b/.autorc.json index 66f2c61f1..e7468034e 100644 --- a/.autorc.json +++ b/.autorc.json @@ -1,13 +1,6 @@ { - "plugins": [ - "npm", - "conventional-commits", - "first-time-contributor", - "released" - ], - "baseBranch": "stable", - "prereleaseBranches": [ - "next" - ], - "author": "GitHub Actions Bot " + "plugins": ["npm", "conventional-commits", "first-time-contributor", "released"], + "baseBranch": "stable", + "prereleaseBranches": ["next"], + "author": "GitHub Actions Bot " } diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 465b7e221..000000000 --- a/.editorconfig +++ /dev/null @@ -1,23 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true - -[*.ts] -indent_style = space -indent_size = 4 - -[*.json] -indent_style = space -indent_size = 4 - -[test/**/schema.json] -indent_style = space -indent_size = 2 - -[{package.json,azure-pipelines.yml}] -indent_style = space -indent_size = 2 diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index cf3c9cc23..000000000 --- a/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -test/valid-data -test/invalid-data -test/config diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index bd8502a5f..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,41 +0,0 @@ -module.exports = { - parser: "@typescript-eslint/parser", - extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"], - env: { - browser: true, - node: true, - }, - parserOptions: { - ecmaVersion: 2018, - sourceType: "module", - }, - rules: { - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/prefer-for-of": "error", - "@typescript-eslint/no-require-imports": "error", - "@typescript-eslint/no-parameter-properties": "off", - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": [ - "error", - { - vars: "all", - args: "none", - ignoreRestSiblings: true, - }, - ], - "@typescript-eslint/no-object-literal-type-assertion": "off", - "@typescript-eslint/no-namespace": "error", - "@typescript-eslint/no-non-null-assertion": "off", - "max-len": ["error", { code: 120, tabWidth: 4 }], - "no-alert": "error", - "prefer-const": "error", - "no-return-assign": "error", - "no-useless-call": "error", - "no-shadow": "error", - "no-useless-concat": "error", - "no-undef": "off", - "no-prototype-builtins": "off", - "prettier/prettier": "error", - }, -}; diff --git a/.prettierignore b/.prettierignore index b28375367..24d0dc128 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,4 @@ -azure-pipelines.yml package.json test/valid-data/**/*.json +babel.config.cjs +jest.config.cjs diff --git a/.prettierrc.json b/.prettierrc.json index 09e20e9d7..b2e500baf 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,8 +1,6 @@ { - "trailingComma": "es5", "printWidth": 120, "tabWidth": 4, - "endOfLine": "lf", "overrides": [ { "files": "*.json", diff --git a/.vscode/launch.json b/.vscode/launch.json index 283c168d6..49feb4528 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,42 +1,31 @@ { - // Use IntelliSense to learn about possible Node.js debug attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - // - // Helps with debugging parsing. - // - Set break points in the code - // - Open the file you want to parse: test/**/main.ts - // - F5 to run the debugger. - "name": "Debug Test Case", - "type": "node", - "request": "launch", - "runtimeExecutable": "node", - "runtimeArgs": [ - "--nolazy", - "-r", - "ts-node/register" - ], - "args": [ - "ts-json-schema-generator.ts", - "-p", - "${file}" - ], - "cwd": "${workspaceFolder}", - "internalConsoleOptions": "openOnSessionStart", - "skipFiles": [ - "/**", - "node_modules/**" - ] - }, - { - "type": "node", - "request": "attach", - "name": "Attach", - "port": 9229, - "protocol": "inspector" - } - ] + // Use IntelliSense to learn about possible Node.js debug attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + // + // Helps with debugging parsing. + // - Set break points in the code + // - Open the file you want to parse: test/**/main.ts + // - F5 to run the debugger. + "name": "Debug Test Case", + "type": "node", + "request": "launch", + "runtimeExecutable": "node", + "runtimeArgs": ["--nolazy", "-r", "ts-node/register"], + "args": ["ts-json-schema-generator.ts", "-p", "${file}"], + "cwd": "${workspaceFolder}", + "internalConsoleOptions": "openOnSessionStart", + "skipFiles": ["/**", "node_modules/**"] + }, + { + "type": "node", + "request": "attach", + "name": "Attach", + "port": 9229, + "protocol": "inspector" + } + ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index b568d7614..0e20a9a33 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,17 +1,18 @@ // Place your settings in this file to overwrite default and user settings. { "search.exclude": { - "dist": true, - "bin": true + "dist": true }, "files.trimTrailingWhitespace": true, "typescript.tsdk": "node_modules/typescript/lib", "files.insertFinalNewline": true, - "eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"], + "eslint.validate": ["javascript", "javascriptreact", "typescript"], "editor.tabSize": 4, "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" }, - "jest.autoRun": "off" + "eslint.experimental.useFlatConfig": true, + "jest.runMode": "on-demand", + "javascript.preferences.importModuleSpecifierEnding": "js" } diff --git a/babel.config.js b/babel.config.cjs similarity index 100% rename from babel.config.js rename to babel.config.cjs diff --git a/bin/ts-json-schema-generator b/bin/ts-json-schema-generator index 6b47cd55a..2177a3c7f 100755 --- a/bin/ts-json-schema-generator +++ b/bin/ts-json-schema-generator @@ -1,2 +1,2 @@ #!/usr/bin/env node -require('../dist/ts-json-schema-generator'); +import("../dist/ts-json-schema-generator.js"); diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 000000000..1963ae3ee --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,78 @@ +import eslint from "@eslint/js"; +import globals from "globals"; +import tseslint from "typescript-eslint"; +import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended"; + +/** @type {import('@types/eslint').Linter.FlatConfig[]} */ +export default tseslint.config( + { + ignores: ["dist"], + }, + eslint.configs.recommended, + { + files: [ + "ts-json-schema-generator.ts", + "index.ts", + "src/**/*.ts", + "factory/**/*.ts", + "bin/**", + "test/**/*.test.ts", + "test/utils.ts", + ], + extends: tseslint.configs.recommendedTypeChecked, + languageOptions: { + sourceType: "module", + parserOptions: { + project: "tsconfig.eslint.json", + tsconfigRootDir: import.meta.dirname, + }, + }, + rules: { + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/prefer-for-of": "error", + "@typescript-eslint/no-require-imports": "error", + "@typescript-eslint/no-parameter-properties": "off", + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": [ + "error", + { + vars: "all", + args: "none", + ignoreRestSiblings: true, + }, + ], + "@typescript-eslint/no-object-literal-type-assertion": "off", + "@typescript-eslint/no-namespace": "error", + "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/no-unsafe-assignment": "warn", + "@typescript-eslint/no-unsafe-member-access": "warn", + "@typescript-eslint/no-unsafe-return": "warn", + "@typescript-eslint/no-unsafe-argument": "warn", + "@typescript-eslint/no-unsafe-call": "warn", + "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/no-unnecessary-type-assertion": "warn", + "no-alert": "error", + "prefer-const": "error", + "no-return-assign": "error", + "no-useless-call": "error", + "no-shadow": "error", + "no-useless-concat": "error", + "no-undef": "off", + "no-prototype-builtins": "off", + }, + }, + { + files: ["*.js"], + ...tseslint.configs.disableTypeChecked, + }, + { + files: ["test/**/*.test.ts"], + languageOptions: { + globals: { + ...globals.jest, + }, + }, + }, + eslintPluginPrettierRecommended, +); diff --git a/factory/formatter.ts b/factory/formatter.ts index f7ba0e831..b77a9b954 100644 --- a/factory/formatter.ts +++ b/factory/formatter.ts @@ -1,40 +1,40 @@ -import { ChainTypeFormatter } from "../src/ChainTypeFormatter"; -import { CircularReferenceTypeFormatter } from "../src/CircularReferenceTypeFormatter"; -import { CompletedConfig } from "../src/Config"; -import { MutableTypeFormatter } from "../src/MutableTypeFormatter"; -import { TypeFormatter } from "../src/TypeFormatter"; -import { AliasTypeFormatter } from "../src/TypeFormatter/AliasTypeFormatter"; -import { AnnotatedTypeFormatter } from "../src/TypeFormatter/AnnotatedTypeFormatter"; -import { AnyTypeFormatter } from "../src/TypeFormatter/AnyTypeFormatter"; -import { ArrayTypeFormatter } from "../src/TypeFormatter/ArrayTypeFormatter"; -import { BooleanTypeFormatter } from "../src/TypeFormatter/BooleanTypeFormatter"; -import { ConstructorTypeFormatter } from "../src/TypeFormatter/ConstructorTypeFormatter"; -import { DefinitionTypeFormatter } from "../src/TypeFormatter/DefinitionTypeFormatter"; -import { EnumTypeFormatter } from "../src/TypeFormatter/EnumTypeFormatter"; -import { FunctionTypeFormatter } from "../src/TypeFormatter/FunctionTypeFormatter"; -import { HiddenTypeFormatter } from "../src/TypeFormatter/HiddenTypeFormatter"; -import { IntersectionTypeFormatter } from "../src/TypeFormatter/IntersectionTypeFormatter"; -import { LiteralTypeFormatter } from "../src/TypeFormatter/LiteralTypeFormatter"; -import { LiteralUnionTypeFormatter } from "../src/TypeFormatter/LiteralUnionTypeFormatter"; -import { NeverTypeFormatter } from "../src/TypeFormatter/NeverTypeFormatter"; -import { NullTypeFormatter } from "../src/TypeFormatter/NullTypeFormatter"; -import { NumberTypeFormatter } from "../src/TypeFormatter/NumberTypeFormatter"; -import { ObjectTypeFormatter } from "../src/TypeFormatter/ObjectTypeFormatter"; -import { OptionalTypeFormatter } from "../src/TypeFormatter/OptionalTypeFormatter"; -import { PrimitiveUnionTypeFormatter } from "../src/TypeFormatter/PrimitiveUnionTypeFormatter"; -import { ReferenceTypeFormatter } from "../src/TypeFormatter/ReferenceTypeFormatter"; -import { RestTypeFormatter } from "../src/TypeFormatter/RestTypeFormatter"; -import { StringTypeFormatter } from "../src/TypeFormatter/StringTypeFormatter"; -import { SymbolTypeFormatter } from "../src/TypeFormatter/SymbolTypeFormatter"; -import { TupleTypeFormatter } from "../src/TypeFormatter/TupleTypeFormatter"; -import { UndefinedTypeFormatter } from "../src/TypeFormatter/UndefinedTypeFormatter"; -import { UnionTypeFormatter } from "../src/TypeFormatter/UnionTypeFormatter"; -import { UnknownTypeFormatter } from "../src/TypeFormatter/UnknownTypeFormatter"; -import { VoidTypeFormatter } from "../src/TypeFormatter/VoidTypeFormatter"; +import { ChainTypeFormatter } from "../src/ChainTypeFormatter.js"; +import { CircularReferenceTypeFormatter } from "../src/CircularReferenceTypeFormatter.js"; +import { CompletedConfig } from "../src/Config.js"; +import { MutableTypeFormatter } from "../src/MutableTypeFormatter.js"; +import { TypeFormatter } from "../src/TypeFormatter.js"; +import { AliasTypeFormatter } from "../src/TypeFormatter/AliasTypeFormatter.js"; +import { AnnotatedTypeFormatter } from "../src/TypeFormatter/AnnotatedTypeFormatter.js"; +import { AnyTypeFormatter } from "../src/TypeFormatter/AnyTypeFormatter.js"; +import { ArrayTypeFormatter } from "../src/TypeFormatter/ArrayTypeFormatter.js"; +import { BooleanTypeFormatter } from "../src/TypeFormatter/BooleanTypeFormatter.js"; +import { ConstructorTypeFormatter } from "../src/TypeFormatter/ConstructorTypeFormatter.js"; +import { DefinitionTypeFormatter } from "../src/TypeFormatter/DefinitionTypeFormatter.js"; +import { EnumTypeFormatter } from "../src/TypeFormatter/EnumTypeFormatter.js"; +import { FunctionTypeFormatter } from "../src/TypeFormatter/FunctionTypeFormatter.js"; +import { HiddenTypeFormatter } from "../src/TypeFormatter/HiddenTypeFormatter.js"; +import { IntersectionTypeFormatter } from "../src/TypeFormatter/IntersectionTypeFormatter.js"; +import { LiteralTypeFormatter } from "../src/TypeFormatter/LiteralTypeFormatter.js"; +import { LiteralUnionTypeFormatter } from "../src/TypeFormatter/LiteralUnionTypeFormatter.js"; +import { NeverTypeFormatter } from "../src/TypeFormatter/NeverTypeFormatter.js"; +import { NullTypeFormatter } from "../src/TypeFormatter/NullTypeFormatter.js"; +import { NumberTypeFormatter } from "../src/TypeFormatter/NumberTypeFormatter.js"; +import { ObjectTypeFormatter } from "../src/TypeFormatter/ObjectTypeFormatter.js"; +import { OptionalTypeFormatter } from "../src/TypeFormatter/OptionalTypeFormatter.js"; +import { PrimitiveUnionTypeFormatter } from "../src/TypeFormatter/PrimitiveUnionTypeFormatter.js"; +import { ReferenceTypeFormatter } from "../src/TypeFormatter/ReferenceTypeFormatter.js"; +import { RestTypeFormatter } from "../src/TypeFormatter/RestTypeFormatter.js"; +import { StringTypeFormatter } from "../src/TypeFormatter/StringTypeFormatter.js"; +import { SymbolTypeFormatter } from "../src/TypeFormatter/SymbolTypeFormatter.js"; +import { TupleTypeFormatter } from "../src/TypeFormatter/TupleTypeFormatter.js"; +import { UndefinedTypeFormatter } from "../src/TypeFormatter/UndefinedTypeFormatter.js"; +import { UnionTypeFormatter } from "../src/TypeFormatter/UnionTypeFormatter.js"; +import { UnknownTypeFormatter } from "../src/TypeFormatter/UnknownTypeFormatter.js"; +import { VoidTypeFormatter } from "../src/TypeFormatter/VoidTypeFormatter.js"; export type FormatterAugmentor = ( formatter: MutableTypeFormatter, - circularReferenceTypeFormatter: CircularReferenceTypeFormatter + circularReferenceTypeFormatter: CircularReferenceTypeFormatter, ) => void; export function createFormatter(config: CompletedConfig, augmentor?: FormatterAugmentor): TypeFormatter { diff --git a/factory/generator.ts b/factory/generator.ts index 8c36666f6..bf54919b4 100644 --- a/factory/generator.ts +++ b/factory/generator.ts @@ -1,8 +1,8 @@ -import { Config, DEFAULT_CONFIG } from "../src/Config"; -import { SchemaGenerator } from "../src/SchemaGenerator"; -import { createFormatter } from "./formatter"; -import { createParser } from "./parser"; -import { createProgram } from "./program"; +import { Config, DEFAULT_CONFIG } from "../src/Config.js"; +import { SchemaGenerator } from "../src/SchemaGenerator.js"; +import { createFormatter } from "./formatter.js"; +import { createParser } from "./parser.js"; +import { createProgram } from "./program.js"; export function createGenerator(config: Config): SchemaGenerator { const completedConfig = { ...DEFAULT_CONFIG, ...config }; diff --git a/factory/index.ts b/factory/index.ts index 61a20712d..bd32a44bb 100644 --- a/factory/index.ts +++ b/factory/index.ts @@ -1,4 +1,4 @@ -export * from "./formatter"; -export * from "./generator"; -export * from "./parser"; -export * from "./program"; +export * from "./formatter.js"; +export * from "./generator.js"; +export * from "./parser.js"; +export * from "./program.js"; diff --git a/factory/parser.ts b/factory/parser.ts index 8a8c039ad..67dce6ff7 100644 --- a/factory/parser.ts +++ b/factory/parser.ts @@ -1,63 +1,63 @@ import ts from "typescript"; -import { BasicAnnotationsReader } from "../src/AnnotationsReader/BasicAnnotationsReader"; -import { ExtendedAnnotationsReader } from "../src/AnnotationsReader/ExtendedAnnotationsReader"; -import { ChainNodeParser } from "../src/ChainNodeParser"; -import { CircularReferenceNodeParser } from "../src/CircularReferenceNodeParser"; -import { CompletedConfig } from "../src/Config"; -import { ExposeNodeParser } from "../src/ExposeNodeParser"; -import { MutableParser } from "../src/MutableParser"; -import { NodeParser } from "../src/NodeParser"; -import { AnnotatedNodeParser } from "../src/NodeParser/AnnotatedNodeParser"; -import { AnyTypeNodeParser } from "../src/NodeParser/AnyTypeNodeParser"; -import { ArrayLiteralExpressionNodeParser } from "../src/NodeParser/ArrayLiteralExpressionNodeParser"; -import { ArrayNodeParser } from "../src/NodeParser/ArrayNodeParser"; -import { AsExpressionNodeParser } from "../src/NodeParser/AsExpressionNodeParser"; -import { BooleanLiteralNodeParser } from "../src/NodeParser/BooleanLiteralNodeParser"; -import { BooleanTypeNodeParser } from "../src/NodeParser/BooleanTypeNodeParser"; -import { CallExpressionParser } from "../src/NodeParser/CallExpressionParser"; -import { ConditionalTypeNodeParser } from "../src/NodeParser/ConditionalTypeNodeParser"; -import { ConstructorNodeParser } from "../src/NodeParser/ConstructorNodeParser"; -import { EnumNodeParser } from "../src/NodeParser/EnumNodeParser"; -import { ExpressionWithTypeArgumentsNodeParser } from "../src/NodeParser/ExpressionWithTypeArgumentsNodeParser"; -import { FunctionNodeParser } from "../src/NodeParser/FunctionNodeParser"; -import { HiddenNodeParser } from "../src/NodeParser/HiddenTypeNodeParser"; -import { IndexedAccessTypeNodeParser } from "../src/NodeParser/IndexedAccessTypeNodeParser"; -import { InferTypeNodeParser } from "../src/NodeParser/InferTypeNodeParser"; -import { InterfaceAndClassNodeParser } from "../src/NodeParser/InterfaceAndClassNodeParser"; -import { IntersectionNodeParser } from "../src/NodeParser/IntersectionNodeParser"; -import { IntrinsicNodeParser } from "../src/NodeParser/IntrinsicNodeParser"; -import { LiteralNodeParser } from "../src/NodeParser/LiteralNodeParser"; -import { MappedTypeNodeParser } from "../src/NodeParser/MappedTypeNodeParser"; -import { NamedTupleMemberNodeParser } from "../src/NodeParser/NamedTupleMemberNodeParser"; -import { NeverTypeNodeParser } from "../src/NodeParser/NeverTypeNodeParser"; -import { NullLiteralNodeParser } from "../src/NodeParser/NullLiteralNodeParser"; -import { NumberLiteralNodeParser } from "../src/NodeParser/NumberLiteralNodeParser"; -import { NumberTypeNodeParser } from "../src/NodeParser/NumberTypeNodeParser"; -import { ObjectLiteralExpressionNodeParser } from "../src/NodeParser/ObjectLiteralExpressionNodeParser"; -import { ObjectTypeNodeParser } from "../src/NodeParser/ObjectTypeNodeParser"; -import { OptionalTypeNodeParser } from "../src/NodeParser/OptionalTypeNodeParser"; -import { ParameterParser } from "../src/NodeParser/ParameterParser"; -import { ParenthesizedNodeParser } from "../src/NodeParser/ParenthesizedNodeParser"; -import { PrefixUnaryExpressionNodeParser } from "../src/NodeParser/PrefixUnaryExpressionNodeParser"; -import { PropertyAccessExpressionParser } from "../src/NodeParser/PropertyAccessExpressionParser"; -import { RestTypeNodeParser } from "../src/NodeParser/RestTypeNodeParser"; -import { StringLiteralNodeParser } from "../src/NodeParser/StringLiteralNodeParser"; -import { StringTemplateLiteralNodeParser } from "../src/NodeParser/StringTemplateLiteralNodeParser"; -import { StringTypeNodeParser } from "../src/NodeParser/StringTypeNodeParser"; -import { SymbolTypeNodeParser } from "../src/NodeParser/SymbolTypeNodeParser"; -import { TupleNodeParser } from "../src/NodeParser/TupleNodeParser"; -import { TypeAliasNodeParser } from "../src/NodeParser/TypeAliasNodeParser"; -import { TypeLiteralNodeParser } from "../src/NodeParser/TypeLiteralNodeParser"; -import { TypeofNodeParser } from "../src/NodeParser/TypeofNodeParser"; -import { TypeOperatorNodeParser } from "../src/NodeParser/TypeOperatorNodeParser"; -import { TypeReferenceNodeParser } from "../src/NodeParser/TypeReferenceNodeParser"; -import { UndefinedTypeNodeParser } from "../src/NodeParser/UndefinedTypeNodeParser"; -import { UnionNodeParser } from "../src/NodeParser/UnionNodeParser"; -import { UnknownTypeNodeParser } from "../src/NodeParser/UnknownTypeNodeParser"; -import { VoidTypeNodeParser } from "../src/NodeParser/VoidTypeNodeParser"; -import { SubNodeParser } from "../src/SubNodeParser"; -import { TopRefNodeParser } from "../src/TopRefNodeParser"; -import { SatisfiesNodeParser } from "../src/NodeParser/SatisfiesNodeParser"; +import { BasicAnnotationsReader } from "../src/AnnotationsReader/BasicAnnotationsReader.js"; +import { ExtendedAnnotationsReader } from "../src/AnnotationsReader/ExtendedAnnotationsReader.js"; +import { ChainNodeParser } from "../src/ChainNodeParser.js"; +import { CircularReferenceNodeParser } from "../src/CircularReferenceNodeParser.js"; +import { CompletedConfig } from "../src/Config.js"; +import { ExposeNodeParser } from "../src/ExposeNodeParser.js"; +import { MutableParser } from "../src/MutableParser.js"; +import { NodeParser } from "../src/NodeParser.js"; +import { AnnotatedNodeParser } from "../src/NodeParser/AnnotatedNodeParser.js"; +import { AnyTypeNodeParser } from "../src/NodeParser/AnyTypeNodeParser.js"; +import { ArrayLiteralExpressionNodeParser } from "../src/NodeParser/ArrayLiteralExpressionNodeParser.js"; +import { ArrayNodeParser } from "../src/NodeParser/ArrayNodeParser.js"; +import { AsExpressionNodeParser } from "../src/NodeParser/AsExpressionNodeParser.js"; +import { BooleanLiteralNodeParser } from "../src/NodeParser/BooleanLiteralNodeParser.js"; +import { BooleanTypeNodeParser } from "../src/NodeParser/BooleanTypeNodeParser.js"; +import { CallExpressionParser } from "../src/NodeParser/CallExpressionParser.js"; +import { ConditionalTypeNodeParser } from "../src/NodeParser/ConditionalTypeNodeParser.js"; +import { ConstructorNodeParser } from "../src/NodeParser/ConstructorNodeParser.js"; +import { EnumNodeParser } from "../src/NodeParser/EnumNodeParser.js"; +import { ExpressionWithTypeArgumentsNodeParser } from "../src/NodeParser/ExpressionWithTypeArgumentsNodeParser.js"; +import { FunctionNodeParser } from "../src/NodeParser/FunctionNodeParser.js"; +import { HiddenNodeParser } from "../src/NodeParser/HiddenTypeNodeParser.js"; +import { IndexedAccessTypeNodeParser } from "../src/NodeParser/IndexedAccessTypeNodeParser.js"; +import { InferTypeNodeParser } from "../src/NodeParser/InferTypeNodeParser.js"; +import { InterfaceAndClassNodeParser } from "../src/NodeParser/InterfaceAndClassNodeParser.js"; +import { IntersectionNodeParser } from "../src/NodeParser/IntersectionNodeParser.js"; +import { IntrinsicNodeParser } from "../src/NodeParser/IntrinsicNodeParser.js"; +import { LiteralNodeParser } from "../src/NodeParser/LiteralNodeParser.js"; +import { MappedTypeNodeParser } from "../src/NodeParser/MappedTypeNodeParser.js"; +import { NamedTupleMemberNodeParser } from "../src/NodeParser/NamedTupleMemberNodeParser.js"; +import { NeverTypeNodeParser } from "../src/NodeParser/NeverTypeNodeParser.js"; +import { NullLiteralNodeParser } from "../src/NodeParser/NullLiteralNodeParser.js"; +import { NumberLiteralNodeParser } from "../src/NodeParser/NumberLiteralNodeParser.js"; +import { NumberTypeNodeParser } from "../src/NodeParser/NumberTypeNodeParser.js"; +import { ObjectLiteralExpressionNodeParser } from "../src/NodeParser/ObjectLiteralExpressionNodeParser.js"; +import { ObjectTypeNodeParser } from "../src/NodeParser/ObjectTypeNodeParser.js"; +import { OptionalTypeNodeParser } from "../src/NodeParser/OptionalTypeNodeParser.js"; +import { ParameterParser } from "../src/NodeParser/ParameterParser.js"; +import { ParenthesizedNodeParser } from "../src/NodeParser/ParenthesizedNodeParser.js"; +import { PrefixUnaryExpressionNodeParser } from "../src/NodeParser/PrefixUnaryExpressionNodeParser.js"; +import { PropertyAccessExpressionParser } from "../src/NodeParser/PropertyAccessExpressionParser.js"; +import { RestTypeNodeParser } from "../src/NodeParser/RestTypeNodeParser.js"; +import { StringLiteralNodeParser } from "../src/NodeParser/StringLiteralNodeParser.js"; +import { StringTemplateLiteralNodeParser } from "../src/NodeParser/StringTemplateLiteralNodeParser.js"; +import { StringTypeNodeParser } from "../src/NodeParser/StringTypeNodeParser.js"; +import { SymbolTypeNodeParser } from "../src/NodeParser/SymbolTypeNodeParser.js"; +import { TupleNodeParser } from "../src/NodeParser/TupleNodeParser.js"; +import { TypeAliasNodeParser } from "../src/NodeParser/TypeAliasNodeParser.js"; +import { TypeLiteralNodeParser } from "../src/NodeParser/TypeLiteralNodeParser.js"; +import { TypeofNodeParser } from "../src/NodeParser/TypeofNodeParser.js"; +import { TypeOperatorNodeParser } from "../src/NodeParser/TypeOperatorNodeParser.js"; +import { TypeReferenceNodeParser } from "../src/NodeParser/TypeReferenceNodeParser.js"; +import { UndefinedTypeNodeParser } from "../src/NodeParser/UndefinedTypeNodeParser.js"; +import { UnionNodeParser } from "../src/NodeParser/UnionNodeParser.js"; +import { UnknownTypeNodeParser } from "../src/NodeParser/UnknownTypeNodeParser.js"; +import { VoidTypeNodeParser } from "../src/NodeParser/VoidTypeNodeParser.js"; +import { SubNodeParser } from "../src/SubNodeParser.js"; +import { TopRefNodeParser } from "../src/TopRefNodeParser.js"; +import { SatisfiesNodeParser } from "../src/NodeParser/SatisfiesNodeParser.js"; export type ParserAugmentor = (parser: MutableParser) => void; @@ -76,7 +76,7 @@ export function createParser(program: ts.Program, config: CompletedConfig, augme if (config.jsDoc === "extended") { return new AnnotatedNodeParser( nodeParser, - new ExtendedAnnotationsReader(typeChecker, extraTags, config.markdownDescription) + new ExtendedAnnotationsReader(typeChecker, extraTags, config.markdownDescription), ); } else if (config.jsDoc === "basic") { return new AnnotatedNodeParser(nodeParser, new BasicAnnotationsReader(extraTags)); @@ -149,20 +149,20 @@ export function createParser(program: ts.Program, config: CompletedConfig, augme new InterfaceAndClassNodeParser( typeChecker, withJsDoc(chainNodeParser), - config.additionalProperties - ) - ) - ) - ) + config.additionalProperties, + ), + ), + ), + ), ) .addNodeParser( withCircular( withExpose( withJsDoc( - new TypeLiteralNodeParser(typeChecker, withJsDoc(chainNodeParser), config.additionalProperties) - ) - ) - ) + new TypeLiteralNodeParser(typeChecker, withJsDoc(chainNodeParser), config.additionalProperties), + ), + ), + ), ) .addNodeParser(new ArrayNodeParser(chainNodeParser)); diff --git a/factory/program.ts b/factory/program.ts index 083a9fbc5..0e6a7c03a 100644 --- a/factory/program.ts +++ b/factory/program.ts @@ -3,11 +3,11 @@ import * as path from "path"; import ts from "typescript"; import normalize from "normalize-path"; -import { CompletedConfig, Config } from "../src/Config"; -import { DiagnosticError } from "../src/Error/DiagnosticError"; -import { LogicError } from "../src/Error/LogicError"; -import { NoRootNamesError } from "../src/Error/NoRootNamesError"; -import { NoTSConfigError } from "../src/Error/NoTSConfigError"; +import { CompletedConfig, Config } from "../src/Config.js"; +import { DiagnosticError } from "../src/Error/DiagnosticError.js"; +import { LogicError } from "../src/Error/LogicError.js"; +import { NoRootNamesError } from "../src/Error/NoRootNamesError.js"; +import { NoTSConfigError } from "../src/Error/NoTSConfigError.js"; function loadTsConfigFile(configFile: string) { const raw = ts.sys.readFile(configFile); @@ -25,7 +25,7 @@ function loadTsConfigFile(configFile: string) { ts.sys, path.resolve(path.dirname(configFile)), {}, - configFile + configFile, ); parseResult.options.noEmit = true; delete parseResult.options.out; diff --git a/index.ts b/index.ts index 01c5431ac..0ec7cf8c6 100644 --- a/index.ts +++ b/index.ts @@ -1,166 +1,166 @@ -export * from "./src/Error/BaseError"; -export * from "./src/Error/DiagnosticError"; -export * from "./src/Error/LogicError"; -export * from "./src/Error/NoRootNamesError"; -export * from "./src/Error/NoRootTypeError"; -export * from "./src/Error/NoTSConfigError"; -export * from "./src/Error/UnknownNodeError"; -export * from "./src/Error/UnknownTypeError"; +export * from "./src/Error/BaseError.js"; +export * from "./src/Error/DiagnosticError.js"; +export * from "./src/Error/LogicError.js"; +export * from "./src/Error/NoRootNamesError.js"; +export * from "./src/Error/NoRootTypeError.js"; +export * from "./src/Error/NoTSConfigError.js"; +export * from "./src/Error/UnknownNodeError.js"; +export * from "./src/Error/UnknownTypeError.js"; -export * from "./src/Config"; +export * from "./src/Config.js"; -export * from "./src/Utils/allOfDefinition"; -export * from "./src/Utils/assert"; -export * from "./src/Utils/deepMerge"; -export * from "./src/Utils/derefType"; -export * from "./src/Utils/extractLiterals"; -export * from "./src/Utils/formatError"; -export * from "./src/Utils/hasJsDocTag"; -export * from "./src/Utils/intersectionOfArrays"; -export * from "./src/Utils/isAssignableTo"; -export * from "./src/Utils/isHidden"; -export * from "./src/Utils/modifiers"; -export * from "./src/Utils/narrowType"; -export * from "./src/Utils/nodeKey"; -export * from "./src/Utils/notNever"; -export * from "./src/Utils/preserveAnnotation"; -export * from "./src/Utils/removeUndefined"; -export * from "./src/Utils/removeUnreachable"; -export * from "./src/Utils/StringMap"; -export * from "./src/Utils/String"; -export * from "./src/Utils/symbolAtNode"; -export * from "./src/Utils/typeKeys"; -export * from "./src/Utils/typeName"; -export * from "./src/Utils/uniqueArray"; -export * from "./src/Utils/uniqueTypeArray"; +export * from "./src/Utils/allOfDefinition.js"; +export * from "./src/Utils/assert.js"; +export * from "./src/Utils/deepMerge.js"; +export * from "./src/Utils/derefType.js"; +export * from "./src/Utils/extractLiterals.js"; +export * from "./src/Utils/formatError.js"; +export * from "./src/Utils/hasJsDocTag.js"; +export * from "./src/Utils/intersectionOfArrays.js"; +export * from "./src/Utils/isAssignableTo.js"; +export * from "./src/Utils/isHidden.js"; +export * from "./src/Utils/modifiers.js"; +export * from "./src/Utils/narrowType.js"; +export * from "./src/Utils/nodeKey.js"; +export * from "./src/Utils/notNever.js"; +export * from "./src/Utils/preserveAnnotation.js"; +export * from "./src/Utils/removeUndefined.js"; +export * from "./src/Utils/removeUnreachable.js"; +export * from "./src/Utils/StringMap.js"; +export * from "./src/Utils/String.js"; +export * from "./src/Utils/symbolAtNode.js"; +export * from "./src/Utils/typeKeys.js"; +export * from "./src/Utils/typeName.js"; +export * from "./src/Utils/uniqueArray.js"; +export * from "./src/Utils/uniqueTypeArray.js"; -export * from "./src/Interfaces/AnnotationsReader"; -export * from "./src/Interfaces/MutableParser"; +export * from "./src/Interfaces/AnnotationsReader.js"; +export * from "./src/Interfaces/MutableParser.js"; -export * from "./src/Schema/Definition"; -export * from "./src/Schema/Schema"; +export * from "./src/Schema/Definition.js"; +export * from "./src/Schema/Schema.js"; -export * from "./src/Type/AliasType"; -export * from "./src/Type/AnnotatedType"; -export * from "./src/Type/AnyType"; -export * from "./src/Type/ArrayType"; -export * from "./src/Type/BaseType"; -export * from "./src/Type/BooleanType"; -export * from "./src/Type/DefinitionType"; -export * from "./src/Type/EnumType"; -export * from "./src/Type/FunctionType"; -export * from "./src/Type/HiddenType"; -export * from "./src/Type/IntersectionType"; -export * from "./src/Type/LiteralType"; -export * from "./src/Type/NeverType"; -export * from "./src/Type/NullType"; -export * from "./src/Type/NumberType"; -export * from "./src/Type/ObjectType"; -export * from "./src/Type/OptionalType"; -export * from "./src/Type/PrimitiveType"; -export * from "./src/Type/ReferenceType"; -export * from "./src/Type/RestType"; -export * from "./src/Type/StringType"; -export * from "./src/Type/SymbolType"; -export * from "./src/Type/TupleType"; -export * from "./src/Type/UndefinedType"; -export * from "./src/Type/UnionType"; -export * from "./src/Type/UnknownType"; -export * from "./src/Type/VoidType"; +export * from "./src/Type/AliasType.js"; +export * from "./src/Type/AnnotatedType.js"; +export * from "./src/Type/AnyType.js"; +export * from "./src/Type/ArrayType.js"; +export * from "./src/Type/BaseType.js"; +export * from "./src/Type/BooleanType.js"; +export * from "./src/Type/DefinitionType.js"; +export * from "./src/Type/EnumType.js"; +export * from "./src/Type/FunctionType.js"; +export * from "./src/Type/HiddenType.js"; +export * from "./src/Type/IntersectionType.js"; +export * from "./src/Type/LiteralType.js"; +export * from "./src/Type/NeverType.js"; +export * from "./src/Type/NullType.js"; +export * from "./src/Type/NumberType.js"; +export * from "./src/Type/ObjectType.js"; +export * from "./src/Type/OptionalType.js"; +export * from "./src/Type/PrimitiveType.js"; +export * from "./src/Type/ReferenceType.js"; +export * from "./src/Type/RestType.js"; +export * from "./src/Type/StringType.js"; +export * from "./src/Type/SymbolType.js"; +export * from "./src/Type/TupleType.js"; +export * from "./src/Type/UndefinedType.js"; +export * from "./src/Type/UnionType.js"; +export * from "./src/Type/UnknownType.js"; +export * from "./src/Type/VoidType.js"; -export * from "./src/AnnotationsReader/BasicAnnotationsReader"; -export * from "./src/AnnotationsReader/ExtendedAnnotationsReader"; +export * from "./src/AnnotationsReader/BasicAnnotationsReader.js"; +export * from "./src/AnnotationsReader/ExtendedAnnotationsReader.js"; -export * from "./src/TypeFormatter"; -export * from "./src/SubTypeFormatter"; -export * from "./src/ChainTypeFormatter"; -export * from "./src/MutableTypeFormatter"; -export * from "./src/CircularReferenceTypeFormatter"; -export * from "./src/TypeFormatter/AliasTypeFormatter"; -export * from "./src/TypeFormatter/AnnotatedTypeFormatter"; -export * from "./src/TypeFormatter/AnyTypeFormatter"; -export * from "./src/TypeFormatter/ArrayTypeFormatter"; -export * from "./src/TypeFormatter/BooleanTypeFormatter"; -export * from "./src/TypeFormatter/DefinitionTypeFormatter"; -export * from "./src/TypeFormatter/EnumTypeFormatter"; -export * from "./src/TypeFormatter/HiddenTypeFormatter"; -export * from "./src/TypeFormatter/IntersectionTypeFormatter"; -export * from "./src/TypeFormatter/LiteralTypeFormatter"; -export * from "./src/TypeFormatter/LiteralUnionTypeFormatter"; -export * from "./src/TypeFormatter/NeverTypeFormatter"; -export * from "./src/TypeFormatter/NullTypeFormatter"; -export * from "./src/TypeFormatter/NumberTypeFormatter"; -export * from "./src/TypeFormatter/ObjectTypeFormatter"; -export * from "./src/TypeFormatter/OptionalTypeFormatter"; -export * from "./src/TypeFormatter/PrimitiveUnionTypeFormatter"; -export * from "./src/TypeFormatter/ReferenceTypeFormatter"; -export * from "./src/TypeFormatter/RestTypeFormatter"; -export * from "./src/TypeFormatter/StringTypeFormatter"; -export * from "./src/TypeFormatter/SymbolTypeFormatter"; -export * from "./src/TypeFormatter/TupleTypeFormatter"; -export * from "./src/TypeFormatter/UndefinedTypeFormatter"; -export * from "./src/TypeFormatter/UnionTypeFormatter"; -export * from "./src/TypeFormatter/UnknownTypeFormatter"; -export * from "./src/TypeFormatter/VoidTypeFormatter"; -export * from "./src/TypeFormatter/FunctionTypeFormatter"; +export * from "./src/TypeFormatter.js"; +export * from "./src/SubTypeFormatter.js"; +export * from "./src/ChainTypeFormatter.js"; +export * from "./src/MutableTypeFormatter.js"; +export * from "./src/CircularReferenceTypeFormatter.js"; +export * from "./src/TypeFormatter/AliasTypeFormatter.js"; +export * from "./src/TypeFormatter/AnnotatedTypeFormatter.js"; +export * from "./src/TypeFormatter/AnyTypeFormatter.js"; +export * from "./src/TypeFormatter/ArrayTypeFormatter.js"; +export * from "./src/TypeFormatter/BooleanTypeFormatter.js"; +export * from "./src/TypeFormatter/DefinitionTypeFormatter.js"; +export * from "./src/TypeFormatter/EnumTypeFormatter.js"; +export * from "./src/TypeFormatter/HiddenTypeFormatter.js"; +export * from "./src/TypeFormatter/IntersectionTypeFormatter.js"; +export * from "./src/TypeFormatter/LiteralTypeFormatter.js"; +export * from "./src/TypeFormatter/LiteralUnionTypeFormatter.js"; +export * from "./src/TypeFormatter/NeverTypeFormatter.js"; +export * from "./src/TypeFormatter/NullTypeFormatter.js"; +export * from "./src/TypeFormatter/NumberTypeFormatter.js"; +export * from "./src/TypeFormatter/ObjectTypeFormatter.js"; +export * from "./src/TypeFormatter/OptionalTypeFormatter.js"; +export * from "./src/TypeFormatter/PrimitiveUnionTypeFormatter.js"; +export * from "./src/TypeFormatter/ReferenceTypeFormatter.js"; +export * from "./src/TypeFormatter/RestTypeFormatter.js"; +export * from "./src/TypeFormatter/StringTypeFormatter.js"; +export * from "./src/TypeFormatter/SymbolTypeFormatter.js"; +export * from "./src/TypeFormatter/TupleTypeFormatter.js"; +export * from "./src/TypeFormatter/UndefinedTypeFormatter.js"; +export * from "./src/TypeFormatter/UnionTypeFormatter.js"; +export * from "./src/TypeFormatter/UnknownTypeFormatter.js"; +export * from "./src/TypeFormatter/VoidTypeFormatter.js"; +export * from "./src/TypeFormatter/FunctionTypeFormatter.js"; -export * from "./src/NodeParser"; -export * from "./src/SubNodeParser"; -export * from "./src/ChainNodeParser"; -export * from "./src/ExposeNodeParser"; -export * from "./src/TopRefNodeParser"; -export * from "./src/CircularReferenceNodeParser"; -export * from "./src/NodeParser/AnnotatedNodeParser"; -export * from "./src/NodeParser/AnyTypeNodeParser"; -export * from "./src/NodeParser/ArrayLiteralExpressionNodeParser"; -export * from "./src/NodeParser/ArrayNodeParser"; -export * from "./src/NodeParser/AsExpressionNodeParser"; -export * from "./src/NodeParser/BooleanLiteralNodeParser"; -export * from "./src/NodeParser/BooleanTypeNodeParser"; -export * from "./src/NodeParser/CallExpressionParser"; -export * from "./src/NodeParser/ConditionalTypeNodeParser"; -export * from "./src/NodeParser/EnumNodeParser"; -export * from "./src/NodeParser/ExpressionWithTypeArgumentsNodeParser"; -export * from "./src/NodeParser/FunctionNodeParser"; -export * from "./src/NodeParser/ConstructorNodeParser"; -export * from "./src/NodeParser/HiddenTypeNodeParser"; -export * from "./src/NodeParser/IndexedAccessTypeNodeParser"; -export * from "./src/NodeParser/InterfaceAndClassNodeParser"; -export * from "./src/NodeParser/IntersectionNodeParser"; -export * from "./src/NodeParser/IntrinsicNodeParser"; -export * from "./src/NodeParser/LiteralNodeParser"; -export * from "./src/NodeParser/MappedTypeNodeParser"; -export * from "./src/NodeParser/NeverTypeNodeParser"; -export * from "./src/NodeParser/NullLiteralNodeParser"; -export * from "./src/NodeParser/NumberLiteralNodeParser"; -export * from "./src/NodeParser/NumberTypeNodeParser"; -export * from "./src/NodeParser/ObjectLiteralExpressionNodeParser"; -export * from "./src/NodeParser/ObjectTypeNodeParser"; -export * from "./src/NodeParser/OptionalTypeNodeParser"; -export * from "./src/NodeParser/ParameterParser"; -export * from "./src/NodeParser/ParenthesizedNodeParser"; -export * from "./src/NodeParser/PrefixUnaryExpressionNodeParser"; -export * from "./src/NodeParser/PropertyAccessExpressionParser"; -export * from "./src/NodeParser/RestTypeNodeParser"; -export * from "./src/NodeParser/StringLiteralNodeParser"; -export * from "./src/NodeParser/StringTemplateLiteralNodeParser"; -export * from "./src/NodeParser/StringTypeNodeParser"; -export * from "./src/NodeParser/SymbolTypeNodeParser"; -export * from "./src/NodeParser/TupleNodeParser"; -export * from "./src/NodeParser/TypeAliasNodeParser"; -export * from "./src/NodeParser/TypeLiteralNodeParser"; -export * from "./src/NodeParser/TypeofNodeParser"; -export * from "./src/NodeParser/TypeOperatorNodeParser"; -export * from "./src/NodeParser/TypeReferenceNodeParser"; -export * from "./src/NodeParser/UndefinedLiteralNodeParser"; -export * from "./src/NodeParser/UndefinedTypeNodeParser"; -export * from "./src/NodeParser/UnionNodeParser"; -export * from "./src/NodeParser/UnknownTypeNodeParser"; -export * from "./src/NodeParser/VoidTypeNodeParser"; +export * from "./src/NodeParser.js"; +export * from "./src/SubNodeParser.js"; +export * from "./src/ChainNodeParser.js"; +export * from "./src/ExposeNodeParser.js"; +export * from "./src/TopRefNodeParser.js"; +export * from "./src/CircularReferenceNodeParser.js"; +export * from "./src/NodeParser/AnnotatedNodeParser.js"; +export * from "./src/NodeParser/AnyTypeNodeParser.js"; +export * from "./src/NodeParser/ArrayLiteralExpressionNodeParser.js"; +export * from "./src/NodeParser/ArrayNodeParser.js"; +export * from "./src/NodeParser/AsExpressionNodeParser.js"; +export * from "./src/NodeParser/BooleanLiteralNodeParser.js"; +export * from "./src/NodeParser/BooleanTypeNodeParser.js"; +export * from "./src/NodeParser/CallExpressionParser.js"; +export * from "./src/NodeParser/ConditionalTypeNodeParser.js"; +export * from "./src/NodeParser/EnumNodeParser.js"; +export * from "./src/NodeParser/ExpressionWithTypeArgumentsNodeParser.js"; +export * from "./src/NodeParser/FunctionNodeParser.js"; +export * from "./src/NodeParser/ConstructorNodeParser.js"; +export * from "./src/NodeParser/HiddenTypeNodeParser.js"; +export * from "./src/NodeParser/IndexedAccessTypeNodeParser.js"; +export * from "./src/NodeParser/InterfaceAndClassNodeParser.js"; +export * from "./src/NodeParser/IntersectionNodeParser.js"; +export * from "./src/NodeParser/IntrinsicNodeParser.js"; +export * from "./src/NodeParser/LiteralNodeParser.js"; +export * from "./src/NodeParser/MappedTypeNodeParser.js"; +export * from "./src/NodeParser/NeverTypeNodeParser.js"; +export * from "./src/NodeParser/NullLiteralNodeParser.js"; +export * from "./src/NodeParser/NumberLiteralNodeParser.js"; +export * from "./src/NodeParser/NumberTypeNodeParser.js"; +export * from "./src/NodeParser/ObjectLiteralExpressionNodeParser.js"; +export * from "./src/NodeParser/ObjectTypeNodeParser.js"; +export * from "./src/NodeParser/OptionalTypeNodeParser.js"; +export * from "./src/NodeParser/ParameterParser.js"; +export * from "./src/NodeParser/ParenthesizedNodeParser.js"; +export * from "./src/NodeParser/PrefixUnaryExpressionNodeParser.js"; +export * from "./src/NodeParser/PropertyAccessExpressionParser.js"; +export * from "./src/NodeParser/RestTypeNodeParser.js"; +export * from "./src/NodeParser/StringLiteralNodeParser.js"; +export * from "./src/NodeParser/StringTemplateLiteralNodeParser.js"; +export * from "./src/NodeParser/StringTypeNodeParser.js"; +export * from "./src/NodeParser/SymbolTypeNodeParser.js"; +export * from "./src/NodeParser/TupleNodeParser.js"; +export * from "./src/NodeParser/TypeAliasNodeParser.js"; +export * from "./src/NodeParser/TypeLiteralNodeParser.js"; +export * from "./src/NodeParser/TypeofNodeParser.js"; +export * from "./src/NodeParser/TypeOperatorNodeParser.js"; +export * from "./src/NodeParser/TypeReferenceNodeParser.js"; +export * from "./src/NodeParser/UndefinedLiteralNodeParser.js"; +export * from "./src/NodeParser/UndefinedTypeNodeParser.js"; +export * from "./src/NodeParser/UnionNodeParser.js"; +export * from "./src/NodeParser/UnknownTypeNodeParser.js"; +export * from "./src/NodeParser/VoidTypeNodeParser.js"; -export * from "./src/SchemaGenerator"; +export * from "./src/SchemaGenerator.js"; -export * from "./factory"; +export * from "./factory/index.js"; import ts from "typescript"; export { ts }; diff --git a/jest.config.js b/jest.config.cjs similarity index 70% rename from jest.config.js rename to jest.config.cjs index f76fdd99a..9b551660c 100644 --- a/jest.config.js +++ b/jest.config.cjs @@ -1,4 +1,5 @@ -module.exports = { +/** @type {import('jest').Config} */ +const config = { testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$", moduleFileExtensions: ["js", "ts", "json"], testPathIgnorePatterns: ["/dist/", "/node_modules/", "/build/"], @@ -8,4 +9,9 @@ module.exports = { transform: { ".*": "babel-jest", }, + moduleNameMapper: { + "^(\\.{1,2}/.*)\\.js$": "$1", + }, }; + +module.exports = config; diff --git a/package.json b/package.json index cb10ff0a4..fbdd4eed0 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "Generate JSON schema from your Typescript sources", "main": "dist/index.js", "types": "dist/index.d.ts", + "type": "module", "bin": { "ts-json-schema-generator": "./bin/ts-json-schema-generator" }, @@ -41,16 +42,16 @@ "jsonschema" ], "engines": { - "node": ">=10.0.0" + "node": ">=18.0.0" }, "dependencies": { "@types/json-schema": "^7.0.15", "commander": "^12.0.0", - "glob": "^8.0.3", + "glob": "^10.3.12", "json5": "^2.2.3", "normalize-path": "^3.0.0", "safe-stable-stringify": "^2.4.3", - "typescript": "~5.4.5" + "typescript": "^5.4.5" }, "devDependencies": { "@auto-it/conventional-commits": "^11.1.6", @@ -58,24 +59,25 @@ "@babel/core": "^7.24.4", "@babel/preset-env": "^7.24.4", "@babel/preset-typescript": "^7.24.1", + "@eslint/js": "^9.0.0", + "@types/eslint": "^8.56.9", "@types/glob": "^8.1.0", "@types/jest": "^29.5.12", "@types/node": "^20.12.7", "@types/normalize-path": "^3.0.2", - "@typescript-eslint/eslint-plugin": "^7.6.0", - "@typescript-eslint/parser": "^7.6.0", "ajv": "^8.12.0", "ajv-formats": "^3.0.1", "auto": "^11.1.6", "chai": "^5.1.0", "cross-env": "^7.0.3", - "eslint": "^8.55.0", + "eslint": "^9.0.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", "jest": "^29.7.0", "jest-junit": "^16.0.0", "prettier": "^3.2.5", - "ts-node": "^10.9.2", + "tsx": "^4.7.2", + "typescript-eslint": "^7.7.0", "vega": "^5.28.0", "vega-lite": "^5.18.0" }, @@ -83,14 +85,14 @@ "prepublishOnly": "yarn build", "build": "tsc", "watch": "tsc -w", - "lint": "eslint \"{src,test,factory}/**/*.ts\"", - "format": "yarn lint --fix", + "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": "node -r ts-node/register --inspect-brk ts-json-schema-generator.ts", - "run": "ts-node-transpile-only ts-json-schema-generator.ts", + "debug": "tsx --inspect-brk ts-json-schema-generator.ts", + "run": "tsx ts-json-schema-generator.ts", "release": "yarn build && auto shipit" }, "packageManager": "yarn@1.22.19" diff --git a/src/AnnotationsReader.ts b/src/AnnotationsReader.ts index 4f8743377..97235860d 100644 --- a/src/AnnotationsReader.ts +++ b/src/AnnotationsReader.ts @@ -1,5 +1,5 @@ import ts from "typescript"; -import { Annotations } from "./Type/AnnotatedType"; +import { Annotations } from "./Type/AnnotatedType.js"; export interface AnnotationsReader { getAnnotations(node: ts.Node): Annotations | undefined; diff --git a/src/AnnotationsReader/BasicAnnotationsReader.ts b/src/AnnotationsReader/BasicAnnotationsReader.ts index affbfb027..59ae257df 100644 --- a/src/AnnotationsReader/BasicAnnotationsReader.ts +++ b/src/AnnotationsReader/BasicAnnotationsReader.ts @@ -1,8 +1,8 @@ import json5 from "json5"; import ts from "typescript"; -import { AnnotationsReader } from "../AnnotationsReader"; -import { Annotations } from "../Type/AnnotatedType"; -import { symbolAtNode } from "../Utils/symbolAtNode"; +import { AnnotationsReader } from "../AnnotationsReader.js"; +import { Annotations } from "../Type/AnnotatedType.js"; +import { symbolAtNode } from "../Utils/symbolAtNode.js"; export class BasicAnnotationsReader implements AnnotationsReader { private static requiresDollar = new Set(["id", "comment", "ref"]); diff --git a/src/AnnotationsReader/ExtendedAnnotationsReader.ts b/src/AnnotationsReader/ExtendedAnnotationsReader.ts index 31f25cf5b..ba8fd57aa 100644 --- a/src/AnnotationsReader/ExtendedAnnotationsReader.ts +++ b/src/AnnotationsReader/ExtendedAnnotationsReader.ts @@ -1,14 +1,14 @@ import json5 from "json5"; import ts from "typescript"; -import { Annotations } from "../Type/AnnotatedType"; -import { symbolAtNode } from "../Utils/symbolAtNode"; -import { BasicAnnotationsReader } from "./BasicAnnotationsReader"; +import { Annotations } from "../Type/AnnotatedType.js"; +import { symbolAtNode } from "../Utils/symbolAtNode.js"; +import { BasicAnnotationsReader } from "./BasicAnnotationsReader.js"; export class ExtendedAnnotationsReader extends BasicAnnotationsReader { public constructor( private typeChecker: ts.TypeChecker, extraTags?: Set, - private markdownDescription?: boolean + private markdownDescription?: boolean, ) { super(extraTags); } diff --git a/src/ChainNodeParser.ts b/src/ChainNodeParser.ts index 3a464beff..bd8c2c409 100644 --- a/src/ChainNodeParser.ts +++ b/src/ChainNodeParser.ts @@ -1,17 +1,17 @@ import ts from "typescript"; -import { UnknownNodeError } from "./Error/UnknownNodeError"; -import { MutableParser } from "./MutableParser"; -import { Context } from "./NodeParser"; -import { SubNodeParser } from "./SubNodeParser"; -import { BaseType } from "./Type/BaseType"; -import { ReferenceType } from "./Type/ReferenceType"; +import { UnknownNodeError } from "./Error/UnknownNodeError.js"; +import { MutableParser } from "./MutableParser.js"; +import { Context } from "./NodeParser.js"; +import { SubNodeParser } from "./SubNodeParser.js"; +import { BaseType } from "./Type/BaseType.js"; +import { ReferenceType } from "./Type/ReferenceType.js"; export class ChainNodeParser implements SubNodeParser, MutableParser { protected readonly typeCaches = new WeakMap>(); public constructor( protected typeChecker: ts.TypeChecker, - protected nodeParsers: SubNodeParser[] + protected nodeParsers: SubNodeParser[], ) {} public addNodeParser(nodeParser: SubNodeParser): this { diff --git a/src/ChainTypeFormatter.ts b/src/ChainTypeFormatter.ts index e4ef55102..068e95f98 100644 --- a/src/ChainTypeFormatter.ts +++ b/src/ChainTypeFormatter.ts @@ -1,8 +1,8 @@ -import { UnknownTypeError } from "./Error/UnknownTypeError"; -import { MutableTypeFormatter } from "./MutableTypeFormatter"; -import { Definition } from "./Schema/Definition"; -import { SubTypeFormatter } from "./SubTypeFormatter"; -import { BaseType } from "./Type/BaseType"; +import { UnknownTypeError } from "./Error/UnknownTypeError.js"; +import { MutableTypeFormatter } from "./MutableTypeFormatter.js"; +import { Definition } from "./Schema/Definition.js"; +import { SubTypeFormatter } from "./SubTypeFormatter.js"; +import { BaseType } from "./Type/BaseType.js"; export class ChainTypeFormatter implements SubTypeFormatter, MutableTypeFormatter { public constructor(protected typeFormatters: SubTypeFormatter[]) {} diff --git a/src/CircularReferenceNodeParser.ts b/src/CircularReferenceNodeParser.ts index 28c033568..88244d5f5 100644 --- a/src/CircularReferenceNodeParser.ts +++ b/src/CircularReferenceNodeParser.ts @@ -1,9 +1,9 @@ import ts from "typescript"; -import { Context } from "./NodeParser"; -import { SubNodeParser } from "./SubNodeParser"; -import { BaseType } from "./Type/BaseType"; -import { ReferenceType } from "./Type/ReferenceType"; -import { getKey } from "./Utils/nodeKey"; +import { Context } from "./NodeParser.js"; +import { SubNodeParser } from "./SubNodeParser.js"; +import { BaseType } from "./Type/BaseType.js"; +import { ReferenceType } from "./Type/ReferenceType.js"; +import { getKey } from "./Utils/nodeKey.js"; export class CircularReferenceNodeParser implements SubNodeParser { protected circular: Map = new Map(); diff --git a/src/CircularReferenceTypeFormatter.ts b/src/CircularReferenceTypeFormatter.ts index e7de1c02d..58856377d 100644 --- a/src/CircularReferenceTypeFormatter.ts +++ b/src/CircularReferenceTypeFormatter.ts @@ -1,7 +1,7 @@ -import { Definition } from "./Schema/Definition"; -import { SubTypeFormatter } from "./SubTypeFormatter"; -import { BaseType } from "./Type/BaseType"; -import { uniqueArray } from "./Utils/uniqueArray"; +import { Definition } from "./Schema/Definition.js"; +import { SubTypeFormatter } from "./SubTypeFormatter.js"; +import { BaseType } from "./Type/BaseType.js"; +import { uniqueArray } from "./Utils/uniqueArray.js"; export class CircularReferenceTypeFormatter implements SubTypeFormatter { protected definition: Map = new Map(); diff --git a/src/Error/DiagnosticError.ts b/src/Error/DiagnosticError.ts index 9f7ae3ff5..2c8e00608 100644 --- a/src/Error/DiagnosticError.ts +++ b/src/Error/DiagnosticError.ts @@ -1,10 +1,10 @@ import ts from "typescript"; -import { BaseError } from "./BaseError"; +import { BaseError } from "./BaseError.js"; export class DiagnosticError extends BaseError { public constructor(private diagnostics: readonly ts.Diagnostic[]) { super( - diagnostics.map((diagnostic) => ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")).join("\n\n") + diagnostics.map((diagnostic) => ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")).join("\n\n"), ); } diff --git a/src/Error/LogicError.ts b/src/Error/LogicError.ts index b315bd7e6..6288e444a 100644 --- a/src/Error/LogicError.ts +++ b/src/Error/LogicError.ts @@ -1,4 +1,4 @@ -import { BaseError } from "./BaseError"; +import { BaseError } from "./BaseError.js"; export class LogicError extends BaseError { public constructor(private msg: string) { diff --git a/src/Error/NoRootNamesError.ts b/src/Error/NoRootNamesError.ts index 34fd6173f..12524b987 100644 --- a/src/Error/NoRootNamesError.ts +++ b/src/Error/NoRootNamesError.ts @@ -1,4 +1,4 @@ -import { BaseError } from "./BaseError"; +import { BaseError } from "./BaseError.js"; export class NoRootNamesError extends BaseError { public get name(): string { diff --git a/src/Error/NoRootTypeError.ts b/src/Error/NoRootTypeError.ts index 06977a5d7..60ad8a021 100644 --- a/src/Error/NoRootTypeError.ts +++ b/src/Error/NoRootTypeError.ts @@ -1,4 +1,4 @@ -import { BaseError } from "./BaseError"; +import { BaseError } from "./BaseError.js"; export class NoRootTypeError extends BaseError { public constructor(private type: string) { diff --git a/src/Error/NoTSConfigError.ts b/src/Error/NoTSConfigError.ts index ddcebb26b..fdeaa5724 100644 --- a/src/Error/NoTSConfigError.ts +++ b/src/Error/NoTSConfigError.ts @@ -1,4 +1,4 @@ -import { BaseError } from "./BaseError"; +import { BaseError } from "./BaseError.js"; export class NoTSConfigError extends BaseError { public get name(): string { diff --git a/src/Error/UnknownNodeError.ts b/src/Error/UnknownNodeError.ts index 289fb1b09..f8ea184fc 100644 --- a/src/Error/UnknownNodeError.ts +++ b/src/Error/UnknownNodeError.ts @@ -1,15 +1,15 @@ import ts from "typescript"; -import { BaseError } from "./BaseError"; +import { BaseError } from "./BaseError.js"; export class UnknownNodeError extends BaseError { public constructor( private node: ts.Node, - private reference?: ts.Node + private reference?: ts.Node, ) { super( `Unknown node "${node.getSourceFile() ? node.getFullText() : ""}" of kind "${ ts.SyntaxKind[node.kind] - }"` + }"`, ); } diff --git a/src/Error/UnknownTypeError.ts b/src/Error/UnknownTypeError.ts index 9c06923e3..fec91fc18 100644 --- a/src/Error/UnknownTypeError.ts +++ b/src/Error/UnknownTypeError.ts @@ -1,5 +1,5 @@ -import { BaseType } from "../Type/BaseType"; -import { BaseError } from "./BaseError"; +import { BaseType } from "../Type/BaseType.js"; +import { BaseError } from "./BaseError.js"; export class UnknownTypeError extends BaseError { public constructor(private type: BaseType) { diff --git a/src/ExposeNodeParser.ts b/src/ExposeNodeParser.ts index 58d341984..baa9ea5b4 100644 --- a/src/ExposeNodeParser.ts +++ b/src/ExposeNodeParser.ts @@ -1,18 +1,18 @@ import ts from "typescript"; -import { Context } from "./NodeParser"; -import { SubNodeParser } from "./SubNodeParser"; -import { BaseType } from "./Type/BaseType"; -import { DefinitionType } from "./Type/DefinitionType"; -import { ReferenceType } from "./Type/ReferenceType"; -import { hasJsDocTag } from "./Utils/hasJsDocTag"; -import { symbolAtNode } from "./Utils/symbolAtNode"; +import { Context } from "./NodeParser.js"; +import { SubNodeParser } from "./SubNodeParser.js"; +import { BaseType } from "./Type/BaseType.js"; +import { DefinitionType } from "./Type/DefinitionType.js"; +import { ReferenceType } from "./Type/ReferenceType.js"; +import { hasJsDocTag } from "./Utils/hasJsDocTag.js"; +import { symbolAtNode } from "./Utils/symbolAtNode.js"; export class ExposeNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, protected subNodeParser: SubNodeParser, protected expose: "all" | "none" | "export", - protected jsDoc: "none" | "extended" | "basic" + protected jsDoc: "none" | "extended" | "basic", ) {} public supportsNode(node: ts.Node): boolean { diff --git a/src/Interfaces/AnnotationsReader.ts b/src/Interfaces/AnnotationsReader.ts index de36828e9..ec9aa89cb 100755 --- a/src/Interfaces/AnnotationsReader.ts +++ b/src/Interfaces/AnnotationsReader.ts @@ -1,5 +1,5 @@ import ts from "typescript"; -import { Annotations } from "../Type/AnnotatedType"; +import { Annotations } from "../Type/AnnotatedType.js"; export interface AnnotationsReader { getAnnotations(node: ts.Node): Annotations | undefined; diff --git a/src/Interfaces/MutableParser.ts b/src/Interfaces/MutableParser.ts index 174cf665b..56eed1d34 100755 --- a/src/Interfaces/MutableParser.ts +++ b/src/Interfaces/MutableParser.ts @@ -1,4 +1,4 @@ -import { SubNodeParser } from "./SubNodeParser"; +import { SubNodeParser } from "./SubNodeParser.js"; export interface MutableParser { addNodeParser(parser: SubNodeParser): MutableParser; diff --git a/src/Interfaces/MutableTypeFormatter.ts b/src/Interfaces/MutableTypeFormatter.ts index d04ac5a74..ded6bd583 100755 --- a/src/Interfaces/MutableTypeFormatter.ts +++ b/src/Interfaces/MutableTypeFormatter.ts @@ -1,4 +1,4 @@ -import { SubTypeFormatter } from "./SubTypeFormatter"; +import { SubTypeFormatter } from "./SubTypeFormatter.js"; export interface MutableTypeFormatter { addTypeFormatter(formatter: SubTypeFormatter): MutableTypeFormatter; diff --git a/src/Interfaces/SubNodeParser.ts b/src/Interfaces/SubNodeParser.ts index 86e25a569..df0685150 100755 --- a/src/Interfaces/SubNodeParser.ts +++ b/src/Interfaces/SubNodeParser.ts @@ -1,5 +1,5 @@ import ts from "typescript"; -import { NodeParser } from "../NodeParser"; +import { NodeParser } from "../NodeParser.js"; export interface SubNodeParser extends NodeParser { supportsNode(node: ts.Node): boolean; diff --git a/src/Interfaces/SubTypeFormatter.ts b/src/Interfaces/SubTypeFormatter.ts index 1faadb544..2134e5aab 100755 --- a/src/Interfaces/SubTypeFormatter.ts +++ b/src/Interfaces/SubTypeFormatter.ts @@ -1,5 +1,5 @@ -import { BaseType } from "../Type/BaseType"; -import { TypeFormatter } from "./TypeFormatter"; +import { BaseType } from "../Type/BaseType.js"; +import { TypeFormatter } from "./TypeFormatter.js"; export interface SubTypeFormatter extends TypeFormatter { supportsType(type: BaseType): boolean; diff --git a/src/Interfaces/TypeFormatter.ts b/src/Interfaces/TypeFormatter.ts index 1cf60f5a3..0eff45122 100755 --- a/src/Interfaces/TypeFormatter.ts +++ b/src/Interfaces/TypeFormatter.ts @@ -1,5 +1,5 @@ -import { Definition } from "../Schema/Definition"; -import { BaseType } from "../Type/BaseType"; +import { Definition } from "../Schema/Definition.js"; +import { BaseType } from "../Type/BaseType.js"; export interface TypeFormatter { getDefinition(type: BaseType): Definition; diff --git a/src/MutableParser.ts b/src/MutableParser.ts index 174cf665b..56eed1d34 100644 --- a/src/MutableParser.ts +++ b/src/MutableParser.ts @@ -1,4 +1,4 @@ -import { SubNodeParser } from "./SubNodeParser"; +import { SubNodeParser } from "./SubNodeParser.js"; export interface MutableParser { addNodeParser(parser: SubNodeParser): MutableParser; diff --git a/src/MutableTypeFormatter.ts b/src/MutableTypeFormatter.ts index d04ac5a74..ded6bd583 100644 --- a/src/MutableTypeFormatter.ts +++ b/src/MutableTypeFormatter.ts @@ -1,4 +1,4 @@ -import { SubTypeFormatter } from "./SubTypeFormatter"; +import { SubTypeFormatter } from "./SubTypeFormatter.js"; export interface MutableTypeFormatter { addTypeFormatter(formatter: SubTypeFormatter): MutableTypeFormatter; diff --git a/src/NodeParser.ts b/src/NodeParser.ts index c649a8706..b9f944dc3 100644 --- a/src/NodeParser.ts +++ b/src/NodeParser.ts @@ -1,8 +1,8 @@ import stringify from "safe-stable-stringify"; import ts from "typescript"; -import { BaseType } from "./Type/BaseType"; -import { ReferenceType } from "./Type/ReferenceType"; -import { getKey } from "./Utils/nodeKey"; +import { BaseType } from "./Type/BaseType.js"; +import { ReferenceType } from "./Type/ReferenceType.js"; +import { getKey } from "./Utils/nodeKey.js"; export class Context { private cacheKey: string | null = null; diff --git a/src/NodeParser/AnnotatedNodeParser.ts b/src/NodeParser/AnnotatedNodeParser.ts index aba9dbe1d..f803aea21 100644 --- a/src/NodeParser/AnnotatedNodeParser.ts +++ b/src/NodeParser/AnnotatedNodeParser.ts @@ -1,20 +1,20 @@ import ts from "typescript"; -import { AnnotationsReader } from "../AnnotationsReader"; -import { ExtendedAnnotationsReader } from "../AnnotationsReader/ExtendedAnnotationsReader"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { AnnotatedType } from "../Type/AnnotatedType"; -import { BaseType } from "../Type/BaseType"; -import { ReferenceType } from "../Type/ReferenceType"; -import { removeUndefined } from "../Utils/removeUndefined"; -import { DefinitionType } from "../Type/DefinitionType"; -import { UnionType } from "../Type/UnionType"; -import { AnyType } from "../Type/AnyType"; +import { AnnotationsReader } from "../AnnotationsReader.js"; +import { ExtendedAnnotationsReader } from "../AnnotationsReader/ExtendedAnnotationsReader.js"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { AnnotatedType } from "../Type/AnnotatedType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { ReferenceType } from "../Type/ReferenceType.js"; +import { removeUndefined } from "../Utils/removeUndefined.js"; +import { DefinitionType } from "../Type/DefinitionType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { AnyType } from "../Type/AnyType.js"; export class AnnotatedNodeParser implements SubNodeParser { public constructor( protected childNodeParser: SubNodeParser, - protected annotationsReader: AnnotationsReader + protected annotationsReader: AnnotationsReader, ) {} public supportsNode(node: ts.Node): boolean { diff --git a/src/NodeParser/AnyTypeNodeParser.ts b/src/NodeParser/AnyTypeNodeParser.ts index da18ca2d3..0cb881384 100644 --- a/src/NodeParser/AnyTypeNodeParser.ts +++ b/src/NodeParser/AnyTypeNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { AnyType } from "../Type/AnyType"; -import { BaseType } from "../Type/BaseType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { AnyType } from "../Type/AnyType.js"; +import { BaseType } from "../Type/BaseType.js"; export class AnyTypeNodeParser implements SubNodeParser { public supportsNode(node: ts.KeywordTypeNode): boolean { diff --git a/src/NodeParser/ArrayLiteralExpressionNodeParser.ts b/src/NodeParser/ArrayLiteralExpressionNodeParser.ts index f114b298c..0b22b7975 100644 --- a/src/NodeParser/ArrayLiteralExpressionNodeParser.ts +++ b/src/NodeParser/ArrayLiteralExpressionNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { TupleType } from "../Type/TupleType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { TupleType } from "../Type/TupleType.js"; export class ArrayLiteralExpressionNodeParser implements SubNodeParser { public constructor(protected childNodeParser: NodeParser) {} diff --git a/src/NodeParser/ArrayNodeParser.ts b/src/NodeParser/ArrayNodeParser.ts index eb9fd357a..467f635d7 100644 --- a/src/NodeParser/ArrayNodeParser.ts +++ b/src/NodeParser/ArrayNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { ArrayType } from "../Type/ArrayType"; -import { BaseType } from "../Type/BaseType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { ArrayType } from "../Type/ArrayType.js"; +import { BaseType } from "../Type/BaseType.js"; export class ArrayNodeParser implements SubNodeParser { public constructor(protected childNodeParser: NodeParser) {} diff --git a/src/NodeParser/AsExpressionNodeParser.ts b/src/NodeParser/AsExpressionNodeParser.ts index e6b7929ec..68222bdda 100644 --- a/src/NodeParser/AsExpressionNodeParser.ts +++ b/src/NodeParser/AsExpressionNodeParser.ts @@ -1,8 +1,8 @@ -import { NodeParser } from "../NodeParser"; +import { NodeParser } from "../NodeParser.js"; import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; export class AsExpressionNodeParser implements SubNodeParser { public constructor(protected childNodeParser: NodeParser) {} diff --git a/src/NodeParser/BooleanLiteralNodeParser.ts b/src/NodeParser/BooleanLiteralNodeParser.ts index 81bc91750..ca1c39c30 100644 --- a/src/NodeParser/BooleanLiteralNodeParser.ts +++ b/src/NodeParser/BooleanLiteralNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { LiteralType } from "../Type/LiteralType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { LiteralType } from "../Type/LiteralType.js"; export class BooleanLiteralNodeParser implements SubNodeParser { public supportsNode(node: ts.BooleanLiteral): boolean { diff --git a/src/NodeParser/BooleanTypeNodeParser.ts b/src/NodeParser/BooleanTypeNodeParser.ts index 03ba17440..718172d49 100644 --- a/src/NodeParser/BooleanTypeNodeParser.ts +++ b/src/NodeParser/BooleanTypeNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { BooleanType } from "../Type/BooleanType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { BooleanType } from "../Type/BooleanType.js"; export class BooleanTypeNodeParser implements SubNodeParser { public supportsNode(node: ts.KeywordTypeNode): boolean { diff --git a/src/NodeParser/CallExpressionParser.ts b/src/NodeParser/CallExpressionParser.ts index 01d5cd53d..26849627d 100644 --- a/src/NodeParser/CallExpressionParser.ts +++ b/src/NodeParser/CallExpressionParser.ts @@ -1,16 +1,16 @@ -import { TupleType } from "../Type/TupleType"; +import { TupleType } from "../Type/TupleType.js"; import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { UnionType } from "../Type/UnionType"; -import { LiteralType } from "../Type/LiteralType"; -import { SymbolType } from "../Type/SymbolType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { LiteralType } from "../Type/LiteralType.js"; +import { SymbolType } from "../Type/SymbolType.js"; export class CallExpressionParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.CallExpression): boolean { @@ -34,7 +34,7 @@ export class CallExpressionParser implements SubNodeParser { const symbol = type.symbol || type.aliasSymbol; const decl = symbol.valueDeclaration || symbol.declarations![0]; const subContext = this.createSubContext(node, context); - return this.childNodeParser.createType(decl, subContext)!; + return this.childNodeParser.createType(decl, subContext); } protected createSubContext(node: ts.CallExpression, parentContext: Context): Context { diff --git a/src/NodeParser/ConditionalTypeNodeParser.ts b/src/NodeParser/ConditionalTypeNodeParser.ts index d462f66a6..6e05b1bd2 100644 --- a/src/NodeParser/ConditionalTypeNodeParser.ts +++ b/src/NodeParser/ConditionalTypeNodeParser.ts @@ -1,23 +1,23 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { isAssignableTo } from "../Utils/isAssignableTo"; -import { narrowType } from "../Utils/narrowType"; -import { UnionType } from "../Type/UnionType"; -import { NeverType } from "../Type/NeverType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { isAssignableTo } from "../Utils/isAssignableTo.js"; +import { narrowType } from "../Utils/narrowType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { NeverType } from "../Type/NeverType.js"; class CheckType { constructor( public parameterName: string, - public type: BaseType + public type: BaseType, ) {} } export class ConditionalTypeNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.ConditionalTypeNode): boolean { @@ -36,7 +36,7 @@ export class ConditionalTypeNodeParser implements SubNodeParser { const result = isAssignableTo(extendsType, checkType, inferMap); return this.childNodeParser.createType( result ? node.trueType : node.falseType, - this.createSubContext(node, context, undefined, result ? inferMap : new Map()) + this.createSubContext(node, context, undefined, result ? inferMap : new Map()), ); } @@ -49,7 +49,7 @@ export class ConditionalTypeNodeParser implements SubNodeParser { if (!(trueCheckType instanceof NeverType)) { const result = this.childNodeParser.createType( node.trueType, - this.createSubContext(node, context, new CheckType(checkTypeParameterName, trueCheckType), inferMap) + this.createSubContext(node, context, new CheckType(checkTypeParameterName, trueCheckType), inferMap), ); if (result) { results.push(result); @@ -58,7 +58,7 @@ export class ConditionalTypeNodeParser implements SubNodeParser { if (!(falseCheckType instanceof NeverType)) { const result = this.childNodeParser.createType( node.falseType, - this.createSubContext(node, context, new CheckType(checkTypeParameterName, falseCheckType)) + this.createSubContext(node, context, new CheckType(checkTypeParameterName, falseCheckType)), ); if (result) { results.push(result); @@ -97,7 +97,7 @@ export class ConditionalTypeNodeParser implements SubNodeParser { node: ts.ConditionalTypeNode, parentContext: Context, checkType?: CheckType, - inferMap: Map = new Map() + inferMap: Map = new Map(), ): Context { const subContext = new Context(node); diff --git a/src/NodeParser/ConstructorNodeParser.ts b/src/NodeParser/ConstructorNodeParser.ts index 3af1748c6..4376903bc 100644 --- a/src/NodeParser/ConstructorNodeParser.ts +++ b/src/NodeParser/ConstructorNodeParser.ts @@ -1,17 +1,17 @@ import ts from "typescript"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { ConstructorType } from "../Type/ConstructorType"; -import { FunctionOptions } from "../Config"; -import { NeverType } from "../Type/NeverType"; -import { Context, NodeParser } from "../NodeParser"; -import { DefinitionType } from "../Type/DefinitionType"; -import { getNamedArguments, getTypeName } from "./FunctionNodeParser"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { ConstructorType } from "../Type/ConstructorType.js"; +import { FunctionOptions } from "../Config.js"; +import { NeverType } from "../Type/NeverType.js"; +import { Context, NodeParser } from "../NodeParser.js"; +import { DefinitionType } from "../Type/DefinitionType.js"; +import { getNamedArguments, getTypeName } from "./FunctionNodeParser.js"; export class ConstructorNodeParser implements SubNodeParser { constructor( protected childNodeParser: NodeParser, - protected functions: FunctionOptions + protected functions: FunctionOptions, ) {} public supportsNode(node: ts.TypeNode): boolean { diff --git a/src/NodeParser/EnumNodeParser.ts b/src/NodeParser/EnumNodeParser.ts index 0064f6fd0..a23a3a49c 100644 --- a/src/NodeParser/EnumNodeParser.ts +++ b/src/NodeParser/EnumNodeParser.ts @@ -1,10 +1,10 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { EnumType, EnumValue } from "../Type/EnumType"; -import { isNodeHidden } from "../Utils/isHidden"; -import { getKey } from "../Utils/nodeKey"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { EnumType, EnumValue } from "../Type/EnumType.js"; +import { isNodeHidden } from "../Utils/isHidden.js"; +import { getKey } from "../Utils/nodeKey.js"; export class EnumNodeParser implements SubNodeParser { public constructor(protected typeChecker: ts.TypeChecker) {} @@ -19,7 +19,7 @@ export class EnumNodeParser implements SubNodeParser { `enum-${getKey(node, context)}`, members .filter((member: ts.EnumMember) => !isNodeHidden(member)) - .map((member, index) => this.getMemberValue(member, index)) + .map((member, index) => this.getMemberValue(member, index)), ); } diff --git a/src/NodeParser/ExpressionWithTypeArgumentsNodeParser.ts b/src/NodeParser/ExpressionWithTypeArgumentsNodeParser.ts index 07ce2c157..b7e382166 100644 --- a/src/NodeParser/ExpressionWithTypeArgumentsNodeParser.ts +++ b/src/NodeParser/ExpressionWithTypeArgumentsNodeParser.ts @@ -1,12 +1,12 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; export class ExpressionWithTypeArgumentsNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.ExpressionWithTypeArguments): boolean { @@ -18,7 +18,7 @@ export class ExpressionWithTypeArgumentsNodeParser implements SubNodeParser { const aliasedSymbol = this.typeChecker.getAliasedSymbol(typeSymbol); return this.childNodeParser.createType( aliasedSymbol.declarations![0], - this.createSubContext(node, context) + this.createSubContext(node, context), ); } else if (typeSymbol.flags & ts.SymbolFlags.TypeParameter) { return context.getArgument(typeSymbol.name); diff --git a/src/NodeParser/FunctionNodeParser.ts b/src/NodeParser/FunctionNodeParser.ts index 89aea7c8e..d75003824 100644 --- a/src/NodeParser/FunctionNodeParser.ts +++ b/src/NodeParser/FunctionNodeParser.ts @@ -1,18 +1,18 @@ import ts from "typescript"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { FunctionType } from "../Type/FunctionType"; -import { FunctionOptions } from "../Config"; -import { NeverType } from "../Type/NeverType"; -import { DefinitionType } from "../Type/DefinitionType"; -import { Context, NodeParser } from "../NodeParser"; -import { ObjectProperty, ObjectType } from "../Type/ObjectType"; -import { getKey } from "../Utils/nodeKey"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { FunctionType } from "../Type/FunctionType.js"; +import { FunctionOptions } from "../Config.js"; +import { NeverType } from "../Type/NeverType.js"; +import { DefinitionType } from "../Type/DefinitionType.js"; +import { Context, NodeParser } from "../NodeParser.js"; +import { ObjectProperty, ObjectType } from "../Type/ObjectType.js"; +import { getKey } from "../Utils/nodeKey.js"; export class FunctionNodeParser implements SubNodeParser { constructor( protected childNodeParser: NodeParser, - protected functions: FunctionOptions + protected functions: FunctionOptions, ) {} public supportsNode(node: ts.TypeNode): boolean { @@ -26,7 +26,7 @@ export class FunctionNodeParser implements SubNodeParser { public createType( node: ts.FunctionTypeNode | ts.FunctionExpression | ts.FunctionDeclaration | ts.ArrowFunction, - context: Context + context: Context, ): BaseType { if (this.functions === "hide") { return new NeverType(); @@ -47,7 +47,7 @@ export function getNamedArguments( | ts.FunctionDeclaration | ts.ArrowFunction | ts.ConstructorTypeNode, - context: Context + context: Context, ) { if (node.parameters.length === 0) { return undefined; @@ -66,7 +66,7 @@ export function getNamedArguments( return new ObjectProperty(node.parameters[index].name.getText(), parameterType, required); }), - false + false, ); } @@ -76,7 +76,7 @@ export function getTypeName( | ts.FunctionExpression | ts.FunctionDeclaration | ts.ArrowFunction - | ts.ConstructorTypeNode + | ts.ConstructorTypeNode, ): string | undefined { if (ts.isArrowFunction(node) || ts.isFunctionExpression(node) || ts.isFunctionTypeNode(node)) { const parent = node.parent; diff --git a/src/NodeParser/HiddenTypeNodeParser.ts b/src/NodeParser/HiddenTypeNodeParser.ts index 42a514278..681cb35bf 100644 --- a/src/NodeParser/HiddenTypeNodeParser.ts +++ b/src/NodeParser/HiddenTypeNodeParser.ts @@ -1,9 +1,9 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { HiddenType } from "../Type/HiddenType"; -import { isNodeHidden } from "../Utils/isHidden"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { HiddenType } from "../Type/HiddenType.js"; +import { isNodeHidden } from "../Utils/isHidden.js"; export class HiddenNodeParser implements SubNodeParser { public constructor(protected typeChecker: ts.TypeChecker) {} diff --git a/src/NodeParser/IndexedAccessTypeNodeParser.ts b/src/NodeParser/IndexedAccessTypeNodeParser.ts index 694e546cc..2544ae1c5 100644 --- a/src/NodeParser/IndexedAccessTypeNodeParser.ts +++ b/src/NodeParser/IndexedAccessTypeNodeParser.ts @@ -1,22 +1,22 @@ import ts from "typescript"; -import { LogicError } from "../Error/LogicError"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { LiteralType } from "../Type/LiteralType"; -import { NeverType } from "../Type/NeverType"; -import { NumberType } from "../Type/NumberType"; -import { ReferenceType } from "../Type/ReferenceType"; -import { StringType } from "../Type/StringType"; -import { TupleType } from "../Type/TupleType"; -import { UnionType } from "../Type/UnionType"; -import { derefType } from "../Utils/derefType"; -import { getTypeByKey } from "../Utils/typeKeys"; +import { LogicError } from "../Error/LogicError.js"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { LiteralType } from "../Type/LiteralType.js"; +import { NeverType } from "../Type/NeverType.js"; +import { NumberType } from "../Type/NumberType.js"; +import { ReferenceType } from "../Type/ReferenceType.js"; +import { StringType } from "../Type/StringType.js"; +import { TupleType } from "../Type/TupleType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { derefType } from "../Utils/derefType.js"; +import { getTypeByKey } from "../Utils/typeKeys.js"; export class IndexedAccessTypeNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.TypeNode): boolean { @@ -36,7 +36,7 @@ export class IndexedAccessTypeNodeParser implements SubNodeParser { ts.isPropertySignature(m) && Boolean(m.type) && ts.isIdentifier(m.name) && - m.name.text === indexType.getValue() + m.name.text === indexType.getValue(), ); return member && this.childNodeParser.createType(member.type, context); @@ -62,7 +62,7 @@ export class IndexedAccessTypeNodeParser implements SubNodeParser { const propertyTypes = indexTypes.map((type) => { if (!(type instanceof LiteralType || type instanceof StringType || type instanceof NumberType)) { throw new LogicError( - `Unexpected type "${type.getId()}" (expected "LiteralType" or "StringType" or "NumberType")` + `Unexpected type "${type.getId()}" (expected "LiteralType.js" or "StringType.js" or "NumberType.js")`, ); } diff --git a/src/NodeParser/InferTypeNodeParser.ts b/src/NodeParser/InferTypeNodeParser.ts index 5ce69bc69..141ea9b5b 100644 --- a/src/NodeParser/InferTypeNodeParser.ts +++ b/src/NodeParser/InferTypeNodeParser.ts @@ -1,13 +1,13 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { InferType } from "../Type/InferType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { InferType } from "../Type/InferType.js"; export class InferTypeNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.InferTypeNode): boolean { diff --git a/src/NodeParser/InterfaceAndClassNodeParser.ts b/src/NodeParser/InterfaceAndClassNodeParser.ts index 47894e0da..ca8a715b9 100644 --- a/src/NodeParser/InterfaceAndClassNodeParser.ts +++ b/src/NodeParser/InterfaceAndClassNodeParser.ts @@ -1,20 +1,20 @@ import ts, { PropertyName } from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { ArrayType } from "../Type/ArrayType"; -import { BaseType } from "../Type/BaseType"; -import { NeverType } from "../Type/NeverType"; -import { ObjectProperty, ObjectType } from "../Type/ObjectType"; -import { ReferenceType } from "../Type/ReferenceType"; -import { isNodeHidden } from "../Utils/isHidden"; -import { isPublic, isStatic } from "../Utils/modifiers"; -import { getKey } from "../Utils/nodeKey"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { ArrayType } from "../Type/ArrayType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { NeverType } from "../Type/NeverType.js"; +import { ObjectProperty, ObjectType } from "../Type/ObjectType.js"; +import { ReferenceType } from "../Type/ReferenceType.js"; +import { isNodeHidden } from "../Utils/isHidden.js"; +import { isPublic, isStatic } from "../Utils/modifiers.js"; +import { getKey } from "../Utils/nodeKey.js"; export class InterfaceAndClassNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, protected childNodeParser: NodeParser, - protected readonly additionalProperties: boolean + protected readonly additionalProperties: boolean, ) {} public supportsNode(node: ts.InterfaceDeclaration | ts.ClassDeclaration): boolean { @@ -24,7 +24,7 @@ export class InterfaceAndClassNodeParser implements SubNodeParser { public createType( node: ts.InterfaceDeclaration | ts.ClassDeclaration, context: Context, - reference?: ReferenceType + reference?: ReferenceType, ): BaseType { if (node.typeParameters?.length) { node.typeParameters.forEach((typeParam) => { @@ -97,13 +97,13 @@ export class InterfaceAndClassNodeParser implements SubNodeParser { ...result, ...baseType.types.map((expression) => this.childNodeParser.createType(expression, context)), ], - [] + [], ); } protected getProperties( node: ts.InterfaceDeclaration | ts.ClassDeclaration, - context: Context + context: Context, ): ObjectProperty[] | undefined { let hasRequiredNever = false; @@ -112,7 +112,7 @@ export class InterfaceAndClassNodeParser implements SubNodeParser { (members, member) => { if (ts.isConstructorDeclaration(member)) { const params = member.parameters.filter((param) => - ts.isParameterPropertyDeclaration(param, param.parent) + ts.isParameterPropertyDeclaration(param, param.parent), ) as ts.ParameterPropertyDeclaration[]; members.push(...params); } else if (ts.isPropertySignature(member) || ts.isPropertyDeclaration(member)) { @@ -120,7 +120,7 @@ export class InterfaceAndClassNodeParser implements SubNodeParser { } return members; }, - [] as (ts.PropertyDeclaration | ts.PropertySignature | ts.ParameterPropertyDeclaration)[] + [] as (ts.PropertyDeclaration | ts.PropertySignature | ts.ParameterPropertyDeclaration)[], ) .filter((member) => isPublic(member) && !isStatic(member) && !isNodeHidden(member)) .reduce((entries, member) => { @@ -143,8 +143,8 @@ export class InterfaceAndClassNodeParser implements SubNodeParser { new ObjectProperty( this.getPropertyName(member.name), this.childNodeParser.createType(memberType, context), - !member.questionToken - ) + !member.questionToken, + ), ) .filter((prop) => { const type = prop.getType(); @@ -163,14 +163,14 @@ export class InterfaceAndClassNodeParser implements SubNodeParser { protected getAdditionalProperties( node: ts.InterfaceDeclaration | ts.ClassDeclaration, - context: Context + context: Context, ): BaseType | boolean { const indexSignature = (node.members as ts.NodeArray).find(ts.isIndexSignatureDeclaration); if (!indexSignature) { return this.additionalProperties; } - return this.childNodeParser.createType(indexSignature.type!, context) ?? this.additionalProperties; + return this.childNodeParser.createType(indexSignature.type, context) ?? this.additionalProperties; } protected getTypeId(node: ts.Node, context: Context): string { diff --git a/src/NodeParser/IntersectionNodeParser.ts b/src/NodeParser/IntersectionNodeParser.ts index 24111bb71..d94416a34 100644 --- a/src/NodeParser/IntersectionNodeParser.ts +++ b/src/NodeParser/IntersectionNodeParser.ts @@ -1,19 +1,23 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { IntersectionType } from "../Type/IntersectionType"; -import { PrimitiveType } from "../Type/PrimitiveType"; -import { UnionType } from "../Type/UnionType"; -import { derefType } from "../Utils/derefType"; -import { uniqueTypeArray } from "../Utils/uniqueTypeArray"; -import { UndefinedType } from "../Type/UndefinedType"; -import { NeverType } from "../Type/NeverType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { IntersectionType } from "../Type/IntersectionType.js"; +import { PrimitiveType } from "../Type/PrimitiveType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { derefType } from "../Utils/derefType.js"; +import { uniqueTypeArray } from "../Utils/uniqueTypeArray.js"; +import { UndefinedType } from "../Type/UndefinedType.js"; +import { NeverType } from "../Type/NeverType.js"; +import { ObjectType } from "../Type/ObjectType.js"; +import { StringType } from "../Type/StringType.js"; +import { LiteralType } from "../Type/LiteralType.js"; +import { isLiteralUnion } from "../TypeFormatter/LiteralUnionTypeFormatter.js"; export class IntersectionNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.IntersectionTypeNode): boolean { @@ -28,10 +32,26 @@ export class IntersectionNodeParser implements SubNodeParser { return new NeverType(); } - return translate(types as BaseType[]); + // handle autocomplete hacks like `string & {}` + if (types.length === 2 && types.some((t) => isEmptyObject(t))) { + if (types.some((t) => t instanceof StringType)) { + return new StringType(true); + } + const nonObject = types.find((t) => !isEmptyObject(t)); + if (nonObject instanceof LiteralType || (nonObject instanceof UnionType && isLiteralUnion(nonObject))) { + return nonObject; + } + } + + return translate(types); } } +function isEmptyObject(x: BaseType) { + const t = derefType(x); + return t instanceof ObjectType && !t.getAdditionalProperties() && !t.getProperties().length; +} + function derefAndFlattenUnions(type: BaseType): BaseType[] { const derefed = derefType(type); return derefed instanceof UnionType @@ -47,7 +67,7 @@ function derefAndFlattenUnions(type: BaseType): BaseType[] { * `(A & B) | (A & C)`. If no translation is needed then the original intersection type is returned. */ export function translate(types: BaseType[]): BaseType { - types = uniqueTypeArray(types as BaseType[]); + types = uniqueTypeArray(types); if (types.length == 1) { return types[0]; diff --git a/src/NodeParser/IntrinsicNodeParser.ts b/src/NodeParser/IntrinsicNodeParser.ts index 3d8f76ac6..9377dcfdd 100644 --- a/src/NodeParser/IntrinsicNodeParser.ts +++ b/src/NodeParser/IntrinsicNodeParser.ts @@ -1,11 +1,11 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { LiteralType } from "../Type/LiteralType"; -import { UnionType } from "../Type/UnionType"; -import assert from "../Utils/assert"; -import { extractLiterals } from "../Utils/extractLiterals"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { LiteralType } from "../Type/LiteralType.js"; +import { UnionType } from "../Type/UnionType.js"; +import assert from "../Utils/assert.js"; +import { extractLiterals } from "../Utils/extractLiterals.js"; export const intrinsicMethods: Record string) | undefined> = { Uppercase: (v) => v.toUpperCase(), diff --git a/src/NodeParser/LiteralNodeParser.ts b/src/NodeParser/LiteralNodeParser.ts index bf81a977f..31ea08dea 100644 --- a/src/NodeParser/LiteralNodeParser.ts +++ b/src/NodeParser/LiteralNodeParser.ts @@ -1,7 +1,7 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; export class LiteralNodeParser implements SubNodeParser { public constructor(protected childNodeParser: NodeParser) {} diff --git a/src/NodeParser/MappedTypeNodeParser.ts b/src/NodeParser/MappedTypeNodeParser.ts index e17543a2a..62561819b 100644 --- a/src/NodeParser/MappedTypeNodeParser.ts +++ b/src/NodeParser/MappedTypeNodeParser.ts @@ -1,28 +1,28 @@ import ts from "typescript"; -import { LogicError } from "../Error/LogicError"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { AnnotatedType } from "../Type/AnnotatedType"; -import { ArrayType } from "../Type/ArrayType"; -import { BaseType } from "../Type/BaseType"; -import { DefinitionType } from "../Type/DefinitionType"; -import { EnumType, EnumValue } from "../Type/EnumType"; -import { LiteralType } from "../Type/LiteralType"; -import { NeverType } from "../Type/NeverType"; -import { NumberType } from "../Type/NumberType"; -import { ObjectProperty, ObjectType } from "../Type/ObjectType"; -import { StringType } from "../Type/StringType"; -import { SymbolType } from "../Type/SymbolType"; -import { UnionType } from "../Type/UnionType"; -import { derefAnnotatedType, derefType } from "../Utils/derefType"; -import { getKey } from "../Utils/nodeKey"; -import { preserveAnnotation } from "../Utils/preserveAnnotation"; -import { removeUndefined } from "../Utils/removeUndefined"; +import { LogicError } from "../Error/LogicError.js"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { AnnotatedType } from "../Type/AnnotatedType.js"; +import { ArrayType } from "../Type/ArrayType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { DefinitionType } from "../Type/DefinitionType.js"; +import { EnumType, EnumValue } from "../Type/EnumType.js"; +import { LiteralType } from "../Type/LiteralType.js"; +import { NeverType } from "../Type/NeverType.js"; +import { NumberType } from "../Type/NumberType.js"; +import { ObjectProperty, ObjectType } from "../Type/ObjectType.js"; +import { StringType } from "../Type/StringType.js"; +import { SymbolType } from "../Type/SymbolType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { derefAnnotatedType, derefType } from "../Utils/derefType.js"; +import { getKey } from "../Utils/nodeKey.js"; +import { preserveAnnotation } from "../Utils/preserveAnnotation.js"; +import { removeUndefined } from "../Utils/removeUndefined.js"; export class MappedTypeNodeParser implements SubNodeParser { public constructor( protected childNodeParser: NodeParser, - protected readonly additionalProperties: boolean + protected readonly additionalProperties: boolean, ) {} public supportsNode(node: ts.MappedTypeNode): boolean { @@ -40,7 +40,7 @@ export class MappedTypeNodeParser implements SubNodeParser { id, [], this.getProperties(node, keyListType, context), - this.getAdditionalProperties(node, keyListType, context) + this.getAdditionalProperties(node, keyListType, context), ); } else if (keyListType instanceof LiteralType) { // Key type resolves to single known property @@ -53,7 +53,7 @@ export class MappedTypeNodeParser implements SubNodeParser { if (constraintType?.getId() === "number") { const type = this.childNodeParser.createType( node.type!, - this.createSubContext(node, keyListType, context) + this.createSubContext(node, keyListType, context), ); return type instanceof NeverType ? new NeverType() : new ArrayType(type); } @@ -83,10 +83,9 @@ export class MappedTypeNodeParser implements SubNodeParser { return new ObjectType(id, [], [], false); } else { throw new LogicError( - // eslint-disable-next-line max-len `Unexpected key type "${ constraintType ? constraintType.getId() : constraintType - }" for type "${node.getText()}" (expected "UnionType" or "StringType")` + }" for type "${node.getText()}" (expected "UnionType" or "StringType")`, ); } } @@ -96,7 +95,7 @@ export class MappedTypeNodeParser implements SubNodeParser { return rawKey; } const key = derefType( - this.childNodeParser.createType(node.nameType, this.createSubContext(node, rawKey, context)) + this.childNodeParser.createType(node.nameType, this.createSubContext(node, rawKey, context)), ); return key; @@ -111,7 +110,7 @@ export class MappedTypeNodeParser implements SubNodeParser { .reduce((result: ObjectProperty[], [key, mappedKey]: [LiteralType, LiteralType]) => { const propertyType = this.childNodeParser.createType( node.type!, - this.createSubContext(node, key, context) + this.createSubContext(node, key, context), ); let newType = derefAnnotatedType(propertyType); @@ -125,7 +124,7 @@ export class MappedTypeNodeParser implements SubNodeParser { const objectProperty = new ObjectProperty( mappedKey.getValue().toString(), preserveAnnotation(propertyType, newType), - !node.questionToken && !hasUndefined + !node.questionToken && !hasUndefined, ); result.push(objectProperty); @@ -140,7 +139,7 @@ export class MappedTypeNodeParser implements SubNodeParser { .map((value: EnumValue) => { const type = this.childNodeParser.createType( node.type!, - this.createSubContext(node, new LiteralType(value!), context) + this.createSubContext(node, new LiteralType(value!), context), ); return new ObjectProperty(value!.toString(), type, !node.questionToken); @@ -150,7 +149,7 @@ export class MappedTypeNodeParser implements SubNodeParser { protected getAdditionalProperties( node: ts.MappedTypeNode, keyListType: UnionType, - context: Context + context: Context, ): BaseType | boolean { const key = keyListType.getTypes().filter((type) => !(type instanceof LiteralType))[0]; if (key) { @@ -165,8 +164,8 @@ export class MappedTypeNodeParser implements SubNodeParser { protected createSubContext( node: ts.MappedTypeNode, - key: LiteralType | StringType, - parentContext: Context + key: LiteralType | StringType | NumberType, + parentContext: Context, ): Context { const subContext = new Context(node); diff --git a/src/NodeParser/NamedTupleMemberNodeParser.ts b/src/NodeParser/NamedTupleMemberNodeParser.ts index 5f33c2216..168226196 100644 --- a/src/NodeParser/NamedTupleMemberNodeParser.ts +++ b/src/NodeParser/NamedTupleMemberNodeParser.ts @@ -1,11 +1,11 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { AnnotatedType } from "../Type/AnnotatedType"; -import { ArrayType } from "../Type/ArrayType"; -import { BaseType } from "../Type/BaseType"; -import { ReferenceType } from "../Type/ReferenceType"; -import { RestType } from "../Type/RestType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { AnnotatedType } from "../Type/AnnotatedType.js"; +import { ArrayType } from "../Type/ArrayType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { ReferenceType } from "../Type/ReferenceType.js"; +import { RestType } from "../Type/RestType.js"; export class NamedTupleMemberNodeParser implements SubNodeParser { public constructor(protected childNodeParser: NodeParser) {} diff --git a/src/NodeParser/NeverTypeNodeParser.ts b/src/NodeParser/NeverTypeNodeParser.ts index 46d4c4fb6..5c1f950a6 100644 --- a/src/NodeParser/NeverTypeNodeParser.ts +++ b/src/NodeParser/NeverTypeNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { NeverType } from "../Type/NeverType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { NeverType } from "../Type/NeverType.js"; export class NeverTypeNodeParser implements SubNodeParser { public supportsNode(node: ts.KeywordTypeNode): boolean { diff --git a/src/NodeParser/NullLiteralNodeParser.ts b/src/NodeParser/NullLiteralNodeParser.ts index a1dd7bc1f..9aa9f7d9d 100644 --- a/src/NodeParser/NullLiteralNodeParser.ts +++ b/src/NodeParser/NullLiteralNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { NullType } from "../Type/NullType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { NullType } from "../Type/NullType.js"; export class NullLiteralNodeParser implements SubNodeParser { public supportsNode(node: ts.NullLiteral): boolean { diff --git a/src/NodeParser/NumberLiteralNodeParser.ts b/src/NodeParser/NumberLiteralNodeParser.ts index 38fd32fdb..5d0214aa6 100644 --- a/src/NodeParser/NumberLiteralNodeParser.ts +++ b/src/NodeParser/NumberLiteralNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { LiteralType } from "../Type/LiteralType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { LiteralType } from "../Type/LiteralType.js"; export class NumberLiteralNodeParser implements SubNodeParser { public supportsNode(node: ts.NumericLiteral): boolean { diff --git a/src/NodeParser/NumberTypeNodeParser.ts b/src/NodeParser/NumberTypeNodeParser.ts index 68ed1e21a..8ff6e201b 100644 --- a/src/NodeParser/NumberTypeNodeParser.ts +++ b/src/NodeParser/NumberTypeNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { NumberType } from "../Type/NumberType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { NumberType } from "../Type/NumberType.js"; export class NumberTypeNodeParser implements SubNodeParser { public supportsNode(node: ts.KeywordTypeNode): boolean { diff --git a/src/NodeParser/ObjectLiteralExpressionNodeParser.ts b/src/NodeParser/ObjectLiteralExpressionNodeParser.ts index e741e43ac..30dc25889 100644 --- a/src/NodeParser/ObjectLiteralExpressionNodeParser.ts +++ b/src/NodeParser/ObjectLiteralExpressionNodeParser.ts @@ -1,10 +1,10 @@ -import { NodeParser } from "../NodeParser"; +import { NodeParser } from "../NodeParser.js"; import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { getKey } from "../Utils/nodeKey"; -import { ObjectProperty, ObjectType } from "../Type/ObjectType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { getKey } from "../Utils/nodeKey.js"; +import { ObjectProperty, ObjectType } from "../Type/ObjectType.js"; export class ObjectLiteralExpressionNodeParser implements SubNodeParser { public constructor(protected childNodeParser: NodeParser) {} @@ -19,8 +19,8 @@ export class ObjectLiteralExpressionNodeParser implements SubNodeParser { new ObjectProperty( t.name!.getText(), this.childNodeParser.createType((t as any).initializer, context), - !(t as any).questionToken - ) + !(t as any).questionToken, + ), ); return new ObjectType(`object-${getKey(node, context)}`, [], properties, false); diff --git a/src/NodeParser/ObjectTypeNodeParser.ts b/src/NodeParser/ObjectTypeNodeParser.ts index fe6e63023..b2e796e71 100644 --- a/src/NodeParser/ObjectTypeNodeParser.ts +++ b/src/NodeParser/ObjectTypeNodeParser.ts @@ -1,9 +1,9 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { ObjectType } from "../Type/ObjectType"; -import { getKey } from "../Utils/nodeKey"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { ObjectType } from "../Type/ObjectType.js"; +import { getKey } from "../Utils/nodeKey.js"; export class ObjectTypeNodeParser implements SubNodeParser { public supportsNode(node: ts.KeywordTypeNode): boolean { diff --git a/src/NodeParser/OptionalTypeNodeParser.ts b/src/NodeParser/OptionalTypeNodeParser.ts index ed0ab2ea5..4eeab8c64 100644 --- a/src/NodeParser/OptionalTypeNodeParser.ts +++ b/src/NodeParser/OptionalTypeNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { OptionalType } from "../Type/OptionalType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { OptionalType } from "../Type/OptionalType.js"; export class OptionalTypeNodeParser implements SubNodeParser { public constructor(protected childNodeParser: NodeParser) {} diff --git a/src/NodeParser/ParameterParser.ts b/src/NodeParser/ParameterParser.ts index b98776406..bfb190727 100644 --- a/src/NodeParser/ParameterParser.ts +++ b/src/NodeParser/ParameterParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { NodeParser } from "../NodeParser"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; +import { NodeParser } from "../NodeParser.js"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; export class ParameterParser implements SubNodeParser { constructor(protected childNodeParser: NodeParser) {} diff --git a/src/NodeParser/ParenthesizedNodeParser.ts b/src/NodeParser/ParenthesizedNodeParser.ts index 4957f965b..5b83e965a 100644 --- a/src/NodeParser/ParenthesizedNodeParser.ts +++ b/src/NodeParser/ParenthesizedNodeParser.ts @@ -1,7 +1,7 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; export class ParenthesizedNodeParser implements SubNodeParser { public constructor(protected childNodeParser: NodeParser) {} diff --git a/src/NodeParser/PrefixUnaryExpressionNodeParser.ts b/src/NodeParser/PrefixUnaryExpressionNodeParser.ts index 8ff866bb9..13e11ec12 100644 --- a/src/NodeParser/PrefixUnaryExpressionNodeParser.ts +++ b/src/NodeParser/PrefixUnaryExpressionNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { LiteralType } from "../Type/LiteralType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { LiteralType } from "../Type/LiteralType.js"; export class PrefixUnaryExpressionNodeParser implements SubNodeParser { public constructor(protected childNodeParser: NodeParser) {} @@ -28,7 +28,7 @@ export class PrefixUnaryExpressionNodeParser implements SubNodeParser { } } else { throw new Error( - `Expected operand to be "LiteralType" but is "${operand ? operand.constructor.name : operand}"` + `Expected operand to be "LiteralType" but is "${operand ? operand.constructor.name : operand}"`, ); } } diff --git a/src/NodeParser/PropertyAccessExpressionParser.ts b/src/NodeParser/PropertyAccessExpressionParser.ts index bf6bee69f..2dec5c6bf 100644 --- a/src/NodeParser/PropertyAccessExpressionParser.ts +++ b/src/NodeParser/PropertyAccessExpressionParser.ts @@ -1,12 +1,12 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; export class PropertyAccessExpressionParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.PropertyAccessExpression): boolean { diff --git a/src/NodeParser/RestTypeNodeParser.ts b/src/NodeParser/RestTypeNodeParser.ts index 357b7ed3a..0652f49b7 100644 --- a/src/NodeParser/RestTypeNodeParser.ts +++ b/src/NodeParser/RestTypeNodeParser.ts @@ -1,11 +1,11 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { ArrayType } from "../Type/ArrayType"; -import { BaseType } from "../Type/BaseType"; -import { InferType } from "../Type/InferType"; -import { RestType } from "../Type/RestType"; -import { TupleType } from "../Type/TupleType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { ArrayType } from "../Type/ArrayType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { InferType } from "../Type/InferType.js"; +import { RestType } from "../Type/RestType.js"; +import { TupleType } from "../Type/TupleType.js"; export class RestTypeNodeParser implements SubNodeParser { public constructor(protected childNodeParser: NodeParser) {} diff --git a/src/NodeParser/SatisfiesNodeParser.ts b/src/NodeParser/SatisfiesNodeParser.ts index effcef473..1553b0ec0 100644 --- a/src/NodeParser/SatisfiesNodeParser.ts +++ b/src/NodeParser/SatisfiesNodeParser.ts @@ -1,7 +1,7 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; export class SatisfiesNodeParser implements SubNodeParser { public constructor(protected childNodeParser: NodeParser) {} diff --git a/src/NodeParser/StringLiteralNodeParser.ts b/src/NodeParser/StringLiteralNodeParser.ts index ae24a6f62..45063fe0f 100644 --- a/src/NodeParser/StringLiteralNodeParser.ts +++ b/src/NodeParser/StringLiteralNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { LiteralType } from "../Type/LiteralType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { LiteralType } from "../Type/LiteralType.js"; export class StringLiteralNodeParser implements SubNodeParser { public supportsNode(node: ts.StringLiteral): boolean { diff --git a/src/NodeParser/StringTemplateLiteralNodeParser.ts b/src/NodeParser/StringTemplateLiteralNodeParser.ts index 945212b67..0ecf642f4 100644 --- a/src/NodeParser/StringTemplateLiteralNodeParser.ts +++ b/src/NodeParser/StringTemplateLiteralNodeParser.ts @@ -1,12 +1,12 @@ import ts from "typescript"; -import { UnknownTypeError } from "../Error/UnknownTypeError"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { LiteralType } from "../Type/LiteralType"; -import { StringType } from "../Type/StringType"; -import { UnionType } from "../Type/UnionType"; -import { extractLiterals } from "../Utils/extractLiterals"; +import { UnknownTypeError } from "../Error/UnknownTypeError.js"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { LiteralType } from "../Type/LiteralType.js"; +import { StringType } from "../Type/StringType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { extractLiterals } from "../Utils/extractLiterals.js"; export class StringTemplateLiteralNodeParser implements SubNodeParser { public constructor(protected childNodeParser: NodeParser) {} @@ -28,7 +28,7 @@ export class StringTemplateLiteralNodeParser implements SubNodeParser { const suffix = span.literal.text; const type = this.childNodeParser.createType(span.type, context); return extractLiterals(type).map((value) => value + suffix); - }) + }), ); const expandedLiterals = expand(matrix); diff --git a/src/NodeParser/StringTypeNodeParser.ts b/src/NodeParser/StringTypeNodeParser.ts index d784f2ae5..104c9ed7d 100644 --- a/src/NodeParser/StringTypeNodeParser.ts +++ b/src/NodeParser/StringTypeNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { StringType } from "../Type/StringType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { StringType } from "../Type/StringType.js"; export class StringTypeNodeParser implements SubNodeParser { public supportsNode(node: ts.KeywordTypeNode): boolean { diff --git a/src/NodeParser/SymbolTypeNodeParser.ts b/src/NodeParser/SymbolTypeNodeParser.ts index 2f6c60670..2dd70eefe 100644 --- a/src/NodeParser/SymbolTypeNodeParser.ts +++ b/src/NodeParser/SymbolTypeNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { SymbolType } from "../Type/SymbolType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { SymbolType } from "../Type/SymbolType.js"; export class SymbolTypeNodeParser implements SubNodeParser { public supportsNode(node: ts.KeywordTypeNode): boolean { diff --git a/src/NodeParser/TupleNodeParser.ts b/src/NodeParser/TupleNodeParser.ts index 7be39ca76..281e8aa6e 100644 --- a/src/NodeParser/TupleNodeParser.ts +++ b/src/NodeParser/TupleNodeParser.ts @@ -1,13 +1,13 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { TupleType } from "../Type/TupleType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { TupleType } from "../Type/TupleType.js"; export class TupleNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.TupleTypeNode): boolean { @@ -18,7 +18,7 @@ export class TupleNodeParser implements SubNodeParser { return new TupleType( node.elements.map((item) => { return this.childNodeParser.createType(item, context); - }) + }), ); } } diff --git a/src/NodeParser/TypeAliasNodeParser.ts b/src/NodeParser/TypeAliasNodeParser.ts index 2425b19e5..5787c04a3 100644 --- a/src/NodeParser/TypeAliasNodeParser.ts +++ b/src/NodeParser/TypeAliasNodeParser.ts @@ -1,16 +1,16 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { AliasType } from "../Type/AliasType"; -import { BaseType } from "../Type/BaseType"; -import { NeverType } from "../Type/NeverType"; -import { ReferenceType } from "../Type/ReferenceType"; -import { getKey } from "../Utils/nodeKey"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { AliasType } from "../Type/AliasType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { NeverType } from "../Type/NeverType.js"; +import { ReferenceType } from "../Type/ReferenceType.js"; +import { getKey } from "../Utils/nodeKey.js"; export class TypeAliasNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.TypeAliasDeclaration): boolean { diff --git a/src/NodeParser/TypeLiteralNodeParser.ts b/src/NodeParser/TypeLiteralNodeParser.ts index c43e977db..4c1b4a5ea 100644 --- a/src/NodeParser/TypeLiteralNodeParser.ts +++ b/src/NodeParser/TypeLiteralNodeParser.ts @@ -1,18 +1,18 @@ import ts, { MethodSignature, PropertySignature } from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { NeverType } from "../Type/NeverType"; -import { ObjectProperty, ObjectType } from "../Type/ObjectType"; -import { ReferenceType } from "../Type/ReferenceType"; -import { isNodeHidden } from "../Utils/isHidden"; -import { getKey } from "../Utils/nodeKey"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { NeverType } from "../Type/NeverType.js"; +import { ObjectProperty, ObjectType } from "../Type/ObjectType.js"; +import { ReferenceType } from "../Type/ReferenceType.js"; +import { isNodeHidden } from "../Utils/isHidden.js"; +import { getKey } from "../Utils/nodeKey.js"; export class TypeLiteralNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, protected childNodeParser: NodeParser, - protected readonly additionalProperties: boolean + protected readonly additionalProperties: boolean, ) {} public supportsNode(node: ts.TypeLiteralNode): boolean { @@ -40,7 +40,7 @@ export class TypeLiteralNodeParser implements SubNodeParser { const properties = node.members .filter( (element): element is PropertySignature | MethodSignature => - ts.isPropertySignature(element) || ts.isMethodSignature(element) + ts.isPropertySignature(element) || ts.isMethodSignature(element), ) .filter((propertyNode) => !isNodeHidden(propertyNode)) .map( @@ -48,8 +48,8 @@ export class TypeLiteralNodeParser implements SubNodeParser { new ObjectProperty( this.getPropertyName(propertyNode.name), this.childNodeParser.createType(propertyNode.type!, context), - !propertyNode.questionToken - ) + !propertyNode.questionToken, + ), ) .filter((prop) => { const type = prop.getType(); @@ -72,7 +72,7 @@ export class TypeLiteralNodeParser implements SubNodeParser { return this.additionalProperties; } - return this.childNodeParser.createType(indexSignature.type!, context) ?? this.additionalProperties; + return this.childNodeParser.createType(indexSignature.type, context) ?? this.additionalProperties; } protected getTypeId(node: ts.Node, context: Context): string { diff --git a/src/NodeParser/TypeOperatorNodeParser.ts b/src/NodeParser/TypeOperatorNodeParser.ts index 8e7e06555..78a9c16c2 100644 --- a/src/NodeParser/TypeOperatorNodeParser.ts +++ b/src/NodeParser/TypeOperatorNodeParser.ts @@ -1,14 +1,14 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { ArrayType } from "../Type/ArrayType"; -import { BaseType } from "../Type/BaseType"; -import { NumberType } from "../Type/NumberType"; -import { ObjectType } from "../Type/ObjectType"; -import { StringType } from "../Type/StringType"; -import { UnionType } from "../Type/UnionType"; -import { derefType } from "../Utils/derefType"; -import { getTypeKeys } from "../Utils/typeKeys"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { ArrayType } from "../Type/ArrayType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { NumberType } from "../Type/NumberType.js"; +import { ObjectType } from "../Type/ObjectType.js"; +import { StringType } from "../Type/StringType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { derefType } from "../Utils/derefType.js"; +import { getTypeKeys } from "../Utils/typeKeys.js"; export class TypeOperatorNodeParser implements SubNodeParser { public constructor(protected childNodeParser: NodeParser) {} diff --git a/src/NodeParser/TypeReferenceNodeParser.ts b/src/NodeParser/TypeReferenceNodeParser.ts index 51e01b8f0..eb90ee253 100644 --- a/src/NodeParser/TypeReferenceNodeParser.ts +++ b/src/NodeParser/TypeReferenceNodeParser.ts @@ -1,12 +1,12 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import type { SubNodeParser } from "../SubNodeParser"; -import { AnnotatedType } from "../Type/AnnotatedType"; -import { AnyType } from "../Type/AnyType"; -import { ArrayType } from "../Type/ArrayType"; -import type { BaseType } from "../Type/BaseType"; -import { StringType } from "../Type/StringType"; +import { Context, NodeParser } from "../NodeParser.js"; +import type { SubNodeParser } from "../SubNodeParser.js"; +import { AnnotatedType } from "../Type/AnnotatedType.js"; +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"; const invalidTypes: Record = { [ts.SyntaxKind.ModuleDeclaration]: true, @@ -16,7 +16,7 @@ const invalidTypes: Record = { export class TypeReferenceNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.TypeReferenceNode): boolean { @@ -33,7 +33,7 @@ export class TypeReferenceNodeParser implements SubNodeParser { // Wraps promise type to avoid resolving to a empty Object type. if (typeSymbol.name === "Promise") { - return this.childNodeParser.createType(node.typeArguments![0]!, this.createSubContext(node, context)); + return this.childNodeParser.createType(node.typeArguments![0], this.createSubContext(node, context)); } if (typeSymbol.flags & ts.SymbolFlags.Alias) { @@ -73,7 +73,7 @@ export class TypeReferenceNodeParser implements SubNodeParser { return this.childNodeParser.createType( typeSymbol.declarations!.filter((n: ts.Declaration) => !invalidTypes[n.kind])[0], - this.createSubContext(node, context) + this.createSubContext(node, context), ); } diff --git a/src/NodeParser/TypeofNodeParser.ts b/src/NodeParser/TypeofNodeParser.ts index c70e361a2..cd5ee6200 100644 --- a/src/NodeParser/TypeofNodeParser.ts +++ b/src/NodeParser/TypeofNodeParser.ts @@ -1,19 +1,19 @@ import ts from "typescript"; -import { LogicError } from "../Error/LogicError"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { ObjectType, ObjectProperty } from "../Type/ObjectType"; -import { ReferenceType } from "../Type/ReferenceType"; -import { getKey } from "../Utils/nodeKey"; -import { LiteralType } from "../Type/LiteralType"; -import { NeverType } from "../Type/NeverType"; -import { FunctionType } from "../Type/FunctionType"; +import { LogicError } from "../Error/LogicError.js"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { ObjectType, ObjectProperty } from "../Type/ObjectType.js"; +import { ReferenceType } from "../Type/ReferenceType.js"; +import { getKey } from "../Utils/nodeKey.js"; +import { LiteralType } from "../Type/LiteralType.js"; +import { NeverType } from "../Type/NeverType.js"; +import { FunctionType } from "../Type/FunctionType.js"; export class TypeofNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.TypeQueryNode): boolean { diff --git a/src/NodeParser/UndefinedLiteralNodeParser.ts b/src/NodeParser/UndefinedLiteralNodeParser.ts index 019ccda8f..a821c0966 100644 --- a/src/NodeParser/UndefinedLiteralNodeParser.ts +++ b/src/NodeParser/UndefinedLiteralNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { NullType } from "../Type/NullType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { NullType } from "../Type/NullType.js"; export class UndefinedLiteralNodeParser implements SubNodeParser { public supportsNode(node: ts.KeywordTypeNode): boolean { diff --git a/src/NodeParser/UndefinedTypeNodeParser.ts b/src/NodeParser/UndefinedTypeNodeParser.ts index 046cbbfd9..de05142ec 100644 --- a/src/NodeParser/UndefinedTypeNodeParser.ts +++ b/src/NodeParser/UndefinedTypeNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { UndefinedType } from "../Type/UndefinedType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { UndefinedType } from "../Type/UndefinedType.js"; export class UndefinedTypeNodeParser implements SubNodeParser { public supportsNode(node: ts.KeywordTypeNode): boolean { diff --git a/src/NodeParser/UnionNodeParser.ts b/src/NodeParser/UnionNodeParser.ts index fe3cc58e6..656418c0a 100644 --- a/src/NodeParser/UnionNodeParser.ts +++ b/src/NodeParser/UnionNodeParser.ts @@ -1,15 +1,15 @@ import ts from "typescript"; -import { Context, NodeParser } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { UnionType } from "../Type/UnionType"; -import { BaseType } from "../Type/BaseType"; -import { notNever } from "../Utils/notNever"; -import { NeverType } from "../Type/NeverType"; +import { Context, NodeParser } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { UnionType } from "../Type/UnionType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { notNever } from "../Utils/notNever.js"; +import { NeverType } from "../Type/NeverType.js"; export class UnionNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.UnionTypeNode): boolean { diff --git a/src/NodeParser/UnknownTypeNodeParser.ts b/src/NodeParser/UnknownTypeNodeParser.ts index 5e794fcf1..fcb5b8cfd 100644 --- a/src/NodeParser/UnknownTypeNodeParser.ts +++ b/src/NodeParser/UnknownTypeNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { UnknownType } from "../Type/UnknownType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { UnknownType } from "../Type/UnknownType.js"; export class UnknownTypeNodeParser implements SubNodeParser { public supportsNode(node: ts.KeywordTypeNode): boolean { diff --git a/src/NodeParser/VoidTypeNodeParser.ts b/src/NodeParser/VoidTypeNodeParser.ts index b4a10ff71..c2f89c15e 100644 --- a/src/NodeParser/VoidTypeNodeParser.ts +++ b/src/NodeParser/VoidTypeNodeParser.ts @@ -1,8 +1,8 @@ import ts from "typescript"; -import { Context } from "../NodeParser"; -import { SubNodeParser } from "../SubNodeParser"; -import { BaseType } from "../Type/BaseType"; -import { VoidType } from "../Type/VoidType"; +import { Context } from "../NodeParser.js"; +import { SubNodeParser } from "../SubNodeParser.js"; +import { BaseType } from "../Type/BaseType.js"; +import { VoidType } from "../Type/VoidType.js"; export class VoidTypeNodeParser implements SubNodeParser { public supportsNode(node: ts.KeywordTypeNode): boolean { diff --git a/src/SchemaGenerator.ts b/src/SchemaGenerator.ts index 479649bbb..723aaa7c9 100644 --- a/src/SchemaGenerator.ts +++ b/src/SchemaGenerator.ts @@ -1,23 +1,23 @@ import ts from "typescript"; -import { NoRootTypeError } from "./Error/NoRootTypeError"; -import { Context, NodeParser } from "./NodeParser"; -import { Definition } from "./Schema/Definition"; -import { Schema } from "./Schema/Schema"; -import { BaseType } from "./Type/BaseType"; -import { DefinitionType } from "./Type/DefinitionType"; -import { TypeFormatter } from "./TypeFormatter"; -import { StringMap } from "./Utils/StringMap"; -import { localSymbolAtNode, symbolAtNode } from "./Utils/symbolAtNode"; -import { removeUnreachable } from "./Utils/removeUnreachable"; -import { Config } from "./Config"; -import { hasJsDocTag } from "./Utils/hasJsDocTag"; +import { NoRootTypeError } from "./Error/NoRootTypeError.js"; +import { Context, NodeParser } from "./NodeParser.js"; +import { Definition } from "./Schema/Definition.js"; +import { Schema } from "./Schema/Schema.js"; +import { BaseType } from "./Type/BaseType.js"; +import { DefinitionType } from "./Type/DefinitionType.js"; +import { TypeFormatter } from "./TypeFormatter.js"; +import { StringMap } from "./Utils/StringMap.js"; +import { localSymbolAtNode, symbolAtNode } from "./Utils/symbolAtNode.js"; +import { removeUnreachable } from "./Utils/removeUnreachable.js"; +import { Config } from "./Config.js"; +import { hasJsDocTag } from "./Utils/hasJsDocTag.js"; export class SchemaGenerator { public constructor( protected readonly program: ts.Program, protected readonly nodeParser: NodeParser, protected readonly typeFormatter: TypeFormatter, - protected readonly config?: Config + protected readonly config?: Config, ) {} public createSchema(fullName?: string): Schema { @@ -132,7 +132,7 @@ export class SchemaGenerator { protected appendTypes( sourceFiles: readonly ts.SourceFile[], typeChecker: ts.TypeChecker, - types: Map + types: Map, ): void { for (const sourceFile of sourceFiles) { this.inspectNode(sourceFile, typeChecker, types); diff --git a/src/SubNodeParser.ts b/src/SubNodeParser.ts index 92b2cd200..2109d4a40 100644 --- a/src/SubNodeParser.ts +++ b/src/SubNodeParser.ts @@ -1,5 +1,5 @@ import ts from "typescript"; -import { NodeParser } from "./NodeParser"; +import { NodeParser } from "./NodeParser.js"; export interface SubNodeParser extends NodeParser { supportsNode(node: ts.Node): boolean; diff --git a/src/SubTypeFormatter.ts b/src/SubTypeFormatter.ts index a1b8a5e85..1e5dc717e 100644 --- a/src/SubTypeFormatter.ts +++ b/src/SubTypeFormatter.ts @@ -1,5 +1,5 @@ -import { BaseType } from "./Type/BaseType"; -import { TypeFormatter } from "./TypeFormatter"; +import { BaseType } from "./Type/BaseType.js"; +import { TypeFormatter } from "./TypeFormatter.js"; export interface SubTypeFormatter extends TypeFormatter { supportsType(type: BaseType): boolean; diff --git a/src/TopRefNodeParser.ts b/src/TopRefNodeParser.ts index 1a6b9a4a9..dec37f697 100644 --- a/src/TopRefNodeParser.ts +++ b/src/TopRefNodeParser.ts @@ -1,13 +1,13 @@ import ts from "typescript"; -import { Context, NodeParser } from "./NodeParser"; -import { BaseType } from "./Type/BaseType"; -import { DefinitionType } from "./Type/DefinitionType"; +import { Context, NodeParser } from "./NodeParser.js"; +import { BaseType } from "./Type/BaseType.js"; +import { DefinitionType } from "./Type/DefinitionType.js"; export class TopRefNodeParser implements NodeParser { public constructor( protected childNodeParser: NodeParser, protected fullName: string | undefined, - protected topRef: boolean + protected topRef: boolean, ) {} public createType(node: ts.Node, context: Context): BaseType { diff --git a/src/Type/AliasType.ts b/src/Type/AliasType.ts index e8d2e6887..1f43799bf 100644 --- a/src/Type/AliasType.ts +++ b/src/Type/AliasType.ts @@ -1,9 +1,9 @@ -import { BaseType } from "./BaseType"; +import { BaseType } from "./BaseType.js"; export class AliasType extends BaseType { public constructor( private id: string, - private type: BaseType + private type: BaseType, ) { super(); } diff --git a/src/Type/AnnotatedType.ts b/src/Type/AnnotatedType.ts index da55f5558..1f328703a 100644 --- a/src/Type/AnnotatedType.ts +++ b/src/Type/AnnotatedType.ts @@ -1,5 +1,5 @@ -import { BaseType } from "./BaseType"; -import { hash } from "../Utils/nodeKey"; +import { BaseType } from "./BaseType.js"; +import { hash } from "../Utils/nodeKey.js"; export interface Annotations { [name: string]: any; @@ -9,7 +9,7 @@ export class AnnotatedType extends BaseType { public constructor( private type: BaseType, private annotations: Annotations, - private nullable: boolean + private nullable: boolean, ) { super(); } diff --git a/src/Type/AnyType.ts b/src/Type/AnyType.ts index 8bb64930b..c4390c672 100644 --- a/src/Type/AnyType.ts +++ b/src/Type/AnyType.ts @@ -1,4 +1,4 @@ -import { BaseType } from "./BaseType"; +import { BaseType } from "./BaseType.js"; export class AnyType extends BaseType { public getId(): string { diff --git a/src/Type/ArrayType.ts b/src/Type/ArrayType.ts index 915fa3ce1..82057cb6a 100644 --- a/src/Type/ArrayType.ts +++ b/src/Type/ArrayType.ts @@ -1,4 +1,4 @@ -import { BaseType } from "./BaseType"; +import { BaseType } from "./BaseType.js"; export class ArrayType extends BaseType { public constructor(private item: BaseType) { diff --git a/src/Type/BooleanType.ts b/src/Type/BooleanType.ts index 843dc888f..87169bdae 100644 --- a/src/Type/BooleanType.ts +++ b/src/Type/BooleanType.ts @@ -1,4 +1,4 @@ -import { PrimitiveType } from "./PrimitiveType"; +import { PrimitiveType } from "./PrimitiveType.js"; export class BooleanType extends PrimitiveType { public getId(): string { diff --git a/src/Type/ConstructorType.ts b/src/Type/ConstructorType.ts index 562b29c97..ec220872b 100644 --- a/src/Type/ConstructorType.ts +++ b/src/Type/ConstructorType.ts @@ -1,13 +1,13 @@ import ts from "typescript"; -import { BaseType } from "./BaseType"; -import { ObjectType } from "./ObjectType"; +import { BaseType } from "./BaseType.js"; +import { ObjectType } from "./ObjectType.js"; export class ConstructorType extends BaseType { private comment: string; constructor( node?: ts.ConstructorTypeNode, - protected namedArguments?: ObjectType + protected namedArguments?: ObjectType, ) { super(); diff --git a/src/Type/DefinitionType.ts b/src/Type/DefinitionType.ts index e7f8f71d8..2020945a1 100644 --- a/src/Type/DefinitionType.ts +++ b/src/Type/DefinitionType.ts @@ -1,9 +1,9 @@ -import { BaseType } from "./BaseType"; +import { BaseType } from "./BaseType.js"; export class DefinitionType extends BaseType { public constructor( private name: string | undefined, - private type: BaseType + private type: BaseType, ) { super(); } diff --git a/src/Type/EnumType.ts b/src/Type/EnumType.ts index 0a252ae45..d9795c459 100644 --- a/src/Type/EnumType.ts +++ b/src/Type/EnumType.ts @@ -1,6 +1,6 @@ -import { BaseType } from "./BaseType"; -import { LiteralType } from "./LiteralType"; -import { NullType } from "./NullType"; +import { BaseType } from "./BaseType.js"; +import { LiteralType } from "./LiteralType.js"; +import { NullType } from "./NullType.js"; export type EnumValue = string | boolean | number | null; @@ -9,7 +9,7 @@ export class EnumType extends BaseType { public constructor( private id: string, - private values: readonly EnumValue[] + private values: readonly EnumValue[], ) { super(); this.types = values.map((value) => (value == null ? new NullType() : new LiteralType(value))); diff --git a/src/Type/FunctionType.ts b/src/Type/FunctionType.ts index af064bc60..169dac7ad 100644 --- a/src/Type/FunctionType.ts +++ b/src/Type/FunctionType.ts @@ -1,13 +1,13 @@ import ts from "typescript"; -import { BaseType } from "./BaseType"; -import { ObjectType } from "./ObjectType"; +import { BaseType } from "./BaseType.js"; +import { ObjectType } from "./ObjectType.js"; export class FunctionType extends BaseType { private comment: string; constructor( node?: ts.FunctionTypeNode | ts.FunctionExpression | ts.FunctionDeclaration | ts.ArrowFunction, - protected namedArguments?: ObjectType + protected namedArguments?: ObjectType, ) { super(); diff --git a/src/Type/HiddenType.ts b/src/Type/HiddenType.ts index 07fa68034..ac919856e 100644 --- a/src/Type/HiddenType.ts +++ b/src/Type/HiddenType.ts @@ -1,4 +1,4 @@ -import { NeverType } from "./NeverType"; +import { NeverType } from "./NeverType.js"; export class HiddenType extends NeverType { public getId(): string { diff --git a/src/Type/InferType.ts b/src/Type/InferType.ts index 6a2ed2be0..42809f6d0 100644 --- a/src/Type/InferType.ts +++ b/src/Type/InferType.ts @@ -1,4 +1,4 @@ -import { BaseType } from "./BaseType"; +import { BaseType } from "./BaseType.js"; export class InferType extends BaseType { constructor(private id: string) { diff --git a/src/Type/IntersectionType.ts b/src/Type/IntersectionType.ts index ea410d383..1b75f8961 100644 --- a/src/Type/IntersectionType.ts +++ b/src/Type/IntersectionType.ts @@ -1,4 +1,4 @@ -import { BaseType } from "./BaseType"; +import { BaseType } from "./BaseType.js"; export class IntersectionType extends BaseType { public constructor(private types: BaseType[]) { diff --git a/src/Type/LiteralType.ts b/src/Type/LiteralType.ts index 4a37d20fa..0b7840304 100644 --- a/src/Type/LiteralType.ts +++ b/src/Type/LiteralType.ts @@ -1,4 +1,4 @@ -import { BaseType } from "./BaseType"; +import { BaseType } from "./BaseType.js"; export type LiteralValue = string | number | boolean; @@ -14,4 +14,8 @@ export class LiteralType extends BaseType { public getValue(): LiteralValue { return this.value; } + + public isString(): boolean { + return typeof this.value === "string"; + } } diff --git a/src/Type/NeverType.ts b/src/Type/NeverType.ts index f2f8c7e78..15804d760 100644 --- a/src/Type/NeverType.ts +++ b/src/Type/NeverType.ts @@ -1,4 +1,4 @@ -import { BaseType } from "./BaseType"; +import { BaseType } from "./BaseType.js"; export class NeverType extends BaseType { public getId(): string { diff --git a/src/Type/NullType.ts b/src/Type/NullType.ts index 57fd7ffb7..22499fdb3 100644 --- a/src/Type/NullType.ts +++ b/src/Type/NullType.ts @@ -1,4 +1,4 @@ -import { PrimitiveType } from "./PrimitiveType"; +import { PrimitiveType } from "./PrimitiveType.js"; export class NullType extends PrimitiveType { public getId(): string { diff --git a/src/Type/NumberType.ts b/src/Type/NumberType.ts index 7d5dc7cba..6f3b9edec 100644 --- a/src/Type/NumberType.ts +++ b/src/Type/NumberType.ts @@ -1,4 +1,4 @@ -import { PrimitiveType } from "./PrimitiveType"; +import { PrimitiveType } from "./PrimitiveType.js"; export class NumberType extends PrimitiveType { public getId(): string { diff --git a/src/Type/ObjectType.ts b/src/Type/ObjectType.ts index 6828df694..a68aefa1a 100644 --- a/src/Type/ObjectType.ts +++ b/src/Type/ObjectType.ts @@ -1,11 +1,11 @@ -import { BaseType } from "./BaseType"; -import { strip } from "../Utils/String"; +import { BaseType } from "./BaseType.js"; +import { strip } from "../Utils/String.js"; export class ObjectProperty { public constructor( private name: string, private type: BaseType, - private required: boolean + private required: boolean, ) {} public getName(): string { @@ -26,7 +26,7 @@ export class ObjectType extends BaseType { private properties: readonly ObjectProperty[], private additionalProperties: BaseType | boolean, // whether the object is `object` - private nonPrimitive: boolean = false + private nonPrimitive: boolean = false, ) { super(); } diff --git a/src/Type/OptionalType.ts b/src/Type/OptionalType.ts index b1faf6fb8..761540644 100644 --- a/src/Type/OptionalType.ts +++ b/src/Type/OptionalType.ts @@ -1,4 +1,4 @@ -import { BaseType } from "./BaseType"; +import { BaseType } from "./BaseType.js"; export class OptionalType extends BaseType { public constructor(private item: BaseType) { diff --git a/src/Type/PrimitiveType.ts b/src/Type/PrimitiveType.ts index 91f62e1f0..799aa01b7 100644 --- a/src/Type/PrimitiveType.ts +++ b/src/Type/PrimitiveType.ts @@ -1,3 +1,3 @@ -import { BaseType } from "./BaseType"; +import { BaseType } from "./BaseType.js"; export abstract class PrimitiveType extends BaseType {} diff --git a/src/Type/ReferenceType.ts b/src/Type/ReferenceType.ts index 925ca72a1..74bd9946e 100644 --- a/src/Type/ReferenceType.ts +++ b/src/Type/ReferenceType.ts @@ -1,4 +1,4 @@ -import { BaseType } from "./BaseType"; +import { BaseType } from "./BaseType.js"; export class ReferenceType extends BaseType { private type: BaseType | null = null; diff --git a/src/Type/RestType.ts b/src/Type/RestType.ts index 5d4b9190f..ac1e3b4c2 100644 --- a/src/Type/RestType.ts +++ b/src/Type/RestType.ts @@ -1,12 +1,12 @@ -import { ArrayType } from "./ArrayType"; -import { BaseType } from "./BaseType"; -import { InferType } from "./InferType"; -import { TupleType } from "./TupleType"; +import { ArrayType } from "./ArrayType.js"; +import { BaseType } from "./BaseType.js"; +import { InferType } from "./InferType.js"; +import { TupleType } from "./TupleType.js"; export class RestType extends BaseType { public constructor( private item: ArrayType | InferType | TupleType, - private title: string | null = null + private title: string | null = null, ) { super(); } diff --git a/src/Type/StringType.ts b/src/Type/StringType.ts index faf7dda91..bc73cc1c8 100644 --- a/src/Type/StringType.ts +++ b/src/Type/StringType.ts @@ -1,7 +1,15 @@ -import { PrimitiveType } from "./PrimitiveType"; +import { PrimitiveType } from "./PrimitiveType.js"; export class StringType extends PrimitiveType { + constructor(protected preserveLiterals = false) { + super(); + } + public getId(): string { return "string"; } + + public getPreserveLiterals(): boolean { + return this.preserveLiterals; + } } diff --git a/src/Type/SymbolType.ts b/src/Type/SymbolType.ts index 4ef61c652..a70db3888 100644 --- a/src/Type/SymbolType.ts +++ b/src/Type/SymbolType.ts @@ -1,4 +1,4 @@ -import { PrimitiveType } from "./PrimitiveType"; +import { PrimitiveType } from "./PrimitiveType.js"; export class SymbolType extends PrimitiveType { public getId(): string { diff --git a/src/Type/TupleType.ts b/src/Type/TupleType.ts index 31b8e5f7a..bacdd06b5 100644 --- a/src/Type/TupleType.ts +++ b/src/Type/TupleType.ts @@ -1,8 +1,8 @@ -import { derefType } from "../Utils/derefType"; -import { ArrayType } from "./ArrayType"; -import { BaseType } from "./BaseType"; -import { InferType } from "./InferType"; -import { RestType } from "./RestType"; +import { derefType } from "../Utils/derefType.js"; +import { ArrayType } from "./ArrayType.js"; +import { BaseType } from "./BaseType.js"; +import { InferType } from "./InferType.js"; +import { RestType } from "./RestType.js"; function normalize(types: Readonly>): Array { let normalized: Array = []; diff --git a/src/Type/UndefinedType.ts b/src/Type/UndefinedType.ts index 64c684e8d..263359dbb 100644 --- a/src/Type/UndefinedType.ts +++ b/src/Type/UndefinedType.ts @@ -1,4 +1,4 @@ -import { BaseType } from "./BaseType"; +import { BaseType } from "./BaseType.js"; export class UndefinedType extends BaseType { public getId(): string { diff --git a/src/Type/UnionType.ts b/src/Type/UnionType.ts index 444482975..2d36da255 100644 --- a/src/Type/UnionType.ts +++ b/src/Type/UnionType.ts @@ -1,7 +1,7 @@ -import { BaseType } from "./BaseType"; -import { uniqueTypeArray } from "../Utils/uniqueTypeArray"; -import { NeverType } from "./NeverType"; -import { derefType } from "../Utils/derefType"; +import { BaseType } from "./BaseType.js"; +import { uniqueTypeArray } from "../Utils/uniqueTypeArray.js"; +import { NeverType } from "./NeverType.js"; +import { derefType } from "../Utils/derefType.js"; export class UnionType extends BaseType { private readonly types: BaseType[]; @@ -17,7 +17,7 @@ export class UnionType extends BaseType { flatTypes.push(type); } return flatTypes; - }, [] as BaseType[]) + }, [] as BaseType[]), ); } diff --git a/src/Type/UnknownType.ts b/src/Type/UnknownType.ts index 5f624a29d..6cce276ff 100644 --- a/src/Type/UnknownType.ts +++ b/src/Type/UnknownType.ts @@ -1,4 +1,4 @@ -import { BaseType } from "./BaseType"; +import { BaseType } from "./BaseType.js"; export class UnknownType extends BaseType { constructor() { diff --git a/src/Type/VoidType.ts b/src/Type/VoidType.ts index 32232c1ef..426529663 100644 --- a/src/Type/VoidType.ts +++ b/src/Type/VoidType.ts @@ -1,4 +1,4 @@ -import { BaseType } from "./BaseType"; +import { BaseType } from "./BaseType.js"; export class VoidType extends BaseType { public getId(): string { diff --git a/src/TypeFormatter.ts b/src/TypeFormatter.ts index d1108f9bf..edbb9bb03 100644 --- a/src/TypeFormatter.ts +++ b/src/TypeFormatter.ts @@ -1,5 +1,5 @@ -import { Definition } from "./Schema/Definition"; -import { BaseType } from "./Type/BaseType"; +import { Definition } from "./Schema/Definition.js"; +import { BaseType } from "./Type/BaseType.js"; export interface TypeFormatter { getDefinition(type: BaseType): Definition; diff --git a/src/TypeFormatter/AliasTypeFormatter.ts b/src/TypeFormatter/AliasTypeFormatter.ts index f9d5887df..18ea3b29d 100644 --- a/src/TypeFormatter/AliasTypeFormatter.ts +++ b/src/TypeFormatter/AliasTypeFormatter.ts @@ -1,8 +1,8 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { AliasType } from "../Type/AliasType"; -import { BaseType } from "../Type/BaseType"; -import { TypeFormatter } from "../TypeFormatter"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { AliasType } from "../Type/AliasType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { TypeFormatter } from "../TypeFormatter.js"; export class AliasTypeFormatter implements SubTypeFormatter { public constructor(protected childTypeFormatter: TypeFormatter) {} diff --git a/src/TypeFormatter/AnnotatedTypeFormatter.ts b/src/TypeFormatter/AnnotatedTypeFormatter.ts index a035cf7d9..06c18c8f7 100644 --- a/src/TypeFormatter/AnnotatedTypeFormatter.ts +++ b/src/TypeFormatter/AnnotatedTypeFormatter.ts @@ -1,10 +1,10 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { AnnotatedType } from "../Type/AnnotatedType"; -import { BaseType } from "../Type/BaseType"; -import { UnionType } from "../Type/UnionType"; -import { TypeFormatter } from "../TypeFormatter"; -import { derefType } from "../Utils/derefType"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { AnnotatedType } from "../Type/AnnotatedType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { TypeFormatter } from "../TypeFormatter.js"; +import { derefType } from "../Utils/derefType.js"; export function makeNullable(def: Definition): Definition { const union: Definition[] | undefined = (def.oneOf as Definition[]) || def.anyOf; @@ -61,9 +61,7 @@ export class AnnotatedTypeFormatter implements SubTypeFormatter { delete annotations.discriminator; } else { throw new Error( - `Cannot assign discriminator tag to type: ${JSON.stringify( - derefed - )}. This tag can only be assigned to union types.` + `Cannot assign discriminator tag to type: ${derefed.getName()}. This tag can only be assigned to union types.`, ); } } diff --git a/src/TypeFormatter/AnyTypeFormatter.ts b/src/TypeFormatter/AnyTypeFormatter.ts index 11e279757..aa0d05cf9 100644 --- a/src/TypeFormatter/AnyTypeFormatter.ts +++ b/src/TypeFormatter/AnyTypeFormatter.ts @@ -1,7 +1,7 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { AnyType } from "../Type/AnyType"; -import { BaseType } from "../Type/BaseType"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { AnyType } from "../Type/AnyType.js"; +import { BaseType } from "../Type/BaseType.js"; export class AnyTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/ArrayTypeFormatter.ts b/src/TypeFormatter/ArrayTypeFormatter.ts index 7939d4f13..699f4a560 100644 --- a/src/TypeFormatter/ArrayTypeFormatter.ts +++ b/src/TypeFormatter/ArrayTypeFormatter.ts @@ -1,8 +1,8 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { ArrayType } from "../Type/ArrayType"; -import { BaseType } from "../Type/BaseType"; -import { TypeFormatter } from "../TypeFormatter"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { ArrayType } from "../Type/ArrayType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { TypeFormatter } from "../TypeFormatter.js"; export class ArrayTypeFormatter implements SubTypeFormatter { public constructor(private childTypeFormatter: TypeFormatter) {} diff --git a/src/TypeFormatter/BooleanTypeFormatter.ts b/src/TypeFormatter/BooleanTypeFormatter.ts index df8a8b60f..5a022188a 100644 --- a/src/TypeFormatter/BooleanTypeFormatter.ts +++ b/src/TypeFormatter/BooleanTypeFormatter.ts @@ -1,7 +1,7 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { BooleanType } from "../Type/BooleanType"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { BooleanType } from "../Type/BooleanType.js"; export class BooleanTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/ConstructorTypeFormatter.ts b/src/TypeFormatter/ConstructorTypeFormatter.ts index 19169c778..e6ed6b003 100644 --- a/src/TypeFormatter/ConstructorTypeFormatter.ts +++ b/src/TypeFormatter/ConstructorTypeFormatter.ts @@ -1,6 +1,6 @@ -import { BaseType } from "../Type/BaseType"; -import { ConstructorType } from "../Type/ConstructorType"; -import { FunctionTypeFormatter } from "./FunctionTypeFormatter"; +import { BaseType } from "../Type/BaseType.js"; +import { ConstructorType } from "../Type/ConstructorType.js"; +import { FunctionTypeFormatter } from "./FunctionTypeFormatter.js"; export class ConstructorTypeFormatter extends FunctionTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/DefinitionTypeFormatter.ts b/src/TypeFormatter/DefinitionTypeFormatter.ts index 4b768afa5..f068e352d 100644 --- a/src/TypeFormatter/DefinitionTypeFormatter.ts +++ b/src/TypeFormatter/DefinitionTypeFormatter.ts @@ -1,14 +1,14 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { DefinitionType } from "../Type/DefinitionType"; -import { TypeFormatter } from "../TypeFormatter"; -import { uniqueArray } from "../Utils/uniqueArray"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { DefinitionType } from "../Type/DefinitionType.js"; +import { TypeFormatter } from "../TypeFormatter.js"; +import { uniqueArray } from "../Utils/uniqueArray.js"; export class DefinitionTypeFormatter implements SubTypeFormatter { public constructor( protected childTypeFormatter: TypeFormatter, - protected encodeRefs: boolean + protected encodeRefs: boolean, ) {} public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/EnumTypeFormatter.ts b/src/TypeFormatter/EnumTypeFormatter.ts index fdb6b4097..39a2799c0 100644 --- a/src/TypeFormatter/EnumTypeFormatter.ts +++ b/src/TypeFormatter/EnumTypeFormatter.ts @@ -1,9 +1,9 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { EnumType } from "../Type/EnumType"; -import { typeName } from "../Utils/typeName"; -import { uniqueArray } from "../Utils/uniqueArray"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { EnumType } from "../Type/EnumType.js"; +import { typeName } from "../Utils/typeName.js"; +import { uniqueArray } from "../Utils/uniqueArray.js"; export class EnumTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/FunctionTypeFormatter.ts b/src/TypeFormatter/FunctionTypeFormatter.ts index fb2233991..596661be2 100644 --- a/src/TypeFormatter/FunctionTypeFormatter.ts +++ b/src/TypeFormatter/FunctionTypeFormatter.ts @@ -1,14 +1,14 @@ -import { FunctionOptions } from "../Config"; -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { FunctionType } from "../Type/FunctionType"; -import { TypeFormatter } from "../TypeFormatter"; +import { FunctionOptions } from "../Config.js"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { FunctionType } from "../Type/FunctionType.js"; +import { TypeFormatter } from "../TypeFormatter.js"; export class FunctionTypeFormatter implements SubTypeFormatter { constructor( protected childTypeFormatter: TypeFormatter, - protected functions: FunctionOptions + protected functions: FunctionOptions, ) {} public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/HiddenTypeFormatter.ts b/src/TypeFormatter/HiddenTypeFormatter.ts index feecbc361..30cd6dc97 100644 --- a/src/TypeFormatter/HiddenTypeFormatter.ts +++ b/src/TypeFormatter/HiddenTypeFormatter.ts @@ -1,7 +1,7 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { HiddenType } from "../Type/HiddenType"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { HiddenType } from "../Type/HiddenType.js"; export class HiddenTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/IntersectionTypeFormatter.ts b/src/TypeFormatter/IntersectionTypeFormatter.ts index f9a7d4af1..4554896b5 100644 --- a/src/TypeFormatter/IntersectionTypeFormatter.ts +++ b/src/TypeFormatter/IntersectionTypeFormatter.ts @@ -1,12 +1,12 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { ArrayType } from "../Type/ArrayType"; -import { BaseType } from "../Type/BaseType"; -import { IntersectionType } from "../Type/IntersectionType"; -import { TupleType } from "../Type/TupleType"; -import { TypeFormatter } from "../TypeFormatter"; -import { getAllOfDefinitionReducer } from "../Utils/allOfDefinition"; -import { uniqueArray } from "../Utils/uniqueArray"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { ArrayType } from "../Type/ArrayType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { IntersectionType } from "../Type/IntersectionType.js"; +import { TupleType } from "../Type/TupleType.js"; +import { TypeFormatter } from "../TypeFormatter.js"; +import { getAllOfDefinitionReducer } from "../Utils/allOfDefinition.js"; +import { uniqueArray } from "../Utils/uniqueArray.js"; export class IntersectionTypeFormatter implements SubTypeFormatter { public constructor(protected childTypeFormatter: TypeFormatter) {} @@ -35,7 +35,7 @@ export class IntersectionTypeFormatter implements SubTypeFormatter { nonArrayLikeTypes.reduce(getAllOfDefinitionReducer(this.childTypeFormatter), { type: "object", additionalProperties: false, - }) + }), ); } @@ -46,7 +46,7 @@ export class IntersectionTypeFormatter implements SubTypeFormatter { return uniqueArray( type .getTypes() - .reduce((result: BaseType[], item) => [...result, ...this.childTypeFormatter.getChildren(item)], []) + .reduce((result: BaseType[], item) => [...result, ...this.childTypeFormatter.getChildren(item)], []), ); } } diff --git a/src/TypeFormatter/LiteralTypeFormatter.ts b/src/TypeFormatter/LiteralTypeFormatter.ts index 8f510b3b8..32e3a1bb9 100644 --- a/src/TypeFormatter/LiteralTypeFormatter.ts +++ b/src/TypeFormatter/LiteralTypeFormatter.ts @@ -1,8 +1,8 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { LiteralType } from "../Type/LiteralType"; -import { typeName } from "../Utils/typeName"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { LiteralType } from "../Type/LiteralType.js"; +import { typeName } from "../Utils/typeName.js"; export class LiteralTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/LiteralUnionTypeFormatter.ts b/src/TypeFormatter/LiteralUnionTypeFormatter.ts index 272c817f3..68572bfce 100644 --- a/src/TypeFormatter/LiteralUnionTypeFormatter.ts +++ b/src/TypeFormatter/LiteralUnionTypeFormatter.ts @@ -1,44 +1,98 @@ -import { Definition } from "../Schema/Definition"; -import { RawTypeName } from "../Schema/RawType"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { LiteralType } from "../Type/LiteralType"; -import { NullType } from "../Type/NullType"; -import { UnionType } from "../Type/UnionType"; -import { typeName } from "../Utils/typeName"; -import { uniqueArray } from "../Utils/uniqueArray"; +import { Definition } from "../Schema/Definition.js"; +import { RawTypeName } from "../Schema/RawType.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { LiteralType, LiteralValue } from "../Type/LiteralType.js"; +import { NullType } from "../Type/NullType.js"; +import { StringType } from "../Type/StringType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { derefAliasedType, isHiddenType } from "../Utils/derefType.js"; +import { typeName } from "../Utils/typeName.js"; +import { uniqueArray } from "../Utils/uniqueArray.js"; export class LiteralUnionTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { - return type instanceof UnionType && type.getTypes().length > 0 && this.isLiteralUnion(type); + return type instanceof UnionType && type.getTypes().length > 0 && isLiteralUnion(type); } public getDefinition(type: UnionType): Definition { - const values = uniqueArray(type.getTypes().map((item: LiteralType | NullType) => this.getLiteralValue(item))); - const types = uniqueArray(type.getTypes().map((item: LiteralType | NullType) => this.getLiteralType(item))); + let hasString = false; + let preserveLiterals = false; + let allStrings = true; + let hasNull = false; - if (types.length === 1) { + const flattenedTypes = flattenTypes(type); + + // filter out String types since we need to be more careful about them + const types = flattenedTypes.filter((t) => { + if (t instanceof StringType) { + hasString = true; + preserveLiterals = preserveLiterals || t.getPreserveLiterals(); + return false; + } else if (t instanceof NullType) { + hasNull = true; + return true; + } else if (t instanceof LiteralType && !t.isString()) { + allStrings = false; + } + + return true; + }); + + if (allStrings && hasString && !preserveLiterals) { return { - type: types[0], - enum: values, + type: hasNull ? ["string", "null"] : "string", }; - } else { + } + + const values = uniqueArray(types.map(getLiteralValue)); + const typeNames = uniqueArray(types.map(getLiteralType)); + + const ret = { + type: typeNames.length === 1 ? typeNames[0] : typeNames, + enum: values, + }; + + if (preserveLiterals) { return { - type: types, - enum: values, + anyOf: [ + { + type: "string", + }, + ret, + ], }; } + + return ret; } public getChildren(type: UnionType): BaseType[] { return []; } +} - protected isLiteralUnion(type: UnionType): boolean { - return type.getTypes().every((item) => item instanceof LiteralType || item instanceof NullType); - } - protected getLiteralValue(value: LiteralType | NullType): string | number | boolean | null { - return value instanceof LiteralType ? value.getValue() : null; - } - protected getLiteralType(value: LiteralType | NullType): RawTypeName { - return value instanceof LiteralType ? typeName(value.getValue()) : "null"; - } +function flattenTypes(type: UnionType): (StringType | LiteralType | NullType)[] { + return type + .getTypes() + .filter((t) => !isHiddenType(t)) + .map(derefAliasedType) + .flatMap((t) => { + if (t instanceof UnionType) { + return flattenTypes(t); + } + return t as StringType | LiteralType | NullType; + }); +} + +export function isLiteralUnion(type: UnionType): boolean { + return flattenTypes(type).every( + (item) => item instanceof LiteralType || item instanceof NullType || item instanceof StringType, + ); +} + +function getLiteralValue(value: LiteralType | NullType): LiteralValue | null { + return value instanceof LiteralType ? value.getValue() : null; +} + +function getLiteralType(value: LiteralType | NullType): RawTypeName { + return value instanceof LiteralType ? typeName(value.getValue()) : "null"; } diff --git a/src/TypeFormatter/NeverTypeFormatter.ts b/src/TypeFormatter/NeverTypeFormatter.ts index 19b07439c..f9f43f0cb 100644 --- a/src/TypeFormatter/NeverTypeFormatter.ts +++ b/src/TypeFormatter/NeverTypeFormatter.ts @@ -1,7 +1,7 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { NeverType } from "../Type/NeverType"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { NeverType } from "../Type/NeverType.js"; export class NeverTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/NullTypeFormatter.ts b/src/TypeFormatter/NullTypeFormatter.ts index 0f8bab55b..547ce8df9 100644 --- a/src/TypeFormatter/NullTypeFormatter.ts +++ b/src/TypeFormatter/NullTypeFormatter.ts @@ -1,7 +1,7 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { NullType } from "../Type/NullType"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { NullType } from "../Type/NullType.js"; export class NullTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/NumberTypeFormatter.ts b/src/TypeFormatter/NumberTypeFormatter.ts index c1f6376a2..f8f3c35be 100644 --- a/src/TypeFormatter/NumberTypeFormatter.ts +++ b/src/TypeFormatter/NumberTypeFormatter.ts @@ -1,7 +1,7 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { NumberType } from "../Type/NumberType"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { NumberType } from "../Type/NumberType.js"; export class NumberTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/ObjectTypeFormatter.ts b/src/TypeFormatter/ObjectTypeFormatter.ts index ea6cab155..afda61dd7 100644 --- a/src/TypeFormatter/ObjectTypeFormatter.ts +++ b/src/TypeFormatter/ObjectTypeFormatter.ts @@ -1,19 +1,19 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { AnyType } from "../Type/AnyType"; -import { SymbolType } from "../Type/SymbolType"; -import { BaseType } from "../Type/BaseType"; -import { ObjectProperty, ObjectType } from "../Type/ObjectType"; -import { UndefinedType } from "../Type/UndefinedType"; -import { UnionType } from "../Type/UnionType"; -import { TypeFormatter } from "../TypeFormatter"; -import { getAllOfDefinitionReducer } from "../Utils/allOfDefinition"; -import { derefType } from "../Utils/derefType"; -import { preserveAnnotation } from "../Utils/preserveAnnotation"; -import { removeUndefined } from "../Utils/removeUndefined"; -import { StringMap } from "../Utils/StringMap"; -import { uniqueArray } from "../Utils/uniqueArray"; -import { NeverType } from "../Type/NeverType"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { AnyType } from "../Type/AnyType.js"; +import { SymbolType } from "../Type/SymbolType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { ObjectProperty, ObjectType } from "../Type/ObjectType.js"; +import { UndefinedType } from "../Type/UndefinedType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { TypeFormatter } from "../TypeFormatter.js"; +import { getAllOfDefinitionReducer } from "../Utils/allOfDefinition.js"; +import { derefType } from "../Utils/derefType.js"; +import { preserveAnnotation } from "../Utils/preserveAnnotation.js"; +import { removeUndefined } from "../Utils/removeUndefined.js"; +import { StringMap } from "../Utils/StringMap.js"; +import { uniqueArray } from "../Utils/uniqueArray.js"; +import { NeverType } from "../Type/NeverType.js"; export class ObjectTypeFormatter implements SubTypeFormatter { public constructor(protected childTypeFormatter: TypeFormatter) {} @@ -39,7 +39,7 @@ export class ObjectTypeFormatter implements SubTypeFormatter { .getBaseTypes() .reduce( (result: BaseType[], baseType) => [...result, ...this.childTypeFormatter.getChildren(baseType)], - [] + [], ); const childrenOfAdditionalProps = @@ -65,7 +65,7 @@ export class ObjectTypeFormatter implements SubTypeFormatter { if (additionalProperties === false) { objectProperties = objectProperties.filter( - (property) => !(derefType(property.getType()) instanceof NeverType) + (property) => !(derefType(property.getType()) instanceof NeverType), ); } @@ -113,6 +113,6 @@ export class ObjectTypeFormatter implements SubTypeFormatter { return property; } - return new ObjectProperty(property.getName(), preserveAnnotation(propertyType!, newPropType), false); + return new ObjectProperty(property.getName(), preserveAnnotation(propertyType, newPropType), false); } } diff --git a/src/TypeFormatter/OptionalTypeFormatter.ts b/src/TypeFormatter/OptionalTypeFormatter.ts index 59b255a8b..14644384e 100644 --- a/src/TypeFormatter/OptionalTypeFormatter.ts +++ b/src/TypeFormatter/OptionalTypeFormatter.ts @@ -1,8 +1,8 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { OptionalType } from "../Type/OptionalType"; -import { TypeFormatter } from "../TypeFormatter"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { OptionalType } from "../Type/OptionalType.js"; +import { TypeFormatter } from "../TypeFormatter.js"; export class OptionalTypeFormatter implements SubTypeFormatter { public constructor(protected childTypeFormatter: TypeFormatter) {} diff --git a/src/TypeFormatter/PrimitiveUnionTypeFormatter.ts b/src/TypeFormatter/PrimitiveUnionTypeFormatter.ts index e8f704474..92b2cc65f 100644 --- a/src/TypeFormatter/PrimitiveUnionTypeFormatter.ts +++ b/src/TypeFormatter/PrimitiveUnionTypeFormatter.ts @@ -1,15 +1,15 @@ -import { LogicError } from "../Error/LogicError"; -import { Definition } from "../Schema/Definition"; -import { RawTypeName } from "../Schema/RawType"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { BooleanType } from "../Type/BooleanType"; -import { NullType } from "../Type/NullType"; -import { NumberType } from "../Type/NumberType"; -import { PrimitiveType } from "../Type/PrimitiveType"; -import { StringType } from "../Type/StringType"; -import { UnionType } from "../Type/UnionType"; -import { uniqueArray } from "../Utils/uniqueArray"; +import { LogicError } from "../Error/LogicError.js"; +import { Definition } from "../Schema/Definition.js"; +import { RawTypeName } from "../Schema/RawType.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { BooleanType } from "../Type/BooleanType.js"; +import { NullType } from "../Type/NullType.js"; +import { NumberType } from "../Type/NumberType.js"; +import { PrimitiveType } from "../Type/PrimitiveType.js"; +import { StringType } from "../Type/StringType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { uniqueArray } from "../Utils/uniqueArray.js"; export class PrimitiveUnionTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/ReferenceTypeFormatter.ts b/src/TypeFormatter/ReferenceTypeFormatter.ts index b650caf2d..23913b92b 100644 --- a/src/TypeFormatter/ReferenceTypeFormatter.ts +++ b/src/TypeFormatter/ReferenceTypeFormatter.ts @@ -1,14 +1,14 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { DefinitionType } from "../Type/DefinitionType"; -import { ReferenceType } from "../Type/ReferenceType"; -import { TypeFormatter } from "../TypeFormatter"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { DefinitionType } from "../Type/DefinitionType.js"; +import { ReferenceType } from "../Type/ReferenceType.js"; +import { TypeFormatter } from "../TypeFormatter.js"; export class ReferenceTypeFormatter implements SubTypeFormatter { public constructor( protected childTypeFormatter: TypeFormatter, - protected encodeRefs: boolean + protected encodeRefs: boolean, ) {} public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/RestTypeFormatter.ts b/src/TypeFormatter/RestTypeFormatter.ts index cc22d674e..a2f7ccd6f 100644 --- a/src/TypeFormatter/RestTypeFormatter.ts +++ b/src/TypeFormatter/RestTypeFormatter.ts @@ -1,8 +1,8 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { RestType } from "../Type/RestType"; -import { TypeFormatter } from "../TypeFormatter"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { RestType } from "../Type/RestType.js"; +import { TypeFormatter } from "../TypeFormatter.js"; export class RestTypeFormatter implements SubTypeFormatter { public constructor(protected childTypeFormatter: TypeFormatter) {} diff --git a/src/TypeFormatter/StringTypeFormatter.ts b/src/TypeFormatter/StringTypeFormatter.ts index 09a9dd916..a8d3e7327 100644 --- a/src/TypeFormatter/StringTypeFormatter.ts +++ b/src/TypeFormatter/StringTypeFormatter.ts @@ -1,7 +1,7 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { StringType } from "../Type/StringType"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { StringType } from "../Type/StringType.js"; export class StringTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/SymbolTypeFormatter.ts b/src/TypeFormatter/SymbolTypeFormatter.ts index 5f64c6962..e011a427d 100644 --- a/src/TypeFormatter/SymbolTypeFormatter.ts +++ b/src/TypeFormatter/SymbolTypeFormatter.ts @@ -1,7 +1,7 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { SymbolType } from "../Type/SymbolType"; -import { BaseType } from "../Type/BaseType"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { SymbolType } from "../Type/SymbolType.js"; +import { BaseType } from "../Type/BaseType.js"; export class SymbolTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/TupleTypeFormatter.ts b/src/TypeFormatter/TupleTypeFormatter.ts index b0a459615..ee471b6b0 100644 --- a/src/TypeFormatter/TupleTypeFormatter.ts +++ b/src/TypeFormatter/TupleTypeFormatter.ts @@ -1,13 +1,13 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { ArrayType } from "../Type/ArrayType"; -import { BaseType } from "../Type/BaseType"; -import { OptionalType } from "../Type/OptionalType"; -import { RestType } from "../Type/RestType"; -import { TupleType } from "../Type/TupleType"; -import { TypeFormatter } from "../TypeFormatter"; -import { notNever } from "../Utils/notNever"; -import { uniqueArray } from "../Utils/uniqueArray"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { ArrayType } from "../Type/ArrayType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { OptionalType } from "../Type/OptionalType.js"; +import { RestType } from "../Type/RestType.js"; +import { TupleType } from "../Type/TupleType.js"; +import { TypeFormatter } from "../TypeFormatter.js"; +import { notNever } from "../Utils/notNever.js"; +import { uniqueArray } from "../Utils/uniqueArray.js"; function uniformRestType(type: RestType, check_type: BaseType): boolean { const inner = type.getType(); @@ -84,7 +84,7 @@ export class TupleTypeFormatter implements SubTypeFormatter { type .getTypes() .filter(notNever) - .reduce((result: BaseType[], item) => [...result, ...this.childTypeFormatter.getChildren(item)], []) + .reduce((result: BaseType[], item) => [...result, ...this.childTypeFormatter.getChildren(item)], []), ); } } diff --git a/src/TypeFormatter/UndefinedTypeFormatter.ts b/src/TypeFormatter/UndefinedTypeFormatter.ts index ea18f642f..df2e2a128 100644 --- a/src/TypeFormatter/UndefinedTypeFormatter.ts +++ b/src/TypeFormatter/UndefinedTypeFormatter.ts @@ -1,7 +1,7 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { UndefinedType } from "../Type/UndefinedType"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { UndefinedType } from "../Type/UndefinedType.js"; export class UndefinedTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/UnionTypeFormatter.ts b/src/TypeFormatter/UnionTypeFormatter.ts index 0c67ad573..790f57436 100644 --- a/src/TypeFormatter/UnionTypeFormatter.ts +++ b/src/TypeFormatter/UnionTypeFormatter.ts @@ -1,21 +1,21 @@ import { JSONSchema7 } from "json-schema"; -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { LiteralType } from "../Type/LiteralType"; -import { NeverType } from "../Type/NeverType"; -import { UnionType } from "../Type/UnionType"; -import { TypeFormatter } from "../TypeFormatter"; -import { derefType } from "../Utils/derefType"; -import { getTypeByKey } from "../Utils/typeKeys"; -import { uniqueArray } from "../Utils/uniqueArray"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { LiteralType } from "../Type/LiteralType.js"; +import { NeverType } from "../Type/NeverType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { TypeFormatter } from "../TypeFormatter.js"; +import { derefType } from "../Utils/derefType.js"; +import { getTypeByKey } from "../Utils/typeKeys.js"; +import { uniqueArray } from "../Utils/uniqueArray.js"; type DiscriminatorType = "json-schema" | "open-api"; export class UnionTypeFormatter implements SubTypeFormatter { public constructor( protected childTypeFormatter: TypeFormatter, - private discriminatorType?: DiscriminatorType + private discriminatorType?: DiscriminatorType, ) {} public supportsType(type: BaseType): boolean { @@ -40,9 +40,7 @@ export class UnionTypeFormatter implements SubTypeFormatter { if (undefinedIndex != -1) { throw new Error( - `Cannot find discriminator keyword "${discriminator}" in type ${JSON.stringify( - type.getTypes()[undefinedIndex] - )}.` + `Cannot find discriminator keyword "${discriminator}" in type ${type.getTypes()[undefinedIndex].getName()}.`, ); } @@ -66,7 +64,7 @@ export class UnionTypeFormatter implements SubTypeFormatter { const duplicates = kindValues.filter((item, index) => kindValues.indexOf(item) !== index); if (duplicates.length > 0) { throw new Error( - `Duplicate discriminator values: ${duplicates.join(", ")} in type ${JSON.stringify(type.getName())}.` + `Duplicate discriminator values: ${duplicates.join(", ")} in type ${JSON.stringify(type.getName())}.`, ); } @@ -98,38 +96,6 @@ export class UnionTypeFormatter implements SubTypeFormatter { const definitions = this.getTypeDefinitions(type); - // TODO: why is this not covered by LiteralUnionTypeFormatter? - // special case for string literals | string -> string - let stringType = true; - let oneNotEnum = false; - for (const def of definitions) { - if (def.type !== "string") { - stringType = false; - break; - } - if (def.enum === undefined) { - oneNotEnum = true; - } - } - if (stringType && oneNotEnum) { - const values = []; - for (const def of definitions) { - if (def.enum) { - values.push(...def.enum); - } else if (def.const) { - values.push(def.const); - } else { - return { - type: "string", - }; - } - } - return { - type: "string", - enum: values, - }; - } - const flattenedDefinitions: JSONSchema7[] = []; // Flatten anyOf inside anyOf unless the anyOf has an annotation @@ -153,7 +119,7 @@ export class UnionTypeFormatter implements SubTypeFormatter { return uniqueArray( type .getTypes() - .reduce((result: BaseType[], item) => [...result, ...this.childTypeFormatter.getChildren(item)], []) + .reduce((result: BaseType[], item) => [...result, ...this.childTypeFormatter.getChildren(item)], []), ); } } diff --git a/src/TypeFormatter/UnknownTypeFormatter.ts b/src/TypeFormatter/UnknownTypeFormatter.ts index 561b9b34f..bf5aa3b3f 100644 --- a/src/TypeFormatter/UnknownTypeFormatter.ts +++ b/src/TypeFormatter/UnknownTypeFormatter.ts @@ -1,7 +1,7 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { UnknownType } from "../Type/UnknownType"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { UnknownType } from "../Type/UnknownType.js"; export class UnknownTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/VoidTypeFormatter.ts b/src/TypeFormatter/VoidTypeFormatter.ts index b4aba648a..83ce50df5 100644 --- a/src/TypeFormatter/VoidTypeFormatter.ts +++ b/src/TypeFormatter/VoidTypeFormatter.ts @@ -1,7 +1,7 @@ -import { Definition } from "../Schema/Definition"; -import { SubTypeFormatter } from "../SubTypeFormatter"; -import { BaseType } from "../Type/BaseType"; -import { VoidType } from "../Type/VoidType"; +import { Definition } from "../Schema/Definition.js"; +import { SubTypeFormatter } from "../SubTypeFormatter.js"; +import { BaseType } from "../Type/BaseType.js"; +import { VoidType } from "../Type/VoidType.js"; export class VoidTypeFormatter implements SubTypeFormatter { public supportsType(type: BaseType): boolean { diff --git a/src/Utils/allOfDefinition.ts b/src/Utils/allOfDefinition.ts index 03e4ae478..7da418110 100644 --- a/src/Utils/allOfDefinition.ts +++ b/src/Utils/allOfDefinition.ts @@ -1,17 +1,17 @@ -import { Definition } from "../Schema/Definition"; -import { RawTypeName } from "../Schema/RawType"; -import { BaseType } from "../Type/BaseType"; -import { TypeFormatter } from "../TypeFormatter"; -import { uniqueArray } from "./uniqueArray"; -import { deepMerge } from "./deepMerge"; -import { derefType } from "./derefType"; +import { Definition } from "../Schema/Definition.js"; +import { RawTypeName } from "../Schema/RawType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { TypeFormatter } from "../TypeFormatter.js"; +import { uniqueArray } from "./uniqueArray.js"; +import { deepMerge } from "./deepMerge.js"; +import { derefType } from "./derefType.js"; // TODO: Can we do this at parse time? See heritage clause in interfaces. // TODO: We really only need this if the children use additionalProperties: false. export function getAllOfDefinitionReducer(childTypeFormatter: TypeFormatter) { // combine object instead of using allOf because allOf does not work well with additional properties return (definition: Definition, baseType: BaseType): Definition => { - const other = childTypeFormatter.getDefinition(derefType(baseType)!); + const other = childTypeFormatter.getDefinition(derefType(baseType)); definition.properties = deepMerge(other.properties || {}, definition.properties || {}); @@ -33,7 +33,7 @@ export function getAllOfDefinitionReducer(childTypeFormatter: TypeFormatter) { for (const prop of addProps.anyOf as Definition[]) { if (prop.type) { additionalTypes = additionalTypes.concat( - Array.isArray(prop.type) ? prop.type : [prop.type] + Array.isArray(prop.type) ? prop.type : [prop.type], ); } else { additionalProps.push(prop); @@ -41,7 +41,7 @@ export function getAllOfDefinitionReducer(childTypeFormatter: TypeFormatter) { } } else if (addProps.type) { additionalTypes = additionalTypes.concat( - Array.isArray(addProps.type) ? addProps.type : [addProps.type] + Array.isArray(addProps.type) ? addProps.type : [addProps.type], ); } else { additionalProps.push(addProps); diff --git a/src/Utils/assert.ts b/src/Utils/assert.ts index 0b06c55f8..771380f5f 100644 --- a/src/Utils/assert.ts +++ b/src/Utils/assert.ts @@ -1,4 +1,4 @@ -import { LogicError } from "../Error/LogicError"; +import { LogicError } from "../Error/LogicError.js"; export default function assert(value: unknown, message: string): asserts value { if (!value) { diff --git a/src/Utils/deepMerge.ts b/src/Utils/deepMerge.ts index 1dadef268..30bfa68af 100644 --- a/src/Utils/deepMerge.ts +++ b/src/Utils/deepMerge.ts @@ -1,7 +1,7 @@ import { JSONSchema7Definition } from "json-schema"; -import { Definition } from "../Schema/Definition"; -import { RawType } from "../Schema/RawType"; -import { intersectionOfArrays } from "./intersectionOfArrays"; +import { Definition } from "../Schema/Definition.js"; +import { RawType } from "../Schema/RawType.js"; +import { intersectionOfArrays } from "./intersectionOfArrays.js"; /** * Merges nested objects and arrays. @@ -13,7 +13,7 @@ import { intersectionOfArrays } from "./intersectionOfArrays"; */ export function deepMerge( a: { [key: string]: JSONSchema7Definition }, - b: { [key: string]: JSONSchema7Definition } + b: { [key: string]: JSONSchema7Definition }, ): { [x: string]: JSONSchema7Definition } { const output = { ...structuredClone(a), ...structuredClone(b) }; diff --git a/src/Utils/derefType.ts b/src/Utils/derefType.ts index e7b407c2c..0c68d93e7 100644 --- a/src/Utils/derefType.ts +++ b/src/Utils/derefType.ts @@ -1,8 +1,10 @@ -import { AliasType } from "../Type/AliasType"; -import { AnnotatedType } from "../Type/AnnotatedType"; -import { BaseType } from "../Type/BaseType"; -import { DefinitionType } from "../Type/DefinitionType"; -import { ReferenceType } from "../Type/ReferenceType"; +import { AliasType } from "../Type/AliasType.js"; +import { AnnotatedType } from "../Type/AnnotatedType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { DefinitionType } from "../Type/DefinitionType.js"; +import { HiddenType } from "../Type/HiddenType.js"; +import { NeverType } from "../Type/NeverType.js"; +import { ReferenceType } from "../Type/ReferenceType.js"; /** * Dereference the type as far as possible. @@ -25,3 +27,21 @@ export function derefAnnotatedType(type: BaseType): BaseType { return type; } + +export function isHiddenType(type: BaseType): boolean { + if (type instanceof HiddenType || type instanceof NeverType) { + return true; + } else if (type instanceof DefinitionType || type instanceof AliasType || type instanceof AnnotatedType) { + return isHiddenType(type.getType()); + } + + return false; +} + +export function derefAliasedType(type: BaseType): BaseType { + if (type instanceof AliasType) { + return derefAliasedType(type.getType()); + } + + return type; +} diff --git a/src/Utils/extractLiterals.ts b/src/Utils/extractLiterals.ts index aa10421f6..20f9d283f 100644 --- a/src/Utils/extractLiterals.ts +++ b/src/Utils/extractLiterals.ts @@ -1,12 +1,12 @@ -import { UnknownTypeError } from "../Error/UnknownTypeError"; -import { AliasType } from "../Type/AliasType"; -import { BaseType } from "../Type/BaseType"; -import { BooleanType } from "../Type/BooleanType"; -import { DefinitionType } from "../Type/DefinitionType"; -import { EnumType } from "../Type/EnumType"; -import { LiteralType } from "../Type/LiteralType"; -import { UnionType } from "../Type/UnionType"; -import { derefAnnotatedType } from "./derefType"; +import { UnknownTypeError } from "../Error/UnknownTypeError.js"; +import { AliasType } from "../Type/AliasType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { BooleanType } from "../Type/BooleanType.js"; +import { DefinitionType } from "../Type/DefinitionType.js"; +import { EnumType } from "../Type/EnumType.js"; +import { LiteralType } from "../Type/LiteralType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { derefAnnotatedType } from "./derefType.js"; function* _extractLiterals(type: BaseType): Iterable { if (!type) { diff --git a/src/Utils/formatError.ts b/src/Utils/formatError.ts index 6d397c4d7..9c7d369d4 100644 --- a/src/Utils/formatError.ts +++ b/src/Utils/formatError.ts @@ -1,9 +1,9 @@ import * as path from "path"; import ts from "typescript"; -import { BaseError } from "../Error/BaseError"; -import { DiagnosticError } from "../Error/DiagnosticError"; -import { UnknownNodeError } from "../Error/UnknownNodeError"; +import { BaseError } from "../Error/BaseError.js"; +import { DiagnosticError } from "../Error/DiagnosticError.js"; +import { UnknownNodeError } from "../Error/UnknownNodeError.js"; function getNodeLocation(node: ts.Node): [string, number, number] { const sourceFile = node.getSourceFile(); diff --git a/src/Utils/hasJsDocTag.ts b/src/Utils/hasJsDocTag.ts index 8e47b0136..df879ebac 100644 --- a/src/Utils/hasJsDocTag.ts +++ b/src/Utils/hasJsDocTag.ts @@ -1,5 +1,5 @@ import ts from "typescript"; -import { symbolAtNode } from "./symbolAtNode"; +import { symbolAtNode } from "./symbolAtNode.js"; export function hasJsDocTag(node: ts.Node, tagName: string): boolean { const symbol = symbolAtNode(node); diff --git a/src/Utils/intersectionOfArrays.ts b/src/Utils/intersectionOfArrays.ts index dadeb0730..3e2f98376 100644 --- a/src/Utils/intersectionOfArrays.ts +++ b/src/Utils/intersectionOfArrays.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import stringify from "safe-stable-stringify"; export function intersectionOfArrays(a: T[], b: T[]): T[] { diff --git a/src/Utils/isAssignableTo.ts b/src/Utils/isAssignableTo.ts index f368a9efb..0ec183989 100644 --- a/src/Utils/isAssignableTo.ts +++ b/src/Utils/isAssignableTo.ts @@ -1,24 +1,24 @@ -import { AnyType } from "../Type/AnyType"; -import { ArrayType } from "../Type/ArrayType"; -import { BaseType } from "../Type/BaseType"; -import { EnumType } from "../Type/EnumType"; -import { IntersectionType } from "../Type/IntersectionType"; -import { NullType } from "../Type/NullType"; -import { ObjectProperty, ObjectType } from "../Type/ObjectType"; -import { OptionalType } from "../Type/OptionalType"; -import { TupleType } from "../Type/TupleType"; -import { UndefinedType } from "../Type/UndefinedType"; -import { UnionType } from "../Type/UnionType"; -import { UnknownType } from "../Type/UnknownType"; -import { VoidType } from "../Type/VoidType"; -import { derefType } from "./derefType"; -import { LiteralType, LiteralValue } from "../Type/LiteralType"; -import { StringType } from "../Type/StringType"; -import { NumberType } from "../Type/NumberType"; -import { BooleanType } from "../Type/BooleanType"; -import { InferType } from "../Type/InferType"; -import { RestType } from "../Type/RestType"; -import { NeverType } from "../Type/NeverType"; +import { AnyType } from "../Type/AnyType.js"; +import { ArrayType } from "../Type/ArrayType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { EnumType } from "../Type/EnumType.js"; +import { IntersectionType } from "../Type/IntersectionType.js"; +import { NullType } from "../Type/NullType.js"; +import { ObjectProperty, ObjectType } from "../Type/ObjectType.js"; +import { OptionalType } from "../Type/OptionalType.js"; +import { TupleType } from "../Type/TupleType.js"; +import { UndefinedType } from "../Type/UndefinedType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { UnknownType } from "../Type/UnknownType.js"; +import { VoidType } from "../Type/VoidType.js"; +import { derefType } from "./derefType.js"; +import { LiteralType, LiteralValue } from "../Type/LiteralType.js"; +import { StringType } from "../Type/StringType.js"; +import { NumberType } from "../Type/NumberType.js"; +import { BooleanType } from "../Type/BooleanType.js"; +import { InferType } from "../Type/InferType.js"; +import { RestType } from "../Type/RestType.js"; +import { NeverType } from "../Type/NeverType.js"; /** * Returns the combined types from the given intersection. Currently only object types are combined. Maybe more @@ -91,7 +91,7 @@ export function isAssignableTo( target: BaseType, source: BaseType, inferMap: Map = new Map(), - insideTypes: Set = new Set() + insideTypes: Set = new Set(), ): boolean { // Dereference source and target source = derefType(source); @@ -203,7 +203,7 @@ export function isAssignableTo( // Check if target has properties in common with source const inCommon = targetMembers.some((targetMember) => - sourceMembers.some((sourceMember) => targetMember.getName() === sourceMember.getName()) + sourceMembers.some((sourceMember) => targetMember.getName() === sourceMember.getName()), ); return ( @@ -221,7 +221,7 @@ export function isAssignableTo( targetMember.getType(), sourceMember.getType(), inferMap, - new Set(insideTypes).add(source!).add(target!) + new Set(insideTypes).add(source).add(target), ); }) ); @@ -271,7 +271,7 @@ export function isAssignableTo( targetMember.getType(), new TupleType(remaining), inferMap, - insideTypes + insideTypes, ); } // The type cannot be assigned if more than one source diff --git a/src/Utils/isHidden.ts b/src/Utils/isHidden.ts index e259b43df..adb3c880a 100644 --- a/src/Utils/isHidden.ts +++ b/src/Utils/isHidden.ts @@ -1,5 +1,5 @@ import ts from "typescript"; -import { hasJsDocTag } from "./hasJsDocTag"; +import { hasJsDocTag } from "./hasJsDocTag.js"; export function isNodeHidden(node: ts.Node): boolean { return hasJsDocTag(node, "hidden"); diff --git a/src/Utils/narrowType.ts b/src/Utils/narrowType.ts index 52d67e9fe..13b060a67 100644 --- a/src/Utils/narrowType.ts +++ b/src/Utils/narrowType.ts @@ -1,8 +1,8 @@ -import { BaseType } from "../Type/BaseType"; -import { EnumType } from "../Type/EnumType"; -import { NeverType } from "../Type/NeverType"; -import { UnionType } from "../Type/UnionType"; -import { derefType } from "./derefType"; +import { BaseType } from "../Type/BaseType.js"; +import { EnumType } from "../Type/EnumType.js"; +import { NeverType } from "../Type/NeverType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { derefType } from "./derefType.js"; /** * Narrows the given type by passing all variants to the given predicate function. So when type is a union type then @@ -20,7 +20,7 @@ export function narrowType( type: BaseType, // TODO: remove the next line // eslint-disable-next-line no-shadow - predicate: (type: BaseType) => boolean + predicate: (type: BaseType) => boolean, ): BaseType { const derefed = derefType(type); if (derefed instanceof UnionType || derefed instanceof EnumType) { diff --git a/src/Utils/nodeKey.ts b/src/Utils/nodeKey.ts index 55ef4a923..0c460d55b 100644 --- a/src/Utils/nodeKey.ts +++ b/src/Utils/nodeKey.ts @@ -1,6 +1,6 @@ import stringify from "safe-stable-stringify"; import { Node } from "typescript"; -import { Context } from "../NodeParser"; +import { Context } from "../NodeParser.js"; export function hash(a: string | boolean | number | (string | boolean | number)[] | object): string | number { if (typeof a === "number") { diff --git a/src/Utils/notNever.ts b/src/Utils/notNever.ts index acb70baee..8fabcda56 100644 --- a/src/Utils/notNever.ts +++ b/src/Utils/notNever.ts @@ -1,5 +1,5 @@ -import { BaseType } from "../Type/BaseType"; -import { NeverType } from "../Type/NeverType"; +import { BaseType } from "../Type/BaseType.js"; +import { NeverType } from "../Type/NeverType.js"; export function notNever(x: BaseType): boolean { return !(x instanceof NeverType); diff --git a/src/Utils/preserveAnnotation.ts b/src/Utils/preserveAnnotation.ts index 944579397..789f7437b 100644 --- a/src/Utils/preserveAnnotation.ts +++ b/src/Utils/preserveAnnotation.ts @@ -1,5 +1,5 @@ -import { BaseType } from "../Type/BaseType"; -import { AnnotatedType } from "../Type/AnnotatedType"; +import { BaseType } from "../Type/BaseType.js"; +import { AnnotatedType } from "../Type/AnnotatedType.js"; /** * Return the new type wrapped in an annotated type with the same annotations as the original type. diff --git a/src/Utils/removeUndefined.ts b/src/Utils/removeUndefined.ts index d760a5d3e..abcdfbd0a 100644 --- a/src/Utils/removeUndefined.ts +++ b/src/Utils/removeUndefined.ts @@ -1,8 +1,8 @@ -import { BaseType } from "../Type/BaseType"; -import { UndefinedType } from "../Type/UndefinedType"; -import { UnionType } from "../Type/UnionType"; -import { derefAnnotatedType } from "./derefType"; -import { preserveAnnotation } from "./preserveAnnotation"; +import { BaseType } from "../Type/BaseType.js"; +import { UndefinedType } from "../Type/UndefinedType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { derefAnnotatedType } from "./derefType.js"; +import { preserveAnnotation } from "./preserveAnnotation.js"; /** * Remove undefined types from union type. Returns the number of non-undefined properties. @@ -14,7 +14,7 @@ export function removeUndefined(propertyType: UnionType): { numRemoved: number; for (const type of propertyType.getTypes()) { const newType = derefAnnotatedType(type); if (newType instanceof UndefinedType) { - numRemoved += 1; + numRemoved++; } else if (newType instanceof UnionType) { const result = removeUndefined(newType); numRemoved += result.numRemoved; diff --git a/src/Utils/removeUnreachable.ts b/src/Utils/removeUnreachable.ts index 479c99d89..f8a4967fc 100644 --- a/src/Utils/removeUnreachable.ts +++ b/src/Utils/removeUnreachable.ts @@ -1,13 +1,13 @@ import { JSONSchema7Definition } from "json-schema"; -import { Definition } from "../Schema/Definition"; -import { StringMap } from "./StringMap"; +import { Definition } from "../Schema/Definition.js"; +import { StringMap } from "./StringMap.js"; const DEFINITION_OFFSET = "#/definitions/".length; function addReachable( definition: Definition | JSONSchema7Definition, definitions: StringMap, - reachable: Set + reachable: Set, ) { if (typeof definition === "boolean") { return; @@ -65,7 +65,7 @@ function addReachable( export function removeUnreachable( rootTypeDefinition: Definition | undefined, - definitions: StringMap + definitions: StringMap, ): StringMap { if (!rootTypeDefinition) { return definitions; diff --git a/src/Utils/typeKeys.ts b/src/Utils/typeKeys.ts index 328dc277f..d73b2a5bb 100644 --- a/src/Utils/typeKeys.ts +++ b/src/Utils/typeKeys.ts @@ -1,19 +1,19 @@ -import { translate } from "../NodeParser/IntersectionNodeParser"; -import { AnyType } from "../Type/AnyType"; -import { ArrayType } from "../Type/ArrayType"; -import { BaseType } from "../Type/BaseType"; -import { IntersectionType } from "../Type/IntersectionType"; -import { LiteralType } from "../Type/LiteralType"; -import { NumberType } from "../Type/NumberType"; -import { ObjectType } from "../Type/ObjectType"; -import { StringType } from "../Type/StringType"; -import { TupleType } from "../Type/TupleType"; -import { UndefinedType } from "../Type/UndefinedType"; -import { UnionType } from "../Type/UnionType"; -import { derefAnnotatedType, derefType } from "./derefType"; -import { preserveAnnotation } from "./preserveAnnotation"; -import { uniqueArray } from "./uniqueArray"; -import { uniqueTypeArray } from "./uniqueTypeArray"; +import { translate } from "../NodeParser/IntersectionNodeParser.js"; +import { AnyType } from "../Type/AnyType.js"; +import { ArrayType } from "../Type/ArrayType.js"; +import { BaseType } from "../Type/BaseType.js"; +import { IntersectionType } from "../Type/IntersectionType.js"; +import { LiteralType } from "../Type/LiteralType.js"; +import { NumberType } from "../Type/NumberType.js"; +import { ObjectType } from "../Type/ObjectType.js"; +import { StringType } from "../Type/StringType.js"; +import { TupleType } from "../Type/TupleType.js"; +import { UndefinedType } from "../Type/UndefinedType.js"; +import { UnionType } from "../Type/UnionType.js"; +import { derefAnnotatedType, derefType } from "./derefType.js"; +import { preserveAnnotation } from "./preserveAnnotation.js"; +import { uniqueArray } from "./uniqueArray.js"; +import { uniqueTypeArray } from "./uniqueTypeArray.js"; function uniqueLiterals(types: LiteralType[]): LiteralType[] { const values = types.map((type) => type.getValue()); @@ -25,7 +25,7 @@ export function getTypeKeys(type: BaseType): LiteralType[] { if (type instanceof IntersectionType || type instanceof UnionType) { return uniqueLiterals( - type.getTypes().reduce((result: LiteralType[], subType) => [...result, ...getTypeKeys(subType)], []) + type.getTypes().reduce((result: LiteralType[], subType) => [...result, ...getTypeKeys(subType)], []), ); } @@ -39,15 +39,15 @@ export function getTypeKeys(type: BaseType): LiteralType[] { .getBaseTypes() .reduce( (result: LiteralType[], parentType) => [...result, ...getTypeKeys(parentType)], - objectProperties - ) + objectProperties, + ), ); } return []; } -export function getTypeByKey(type: BaseType, index: LiteralType | StringType): BaseType | undefined { +export function getTypeByKey(type: BaseType, index: LiteralType | StringType | NumberType): BaseType | undefined { type = derefType(type); if (type instanceof IntersectionType || type instanceof UnionType) { diff --git a/src/Utils/typeName.ts b/src/Utils/typeName.ts index 5aa3357b2..f522b03e9 100644 --- a/src/Utils/typeName.ts +++ b/src/Utils/typeName.ts @@ -1,4 +1,4 @@ -import { RawType, RawTypeName } from "../Schema/RawType"; +import { RawType, RawTypeName } from "../Schema/RawType.js"; export function typeName(value: RawType): RawTypeName { if (value === null) { diff --git a/src/Utils/uniqueArray.ts b/src/Utils/uniqueArray.ts index 2618eb28f..b20a18031 100644 --- a/src/Utils/uniqueArray.ts +++ b/src/Utils/uniqueArray.ts @@ -1,6 +1,6 @@ export function uniqueArray(array: readonly T[]): T[] { return array.reduce((result: T[], item: T) => { - if (result.indexOf(item) < 0) { + if (!result.includes(item)) { result.push(item); } diff --git a/src/Utils/uniqueTypeArray.ts b/src/Utils/uniqueTypeArray.ts index 902e1a529..ccef94560 100644 --- a/src/Utils/uniqueTypeArray.ts +++ b/src/Utils/uniqueTypeArray.ts @@ -1,4 +1,4 @@ -import { BaseType } from "../Type/BaseType"; +import { BaseType } from "../Type/BaseType.js"; export function uniqueTypeArray(types: T[]): T[] { const uniqueTypes = new Map(); diff --git a/test/README.md b/test/README.md index 02e4264e6..604bf78d6 100644 --- a/test/README.md +++ b/test/README.md @@ -4,10 +4,10 @@ To add/update a test case for generating a valid schema from a Typescript file: -- Look in `test/valid-data` for a sample related to your change. If you don't find one, create your own following the naming convention. For example, when adding the new sample `annotation-default`: - - Create folder `test/valid-data/annotation-default` - - Add `main.ts` to that folder with the type sample -- Update the corresponding `main.ts` file with your changes. -- Run `yarn test:update` to compile the JSON schema -- Add a test to `test/valid-data-annotations.test.ts`, matching a similar pattern to the existing tests. -- Run tests via `yarn jest test/valid-data-annotations.test.ts` (this only runs the subset of tests related to schema validation) +- Look in `test/valid-data` for a sample related to your change. If you don't find one, create your own following the naming convention. For example, when adding the new sample `annotation-default`: + - Create folder `test/valid-data/annotation-default` + - Add `main.ts` to that folder with the type sample +- Update the corresponding `main.ts` file with your changes. +- Run `yarn test:update` to compile the JSON schema +- Add a test to `test/valid-data-annotations.test.ts`, matching a similar pattern to the existing tests. +- Run tests via `yarn jest test/valid-data-annotations.test.ts` (this only runs the subset of tests related to schema validation) diff --git a/test/config.test.ts b/test/config.test.ts index a59f9842b..a9fc245ab 100644 --- a/test/config.test.ts +++ b/test/config.test.ts @@ -8,15 +8,15 @@ import { FormatterAugmentor, createFormatter } from "../factory/formatter"; import { ParserAugmentor, createParser } from "../factory/parser"; import { createProgram } from "../factory/program"; import { BaseType, Context, DefinitionType, ReferenceType, SubNodeParser } from "../index"; -import { CompletedConfig, Config, DEFAULT_CONFIG } from "../src/Config"; -import { Definition } from "../src/Schema/Definition"; -import { SchemaGenerator } from "../src/SchemaGenerator"; -import { SubTypeFormatter } from "../src/SubTypeFormatter"; -import { EnumType } from "../src/Type/EnumType"; -import { FunctionType } from "../src/Type/FunctionType"; -import { StringType } from "../src/Type/StringType"; -import { TypeFormatter } from "../src/TypeFormatter"; -import { uniqueArray } from "../src/Utils/uniqueArray"; +import { CompletedConfig, Config, DEFAULT_CONFIG } from "../src/Config.js"; +import { Definition } from "../src/Schema/Definition.js"; +import { SchemaGenerator } from "../src/SchemaGenerator.js"; +import { SubTypeFormatter } from "../src/SubTypeFormatter.js"; +import { EnumType } from "../src/Type/EnumType.js"; +import { FunctionType } from "../src/Type/FunctionType.js"; +import { StringType } from "../src/Type/StringType.js"; +import { TypeFormatter } from "../src/TypeFormatter.js"; +import { uniqueArray } from "../src/Utils/uniqueArray.js"; const basePath = "test/config"; @@ -25,7 +25,7 @@ function assertSchema( userConfig: Config & { type: string }, tsconfig?: boolean, formatterAugmentor?: FormatterAugmentor, - parserAugmentor?: ParserAugmentor + parserAugmentor?: ParserAugmentor, ) { return () => { const config: CompletedConfig = { @@ -44,7 +44,7 @@ function assertSchema( program, createParser(program, config, parserAugmentor), createFormatter(config, formatterAugmentor), - config + config, ); const schema = generator.createSchema(config.type); @@ -160,7 +160,7 @@ describe("config", () => { expose: "all", topRef: true, jsDoc: "none", - }) + }), ); it( "expose-all-topref-true-not-exported", @@ -169,7 +169,7 @@ describe("config", () => { expose: "all", topRef: true, jsDoc: "none", - }) + }), ); it( @@ -179,7 +179,7 @@ describe("config", () => { expose: "all", topRef: false, jsDoc: "none", - }) + }), ); it( "expose-all-topref-false-not-exported", @@ -188,7 +188,7 @@ describe("config", () => { expose: "all", topRef: false, jsDoc: "none", - }) + }), ); it( @@ -198,7 +198,7 @@ describe("config", () => { expose: "none", topRef: true, jsDoc: "none", - }) + }), ); it( "expose-none-topref-false", @@ -207,7 +207,7 @@ describe("config", () => { expose: "none", topRef: false, jsDoc: "none", - }) + }), ); it( @@ -217,7 +217,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "none", - }) + }), ); it( "expose-export-topref-false", @@ -226,7 +226,7 @@ describe("config", () => { expose: "export", topRef: false, jsDoc: "none", - }) + }), ); it( @@ -236,7 +236,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "none", - }) + }), ); it( "jsdoc-complex-basic", @@ -245,7 +245,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "basic", - }) + }), ); it( "jsdoc-complex-extended", @@ -254,7 +254,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "extended", - }) + }), ); it( "jsdoc-description-only", @@ -263,7 +263,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "extended", - }) + }), ); it( @@ -273,7 +273,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "extended", - }) + }), ); it( @@ -283,7 +283,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "extended", - }) + }), ); it( @@ -293,7 +293,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "extended", - }) + }), ); it( @@ -303,7 +303,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "extended", - }) + }), ); it( "jsdoc-inheritance-exclude", @@ -312,7 +312,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "extended", - }) + }), ); // ensure that skipping type checking doesn't alter the JSON schema output @@ -324,7 +324,7 @@ describe("config", () => { topRef: true, jsDoc: "extended", skipTypeCheck: true, - }) + }), ); it( "markdown-description", @@ -335,7 +335,7 @@ describe("config", () => { jsDoc: "extended", sortProps: true, markdownDescription: true, - }) + }), ); it( "tsconfig-support", @@ -347,8 +347,8 @@ describe("config", () => { topRef: false, jsDoc: "none", }, - true - ) + true, + ), ); it( @@ -359,7 +359,7 @@ describe("config", () => { encodeRefs: false, topRef: true, jsDoc: "none", - }) + }), ); it( @@ -367,7 +367,7 @@ describe("config", () => { assertSchema("additional-properties", { type: "MyObject", additionalProperties: true, - }) + }), ); it( @@ -375,13 +375,13 @@ describe("config", () => { assertSchema("arrow-function-parameters", { type: "myFunction", expose: "all", - }) + }), ); it( "function-parameters-all", assertSchema("function-parameters-all", { type: "*", - }) + }), ); it( @@ -392,8 +392,8 @@ describe("config", () => { type: "MyObject", }, false, - (formatter) => formatter.addTypeFormatter(new ExampleFunctionTypeFormatter()) - ) + (formatter) => formatter.addTypeFormatter(new ExampleFunctionTypeFormatter()), + ), ); it( @@ -404,8 +404,8 @@ describe("config", () => { type: "MyObject", }, false, - (formatter) => formatter.addTypeFormatter(new ExampleEnumTypeFormatter()) - ) + (formatter) => formatter.addTypeFormatter(new ExampleEnumTypeFormatter()), + ), ); it( @@ -417,8 +417,8 @@ describe("config", () => { }, false, (formatter, circularReferenceTypeFormatter) => - formatter.addTypeFormatter(new ExampleDefinitionOverrideFormatter(circularReferenceTypeFormatter)) - ) + formatter.addTypeFormatter(new ExampleDefinitionOverrideFormatter(circularReferenceTypeFormatter)), + ), ); it( @@ -430,8 +430,8 @@ describe("config", () => { }, false, undefined, - (parser) => parser.addNodeParser(new ExampleConstructorParser()) - ) + (parser) => parser.addNodeParser(new ExampleConstructorParser()), + ), ); it( @@ -443,8 +443,8 @@ describe("config", () => { }, false, undefined, - (parser) => parser.addNodeParser(new ExampleNullParser()) - ) + (parser) => parser.addNodeParser(new ExampleNullParser()), + ), ); it( @@ -452,7 +452,7 @@ describe("config", () => { assertSchema("functions-hide", { type: "MyType", functions: "hide", - }) + }), ); it( @@ -460,6 +460,6 @@ describe("config", () => { assertSchema("functions-comment", { type: "MyType", functions: "comment", - }) + }), ); }); diff --git a/test/config/additional-properties/main.ts b/test/config/additional-properties/main.ts index a3fad2820..897c60a83 100644 --- a/test/config/additional-properties/main.ts +++ b/test/config/additional-properties/main.ts @@ -13,7 +13,6 @@ interface MixedInterface { } export type MixedAlias = PrivateInterface; - export type PublicAnonymousTypeLiteral = { publicValue: string; }; @@ -22,7 +21,6 @@ type PrivateAnonymousTypeLiteral = { privateValue: string; }; - export interface MyObject { exportInterface: ExportInterface; exportAlias: ExportAlias; diff --git a/test/config/arrow-function-parameters/main.ts b/test/config/arrow-function-parameters/main.ts index 4db486f29..72faf3912 100644 --- a/test/config/arrow-function-parameters/main.ts +++ b/test/config/arrow-function-parameters/main.ts @@ -9,7 +9,7 @@ export const myFunction = ( * @description Inline parameter description */ optionalArgument?: string, - optionalArgumentWithDefault: number = 42 + optionalArgumentWithDefault: number = 42, ) => { return "whatever"; }; diff --git a/test/config/custom-formatter-configuration-override/main.ts b/test/config/custom-formatter-configuration-override/main.ts index c31ae3297..dbccf1b4e 100644 --- a/test/config/custom-formatter-configuration-override/main.ts +++ b/test/config/custom-formatter-configuration-override/main.ts @@ -13,7 +13,6 @@ interface MixedInterface { } export type MixedAlias = PrivateInterface; - export type PublicAnonymousTypeLiteral = { publicValue: string; }; @@ -42,6 +41,5 @@ export interface MyObject { publicAnonymousTypeLiteral: PublicAnonymousTypeLiteral; privateAnonymousTypeLiteral: PrivateAnonymousTypeLiteral; - exportedEnum: Direction + exportedEnum: Direction; } - diff --git a/test/config/custom-formatter-configuration/custom-formatter-configuration-override/main.ts b/test/config/custom-formatter-configuration/custom-formatter-configuration-override/main.ts index c31ae3297..dbccf1b4e 100644 --- a/test/config/custom-formatter-configuration/custom-formatter-configuration-override/main.ts +++ b/test/config/custom-formatter-configuration/custom-formatter-configuration-override/main.ts @@ -13,7 +13,6 @@ interface MixedInterface { } export type MixedAlias = PrivateInterface; - export type PublicAnonymousTypeLiteral = { publicValue: string; }; @@ -42,6 +41,5 @@ export interface MyObject { publicAnonymousTypeLiteral: PublicAnonymousTypeLiteral; privateAnonymousTypeLiteral: PrivateAnonymousTypeLiteral; - exportedEnum: Direction + exportedEnum: Direction; } - diff --git a/test/config/custom-formatter-configuration/custom-formatter-configuration-override/schema.json b/test/config/custom-formatter-configuration/custom-formatter-configuration-override/schema.json index bdbaae6f0..002e79a45 100644 --- a/test/config/custom-formatter-configuration/custom-formatter-configuration-override/schema.json +++ b/test/config/custom-formatter-configuration/custom-formatter-configuration-override/schema.json @@ -1,135 +1,121 @@ { - "$ref": "#/definitions/MyObject", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "ExportInterface": { - "type": "object", - "properties": { - "exportValue": { - "type": "string" - } - }, - "required": [ - "exportValue" - ], - "additionalProperties": false + "$ref": "#/definitions/MyObject", + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "ExportInterface": { + "type": "object", + "properties": { + "exportValue": { + "type": "string" + } + }, + "required": ["exportValue"], + "additionalProperties": false + }, + "ExportAlias": { + "$ref": "#/definitions/ExportInterface" + }, + "MixedAlias": { + "type": "object", + "properties": { + "privateValue": { + "type": "string" + } + }, + "required": ["privateValue"], + "additionalProperties": false + }, + "PublicAnonymousTypeLiteral": { + "type": "object", + "properties": { + "publicValue": { + "type": "string" + } + }, + "required": ["publicValue"], + "additionalProperties": false + }, + "MyObject": { + "type": "object", + "properties": { + "exportInterface": { + "$ref": "#/definitions/ExportInterface" }, - "ExportAlias": { - "$ref": "#/definitions/ExportInterface" + "exportAlias": { + "$ref": "#/definitions/ExportAlias" }, - "MixedAlias": { - "type": "object", - "properties": { - "privateValue": { - "type": "string" - } - }, - "required": [ - "privateValue" - ], - "additionalProperties": false + "privateInterface": { + "type": "object", + "properties": { + "privateValue": { + "type": "string" + } + }, + "required": ["privateValue"], + "additionalProperties": false }, - "PublicAnonymousTypeLiteral": { - "type": "object", - "properties": { - "publicValue": { - "type": "string" - } - }, - "required": [ - "publicValue" - ], - "additionalProperties": false + "privateAlias": { + "type": "object", + "properties": { + "privateValue": { + "type": "string" + } + }, + "required": ["privateValue"], + "additionalProperties": false + }, + "mixedInterface": { + "type": "object", + "properties": { + "mixedValue": { + "$ref": "#/definitions/ExportAlias" + } + }, + "required": ["mixedValue"], + "additionalProperties": false + }, + "mixedAlias": { + "$ref": "#/definitions/MixedAlias" + }, + "publicAnonymousTypeLiteral": { + "$ref": "#/definitions/PublicAnonymousTypeLiteral" + }, + "privateAnonymousTypeLiteral": { + "type": "object", + "properties": { + "privateValue": { + "type": "string" + } + }, + "required": ["privateValue"], + "additionalProperties": false }, - "MyObject": { - "type": "object", - "properties": { - "exportInterface": { - "$ref": "#/definitions/ExportInterface" - }, - "exportAlias": { - "$ref": "#/definitions/ExportAlias" - }, - "privateInterface": { - "type": "object", - "properties": { - "privateValue": { - "type": "string" - } - }, - "required": [ - "privateValue" - ], - "additionalProperties": false - }, - "privateAlias": { - "type": "object", - "properties": { - "privateValue": { - "type": "string" - } - }, - "required": [ - "privateValue" - ], - "additionalProperties": false - }, - "mixedInterface": { - "type": "object", - "properties": { - "mixedValue": { - "$ref": "#/definitions/ExportAlias" - } - }, - "required": [ - "mixedValue" - ], - "additionalProperties": false - }, - "mixedAlias": { - "$ref": "#/definitions/MixedAlias" - }, - "publicAnonymousTypeLiteral": { - "$ref": "#/definitions/PublicAnonymousTypeLiteral" - }, - "privateAnonymousTypeLiteral": { - "type": "object", - "properties": { - "privateValue": { - "type": "string" - } - }, - "required": [ - "privateValue" - ], - "additionalProperties": false - }, - "exportedEnum": { - "type": "object", - "properties": { - "isEnum": { - "type": "boolean", - "const": true - }, - "enumLength": { - "type": "number", - "const": 4 - } - } - } + "exportedEnum": { + "type": "object", + "properties": { + "isEnum": { + "type": "boolean", + "const": true }, - "required": [ - "exportInterface", - "exportAlias", - "privateInterface", - "privateAlias", - "mixedInterface", - "mixedAlias", - "publicAnonymousTypeLiteral", - "privateAnonymousTypeLiteral", - "exportedEnum" - ], - "additionalProperties": false + "enumLength": { + "type": "number", + "const": 4 + } + } } + }, + "required": [ + "exportInterface", + "exportAlias", + "privateInterface", + "privateAlias", + "mixedInterface", + "mixedAlias", + "publicAnonymousTypeLiteral", + "privateAnonymousTypeLiteral", + "exportedEnum" + ], + "additionalProperties": false } + } } diff --git a/test/config/custom-formatter-configuration/main.ts b/test/config/custom-formatter-configuration/main.ts index 2fb2275c7..064268e45 100644 --- a/test/config/custom-formatter-configuration/main.ts +++ b/test/config/custom-formatter-configuration/main.ts @@ -13,7 +13,6 @@ interface MixedInterface { } export type MixedAlias = PrivateInterface; - export type PublicAnonymousTypeLiteral = { publicValue: string; }; diff --git a/test/config/custom-parser-configuration-override/main.ts b/test/config/custom-parser-configuration-override/main.ts index ff0e0d97b..4044a461f 100644 --- a/test/config/custom-parser-configuration-override/main.ts +++ b/test/config/custom-parser-configuration-override/main.ts @@ -13,7 +13,6 @@ interface MixedInterface { } export type MixedAlias = PrivateInterface; - export type PublicAnonymousTypeLiteral = { publicValue: string; }; @@ -35,6 +34,5 @@ export interface MyObject { publicAnonymousTypeLiteral: PublicAnonymousTypeLiteral; privateAnonymousTypeLiteral: PrivateAnonymousTypeLiteral; - exportedNull: null + exportedNull: null; } - diff --git a/test/config/custom-parser-configuration/main.ts b/test/config/custom-parser-configuration/main.ts index f74abf683..a02becbf6 100644 --- a/test/config/custom-parser-configuration/main.ts +++ b/test/config/custom-parser-configuration/main.ts @@ -13,7 +13,6 @@ interface MixedInterface { } export type MixedAlias = PrivateInterface; - export type PublicAnonymousTypeLiteral = { publicValue: string; }; @@ -23,7 +22,7 @@ type PrivateAnonymousTypeLiteral = { }; interface ConstructedInterface { - isConstructed: boolean + isConstructed: boolean; } export interface MyObject { @@ -39,5 +38,5 @@ export interface MyObject { publicAnonymousTypeLiteral: PublicAnonymousTypeLiteral; privateAnonymousTypeLiteral: PrivateAnonymousTypeLiteral; - exportedConstructor: (new () => ConstructedInterface); + exportedConstructor: new () => ConstructedInterface; } diff --git a/test/config/expose-all-topref-false-not-exported/main.ts b/test/config/expose-all-topref-false-not-exported/main.ts index b876cf907..13c2c6191 100644 --- a/test/config/expose-all-topref-false-not-exported/main.ts +++ b/test/config/expose-all-topref-false-not-exported/main.ts @@ -13,7 +13,6 @@ interface MixedInterface { } export type MixedAlias = PrivateInterface; - export type PublicAnonymousTypeLiteral = { publicValue: string; }; diff --git a/test/config/expose-all-topref-false/main.ts b/test/config/expose-all-topref-false/main.ts index c78a7d5cc..897c60a83 100644 --- a/test/config/expose-all-topref-false/main.ts +++ b/test/config/expose-all-topref-false/main.ts @@ -13,7 +13,6 @@ interface MixedInterface { } export type MixedAlias = PrivateInterface; - export type PublicAnonymousTypeLiteral = { publicValue: string; }; diff --git a/test/config/expose-all-topref-true-not-exported/main.ts b/test/config/expose-all-topref-true-not-exported/main.ts index 4c4b34415..13c2c6191 100644 --- a/test/config/expose-all-topref-true-not-exported/main.ts +++ b/test/config/expose-all-topref-true-not-exported/main.ts @@ -13,7 +13,6 @@ interface MixedInterface { } export type MixedAlias = PrivateInterface; - export type PublicAnonymousTypeLiteral = { publicValue: string; }; @@ -22,7 +21,6 @@ type PrivateAnonymousTypeLiteral = { privateValue: string; }; - interface MyObject { exportInterface: ExportInterface; exportAlias: ExportAlias; diff --git a/test/config/expose-all-topref-true/main.ts b/test/config/expose-all-topref-true/main.ts index a3fad2820..897c60a83 100644 --- a/test/config/expose-all-topref-true/main.ts +++ b/test/config/expose-all-topref-true/main.ts @@ -13,7 +13,6 @@ interface MixedInterface { } export type MixedAlias = PrivateInterface; - export type PublicAnonymousTypeLiteral = { publicValue: string; }; @@ -22,7 +21,6 @@ type PrivateAnonymousTypeLiteral = { privateValue: string; }; - export interface MyObject { exportInterface: ExportInterface; exportAlias: ExportAlias; diff --git a/test/config/expose-export-topref-false/main.ts b/test/config/expose-export-topref-false/main.ts index a3fad2820..897c60a83 100644 --- a/test/config/expose-export-topref-false/main.ts +++ b/test/config/expose-export-topref-false/main.ts @@ -13,7 +13,6 @@ interface MixedInterface { } export type MixedAlias = PrivateInterface; - export type PublicAnonymousTypeLiteral = { publicValue: string; }; @@ -22,7 +21,6 @@ type PrivateAnonymousTypeLiteral = { privateValue: string; }; - export interface MyObject { exportInterface: ExportInterface; exportAlias: ExportAlias; diff --git a/test/config/expose-export-topref-true/main.ts b/test/config/expose-export-topref-true/main.ts index a3fad2820..897c60a83 100644 --- a/test/config/expose-export-topref-true/main.ts +++ b/test/config/expose-export-topref-true/main.ts @@ -13,7 +13,6 @@ interface MixedInterface { } export type MixedAlias = PrivateInterface; - export type PublicAnonymousTypeLiteral = { publicValue: string; }; @@ -22,7 +21,6 @@ type PrivateAnonymousTypeLiteral = { privateValue: string; }; - export interface MyObject { exportInterface: ExportInterface; exportAlias: ExportAlias; diff --git a/test/config/expose-none-topref-false/main.ts b/test/config/expose-none-topref-false/main.ts index a3fad2820..897c60a83 100644 --- a/test/config/expose-none-topref-false/main.ts +++ b/test/config/expose-none-topref-false/main.ts @@ -13,7 +13,6 @@ interface MixedInterface { } export type MixedAlias = PrivateInterface; - export type PublicAnonymousTypeLiteral = { publicValue: string; }; @@ -22,7 +21,6 @@ type PrivateAnonymousTypeLiteral = { privateValue: string; }; - export interface MyObject { exportInterface: ExportInterface; exportAlias: ExportAlias; diff --git a/test/config/expose-none-topref-true/main.ts b/test/config/expose-none-topref-true/main.ts index a3fad2820..897c60a83 100644 --- a/test/config/expose-none-topref-true/main.ts +++ b/test/config/expose-none-topref-true/main.ts @@ -13,7 +13,6 @@ interface MixedInterface { } export type MixedAlias = PrivateInterface; - export type PublicAnonymousTypeLiteral = { publicValue: string; }; @@ -22,7 +21,6 @@ type PrivateAnonymousTypeLiteral = { privateValue: string; }; - export interface MyObject { exportInterface: ExportInterface; exportAlias: ExportAlias; diff --git a/test/config/function-parameters-all/main.ts b/test/config/function-parameters-all/main.ts index 646777872..60b10043c 100644 --- a/test/config/function-parameters-all/main.ts +++ b/test/config/function-parameters-all/main.ts @@ -1,10 +1,10 @@ -export type String = string +export type String = string; export const myFunction = ( /** * @description Inline parameter description */ - requiredString: String + requiredString: String, ) => { return "whatever"; }; diff --git a/test/config/jsdoc-complex-basic/main.ts b/test/config/jsdoc-complex-basic/main.ts index fdb843839..f72f1d296 100644 --- a/test/config/jsdoc-complex-basic/main.ts +++ b/test/config/jsdoc-complex-basic/main.ts @@ -28,7 +28,7 @@ export interface MyObject { /** * @title Nullable value */ - nullableValue: number | string |null; + nullableValue: number | string | null; /** * @title Optional value */ diff --git a/test/config/jsdoc-complex-extended/main.ts b/test/config/jsdoc-complex-extended/main.ts index caf33971b..99f546a4b 100644 --- a/test/config/jsdoc-complex-extended/main.ts +++ b/test/config/jsdoc-complex-extended/main.ts @@ -34,7 +34,7 @@ export interface MyObject { /** * @title Nullable value */ - nullableValue: number | string |null; + nullableValue: number | string | null; /** * @title Optional value */ diff --git a/test/config/jsdoc-complex-none/main.ts b/test/config/jsdoc-complex-none/main.ts index ac9e35290..d42b95fe1 100644 --- a/test/config/jsdoc-complex-none/main.ts +++ b/test/config/jsdoc-complex-none/main.ts @@ -29,7 +29,7 @@ export interface MyObject { /** * @title Nullable value */ - nullableValue: number | string |null; + nullableValue: number | string | null; /** * @title Optional value */ diff --git a/test/config/jsdoc-description-only/main.ts b/test/config/jsdoc-description-only/main.ts index 10cbf78cd..29a488465 100644 --- a/test/config/jsdoc-description-only/main.ts +++ b/test/config/jsdoc-description-only/main.ts @@ -1,5 +1,4 @@ /** * Some description here */ -export interface MyObject { -} +export interface MyObject {} diff --git a/test/config/markdown-description/main.ts b/test/config/markdown-description/main.ts index ebc599de8..aa9de9454 100644 --- a/test/config/markdown-description/main.ts +++ b/test/config/markdown-description/main.ts @@ -18,7 +18,7 @@ export interface MyObject { /** * @title Nullable value */ - nullableValue: number | string |null; + nullableValue: number | string | null; /** * @title Optional value */ @@ -55,12 +55,12 @@ export interface MyObject { * length: 42 * ``` */ - description: InheritedExample['description']; + description: InheritedExample["description"]; /** * @default "" */ - inheritedDescription: InheritedExample['description']; + inheritedDescription: InheritedExample["description"]; } /** diff --git a/test/config/tsconfig-support/src/main.ts b/test/config/tsconfig-support/src/main.ts index 5a29f7c8b..55b13c707 100644 --- a/test/config/tsconfig-support/src/main.ts +++ b/test/config/tsconfig-support/src/main.ts @@ -1,4 +1,4 @@ -import { MySubObject } from '@src/import1'; +import { MySubObject } from "@src/import1"; export interface MyObject { subObject: MySubObject; diff --git a/test/config/tsconfig-support/tsconfig.json b/test/config/tsconfig-support/tsconfig.json index 64ce2ca60..d1d731729 100644 --- a/test/config/tsconfig-support/tsconfig.json +++ b/test/config/tsconfig-support/tsconfig.json @@ -1,18 +1,16 @@ { - "compilerOptions": { - "noEmit": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "target": "ES5", - "module": "CommonJS", - "strictNullChecks": false, - "allowJs": true, - "baseUrl": ".", - "paths": { - "@src/*": ["src/*"] - } - }, - "files": [ - "src/main.ts" - ] + "compilerOptions": { + "noEmit": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "target": "ES5", + "module": "CommonJS", + "strictNullChecks": false, + "allowJs": true, + "baseUrl": ".", + "paths": { + "@src/*": ["src/*"] + } + }, + "files": ["src/main.ts"] } diff --git a/test/invalid-data.test.ts b/test/invalid-data.test.ts index 9598be24e..5c7437373 100644 --- a/test/invalid-data.test.ts +++ b/test/invalid-data.test.ts @@ -3,8 +3,8 @@ import ts from "typescript"; import { createFormatter } from "../factory/formatter"; import { createParser } from "../factory/parser"; import { createProgram } from "../factory/program"; -import { CompletedConfig, DEFAULT_CONFIG } from "../src/Config"; -import { SchemaGenerator } from "../src/SchemaGenerator"; +import { CompletedConfig, DEFAULT_CONFIG } from "../src/Config.js"; +import { SchemaGenerator } from "../src/SchemaGenerator.js"; function assertSchema(name: string, type: string, message: string) { return () => { @@ -22,7 +22,7 @@ function assertSchema(name: string, type: string, message: string) { const generator: SchemaGenerator = new SchemaGenerator( program, createParser(program, config), - createFormatter(config) + createFormatter(config), ); expect(() => generator.createSchema(type)).toThrow(message); @@ -36,28 +36,18 @@ describe("invalid-data", () => { it("duplicates", assertSchema("duplicates", "MyType", `Type "A" has multiple definitions.`)); it( "missing-discriminator", - assertSchema( - "missing-discriminator", - "MyType", - 'Cannot find discriminator keyword "type" in type ' + - '{"name":"B","type":{"id":"interface-1119825560-40-63-1119825560-0-124",' + - '"baseTypes":[],"properties":[],"additionalProperties":false,"nonPrimitive":false}}.' - ) + assertSchema("missing-discriminator", "MyType", 'Cannot find discriminator keyword "type" in type B.'), ); it( "non-union-discriminator", assertSchema( "non-union-discriminator", "MyType", - "Cannot assign discriminator tag to type: " + - '{"id":"interface-2103469249-0-76-2103469249-0-77","baseTypes":[],' + - '"properties":[{"name":"name","type":{},"required":true}],' + - '"additionalProperties":false,"nonPrimitive":false}. ' + - "This tag can only be assigned to union types." - ) + "Cannot assign discriminator tag to type: interface-2103469249-0-76-2103469249-0-77. This tag can only be assigned to union types.", + ), ); it( "duplicate-discriminator", - assertSchema("duplicate-discriminator", "MyType", 'Duplicate discriminator values: A in type "(A|B)".') + assertSchema("duplicate-discriminator", "MyType", 'Duplicate discriminator values: A in type "(A|B)".'), ); }); diff --git a/test/invalid-data/duplicate-discriminator/main.ts b/test/invalid-data/duplicate-discriminator/main.ts index 1d5844f33..d707ab608 100644 --- a/test/invalid-data/duplicate-discriminator/main.ts +++ b/test/invalid-data/duplicate-discriminator/main.ts @@ -1,12 +1,12 @@ export type A = { - type: "A", - a: string, -} + type: "A"; + a: string; +}; export type B = { - type: "A", - b: string, -} + type: "A"; + b: string; +}; /** * @discriminator type diff --git a/test/invalid-data/duplicates/main.ts b/test/invalid-data/duplicates/main.ts index ad3ed7270..8236015ff 100644 --- a/test/invalid-data/duplicates/main.ts +++ b/test/invalid-data/duplicates/main.ts @@ -1,4 +1,4 @@ -import {A as A1} from "./import1"; -import {A as A2} from "./import2"; +import { A as A1 } from "./import1"; +import { A as A2 } from "./import2"; export type MyType = A1 | A2; diff --git a/test/sourceless-nodes/index.test.ts b/test/sourceless-nodes/index.test.ts index 05db63a31..cb73297f5 100644 --- a/test/sourceless-nodes/index.test.ts +++ b/test/sourceless-nodes/index.test.ts @@ -1,11 +1,11 @@ import path from "path"; import ts from "typescript"; import { createParser } from "../../factory"; -import { Context } from "../../src/NodeParser"; -import { LiteralType } from "../../src/Type/LiteralType"; -import { NumberType } from "../../src/Type/NumberType"; -import { ObjectType } from "../../src/Type/ObjectType"; -import { DEFAULT_CONFIG } from "../../src/Config"; +import { Context } from "../../src/NodeParser.js"; +import { LiteralType } from "../../src/Type/LiteralType.js"; +import { NumberType } from "../../src/Type/NumberType.js"; +import { ObjectType } from "../../src/Type/ObjectType.js"; +import { DEFAULT_CONFIG } from "../../src/Config.js"; const SOURCE = path.resolve(__dirname, "./source.ts"); diff --git a/test/sourceless-nodes/key/index.test.ts b/test/sourceless-nodes/key/index.test.ts index 0a705aaa6..55d53b245 100644 --- a/test/sourceless-nodes/key/index.test.ts +++ b/test/sourceless-nodes/key/index.test.ts @@ -1,10 +1,10 @@ import path from "path"; import ts from "typescript"; import { createParser } from "../../../factory"; -import { Context } from "../../../src/NodeParser"; -import { DefinitionType } from "../../../src/Type/DefinitionType"; -import { ObjectType } from "../../../src/Type/ObjectType"; -import { DEFAULT_CONFIG } from "../../../src/Config"; +import { Context } from "../../../src/NodeParser.js"; +import { DefinitionType } from "../../../src/Type/DefinitionType.js"; +import { ObjectType } from "../../../src/Type/ObjectType.js"; +import { DEFAULT_CONFIG } from "../../../src/Config.js"; const SOURCE = path.resolve(__dirname, "./source.ts"); diff --git a/test/unit/AnnotatedTypeFormatter.test.ts b/test/unit/AnnotatedTypeFormatter.test.ts index 6d362c855..f11dc0c31 100644 --- a/test/unit/AnnotatedTypeFormatter.test.ts +++ b/test/unit/AnnotatedTypeFormatter.test.ts @@ -1,4 +1,4 @@ -import { makeNullable } from "../../src/TypeFormatter/AnnotatedTypeFormatter"; +import { makeNullable } from "../../src/TypeFormatter/AnnotatedTypeFormatter.js"; describe("makeNullable", () => { it("makes number nullable", () => { diff --git a/test/unit/Type/HiddenType.test.ts b/test/unit/Type/HiddenType.test.ts index 271d97d5e..6324b9ce5 100644 --- a/test/unit/Type/HiddenType.test.ts +++ b/test/unit/Type/HiddenType.test.ts @@ -1,5 +1,5 @@ -import { HiddenType } from "../../../src/Type/HiddenType"; -import { NeverType } from "../../../src/Type/NeverType"; +import { HiddenType } from "../../../src/Type/HiddenType.js"; +import { NeverType } from "../../../src/Type/NeverType.js"; describe("HiddenType", () => { it("creates a HiddenType", () => { diff --git a/test/unit/assert.test.ts b/test/unit/assert.test.ts index 115f5085d..91e5c7566 100644 --- a/test/unit/assert.test.ts +++ b/test/unit/assert.test.ts @@ -1,5 +1,5 @@ -import { LogicError } from "../../src/Error/LogicError"; -import assert from "../../src/Utils/assert"; +import { LogicError } from "../../src/Error/LogicError.js"; +import assert from "../../src/Utils/assert.js"; describe("validate assert", () => { it.each` diff --git a/test/unit/deepMerge.test.ts b/test/unit/deepMerge.test.ts index dff14d379..3ec460ff0 100644 --- a/test/unit/deepMerge.test.ts +++ b/test/unit/deepMerge.test.ts @@ -1,4 +1,4 @@ -import { deepMerge } from "../../src/Utils/deepMerge"; +import { deepMerge } from "../../src/Utils/deepMerge.js"; describe("deepMerge", () => { it("merges booleans with enums", () => { @@ -6,7 +6,7 @@ describe("deepMerge", () => { flag: { type: "boolean", const: true }, }); expect( - deepMerge({ flag: { type: "boolean", enum: [true] } }, { flag: { type: "boolean", enum: [true, false] } }) + deepMerge({ flag: { type: "boolean", enum: [true] } }, { flag: { type: "boolean", enum: [true, false] } }), ).toEqual({ flag: { type: "boolean", const: true } }); }); @@ -15,7 +15,7 @@ describe("deepMerge", () => { flag: { type: "boolean", const: false }, }); expect( - deepMerge({ flag: { type: "boolean", const: false } }, { flag: { type: "boolean", enum: [true, false] } }) + deepMerge({ flag: { type: "boolean", const: false } }, { flag: { type: "boolean", enum: [true, false] } }), ).toEqual({ flag: { type: "boolean", const: false } }); }); @@ -24,12 +24,12 @@ describe("deepMerge", () => { flag: { type: "number", enum: [1, 2] }, }); expect( - deepMerge({ flag: { type: "number", enum: [1, 2, 3] } }, { flag: { type: "number", enum: [1, 3] } }) + deepMerge({ flag: { type: "number", enum: [1, 2, 3] } }, { flag: { type: "number", enum: [1, 3] } }), ).toEqual({ flag: { type: "number", enum: [1, 3] }, }); expect( - deepMerge({ flag: { type: "number", enum: [1, 2] } }, { flag: { type: "number", enum: [1, 3] } }) + deepMerge({ flag: { type: "number", enum: [1, 2] } }, { flag: { type: "number", enum: [1, 3] } }), ).toEqual({ flag: { type: "number", const: 1 }, }); diff --git a/test/unit/intersectionOfArrays.test.ts b/test/unit/intersectionOfArrays.test.ts index 0a40d5027..6ea8970d5 100644 --- a/test/unit/intersectionOfArrays.test.ts +++ b/test/unit/intersectionOfArrays.test.ts @@ -1,4 +1,4 @@ -import { intersectionOfArrays } from "../../src/Utils/intersectionOfArrays"; +import { intersectionOfArrays } from "../../src/Utils/intersectionOfArrays.js"; describe("intersectionOfArrays", () => { it("returns members of a in b", () => { diff --git a/test/unit/isAssignableTo.test.ts b/test/unit/isAssignableTo.test.ts index c7e75e9f5..f05744ee4 100644 --- a/test/unit/isAssignableTo.test.ts +++ b/test/unit/isAssignableTo.test.ts @@ -1,26 +1,26 @@ -import { AliasType } from "../../src/Type/AliasType"; -import { AnnotatedType } from "../../src/Type/AnnotatedType"; -import { AnyType } from "../../src/Type/AnyType"; -import { ArrayType } from "../../src/Type/ArrayType"; -import { BooleanType } from "../../src/Type/BooleanType"; -import { DefinitionType } from "../../src/Type/DefinitionType"; -import { InferType } from "../../src/Type/InferType"; -import { IntersectionType } from "../../src/Type/IntersectionType"; -import { LiteralType } from "../../src/Type/LiteralType"; -import { NeverType } from "../../src/Type/NeverType"; -import { NullType } from "../../src/Type/NullType"; -import { NumberType } from "../../src/Type/NumberType"; -import { ObjectProperty, ObjectType } from "../../src/Type/ObjectType"; -import { OptionalType } from "../../src/Type/OptionalType"; -import { ReferenceType } from "../../src/Type/ReferenceType"; -import { RestType } from "../../src/Type/RestType"; -import { StringType } from "../../src/Type/StringType"; -import { TupleType } from "../../src/Type/TupleType"; -import { UndefinedType } from "../../src/Type/UndefinedType"; -import { UnionType } from "../../src/Type/UnionType"; -import { UnknownType } from "../../src/Type/UnknownType"; -import { VoidType } from "../../src/Type/VoidType"; -import { isAssignableTo } from "../../src/Utils/isAssignableTo"; +import { AliasType } from "../../src/Type/AliasType.js"; +import { AnnotatedType } from "../../src/Type/AnnotatedType.js"; +import { AnyType } from "../../src/Type/AnyType.js"; +import { ArrayType } from "../../src/Type/ArrayType.js"; +import { BooleanType } from "../../src/Type/BooleanType.js"; +import { DefinitionType } from "../../src/Type/DefinitionType.js"; +import { InferType } from "../../src/Type/InferType.js"; +import { IntersectionType } from "../../src/Type/IntersectionType.js"; +import { LiteralType } from "../../src/Type/LiteralType.js"; +import { NeverType } from "../../src/Type/NeverType.js"; +import { NullType } from "../../src/Type/NullType.js"; +import { NumberType } from "../../src/Type/NumberType.js"; +import { ObjectProperty, ObjectType } from "../../src/Type/ObjectType.js"; +import { OptionalType } from "../../src/Type/OptionalType.js"; +import { ReferenceType } from "../../src/Type/ReferenceType.js"; +import { RestType } from "../../src/Type/RestType.js"; +import { StringType } from "../../src/Type/StringType.js"; +import { TupleType } from "../../src/Type/TupleType.js"; +import { UndefinedType } from "../../src/Type/UndefinedType.js"; +import { UnionType } from "../../src/Type/UnionType.js"; +import { UnknownType } from "../../src/Type/UnknownType.js"; +import { VoidType } from "../../src/Type/VoidType.js"; +import { isAssignableTo } from "../../src/Utils/isAssignableTo.js"; describe("isAssignableTo", () => { it("returns true for same types", () => { @@ -113,8 +113,8 @@ describe("isAssignableTo", () => { expect( isAssignableTo( new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true), - new AnyType() - ) + new AnyType(), + ), ).toBe(true); expect(isAssignableTo(new BooleanType(), new AnyType())).toBe(true); expect(isAssignableTo(new NumberType(), new AnyType())).toBe(true); @@ -133,8 +133,8 @@ describe("isAssignableTo", () => { expect( isAssignableTo( new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true), - new NeverType() - ) + new NeverType(), + ), ).toBe(true); expect(isAssignableTo(new BooleanType(), new NeverType())).toBe(true); expect(isAssignableTo(new NumberType(), new NeverType())).toBe(true); @@ -153,8 +153,8 @@ describe("isAssignableTo", () => { expect( isAssignableTo( new AnyType(), - new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true) - ) + new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true), + ), ).toBe(true); expect(isAssignableTo(new AnyType(), new BooleanType())).toBe(true); expect(isAssignableTo(new AnyType(), new NumberType())).toBe(true); @@ -173,8 +173,8 @@ describe("isAssignableTo", () => { expect( isAssignableTo( new UnknownType(), - new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true) - ) + new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true), + ), ).toBe(true); expect(isAssignableTo(new UnknownType(), new BooleanType())).toBe(true); expect(isAssignableTo(new UnknownType(), new NumberType())).toBe(true); @@ -194,8 +194,8 @@ describe("isAssignableTo", () => { expect( isAssignableTo( new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], false), - new UnknownType() - ) + new UnknownType(), + ), ).toBe(false); expect(isAssignableTo(new BooleanType(), new UnknownType())).toBe(false); expect(isAssignableTo(new NumberType(), new UnknownType())).toBe(false); @@ -230,13 +230,13 @@ describe("isAssignableTo", () => { }); it("lets tuple type to be assigned to array type if item types match", () => { expect( - isAssignableTo(new ArrayType(new StringType()), new TupleType([new StringType(), new StringType()])) + isAssignableTo(new ArrayType(new StringType()), new TupleType([new StringType(), new StringType()])), ).toBe(true); expect( - isAssignableTo(new ArrayType(new NumberType()), new TupleType([new StringType(), new StringType()])) + isAssignableTo(new ArrayType(new NumberType()), new TupleType([new StringType(), new StringType()])), ).toBe(false); expect( - isAssignableTo(new ArrayType(new StringType()), new TupleType([new StringType(), new NumberType()])) + isAssignableTo(new ArrayType(new StringType()), new TupleType([new StringType(), new NumberType()])), ).toBe(false); }); it("lets array types to be assigned to array-like object", () => { @@ -244,25 +244,25 @@ describe("isAssignableTo", () => { "fixedLengthArrayLike", [], [new ObjectProperty("length", new LiteralType(2), true)], - false + false, ); const nonFixedLengthArrayLike = new ObjectType( "nonFixedLengthArrayLike", [], [new ObjectProperty("length", new NumberType(), true)], - false + false, ); const optionalLengthArrayLike = new ObjectType( "optionalLengthArrayLike", [], [new ObjectProperty("length", new NumberType(), false)], - false + false, ); const nonArrayLike = new ObjectType( "nonArrayLike", [], [new ObjectProperty("foo", new NumberType(), true)], - false + false, ); const arrayType = new ArrayType(new StringType()); @@ -280,59 +280,59 @@ describe("isAssignableTo", () => { }); it("lets only compatible tuple type to be assigned to tuple type", () => { expect( - isAssignableTo(new TupleType([new StringType(), new StringType()]), new ArrayType(new StringType())) + isAssignableTo(new TupleType([new StringType(), new StringType()]), new ArrayType(new StringType())), ).toBe(false); expect(isAssignableTo(new TupleType([new StringType(), new StringType()]), new StringType())).toBe(false); expect( isAssignableTo( new TupleType([new StringType(), new StringType()]), - new TupleType([new StringType(), new NumberType()]) - ) + new TupleType([new StringType(), new NumberType()]), + ), ).toBe(false); expect( isAssignableTo( new TupleType([new StringType(), new StringType()]), - new TupleType([new StringType(), new StringType()]) - ) + new TupleType([new StringType(), new StringType()]), + ), ).toBe(true); expect( isAssignableTo( new TupleType([new StringType(), new OptionalType(new StringType())]), - new TupleType([new StringType()]) - ) + new TupleType([new StringType()]), + ), ).toBe(true); expect( isAssignableTo( new TupleType([new StringType(), new OptionalType(new StringType())]), - new TupleType([new StringType(), new StringType()]) - ) + new TupleType([new StringType(), new StringType()]), + ), ).toBe(true); expect( isAssignableTo( new TupleType([new StringType(), new InferType("T")]), - new TupleType([new StringType(), new NumberType(), new StringType()]) - ) + new TupleType([new StringType(), new NumberType(), new StringType()]), + ), ).toBe(false); expect( isAssignableTo( new TupleType([new StringType(), new InferType("T")]), - new TupleType([new StringType(), new NumberType()]) - ) + new TupleType([new StringType(), new NumberType()]), + ), ).toBe(true); expect( - isAssignableTo(new TupleType([new StringType(), new InferType("T")]), new TupleType([new StringType()])) + isAssignableTo(new TupleType([new StringType(), new InferType("T")]), new TupleType([new StringType()])), ).toBe(false); expect( isAssignableTo( new TupleType([new StringType(), new RestType(new InferType("T"))]), - new TupleType([new StringType()]) - ) + new TupleType([new StringType()]), + ), ).toBe(true); expect( isAssignableTo( new TupleType([new StringType(), new RestType(new InferType("T"))]), - new TupleType([new StringType(), new NumberType(), new StringType()]) - ) + new TupleType([new StringType(), new NumberType(), new StringType()]), + ), ).toBe(true); }); it("lets anything except null and undefined to be assigned to empty object type", () => { @@ -344,7 +344,7 @@ describe("isAssignableTo", () => { expect(isAssignableTo(empty, new NeverType())).toBe(true); expect(isAssignableTo(empty, new NullType())).toBe(false); expect( - isAssignableTo(empty, new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true)) + isAssignableTo(empty, new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true)), ).toBe(true); expect(isAssignableTo(empty, new BooleanType())).toBe(true); expect(isAssignableTo(empty, new NumberType())).toBe(true); @@ -370,7 +370,7 @@ describe("isAssignableTo", () => { "a", [], [new ObjectProperty("a", new StringType(), false), new ObjectProperty("b", new StringType(), false)], - false + false, ); const typeB = new ObjectType("b", [], [new ObjectProperty("b", new StringType(), false)], false); expect(isAssignableTo(typeB, typeA)).toBe(true); @@ -394,7 +394,7 @@ describe("isAssignableTo", () => { "ab", [], [new ObjectProperty("a", new StringType(), true), new ObjectProperty("b", new StringType(), true)], - false + false, ); const aAndB = new IntersectionType([a, b]); expect(isAssignableTo(a, aAndB)).toBe(true); @@ -433,7 +433,7 @@ describe("isAssignableTo", () => { "interface-src/test.ts-0-53-src/test.ts-0-317", [], [new ObjectProperty("a", new StringType(), true)], - false + false, ); const innerDefinition = new DefinitionType("NumericValueRef", objectType); const innerUnion = new UnionType([new NumberType(), innerDefinition]); diff --git a/test/utils.ts b/test/utils.ts index cdc662d09..c0c9dd459 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -7,8 +7,8 @@ import ts from "typescript"; import { createFormatter } from "../factory/formatter"; import { createParser } from "../factory/parser"; import { createProgram } from "../factory/program"; -import { CompletedConfig, Config, DEFAULT_CONFIG } from "../src/Config"; -import { SchemaGenerator } from "../src/SchemaGenerator"; +import { CompletedConfig, Config, DEFAULT_CONFIG } from "../src/Config.js"; +import { SchemaGenerator } from "../src/SchemaGenerator.js"; const validator = new Ajv({ discriminator: true }); addFormats(validator); @@ -46,7 +46,7 @@ export function assertValidSchema( */ ajvOptions?: AjvOptions; mainTsOnly?: boolean; - } + }, ) { return (): void => { const config: CompletedConfig = { diff --git a/test/valid-data-annotations.test.ts b/test/valid-data-annotations.test.ts index 35492baa4..620772522 100644 --- a/test/valid-data-annotations.test.ts +++ b/test/valid-data-annotations.test.ts @@ -14,28 +14,28 @@ describe("valid-data-annotations", () => { "customMultilineProperty", "customUnquotedProperty", ], - }) + }), ); it( "annotation-empty-basic", - assertValidSchema("annotation-empty", "MyObject", { jsDoc: "basic", extraTags: ["customEmptyAnnotation"] }) + assertValidSchema("annotation-empty", "MyObject", { jsDoc: "basic", extraTags: ["customEmptyAnnotation"] }), ); it( "annotation-empty-extended", - assertValidSchema("annotation-empty", "MyObject", { extraTags: ["customEmptyAnnotation"] }) + assertValidSchema("annotation-empty", "MyObject", { extraTags: ["customEmptyAnnotation"] }), ); it( "annotation-deprecated-basic", - assertValidSchema("annotation-deprecated", "MyObject", { jsDoc: "basic", extraTags: ["deprecationMessage"] }) + assertValidSchema("annotation-deprecated", "MyObject", { jsDoc: "basic", extraTags: ["deprecationMessage"] }), ); it( "annotation-deprecated-extended", - assertValidSchema("annotation-deprecated", "MyObject", { extraTags: ["deprecationMessage"] }) + assertValidSchema("annotation-deprecated", "MyObject", { extraTags: ["deprecationMessage"] }), ); it( "annotation-description-override", - assertValidSchema("annotation-description-override", "MyObject", { extraTags: ["markdownDescription"] }) + assertValidSchema("annotation-description-override", "MyObject", { extraTags: ["markdownDescription"] }), ); it("annotation-comment", assertValidSchema("annotation-comment", "MyObject")); @@ -86,6 +86,6 @@ describe("valid-data-annotations", () => { it( "discriminator", - assertValidSchema("discriminator", "Animal", { jsDoc: "basic", discriminatorType: "open-api" }) + assertValidSchema("discriminator", "Animal", { jsDoc: "basic", discriminatorType: "open-api" }), ); }); diff --git a/test/valid-data-other.test.ts b/test/valid-data-other.test.ts index cfb42fa49..e54f499f2 100644 --- a/test/valid-data-other.test.ts +++ b/test/valid-data-other.test.ts @@ -17,7 +17,7 @@ describe("valid-data-other", () => { it("function-parameters-required", assertValidSchema("function-parameters-required", "myFunction")); it( "function-parameters-variable-assignment", - assertValidSchema("function-parameters-variable-assignment", "myFunction") + assertValidSchema("function-parameters-variable-assignment", "myFunction"), ); it("function-function-syntax", assertValidSchema("function-function-syntax", "myFunction")); @@ -25,11 +25,12 @@ describe("valid-data-other", () => { it("string-literals-inline", assertValidSchema("string-literals-inline", "MyObject")); it("string-literals-intrinsic", assertValidSchema("string-literals-intrinsic", "MyObject")); it("string-literals-null", assertValidSchema("string-literals-null", "MyObject")); + it("string-literals-hack", assertValidSchema("string-literals-hack", "MyObject")); it("string-template-literals", assertValidSchema("string-template-literals", "MyObject")); it("string-template-expression-literals", assertValidSchema("string-template-expression-literals", "MyObject")); it( "string-template-expression-literals-import", - assertValidSchema("string-template-expression-literals-import", "MyObject") + assertValidSchema("string-template-expression-literals-import", "MyObject"), ); it("namespace-deep-1", assertValidSchema("namespace-deep-1", "RootNamespace.Def")); @@ -85,7 +86,7 @@ describe("valid-data-other", () => { assertValidSchema("object-required", "MyObject", undefined, { ...objectRequiredSamples, ajvOptions: { $data: true }, - }) + }), ); it("re-export-with-asterisk", assertValidSchema("re-export-with-asterisk", "*", undefined, { mainTsOnly: true })); }); diff --git a/test/valid-data-struct.test.ts b/test/valid-data-struct.test.ts index 5d51c8368..0e8b7a27f 100644 --- a/test/valid-data-struct.test.ts +++ b/test/valid-data-struct.test.ts @@ -10,7 +10,7 @@ describe("valid-data-struct", () => { it("literal-object-type", assertValidSchema("literal-object-type", "MyType")); it( "literal-object-type-with-computed-props", - assertValidSchema("literal-object-type-with-computed-props", "MyType") + assertValidSchema("literal-object-type-with-computed-props", "MyType"), ); it("literal-array-type", assertValidSchema("literal-array-type", "MyType")); it("literal-index-type", assertValidSchema("literal-index-type", "MyType")); diff --git a/test/valid-data-type.test.ts b/test/valid-data-type.test.ts index 11c0a5720..d91be0ac2 100644 --- a/test/valid-data-type.test.ts +++ b/test/valid-data-type.test.ts @@ -4,7 +4,7 @@ describe("valid-data-type", () => { it("type-aliases-primitive", assertValidSchema("type-aliases-primitive", "MyString")); it( "type-aliases-primitive-with-id", - assertValidSchema("type-aliases-primitive-with-id", "MyString", { jsDoc: "none", schemaId: "testId" }) + assertValidSchema("type-aliases-primitive-with-id", "MyString", { jsDoc: "none", schemaId: "testId" }), ); it("type-aliases-object", assertValidSchema("type-aliases-object", "MyAlias")); it("type-aliases-mixed", assertValidSchema("type-aliases-mixed", "MyObject")); @@ -15,11 +15,11 @@ describe("valid-data-type", () => { it("type-aliases-recursive-export", assertValidSchema("type-aliases-recursive-export", "MyObject")); it( "type-aliases-recursive-generics-anonymous", - assertValidSchema("type-aliases-recursive-generics-anonymous", "MyAlias") + assertValidSchema("type-aliases-recursive-generics-anonymous", "MyAlias"), ); it( "type-aliases-recursive-generics-export", - assertValidSchema("type-aliases-recursive-generics-export", "MyAlias") + assertValidSchema("type-aliases-recursive-generics-export", "MyAlias"), ); it("type-aliases-tuple", assertValidSchema("type-aliases-tuple", "MyTuple")); @@ -44,19 +44,19 @@ describe("valid-data-type", () => { it("type-intersection-partial-conflict-ref", assertValidSchema("type-intersection-partial-conflict", "MyType")); it( "type-intersection-partial-conflict-union", - assertValidSchema("type-intersection-partial-conflict-union", "MyType") + assertValidSchema("type-intersection-partial-conflict-union", "MyType"), ); it( "type-intersection-partial-conflict-union-alias", - assertValidSchema("type-intersection-partial-conflict-union-alias", "MyType") + assertValidSchema("type-intersection-partial-conflict-union-alias", "MyType"), ); it( "type-intersection-recursive-interface", - assertValidSchema("type-intersection-recursive-interface", "Intersection") + assertValidSchema("type-intersection-recursive-interface", "Intersection"), ); it( "type-intersection-union-recursive-interface", - assertValidSchema("type-intersection-union-recursive-interface", "Intersection") + assertValidSchema("type-intersection-union-recursive-interface", "Intersection"), ); it("type-intersection-union", assertValidSchema("type-intersection-union", "MyObject")); it("type-intersection-union-enum", assertValidSchema("type-intersection-union-enum", "MyObject")); diff --git a/test/valid-data/annotation-comment/main.ts b/test/valid-data/annotation-comment/main.ts index 23ac0aeef..eab59bf77 100644 --- a/test/valid-data/annotation-comment/main.ts +++ b/test/valid-data/annotation-comment/main.ts @@ -5,11 +5,10 @@ export interface MyObject { /** * @comment Property comment */ - nested: MyNestedObject + nested: MyNestedObject; } /** * @comment Nested object comment */ export interface MyNestedObject {} - diff --git a/test/valid-data/annotation-example/main.ts b/test/valid-data/annotation-example/main.ts index 91a76ff0a..106537e41 100644 --- a/test/valid-data/annotation-example/main.ts +++ b/test/valid-data/annotation-example/main.ts @@ -22,7 +22,7 @@ export interface MyObject { * @example * "This string rocks" */ - nested: MyNestedObject + nested: MyNestedObject; } /** diff --git a/test/valid-data/annotation-id/main.ts b/test/valid-data/annotation-id/main.ts index 8b75ee9d6..3cdfb8123 100644 --- a/test/valid-data/annotation-id/main.ts +++ b/test/valid-data/annotation-id/main.ts @@ -2,7 +2,7 @@ * @id #MyObject */ export interface MyObject { - nested: MyNestedObject + nested: MyNestedObject; } /** diff --git a/test/valid-data/annotation-nullable-definition/main.ts b/test/valid-data/annotation-nullable-definition/main.ts index b78627f98..4728fec40 100644 --- a/test/valid-data/annotation-nullable-definition/main.ts +++ b/test/valid-data/annotation-nullable-definition/main.ts @@ -1,10 +1,10 @@ export class Definition { - name: string + name: string; } -export class MyObject { +export class MyObject { /** * @nullable */ - optional?: Definition[] + optional?: Definition[]; } diff --git a/test/valid-data/annotation-ref/main.ts b/test/valid-data/annotation-ref/main.ts index 740306ab8..6f0314b30 100644 --- a/test/valid-data/annotation-ref/main.ts +++ b/test/valid-data/annotation-ref/main.ts @@ -1,4 +1,3 @@ - export interface MyObject { /** * Nested description @@ -6,7 +5,7 @@ export interface MyObject { * @title Nested title * @ref http://json-schema.org/draft-07/schema# */ - nested: MyNestedObject + nested: MyNestedObject; /** * MyObject description diff --git a/test/valid-data/annotation-union-if-then-enum/main.ts b/test/valid-data/annotation-union-if-then-enum/main.ts index d8e9ff59c..178a374cb 100644 --- a/test/valid-data/annotation-union-if-then-enum/main.ts +++ b/test/valid-data/annotation-union-if-then-enum/main.ts @@ -1,5 +1,5 @@ -type A = { kind: "a" | "A", a: string }; -type B = { kind: "b" | "B", b: string }; +type A = { kind: "a" | "A"; a: string }; +type B = { kind: "b" | "B"; b: string }; /** * @discriminator kind diff --git a/test/valid-data/class-extra-props/main.ts b/test/valid-data/class-extra-props/main.ts index 37be7fc45..bb6b8c810 100644 --- a/test/valid-data/class-extra-props/main.ts +++ b/test/valid-data/class-extra-props/main.ts @@ -1,5 +1,5 @@ export class MyObject { public required: string; public optional?: number; - [name: string]: string|number; + [name: string]: string | number; } diff --git a/test/valid-data/class-jsdoc/main.ts b/test/valid-data/class-jsdoc/main.ts index 7f1abe4ba..329e5d4db 100644 --- a/test/valid-data/class-jsdoc/main.ts +++ b/test/valid-data/class-jsdoc/main.ts @@ -14,5 +14,8 @@ export class MyObject { * @param a Parameter a description * @param b Parameter b description */ - public constructor(public a: string, public b: number) {} + public constructor( + public a: string, + public b: number, + ) {} } diff --git a/test/valid-data/class-single/main.ts b/test/valid-data/class-single/main.ts index 628e13d7f..c66202ca8 100644 --- a/test/valid-data/class-single/main.ts +++ b/test/valid-data/class-single/main.ts @@ -24,7 +24,7 @@ export class MyObject { c: number, // Test that types can be inferred public propC = 42, - public propD?: string + public propD?: string, ) { this.privateProp = false; } diff --git a/test/valid-data/enums-member/main.ts b/test/valid-data/enums-member/main.ts index 843f59120..680359484 100644 --- a/test/valid-data/enums-member/main.ts +++ b/test/valid-data/enums-member/main.ts @@ -1,9 +1,9 @@ export enum A { - B, - C, - D, + B, + C, + D, } export interface MyObject { - code: A.B; + code: A.B; } diff --git a/test/valid-data/enums-template-literal/main.ts b/test/valid-data/enums-template-literal/main.ts index c84d3f455..be25f230b 100644 --- a/test/valid-data/enums-template-literal/main.ts +++ b/test/valid-data/enums-template-literal/main.ts @@ -5,4 +5,4 @@ enum MyEnum { export type MyObject = { prop?: `${MyEnum}`; -} +}; diff --git a/test/valid-data/function-parameters-declaration/main.ts b/test/valid-data/function-parameters-declaration/main.ts index 6a5f11e51..8d36e0b3b 100644 --- a/test/valid-data/function-parameters-declaration/main.ts +++ b/test/valid-data/function-parameters-declaration/main.ts @@ -1 +1 @@ -export function myFunction() { } +export function myFunction() {} diff --git a/test/valid-data/function-parameters-jsdoc/main.ts b/test/valid-data/function-parameters-jsdoc/main.ts index fe406a7b6..003172036 100644 --- a/test/valid-data/function-parameters-jsdoc/main.ts +++ b/test/valid-data/function-parameters-jsdoc/main.ts @@ -2,7 +2,7 @@ export const myFunction = ( /** * @description Inline parameter description */ - requiredString: string + requiredString: string, ) => { return "whatever"; }; diff --git a/test/valid-data/function-parameters-variable-assignment/main.ts b/test/valid-data/function-parameters-variable-assignment/main.ts index 49afd4949..0b70fca21 100644 --- a/test/valid-data/function-parameters-variable-assignment/main.ts +++ b/test/valid-data/function-parameters-variable-assignment/main.ts @@ -1 +1 @@ -export const myFunction = () => { } +export const myFunction = () => {}; diff --git a/test/valid-data/generic-default-conditional/main.ts b/test/valid-data/generic-default-conditional/main.ts index 665853d17..37ea64c58 100644 --- a/test/valid-data/generic-default-conditional/main.ts +++ b/test/valid-data/generic-default-conditional/main.ts @@ -1,5 +1,5 @@ export type MyObject = ConditionalGeneric; -export type ConditionalGeneric = { +export type ConditionalGeneric = { foo: T; -} +}; diff --git a/test/valid-data/generic-default/main.ts b/test/valid-data/generic-default/main.ts index efdbea35e..e9b3e7184 100644 --- a/test/valid-data/generic-default/main.ts +++ b/test/valid-data/generic-default/main.ts @@ -1,5 +1,5 @@ export type MyObject = Generic; export interface Generic { - foo: N; + foo: N; } diff --git a/test/valid-data/generic-nested/main.ts b/test/valid-data/generic-nested/main.ts index 88c030cbd..c819de3ce 100644 --- a/test/valid-data/generic-nested/main.ts +++ b/test/valid-data/generic-nested/main.ts @@ -1,11 +1,9 @@ - export interface MyArrayObjectType { a: string; b: number; c: string; } - export interface IListsable { lists: Array; } @@ -18,4 +16,4 @@ export interface IRes { foo: IListsable; } -export interface MyObject extends Partial> { } +export interface MyObject extends Partial> {} diff --git a/test/valid-data/interface-computed-property-name/main.ts b/test/valid-data/interface-computed-property-name/main.ts index 95d10330b..a9dbce823 100644 --- a/test/valid-data/interface-computed-property-name/main.ts +++ b/test/valid-data/interface-computed-property-name/main.ts @@ -1,8 +1,8 @@ import { key as importedKey, Keys } from "./module"; -const key = "localKey" +const key = "localKey"; enum LocalKeys { - Key = "localEnumKey" + Key = "localEnumKey", } export interface MyObject { diff --git a/test/valid-data/interface-extended-extra-props/main.ts b/test/valid-data/interface-extended-extra-props/main.ts index 7fce1f737..6b8f730e1 100644 --- a/test/valid-data/interface-extended-extra-props/main.ts +++ b/test/valid-data/interface-extended-extra-props/main.ts @@ -1,7 +1,7 @@ export interface MyObject extends StringMap { - param: string + param: string; } export interface StringMap { - [key: string]: any + [key: string]: any; } diff --git a/test/valid-data/interface-extra-props/main.ts b/test/valid-data/interface-extra-props/main.ts index 67fedd75a..eef42700b 100644 --- a/test/valid-data/interface-extra-props/main.ts +++ b/test/valid-data/interface-extra-props/main.ts @@ -1,5 +1,5 @@ export interface MyObject { required: string; optional?: number; - [name: string]: string|number; + [name: string]: string | number; } diff --git a/test/valid-data/interface-property-dash/main.ts b/test/valid-data/interface-property-dash/main.ts index 24e01069b..bb61fb0f0 100644 --- a/test/valid-data/interface-property-dash/main.ts +++ b/test/valid-data/interface-property-dash/main.ts @@ -1,5 +1,5 @@ export interface MyObject { - 'with-dash': string; - 'without': string; + "with-dash": string; + without: string; nodash: string; } diff --git a/test/valid-data/keyof-typeof-enum/Size.ts b/test/valid-data/keyof-typeof-enum/Size.ts index 7d009acc8..253fffd33 100644 --- a/test/valid-data/keyof-typeof-enum/Size.ts +++ b/test/valid-data/keyof-typeof-enum/Size.ts @@ -1,5 +1,5 @@ export enum Size { Small, Medium, - Large + Large, } diff --git a/test/valid-data/keyof-typeof-enum/main.ts b/test/valid-data/keyof-typeof-enum/main.ts index 1511fb5a4..292555362 100644 --- a/test/valid-data/keyof-typeof-enum/main.ts +++ b/test/valid-data/keyof-typeof-enum/main.ts @@ -2,10 +2,10 @@ import { Size } from "./Size"; enum Orientation { Horizontal, - Vertical + Vertical, } export type MyObject = { sizeName?: keyof typeof Size; orientationName?: keyof typeof Orientation; -} +}; diff --git a/test/valid-data/literal-index-type/main.ts b/test/valid-data/literal-index-type/main.ts index 9b0a15edc..d5ea715cc 100644 --- a/test/valid-data/literal-index-type/main.ts +++ b/test/valid-data/literal-index-type/main.ts @@ -1,2 +1,2 @@ const arr = ["abc", "def"]; -export type MyType = typeof arr[number]; +export type MyType = (typeof arr)[number]; diff --git a/test/valid-data/string-literals-hack/main.ts b/test/valid-data/string-literals-hack/main.ts new file mode 100644 index 000000000..81950cb8b --- /dev/null +++ b/test/valid-data/string-literals-hack/main.ts @@ -0,0 +1,15 @@ +type Union = "a" | "b"; + +export type MyObject = { + literals: "foo" | "bar"; + stringWithNull: string | null; + literalWithNull: "foo" | "bar" | null; + literalWithString: "foo" | "bar" | string; + literalWithStringAndNull: "foo" | "bar" | string | null; + withRef: "foo" | Union; + withRefWithString: Union | string; + withHack: "foo" | "bar" | (string & {}); + withHackRecord: "foo" | "bar" | (string & Record); + withHackNull: "foo" | "bar" | null | (string & Record); + hackOnLiteral: ("foo" & Record) | "bar"; +}; diff --git a/test/valid-data/string-literals-hack/schema.json b/test/valid-data/string-literals-hack/schema.json new file mode 100644 index 000000000..e2640ba69 --- /dev/null +++ b/test/valid-data/string-literals-hack/schema.json @@ -0,0 +1,122 @@ +{ + "$ref": "#/definitions/MyObject", + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "MyObject": { + "additionalProperties": false, + "properties": { + "hackOnLiteral": { + "enum": [ + "foo", + "bar" + ], + "type": "string" + }, + "literalWithNull": { + "enum": [ + "foo", + "bar", + null + ], + "type": [ + "string", + "null" + ] + }, + "literalWithString": { + "type": "string" + }, + "literalWithStringAndNull": { + "type": [ + "string", + "null" + ] + }, + "literals": { + "enum": [ + "foo", + "bar" + ], + "type": "string" + }, + "stringWithNull": { + "type": [ + "string", + "null" + ] + }, + "withHack": { + "anyOf": [ + { + "type": "string" + }, + { + "enum": [ + "foo", + "bar" + ], + "type": "string" + } + ] + }, + "withHackNull": { + "anyOf": [ + { + "type": "string" + }, + { + "enum": [ + "foo", + "bar", + null + ], + "type": [ + "string", + "null" + ] + } + ] + }, + "withHackRecord": { + "anyOf": [ + { + "type": "string" + }, + { + "enum": [ + "foo", + "bar" + ], + "type": "string" + } + ] + }, + "withRef": { + "enum": [ + "foo", + "a", + "b" + ], + "type": "string" + }, + "withRefWithString": { + "type": "string" + } + }, + "required": [ + "literals", + "stringWithNull", + "literalWithNull", + "literalWithString", + "literalWithStringAndNull", + "withRef", + "withRefWithString", + "withHack", + "withHackRecord", + "withHackNull", + "hackOnLiteral" + ], + "type": "object" + } + } +} diff --git a/test/valid-data/string-literals-inline/main.ts b/test/valid-data/string-literals-inline/main.ts index ae5d7b662..ba5241a94 100644 --- a/test/valid-data/string-literals-inline/main.ts +++ b/test/valid-data/string-literals-inline/main.ts @@ -1,4 +1,4 @@ -export interface MyObject { +export interface MyObject { foo: "ok" | "fail" | "abort"; bar: "ok" | "fail" | "abort" | string; } diff --git a/test/valid-data/string-literals-null/main.ts b/test/valid-data/string-literals-null/main.ts index dfa8cdc01..57ead798d 100644 --- a/test/valid-data/string-literals-null/main.ts +++ b/test/valid-data/string-literals-null/main.ts @@ -2,4 +2,3 @@ export interface MyObject { enum1: "a" | "b" | null; enum2: "a" | "b"; } - diff --git a/test/valid-data/string-template-expression-literals-import/main.ts b/test/valid-data/string-template-expression-literals-import/main.ts index 0bb65321e..6a6cd3ec1 100644 --- a/test/valid-data/string-template-expression-literals-import/main.ts +++ b/test/valid-data/string-template-expression-literals-import/main.ts @@ -1,4 +1,4 @@ -import { MyType } from './types'; +import { MyType } from "./types"; export interface MyObject { value: `_${MyType}`; diff --git a/test/valid-data/string-template-expression-literals-import/types.ts b/test/valid-data/string-template-expression-literals-import/types.ts index 6a0d58313..a8c80499f 100644 --- a/test/valid-data/string-template-expression-literals-import/types.ts +++ b/test/valid-data/string-template-expression-literals-import/types.ts @@ -1 +1 @@ -export type MyType = 'one' | 'two' | 'three'; +export type MyType = "one" | "two" | "three"; diff --git a/test/valid-data/structure-anonymous/main.ts b/test/valid-data/structure-anonymous/main.ts index ed70c1743..8a548f472 100644 --- a/test/valid-data/structure-anonymous/main.ts +++ b/test/valid-data/structure-anonymous/main.ts @@ -1,7 +1,7 @@ export interface MyObject { field: { subfieldA: number; - subfieldB: (string | number); + subfieldB: string | number; subfieldC: { subsubfieldA: number[]; }; diff --git a/test/valid-data/structure-extra-props/main.ts b/test/valid-data/structure-extra-props/main.ts index f26b7e17e..d175898c5 100644 --- a/test/valid-data/structure-extra-props/main.ts +++ b/test/valid-data/structure-extra-props/main.ts @@ -2,6 +2,6 @@ export interface MyObject { structure: { required: string; optional?: number; - [name: string]: string|number; + [name: string]: string | number; }; } diff --git a/test/valid-data/structure-private/main.ts b/test/valid-data/structure-private/main.ts index 0b47b758d..574235a60 100644 --- a/test/valid-data/structure-private/main.ts +++ b/test/valid-data/structure-private/main.ts @@ -1,6 +1,6 @@ interface MyPrivate { subfieldA: number; - subfieldB: (string | number); + subfieldB: string | number; subfieldC: { subsubfieldA: number[]; }; diff --git a/test/valid-data/type-aliases-local-namespace/main.ts b/test/valid-data/type-aliases-local-namespace/main.ts index d491965e9..32d577fbf 100644 --- a/test/valid-data/type-aliases-local-namespace/main.ts +++ b/test/valid-data/type-aliases-local-namespace/main.ts @@ -1,17 +1,25 @@ namespace A { - export interface A { a: any; } + export interface A { + a: any; + } } namespace B { - export interface B { b: any; } + export interface B { + b: any; + } } namespace C { import A = B.B; - export interface CC { c: A; } + export interface CC { + c: A; + } export interface C extends CC {} } namespace D { import A = C.C; - export interface D { d: A; } + export interface D { + d: A; + } } export interface MyObject extends D.D {} diff --git a/test/valid-data/type-aliases-object/main.ts b/test/valid-data/type-aliases-object/main.ts index 8eb0b6c7f..87af6f6cb 100644 --- a/test/valid-data/type-aliases-object/main.ts +++ b/test/valid-data/type-aliases-object/main.ts @@ -1,4 +1,3 @@ - export interface MyObject { number: number; string: string; diff --git a/test/valid-data/type-aliases-recursive-generics-anonymous/main.ts b/test/valid-data/type-aliases-recursive-generics-anonymous/main.ts index e6bce78a2..f7b91b810 100644 --- a/test/valid-data/type-aliases-recursive-generics-anonymous/main.ts +++ b/test/valid-data/type-aliases-recursive-generics-anonymous/main.ts @@ -1,4 +1,4 @@ -type Map = { [ key: string]: T; }; +type Map = { [key: string]: T }; export type MyAlias = { a: Map; diff --git a/test/valid-data/type-aliases-union/main.ts b/test/valid-data/type-aliases-union/main.ts index 7b984d29c..35a3a9d34 100644 --- a/test/valid-data/type-aliases-union/main.ts +++ b/test/valid-data/type-aliases-union/main.ts @@ -1,4 +1,3 @@ - type BasicArray = (string | number)[]; export interface MyObject { diff --git a/test/valid-data/type-conditional-exclude-complex/main.ts b/test/valid-data/type-conditional-exclude-complex/main.ts index bbc81b70a..d5496146f 100644 --- a/test/valid-data/type-conditional-exclude-complex/main.ts +++ b/test/valid-data/type-conditional-exclude-complex/main.ts @@ -17,7 +17,7 @@ export interface BaseAxis { } type OmitValueRef = { - [P in keyof T]?: Exclude, StringValueRef> + [P in keyof T]?: Exclude, StringValueRef>; }; export type BaseAxisNoSignals = OmitValueRef; diff --git a/test/valid-data/type-conditional-infer-tuple-xor/main.ts b/test/valid-data/type-conditional-infer-tuple-xor/main.ts index aea645ba1..81f766d07 100644 --- a/test/valid-data/type-conditional-infer-tuple-xor/main.ts +++ b/test/valid-data/type-conditional-infer-tuple-xor/main.ts @@ -7,7 +7,7 @@ type XOR = T | U extends object ? (Without & U) | (Without & T type TupleXOR = T extends [infer Only] ? Only : T extends [infer A, infer B, ...infer Rest] - ? TupleXOR<[XOR, ...Rest]> - : never; + ? TupleXOR<[XOR, ...Rest]> + : never; export type MyType = TupleXOR<[{ a: string }, { b: number }, { c: boolean }]>; diff --git a/test/valid-data/type-conditional-inheritance/main.ts b/test/valid-data/type-conditional-inheritance/main.ts index 48290207c..6de34987b 100644 --- a/test/valid-data/type-conditional-inheritance/main.ts +++ b/test/valid-data/type-conditional-inheritance/main.ts @@ -22,14 +22,19 @@ export interface F extends D { f: boolean; } -export type Map = - T extends A ? "a" : - T extends B ? "b" : - T extends C ? "c" : - T extends F ? "f" : - T extends D ? "d" : - T extends E ? "e" : - "unknown"; +export type Map = T extends A + ? "a" + : T extends B + ? "b" + : T extends C + ? "c" + : T extends F + ? "f" + : T extends D + ? "d" + : T extends E + ? "e" + : "unknown"; export type MyObject = { a: Map; diff --git a/test/valid-data/type-conditional-intersection/main.ts b/test/valid-data/type-conditional-intersection/main.ts index f7db9ca0d..eb69e82e2 100644 --- a/test/valid-data/type-conditional-intersection/main.ts +++ b/test/valid-data/type-conditional-intersection/main.ts @@ -12,13 +12,17 @@ interface D extends A, B { d: string; } -type Map = - T extends D ? "D" : - T extends A & B ? "a and b" : - T extends A ? "a" : - T extends B ? "b" : - T extends C ? "c" : - "unknown"; +type Map = T extends D + ? "D" + : T extends A & B + ? "a and b" + : T extends A + ? "a" + : T extends B + ? "b" + : T extends C + ? "c" + : "unknown"; export type MyObject = { a: Map; diff --git a/test/valid-data/type-conditional-narrowing/main.ts b/test/valid-data/type-conditional-narrowing/main.ts index c3fcd0e09..f92d2bab3 100644 --- a/test/valid-data/type-conditional-narrowing/main.ts +++ b/test/valid-data/type-conditional-narrowing/main.ts @@ -1,7 +1,4 @@ -type TypeName = - T extends string ? "string" : - T extends number ? "number" : - "unknown"; +type TypeName = T extends string ? "string" : T extends number ? "number" : "unknown"; export type MyObject = { string: TypeName; @@ -10,4 +7,4 @@ export type MyObject = { unknown?: TypeName; stringOrUnknown?: TypeName; numberOrUnknown?: TypeName; -} +}; diff --git a/test/valid-data/type-conditional-simple/main.ts b/test/valid-data/type-conditional-simple/main.ts index df0e446fb..7641a8419 100644 --- a/test/valid-data/type-conditional-simple/main.ts +++ b/test/valid-data/type-conditional-simple/main.ts @@ -1,7 +1,4 @@ -type TypeName = - T extends string ? "string" : - T extends number ? "number" : - "unknown"; +type TypeName = T extends string ? "string" : T extends number ? "number" : "unknown"; export type MyObject = { a: TypeName; diff --git a/test/valid-data/type-conditional-tuple-narrowing/main.ts b/test/valid-data/type-conditional-tuple-narrowing/main.ts index 2a6f0ecbf..0599b47db 100644 --- a/test/valid-data/type-conditional-tuple-narrowing/main.ts +++ b/test/valid-data/type-conditional-tuple-narrowing/main.ts @@ -1,9 +1,7 @@ -type SecondElementType = T extends { length: 3 } ? - T[1] : - unknown; +type SecondElementType = T extends { length: 3 } ? T[1] : unknown; export type MyObject = { string: SecondElementType<[number, string, boolean]>; - booleanOrNumber: SecondElementType<[string, boolean, string] | [number, number, boolean] >; + booleanOrNumber: SecondElementType<[string, boolean, string] | [number, number, boolean]>; unknown?: SecondElementType; -} +}; diff --git a/test/valid-data/type-conditional-union/main.ts b/test/valid-data/type-conditional-union/main.ts index 482bb5427..0be325233 100644 --- a/test/valid-data/type-conditional-union/main.ts +++ b/test/valid-data/type-conditional-union/main.ts @@ -10,9 +10,7 @@ interface C { c: string; } -type Map = - T extends (A | B) ? "a or b" : - "unknown"; +type Map = T extends A | B ? "a or b" : "unknown"; export type MyObject = { a: Map; diff --git a/test/valid-data/type-date-annotation/main.ts b/test/valid-data/type-date-annotation/main.ts index 4e2f7508d..281fe4a98 100644 --- a/test/valid-data/type-date-annotation/main.ts +++ b/test/valid-data/type-date-annotation/main.ts @@ -2,12 +2,12 @@ export interface MyObject { /** * @examples ["2020-01-01T00:00:00.000Z"] */ - defaultFormat: Date + defaultFormat: Date; /** * @format time * @examples ["12:00:00"] */ - time: Date + time: Date; /** * @format date */ diff --git a/test/valid-data/type-date/main.ts b/test/valid-data/type-date/main.ts index 155f833f3..08701de3f 100644 --- a/test/valid-data/type-date/main.ts +++ b/test/valid-data/type-date/main.ts @@ -1,4 +1,4 @@ -type MyDate = Date +type MyDate = Date; export interface MyObject { date: Date; diff --git a/test/valid-data/type-indexed-access-object-1/main.ts b/test/valid-data/type-indexed-access-object-1/main.ts index cfaedd7f3..9ffc11f1c 100644 --- a/test/valid-data/type-indexed-access-object-1/main.ts +++ b/test/valid-data/type-indexed-access-object-1/main.ts @@ -3,5 +3,5 @@ interface SomeObject { def?: "bar"; } -const obj: SomeObject = {abc: "foo"}; +const obj: SomeObject = { abc: "foo" }; export type MyType = typeof obj.abc; diff --git a/test/valid-data/type-indexed-access-object-2/main.ts b/test/valid-data/type-indexed-access-object-2/main.ts index 4b31180f2..7a5764ba8 100644 --- a/test/valid-data/type-indexed-access-object-2/main.ts +++ b/test/valid-data/type-indexed-access-object-2/main.ts @@ -3,5 +3,5 @@ interface SomeObject { def?: "bar"; } -const obj: SomeObject = {abc: "foo"}; -export type MyType = typeof obj["def"]; +const obj: SomeObject = { abc: "foo" }; +export type MyType = (typeof obj)["def"]; diff --git a/test/valid-data/type-indexed-access-tuple-1/main.ts b/test/valid-data/type-indexed-access-tuple-1/main.ts index 4c8354047..29a1d6f57 100644 --- a/test/valid-data/type-indexed-access-tuple-1/main.ts +++ b/test/valid-data/type-indexed-access-tuple-1/main.ts @@ -1,2 +1,2 @@ const arr: ["foo", "bar"] = ["foo", "bar"]; -export type MyType = typeof arr[0]; +export type MyType = (typeof arr)[0]; diff --git a/test/valid-data/type-indexed-access-tuple-2/main.ts b/test/valid-data/type-indexed-access-tuple-2/main.ts index 2bf623e97..39dba1c83 100644 --- a/test/valid-data/type-indexed-access-tuple-2/main.ts +++ b/test/valid-data/type-indexed-access-tuple-2/main.ts @@ -1,2 +1,2 @@ const arr: ["foo", "bar"] = ["foo", "bar"]; -export type MyType = typeof arr[1]; +export type MyType = (typeof arr)[1]; diff --git a/test/valid-data/type-indexed-access-tuple-union/main.ts b/test/valid-data/type-indexed-access-tuple-union/main.ts index 8d6688c0e..8a914198a 100644 --- a/test/valid-data/type-indexed-access-tuple-union/main.ts +++ b/test/valid-data/type-indexed-access-tuple-union/main.ts @@ -1,2 +1,2 @@ -type FormLayouts = [ "horizontal", "inline", "vertical" ]; +type FormLayouts = ["horizontal", "inline", "vertical"]; export type FormLayout = FormLayouts[number]; diff --git a/test/valid-data/type-indexed-circular-access/main.ts b/test/valid-data/type-indexed-circular-access/main.ts index 22577fb7f..9d603bb84 100644 --- a/test/valid-data/type-indexed-circular-access/main.ts +++ b/test/valid-data/type-indexed-circular-access/main.ts @@ -1,12 +1,15 @@ -type Alpha = { stringProp: string; betaStringProp: Beta['stringProp']; } -type TypedAlphaWithDefault = { tProp: T; betaStringProp: Beta['stringProp']; } -type TypedAlphaWithoutDefault = { tProp: T; eProp: E; betaStringProp: Beta['stringProp']; } +type Alpha = { stringProp: string; betaStringProp: Beta["stringProp"] }; +type TypedAlphaWithDefault = { tProp: T; betaStringProp: Beta["stringProp"] }; +type TypedAlphaWithoutDefault = { tProp: T; eProp: E; betaStringProp: Beta["stringProp"] }; export type Beta = { stringProp: string; - alphaStringProp: Alpha['stringProp']; - alphaNumberDefaultProp: TypedAlphaWithDefault["tProp"] - alphaNumberWithoutDefaultProp: TypedAlphaWithoutDefault["tProp"] - alphaUnionProp: TypedAlphaWithoutDefault["tProp" | "eProp"] - alphaKeyofProp: TypedAlphaWithoutDefault[keyof TypedAlphaWithoutDefault] -} + alphaStringProp: Alpha["stringProp"]; + alphaNumberDefaultProp: TypedAlphaWithDefault["tProp"]; + alphaNumberWithoutDefaultProp: TypedAlphaWithoutDefault["tProp"]; + alphaUnionProp: TypedAlphaWithoutDefault["tProp" | "eProp"]; + alphaKeyofProp: TypedAlphaWithoutDefault[keyof TypedAlphaWithoutDefault< + number | null, + string + >]; +}; diff --git a/test/valid-data/type-intersection-partial-conflict-union-alias/main.ts b/test/valid-data/type-intersection-partial-conflict-union-alias/main.ts index c942bcb77..34f0e46f7 100644 --- a/test/valid-data/type-intersection-partial-conflict-union-alias/main.ts +++ b/test/valid-data/type-intersection-partial-conflict-union-alias/main.ts @@ -1,15 +1,15 @@ -type X = 'a' | 'b' +type X = "a" | "b"; type Foo = { - foo: X -} + foo: X; +}; export type A = Foo & { - foo: 'a' -} + foo: "a"; +}; export type B = Foo & { - foo: 'b' -} + foo: "b"; +}; -export type MyType = A | B +export type MyType = A | B; diff --git a/test/valid-data/type-intersection-partial-conflict-union/main.ts b/test/valid-data/type-intersection-partial-conflict-union/main.ts index e7441c644..6c118d799 100644 --- a/test/valid-data/type-intersection-partial-conflict-union/main.ts +++ b/test/valid-data/type-intersection-partial-conflict-union/main.ts @@ -1,13 +1,13 @@ type Foo = { - foo: 'a' | 'b' -} + foo: "a" | "b"; +}; export type A = Foo & { - foo: 'a' -} + foo: "a"; +}; export type B = Foo & { - foo: 'b' -} + foo: "b"; +}; -export type MyType = A | B +export type MyType = A | B; diff --git a/test/valid-data/type-intersection-union-enum/main.ts b/test/valid-data/type-intersection-union-enum/main.ts index 3f4eb3d44..c9e7e4999 100644 --- a/test/valid-data/type-intersection-union-enum/main.ts +++ b/test/valid-data/type-intersection-union-enum/main.ts @@ -2,6 +2,6 @@ type type1 = "foo" | "bar"; type type2 = type1 | "moo"; export type MyObject = { - field1: type1, - field2: type2, -} + field1: type1; + field2: type2; +}; diff --git a/test/valid-data/type-intersection/main.ts b/test/valid-data/type-intersection/main.ts index 8c31e419c..f8dc7008a 100644 --- a/test/valid-data/type-intersection/main.ts +++ b/test/valid-data/type-intersection/main.ts @@ -10,7 +10,8 @@ export interface Type3 { } export interface MyObject { - value: Type1 & Type2 & { - foo: Type3; - }; + value: Type1 & + Type2 & { + foo: Type3; + }; } diff --git a/test/valid-data/type-keyof-object-function/main.ts b/test/valid-data/type-keyof-object-function/main.ts index d19b6d005..0eb6d3b7d 100644 --- a/test/valid-data/type-keyof-object-function/main.ts +++ b/test/valid-data/type-keyof-object-function/main.ts @@ -1,3 +1,3 @@ export type MyType = keyof { - "key": () => number; + key: () => number; }; diff --git a/test/valid-data/type-keyof-tuple/main.ts b/test/valid-data/type-keyof-tuple/main.ts index 0c4a3d32f..4ea078a6f 100644 --- a/test/valid-data/type-keyof-tuple/main.ts +++ b/test/valid-data/type-keyof-tuple/main.ts @@ -1,6 +1,3 @@ -type SomeTuple = [ - 12, - "baz" -]; +type SomeTuple = [12, "baz"]; export type MyType = keyof SomeTuple; diff --git a/test/valid-data/type-mapped-additional-props/main.ts b/test/valid-data/type-mapped-additional-props/main.ts index 106463ed5..209d1a1a4 100644 --- a/test/valid-data/type-mapped-additional-props/main.ts +++ b/test/valid-data/type-mapped-additional-props/main.ts @@ -1,5 +1,5 @@ export interface Test { - [ name: string ]: string; + [name: string]: string; } export type WithNumbers = { diff --git a/test/valid-data/type-mapped-enum-null/main.ts b/test/valid-data/type-mapped-enum-null/main.ts index ac897a705..312704931 100644 --- a/test/valid-data/type-mapped-enum-null/main.ts +++ b/test/valid-data/type-mapped-enum-null/main.ts @@ -1,5 +1,5 @@ enum Test { - A = null + A = null, } export type MyObject = { diff --git a/test/valid-data/type-mapped-enum-optional/main.ts b/test/valid-data/type-mapped-enum-optional/main.ts index 7f6c1e4b5..1c03457f0 100644 --- a/test/valid-data/type-mapped-enum-optional/main.ts +++ b/test/valid-data/type-mapped-enum-optional/main.ts @@ -1,7 +1,7 @@ enum Test { - A = 'a', - B = 'b', - C = 'c', + A = "a", + B = "b", + C = "c", } export type MyObject = { diff --git a/test/valid-data/type-mapped-enum/main.ts b/test/valid-data/type-mapped-enum/main.ts index 0ca1e59fa..ecf15243d 100644 --- a/test/valid-data/type-mapped-enum/main.ts +++ b/test/valid-data/type-mapped-enum/main.ts @@ -1,7 +1,7 @@ enum Test { - A = 'a', - B = 'b', - C = 'c', + A = "a", + B = "b", + C = "c", } export type MyObject = { diff --git a/test/valid-data/type-maps/main.ts b/test/valid-data/type-maps/main.ts index c65be9f36..55866f51c 100644 --- a/test/valid-data/type-maps/main.ts +++ b/test/valid-data/type-maps/main.ts @@ -5,7 +5,7 @@ export interface MyMap1 { } export interface MyMap2 { - [id: string]: (string | number); + [id: string]: string | number; } export interface MyObject { diff --git a/test/valid-data/type-recursive-deep-exclude/main.ts b/test/valid-data/type-recursive-deep-exclude/main.ts index c4ccf4529..5ce29e124 100644 --- a/test/valid-data/type-recursive-deep-exclude/main.ts +++ b/test/valid-data/type-recursive-deep-exclude/main.ts @@ -1,8 +1,8 @@ type DeepExclude = T extends U ? never : T extends object - ? { - [K in keyof T]: DeepExclude; - } - : T; + ? { + [K in keyof T]: DeepExclude; + } + : T; export type MyType = DeepExclude; diff --git a/test/valid-data/type-regexp/main.ts b/test/valid-data/type-regexp/main.ts index 965cd5543..37e5093de 100644 --- a/test/valid-data/type-regexp/main.ts +++ b/test/valid-data/type-regexp/main.ts @@ -1,4 +1,4 @@ -type MyRegExp = RegExp +type MyRegExp = RegExp; export interface MyObject { regexp: RegExp; diff --git a/test/valid-data/type-typeof-class-static-property/main.ts b/test/valid-data/type-typeof-class-static-property/main.ts index 78a59a5a0..037f0cc38 100644 --- a/test/valid-data/type-typeof-class-static-property/main.ts +++ b/test/valid-data/type-typeof-class-static-property/main.ts @@ -1,5 +1,5 @@ class Foo { - static bar = "foo" + static bar = "foo"; } export type MyType = typeof Foo.bar; diff --git a/test/valid-data/type-typeof-enum/main.ts b/test/valid-data/type-typeof-enum/main.ts index e0d52855f..23700d3a5 100644 --- a/test/valid-data/type-typeof-enum/main.ts +++ b/test/valid-data/type-typeof-enum/main.ts @@ -1,14 +1,14 @@ enum FromZero { a, b, - c + c, } enum SomeCustomInitializers { a = 10, b, c = 20, - d + d, } enum StringEnum { @@ -20,7 +20,7 @@ enum MixedEnum { a, b = 10, c, - d = "foo" + d = "foo", } export type MyObject = { @@ -28,4 +28,4 @@ export type MyObject = { someCustomInitializers: typeof SomeCustomInitializers; stringEnum: typeof StringEnum; mixedEnum: typeof MixedEnum; -} +}; diff --git a/test/valid-data/type-typeof-keys/main.ts b/test/valid-data/type-typeof-keys/main.ts index 3fb33ff4c..1fd3d8800 100644 --- a/test/valid-data/type-typeof-keys/main.ts +++ b/test/valid-data/type-typeof-keys/main.ts @@ -6,4 +6,4 @@ const IDX = { export const keys = Object.keys as (o: T) => Extract[]; export const Foo = keys(IDX); -export type MyType = typeof Foo[number]; +export type MyType = (typeof Foo)[number]; diff --git a/test/valid-data/type-union/main.ts b/test/valid-data/type-union/main.ts index 9f034814f..231f4ff21 100644 --- a/test/valid-data/type-union/main.ts +++ b/test/valid-data/type-union/main.ts @@ -3,7 +3,7 @@ type MyType2 = string | number[]; type MyType3 = (string | number)[]; type MyType4 = "s" | 1; -type MyType5 = "s" | (1)[]; +type MyType5 = "s" | 1[]; type MyType6 = ("s" | 1)[]; export interface TypeUnion { diff --git a/test/valid-data/type-uri/main.ts b/test/valid-data/type-uri/main.ts index 249b299cc..ea03ef2c8 100644 --- a/test/valid-data/type-uri/main.ts +++ b/test/valid-data/type-uri/main.ts @@ -1,4 +1,4 @@ -type MyURL = URL +type MyURL = URL; export interface MyObject { url: URL; diff --git a/test/valid-data/undefined-property/main.ts b/test/valid-data/undefined-property/main.ts index 3a4abf245..9fb5b083b 100644 --- a/test/valid-data/undefined-property/main.ts +++ b/test/valid-data/undefined-property/main.ts @@ -1,5 +1,5 @@ export type MyType = { - a: undefined, - b: null, - c: undefined | string, + a: undefined; + b: null; + c: undefined | string; }; diff --git a/test/valid-data/unique-symbol/main.ts b/test/valid-data/unique-symbol/main.ts index 5df32e106..afb1259e5 100644 --- a/test/valid-data/unique-symbol/main.ts +++ b/test/valid-data/unique-symbol/main.ts @@ -1,7 +1,7 @@ // An explicitly typed unique symbol -const Foo: unique symbol = Symbol('foo'); +const Foo: unique symbol = Symbol("foo"); // A unique symbol using type inference -const Bar = Symbol('bar'); +const Bar = Symbol("bar"); export interface MyObject { foo: typeof Foo; diff --git a/test/vega-lite.test.ts b/test/vega-lite.test.ts index e3f6173b2..e6ea64947 100644 --- a/test/vega-lite.test.ts +++ b/test/vega-lite.test.ts @@ -1,6 +1,6 @@ import { readFileSync, writeFileSync } from "fs"; import { resolve } from "path"; -import { CompletedConfig, DEFAULT_CONFIG } from "../src/Config"; +import { CompletedConfig, DEFAULT_CONFIG } from "../src/Config.js"; import { createGenerator } from "./utils"; import stringify from "safe-stable-stringify"; diff --git a/test/vega-lite/schema.json b/test/vega-lite/schema.json index a0a64b449..b5aef98f9 100644 --- a/test/vega-lite/schema.json +++ b/test/vega-lite/schema.json @@ -4428,46 +4428,37 @@ ] }, "BinnedTimeUnit": { - "anyOf": [ - { - "enum": [ - "binnedyear", - "binnedyearquarter", - "binnedyearquartermonth", - "binnedyearmonth", - "binnedyearmonthdate", - "binnedyearmonthdatehours", - "binnedyearmonthdatehoursminutes", - "binnedyearmonthdatehoursminutesseconds", - "binnedyearweek", - "binnedyearweekday", - "binnedyearweekdayhours", - "binnedyearweekdayhoursminutes", - "binnedyearweekdayhoursminutesseconds", - "binnedyeardayofyear" - ], - "type": "string" - }, - { - "enum": [ - "binnedutcyear", - "binnedutcyearquarter", - "binnedutcyearquartermonth", - "binnedutcyearmonth", - "binnedutcyearmonthdate", - "binnedutcyearmonthdatehours", - "binnedutcyearmonthdatehoursminutes", - "binnedutcyearmonthdatehoursminutesseconds", - "binnedutcyearweek", - "binnedutcyearweekday", - "binnedutcyearweekdayhours", - "binnedutcyearweekdayhoursminutes", - "binnedutcyearweekdayhoursminutesseconds", - "binnedutcyeardayofyear" - ], - "type": "string" - } - ] + "enum": [ + "binnedyear", + "binnedyearquarter", + "binnedyearquartermonth", + "binnedyearmonth", + "binnedyearmonthdate", + "binnedyearmonthdatehours", + "binnedyearmonthdatehoursminutes", + "binnedyearmonthdatehoursminutesseconds", + "binnedyearweek", + "binnedyearweekday", + "binnedyearweekdayhours", + "binnedyearweekdayhoursminutes", + "binnedyearweekdayhoursminutesseconds", + "binnedyeardayofyear", + "binnedutcyear", + "binnedutcyearquarter", + "binnedutcyearquartermonth", + "binnedutcyearmonth", + "binnedutcyearmonthdate", + "binnedutcyearmonthdatehours", + "binnedutcyearmonthdatehoursminutes", + "binnedutcyearmonthdatehoursminutesseconds", + "binnedutcyearweek", + "binnedutcyearweekday", + "binnedutcyearweekdayhours", + "binnedutcyearweekdayhoursminutes", + "binnedutcyearweekdayhoursminutesseconds", + "binnedutcyeardayofyear" + ], + "type": "string" }, "Blend": { "enum": [ @@ -19228,29 +19219,9 @@ "type": "object" }, "ParseValue": { - "anyOf": [ - { - "type": "null" - }, - { - "type": "string" - }, - { - "const": "string", - "type": "string" - }, - { - "const": "boolean", - "type": "string" - }, - { - "const": "date", - "type": "string" - }, - { - "const": "number", - "type": "string" - } + "type": [ + "string", + "null" ] }, "PivotTransform": { diff --git a/ts-json-schema-generator.ts b/ts-json-schema-generator.ts index afc31143e..bdfc59bdf 100644 --- a/ts-json-schema-generator.ts +++ b/ts-json-schema-generator.ts @@ -1,10 +1,10 @@ import { Command, Option } from "commander"; import stableStringify from "safe-stable-stringify"; -import { createGenerator } from "./factory/generator"; -import { Config } from "./src/Config"; -import { BaseError } from "./src/Error/BaseError"; -import { formatError } from "./src/Utils/formatError"; -import * as pkg from "./package.json"; +import { createGenerator } from "./factory/generator.js"; +import { Config } from "./src/Config.js"; +import { BaseError } from "./src/Error/BaseError.js"; +import { formatError } from "./src/Utils/formatError.js"; +import pkg from "./package.json" assert { type: "json" }; import { dirname } from "path"; import { mkdirSync, writeFileSync } from "fs"; @@ -14,26 +14,26 @@ const args = new Command() .option("-i, --id ", "$id for generated schema") .option("-f, --tsconfig ", "Custom tsconfig.json path") .addOption( - new Option("-e, --expose ", "Type exposing").choices(["all", "none", "export"]).default("export") + new Option("-e, --expose ", "Type exposing").choices(["all", "none", "export"]).default("export"), ) .addOption( new Option("-j, --jsDoc ", "Read JsDoc annotations") .choices(["none", "basic", "extended"]) - .default("extended") + .default("extended"), ) .addOption( new Option("--markdown-description", "Generate `markdownDescription` in addition to `description`.").implies({ jsDoc: "extended", - }) + }), ) .addOption( new Option( "--functions ", - // eslint-disable-next-line max-len - "How to handle functions. `fail` will throw an error. `comment` will add a comment. `hide` will treat the function like a NeverType or HiddenType." + + "How to handle functions. `fail` will throw an error. `comment` will add a comment. `hide` will treat the function like a NeverType or HiddenType.", ) .choices(["fail", "comment", "hide"]) - .default("comment") + .default("comment"), ) .option("--minify", "Minify generated schema", false) .option("--unstable", "Do not sort properties") @@ -46,7 +46,7 @@ const args = new Command() "--validation-keywords [value]", "Provide additional validation keywords to include", (value: string, list: string[]) => list.concat(value), - [] + [], ) .option("--additional-properties", "Allow additional properties for objects with no index signature", false) .version(pkg.version) diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json new file mode 100644 index 000000000..5298e95c5 --- /dev/null +++ b/tsconfig.eslint.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "include": ["src/**/*.ts", "factory/**/*.ts", "test/**/*.test.ts", "test/utils.ts"] +} diff --git a/tsconfig.json b/tsconfig.json index 96eff1922..6d82b123a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { - "target": "es2019", - "module": "commonjs", - "moduleResolution": "node", + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "Node16", "esModuleInterop": true, "isolatedModules": false, "experimentalDecorators": true, @@ -25,6 +25,6 @@ "incremental": true }, "files": ["ts-json-schema-generator.ts", "index.ts"], - "include": ["./src/**/*.ts", "./factory/**/*.ts", "./test/**.ts"], + "include": ["src/**/*.ts", "factory/**/*.ts"], "exclude": ["node_modules", "dist"] } diff --git a/yarn.lock b/yarn.lock index c24f4852b..8e97a05af 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1149,6 +1149,121 @@ ts-node "^9" tslib "^2" +"@esbuild/aix-ppc64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.19.12.tgz#d1bc06aedb6936b3b6d313bf809a5a40387d2b7f" + integrity sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA== + +"@esbuild/android-arm64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.19.12.tgz#7ad65a36cfdb7e0d429c353e00f680d737c2aed4" + integrity sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA== + +"@esbuild/android-arm@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.19.12.tgz#b0c26536f37776162ca8bde25e42040c203f2824" + integrity sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w== + +"@esbuild/android-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.19.12.tgz#cb13e2211282012194d89bf3bfe7721273473b3d" + integrity sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew== + +"@esbuild/darwin-arm64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz#cbee41e988020d4b516e9d9e44dd29200996275e" + integrity sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g== + +"@esbuild/darwin-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.19.12.tgz#e37d9633246d52aecf491ee916ece709f9d5f4cd" + integrity sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A== + +"@esbuild/freebsd-arm64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.12.tgz#1ee4d8b682ed363b08af74d1ea2b2b4dbba76487" + integrity sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA== + +"@esbuild/freebsd-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.19.12.tgz#37a693553d42ff77cd7126764b535fb6cc28a11c" + integrity sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg== + +"@esbuild/linux-arm64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.19.12.tgz#be9b145985ec6c57470e0e051d887b09dddb2d4b" + integrity sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA== + +"@esbuild/linux-arm@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.19.12.tgz#207ecd982a8db95f7b5279207d0ff2331acf5eef" + integrity sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w== + +"@esbuild/linux-ia32@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.19.12.tgz#d0d86b5ca1562523dc284a6723293a52d5860601" + integrity sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA== + +"@esbuild/linux-loong64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.19.12.tgz#9a37f87fec4b8408e682b528391fa22afd952299" + integrity sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA== + +"@esbuild/linux-mips64el@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.19.12.tgz#4ddebd4e6eeba20b509d8e74c8e30d8ace0b89ec" + integrity sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w== + +"@esbuild/linux-ppc64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.19.12.tgz#adb67dadb73656849f63cd522f5ecb351dd8dee8" + integrity sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg== + +"@esbuild/linux-riscv64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.19.12.tgz#11bc0698bf0a2abf8727f1c7ace2112612c15adf" + integrity sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg== + +"@esbuild/linux-s390x@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.19.12.tgz#e86fb8ffba7c5c92ba91fc3b27ed5a70196c3cc8" + integrity sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg== + +"@esbuild/linux-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.19.12.tgz#5f37cfdc705aea687dfe5dfbec086a05acfe9c78" + integrity sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg== + +"@esbuild/netbsd-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.19.12.tgz#29da566a75324e0d0dd7e47519ba2f7ef168657b" + integrity sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA== + +"@esbuild/openbsd-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.19.12.tgz#306c0acbdb5a99c95be98bdd1d47c916e7dc3ff0" + integrity sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw== + +"@esbuild/sunos-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.19.12.tgz#0933eaab9af8b9b2c930236f62aae3fc593faf30" + integrity sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA== + +"@esbuild/win32-arm64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.19.12.tgz#773bdbaa1971b36db2f6560088639ccd1e6773ae" + integrity sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A== + +"@esbuild/win32-ia32@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.19.12.tgz#000516cad06354cc84a73f0943a4aa690ef6fd67" + integrity sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ== + +"@esbuild/win32-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz#c57c8afbb4054a3ab8317591a0b7320360b444ae" + integrity sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA== + "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": version "4.4.0" resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" @@ -1161,32 +1276,32 @@ resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.10.0.tgz#548f6de556857c8bb73bbee70c35dc82a2e74d63" integrity sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA== -"@eslint/eslintrc@^2.1.4": - version "2.1.4" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.4.tgz#388a269f0f25c1b6adc317b5a2c55714894c70ad" - integrity sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ== +"@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== dependencies: ajv "^6.12.4" debug "^4.3.2" - espree "^9.6.0" - globals "^13.19.0" + espree "^10.0.1" + globals "^14.0.0" ignore "^5.2.0" import-fresh "^3.2.1" js-yaml "^4.1.0" minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/js@8.57.0": - version "8.57.0" - resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.0.tgz#a5417ae8427873f1dd08b70b3574b453e67b5f7f" - integrity sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g== +"@eslint/js@9.0.0", "@eslint/js@^9.0.0": + version "9.0.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.0.0.tgz#1a9e4b4c96d8c7886e0110ed310a0135144a1691" + integrity sha512-RThY/MnKrhubF6+s1JflwUjPEsnCEmYCWwqa/aRISKWNXGZ9epUwft4bUMM35SdKF9xvBrLydAM1RDHd1Z//ZQ== -"@humanwhocodes/config-array@^0.11.14": - version "0.11.14" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b" - integrity sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg== +"@humanwhocodes/config-array@^0.12.3": + version "0.12.3" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.12.3.tgz#a6216d90f81a30bedd1d4b5d799b47241f318072" + integrity sha512-jsNnTBlMWuTpDkeE3on7+dWJi0D6fdDfeANj/w7MpS8ztROCoLvIO2nG0CcFj+E4k8j4QrSTh4Oryi3i2G669g== dependencies: - "@humanwhocodes/object-schema" "^2.0.2" + "@humanwhocodes/object-schema" "^2.0.3" debug "^4.3.1" minimatch "^3.0.5" @@ -1195,7 +1310,7 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA== -"@humanwhocodes/object-schema@^2.0.2": +"@humanwhocodes/object-schema@^2.0.3": version "2.0.3" resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz#4a2868d75d6d6963e423bcf90b7fd1be343409d3" integrity sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA== @@ -1205,6 +1320,18 @@ resolved "https://registry.yarnpkg.com/@hutson/parse-repository-url/-/parse-repository-url-3.0.2.tgz#98c23c950a3d9b6c8f0daed06da6c3af06981340" integrity sha512-H9XAx3hc0BQHY6l+IFSWHDySypcXsvsuLhgYLUGywmJ5pswRVQJUHpOsobnLYp2ZUaUlKiKDrgWWhosOwAEM8Q== +"@isaacs/cliui@^8.0.2": + version "8.0.2" + resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" + integrity sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA== + dependencies: + string-width "^5.1.2" + string-width-cjs "npm:string-width@^4.2.0" + strip-ansi "^7.0.1" + strip-ansi-cjs "npm:strip-ansi@^6.0.1" + wrap-ansi "^8.1.0" + wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" + "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -1599,6 +1726,11 @@ dependencies: "@octokit/openapi-types" "^12.11.0" +"@pkgjs/parseargs@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" + integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== + "@pkgr/core@^0.1.0": version "0.1.1" resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31" @@ -1686,7 +1818,15 @@ resolved "https://registry.yarnpkg.com/@types/command-line-usage/-/command-line-usage-5.0.4.tgz#374e4c62d78fbc5a670a0f36da10235af879a0d5" integrity sha512-BwR5KP3Es/CSht0xqBcUXS3qCAUVXwpRKsV2+arxeb65atasuXG9LykC9Ab10Cw3s2raH92ZqOeILaQbsB2ACg== -"@types/estree@^1.0.0": +"@types/eslint@^8.56.9": + version "8.56.9" + resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.56.9.tgz#403e9ced04a34e63f1c383c5b8ee1a94442c8cc4" + integrity sha512-W4W3KcqzjJ0sHg2vAq9vfml6OhsJ53TcUjUqfzzZf/EChUtwspszj/S0pzMxnfRcO55/iGq47dscXw71Fxc4Zg== + dependencies: + "@types/estree" "*" + "@types/json-schema" "*" + +"@types/estree@*", "@types/estree@^1.0.0": version "1.0.5" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== @@ -1738,7 +1878,7 @@ expect "^29.0.0" pretty-format "^29.0.0" -"@types/json-schema@^7.0.15": +"@types/json-schema@*", "@types/json-schema@^7.0.15": version "7.0.15" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== @@ -1797,16 +1937,16 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.6.0.tgz#1f5df5cda490a0bcb6fbdd3382e19f1241024242" - integrity sha512-gKmTNwZnblUdnTIJu3e9kmeRRzV2j1a/LUO27KNNAnIC5zjy1aSvXSRp4rVNlmAoHlQ7HzX42NbKpcSr4jF80A== +"@typescript-eslint/eslint-plugin@7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.7.0.tgz#bf34a02f221811505b8bf2f31060c8560c1bb0a3" + integrity sha512-GJWR0YnfrKnsRoluVO3PRb9r5aMZriiMMM/RHj5nnTrBy1/wIgk76XCtCKcnXGjpZQJQRFtGV9/0JJ6n30uwpQ== dependencies: "@eslint-community/regexpp" "^4.10.0" - "@typescript-eslint/scope-manager" "7.6.0" - "@typescript-eslint/type-utils" "7.6.0" - "@typescript-eslint/utils" "7.6.0" - "@typescript-eslint/visitor-keys" "7.6.0" + "@typescript-eslint/scope-manager" "7.7.0" + "@typescript-eslint/type-utils" "7.7.0" + "@typescript-eslint/utils" "7.7.0" + "@typescript-eslint/visitor-keys" "7.7.0" debug "^4.3.4" graphemer "^1.4.0" ignore "^5.3.1" @@ -1814,47 +1954,47 @@ semver "^7.6.0" ts-api-utils "^1.3.0" -"@typescript-eslint/parser@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.6.0.tgz#0aca5de3045d68b36e88903d15addaf13d040a95" - integrity sha512-usPMPHcwX3ZoPWnBnhhorc14NJw9J4HpSXQX4urF2TPKG0au0XhJoZyX62fmvdHONUkmyUe74Hzm1//XA+BoYg== +"@typescript-eslint/parser@7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.7.0.tgz#6b1b3ce76c5de002c43af8ae933613b0f2b4bcc6" + integrity sha512-fNcDm3wSwVM8QYL4HKVBggdIPAy9Q41vcvC/GtDobw3c4ndVT3K6cqudUmjHPw8EAp4ufax0o58/xvWaP2FmTg== dependencies: - "@typescript-eslint/scope-manager" "7.6.0" - "@typescript-eslint/types" "7.6.0" - "@typescript-eslint/typescript-estree" "7.6.0" - "@typescript-eslint/visitor-keys" "7.6.0" + "@typescript-eslint/scope-manager" "7.7.0" + "@typescript-eslint/types" "7.7.0" + "@typescript-eslint/typescript-estree" "7.7.0" + "@typescript-eslint/visitor-keys" "7.7.0" debug "^4.3.4" -"@typescript-eslint/scope-manager@7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-7.6.0.tgz#1e9972f654210bd7500b31feadb61a233f5b5e9d" - integrity sha512-ngttyfExA5PsHSx0rdFgnADMYQi+Zkeiv4/ZxGYUWd0nLs63Ha0ksmp8VMxAIC0wtCFxMos7Lt3PszJssG/E6w== +"@typescript-eslint/scope-manager@7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-7.7.0.tgz#3f0db079b275bb8b0cb5be7613fb3130cfb5de77" + integrity sha512-/8INDn0YLInbe9Wt7dK4cXLDYp0fNHP5xKLHvZl3mOT5X17rK/YShXaiNmorl+/U4VKCVIjJnx4Ri5b0y+HClw== dependencies: - "@typescript-eslint/types" "7.6.0" - "@typescript-eslint/visitor-keys" "7.6.0" + "@typescript-eslint/types" "7.7.0" + "@typescript-eslint/visitor-keys" "7.7.0" -"@typescript-eslint/type-utils@7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-7.6.0.tgz#644f75075f379827d25fe0713e252ccd4e4a428c" - integrity sha512-NxAfqAPNLG6LTmy7uZgpK8KcuiS2NZD/HlThPXQRGwz6u7MDBWRVliEEl1Gj6U7++kVJTpehkhZzCJLMK66Scw== +"@typescript-eslint/type-utils@7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-7.7.0.tgz#36792ff4209a781b058de61631a48df17bdefbc5" + integrity sha512-bOp3ejoRYrhAlnT/bozNQi3nio9tIgv3U5C0mVDdZC7cpcQEDZXvq8inrHYghLVwuNABRqrMW5tzAv88Vy77Sg== dependencies: - "@typescript-eslint/typescript-estree" "7.6.0" - "@typescript-eslint/utils" "7.6.0" + "@typescript-eslint/typescript-estree" "7.7.0" + "@typescript-eslint/utils" "7.7.0" debug "^4.3.4" ts-api-utils "^1.3.0" -"@typescript-eslint/types@7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.6.0.tgz#53dba7c30c87e5f10a731054266dd905f1fbae38" - integrity sha512-h02rYQn8J+MureCvHVVzhl69/GAfQGPQZmOMjG1KfCl7o3HtMSlPaPUAPu6lLctXI5ySRGIYk94clD/AUMCUgQ== +"@typescript-eslint/types@7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.7.0.tgz#23af4d24bf9ce15d8d301236e3e3014143604f27" + integrity sha512-G01YPZ1Bd2hn+KPpIbrAhEWOn5lQBrjxkzHkWvP6NucMXFtfXoevK82hzQdpfuQYuhkvFDeQYbzXCjR1z9Z03w== -"@typescript-eslint/typescript-estree@7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.6.0.tgz#112a3775563799fd3f011890ac8322f80830ac17" - integrity sha512-+7Y/GP9VuYibecrCQWSKgl3GvUM5cILRttpWtnAu8GNL9j11e4tbuGZmZjJ8ejnKYyBRb2ddGQ3rEFCq3QjMJw== +"@typescript-eslint/typescript-estree@7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.7.0.tgz#b5dd6383b4c6a852d7b256a37af971e8982be97f" + integrity sha512-8p71HQPE6CbxIBy2kWHqM1KGrC07pk6RJn40n0DSc6bMOBBREZxSDJ+BmRzc8B5OdaMh1ty3mkuWRg4sCFiDQQ== dependencies: - "@typescript-eslint/types" "7.6.0" - "@typescript-eslint/visitor-keys" "7.6.0" + "@typescript-eslint/types" "7.7.0" + "@typescript-eslint/visitor-keys" "7.7.0" debug "^4.3.4" globby "^11.1.0" is-glob "^4.0.3" @@ -1862,32 +2002,27 @@ semver "^7.6.0" ts-api-utils "^1.3.0" -"@typescript-eslint/utils@7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.6.0.tgz#e400d782280b6f724c8a1204269d984c79202282" - integrity sha512-x54gaSsRRI+Nwz59TXpCsr6harB98qjXYzsRxGqvA5Ue3kQH+FxS7FYU81g/omn22ML2pZJkisy6Q+ElK8pBCA== +"@typescript-eslint/utils@7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.7.0.tgz#3d2b6606a60ac34f3c625facfb3b3ab7e126f58d" + integrity sha512-LKGAXMPQs8U/zMRFXDZOzmMKgFv3COlxUQ+2NMPhbqgVm6R1w+nU1i4836Pmxu9jZAuIeyySNrN/6Rc657ggig== dependencies: "@eslint-community/eslint-utils" "^4.4.0" "@types/json-schema" "^7.0.15" "@types/semver" "^7.5.8" - "@typescript-eslint/scope-manager" "7.6.0" - "@typescript-eslint/types" "7.6.0" - "@typescript-eslint/typescript-estree" "7.6.0" + "@typescript-eslint/scope-manager" "7.7.0" + "@typescript-eslint/types" "7.7.0" + "@typescript-eslint/typescript-estree" "7.7.0" semver "^7.6.0" -"@typescript-eslint/visitor-keys@7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-7.6.0.tgz#d1ce13145844379021e1f9bd102c1d78946f4e76" - integrity sha512-4eLB7t+LlNUmXzfOu1VAIAdkjbu5xNSerURS9X/S5TUKWFRpXRQZbmtPqgKmYx8bj3J0irtQXSiWAOY82v+cgw== +"@typescript-eslint/visitor-keys@7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-7.7.0.tgz#950148cf1ac11562a2d903fdf7acf76714a2dc9e" + integrity sha512-h0WHOj8MhdhY8YWkzIF30R379y0NqyOHExI9N9KCzvmu05EgG4FumeYa3ccfKUSphyWkWQE1ybVrgz/Pbam6YA== dependencies: - "@typescript-eslint/types" "7.6.0" + "@typescript-eslint/types" "7.7.0" eslint-visitor-keys "^3.4.3" -"@ungap/structured-clone@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406" - integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ== - JSONStream@^1.0.4: version "1.3.5" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" @@ -1906,7 +2041,7 @@ acorn-walk@^8.1.1: resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.2.tgz#7703af9415f1b6db9315d6895503862e231d34aa" integrity sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A== -acorn@^8.4.1, acorn@^8.9.0: +acorn@^8.11.3, acorn@^8.4.1: version "8.11.3" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== @@ -1967,6 +2102,11 @@ ansi-regex@^5.0.1: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== +ansi-regex@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" + integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== + ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" @@ -1986,6 +2126,11 @@ ansi-styles@^5.0.0: resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== +ansi-styles@^6.1.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" + integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== + anymatch@^3.0.3: version "3.1.3" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" @@ -2565,7 +2710,7 @@ cross-env@^7.0.3: dependencies: cross-spawn "^7.0.1" -cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3: +cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== @@ -2842,18 +2987,16 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" -doctrine@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" - integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== - dependencies: - esutils "^2.0.2" - dotenv@^8.0.0: version "8.6.0" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.6.0.tgz#061af664d19f7f4d8fc6e4ff9b584ce237adcb8b" integrity sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g== +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== + electron-to-chromium@^1.4.668: version "1.4.736" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.736.tgz#ecb4348f4d5c70fb1e31c347e5bad6b751066416" @@ -2869,6 +3012,11 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== +emoji-regex@^9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== + endent@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/endent/-/endent-2.1.0.tgz#5aaba698fb569e5e18e69e1ff7a28ff35373cd88" @@ -2998,6 +3146,35 @@ es-to-primitive@^1.2.1: is-date-object "^1.0.1" is-symbol "^1.0.2" +esbuild@~0.19.10: + version "0.19.12" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.19.12.tgz#dc82ee5dc79e82f5a5c3b4323a2a641827db3e04" + integrity sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg== + optionalDependencies: + "@esbuild/aix-ppc64" "0.19.12" + "@esbuild/android-arm" "0.19.12" + "@esbuild/android-arm64" "0.19.12" + "@esbuild/android-x64" "0.19.12" + "@esbuild/darwin-arm64" "0.19.12" + "@esbuild/darwin-x64" "0.19.12" + "@esbuild/freebsd-arm64" "0.19.12" + "@esbuild/freebsd-x64" "0.19.12" + "@esbuild/linux-arm" "0.19.12" + "@esbuild/linux-arm64" "0.19.12" + "@esbuild/linux-ia32" "0.19.12" + "@esbuild/linux-loong64" "0.19.12" + "@esbuild/linux-mips64el" "0.19.12" + "@esbuild/linux-ppc64" "0.19.12" + "@esbuild/linux-riscv64" "0.19.12" + "@esbuild/linux-s390x" "0.19.12" + "@esbuild/linux-x64" "0.19.12" + "@esbuild/netbsd-x64" "0.19.12" + "@esbuild/openbsd-x64" "0.19.12" + "@esbuild/sunos-x64" "0.19.12" + "@esbuild/win32-arm64" "0.19.12" + "@esbuild/win32-ia32" "0.19.12" + "@esbuild/win32-x64" "0.19.12" + escalade@^3.1.1: version "3.1.2" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.2.tgz#54076e9ab29ea5bf3d8f1ed62acffbb88272df27" @@ -3031,54 +3208,55 @@ eslint-plugin-prettier@^5.1.3: prettier-linter-helpers "^1.0.0" synckit "^0.8.6" -eslint-scope@^7.2.2: - version "7.2.2" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.2.2.tgz#deb4f92563390f32006894af62a22dba1c46423f" - integrity sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg== +eslint-scope@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-8.0.1.tgz#a9601e4b81a0b9171657c343fb13111688963cfc" + integrity sha512-pL8XjgP4ZOmmwfFE8mEhSxA7ZY4C+LWyqjQ3o4yWkkmD0qcMT9kkW3zWHOczhWcjTSgqycYAgwSlXvZltv65og== dependencies: esrecurse "^4.3.0" estraverse "^5.2.0" -eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4.3: +eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.3: version "3.4.3" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== -eslint@^8.55.0: - version "8.57.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.57.0.tgz#c786a6fd0e0b68941aaf624596fb987089195668" - integrity sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ== +eslint-visitor-keys@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz#e3adc021aa038a2a8e0b2f8b0ce8f66b9483b1fb" + integrity sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw== + +eslint@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.0.0.tgz#6270548758e390343f78c8afd030566d86927d40" + integrity sha512-IMryZ5SudxzQvuod6rUdIUz29qFItWx281VhtFVc2Psy/ZhlCeD/5DT6lBIJ4H3G+iamGJoTln1v+QSuPw0p7Q== dependencies: "@eslint-community/eslint-utils" "^4.2.0" "@eslint-community/regexpp" "^4.6.1" - "@eslint/eslintrc" "^2.1.4" - "@eslint/js" "8.57.0" - "@humanwhocodes/config-array" "^0.11.14" + "@eslint/eslintrc" "^3.0.2" + "@eslint/js" "9.0.0" + "@humanwhocodes/config-array" "^0.12.3" "@humanwhocodes/module-importer" "^1.0.1" "@nodelib/fs.walk" "^1.2.8" - "@ungap/structured-clone" "^1.2.0" ajv "^6.12.4" chalk "^4.0.0" cross-spawn "^7.0.2" debug "^4.3.2" - doctrine "^3.0.0" escape-string-regexp "^4.0.0" - eslint-scope "^7.2.2" - eslint-visitor-keys "^3.4.3" - espree "^9.6.1" + eslint-scope "^8.0.1" + eslint-visitor-keys "^4.0.0" + espree "^10.0.1" esquery "^1.4.2" esutils "^2.0.2" fast-deep-equal "^3.1.3" - file-entry-cache "^6.0.1" + file-entry-cache "^8.0.0" find-up "^5.0.0" glob-parent "^6.0.2" - globals "^13.19.0" graphemer "^1.4.0" ignore "^5.2.0" imurmurhash "^0.1.4" is-glob "^4.0.0" is-path-inside "^3.0.3" - js-yaml "^4.1.0" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.4.1" lodash.merge "^4.6.2" @@ -3088,14 +3266,14 @@ eslint@^8.55.0: strip-ansi "^6.0.1" text-table "^0.2.0" -espree@^9.6.0, espree@^9.6.1: - version "9.6.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" - integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ== +espree@^10.0.1: + version "10.0.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-10.0.1.tgz#600e60404157412751ba4a6f3a2ee1a42433139f" + integrity sha512-MWkrWZbJsL2UwnjxTX3gG8FneachS/Mwg7tdGXce011sJd5b0JG54vat5KHnfSBODZ3Wvzd2WnjxyzsRoVv+ww== dependencies: - acorn "^8.9.0" + acorn "^8.11.3" acorn-jsx "^5.3.2" - eslint-visitor-keys "^3.4.1" + eslint-visitor-keys "^4.0.0" esprima@^4.0.0: version "4.0.1" @@ -3214,12 +3392,12 @@ figures@^2.0.0: dependencies: escape-string-regexp "^1.0.5" -file-entry-cache@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" - integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== +file-entry-cache@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-8.0.0.tgz#7787bddcf1131bffb92636c69457bbc0edd6d81f" + integrity sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ== dependencies: - flat-cache "^3.0.4" + flat-cache "^4.0.0" fill-range@^7.0.1: version "7.0.1" @@ -3258,14 +3436,13 @@ find-up@^5.0.0: locate-path "^6.0.0" path-exists "^4.0.0" -flat-cache@^3.0.4: - version "3.2.0" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.2.0.tgz#2c0c2d5040c99b1632771a9d105725c0115363ee" - integrity sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw== +flat-cache@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-4.0.1.tgz#0ece39fcb14ee012f4b0410bd33dd9c1f011127c" + integrity sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw== dependencies: flatted "^3.2.9" - keyv "^4.5.3" - rimraf "^3.0.2" + keyv "^4.5.4" flatted@^3.2.9: version "3.3.1" @@ -3279,6 +3456,14 @@ for-each@^0.3.3: dependencies: is-callable "^1.1.3" +foreground-child@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.1.1.tgz#1d173e776d75d2772fed08efe4a0de1ea1b12d0d" + integrity sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg== + dependencies: + cross-spawn "^7.0.0" + signal-exit "^4.0.1" + fp-ts@^2.5.3: version "2.16.5" resolved "https://registry.yarnpkg.com/fp-ts/-/fp-ts-2.16.5.tgz#d79b97168aeafcf9612f18bbc017f513ecb20ac9" @@ -3294,7 +3479,7 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -fsevents@^2.3.2: +fsevents@^2.3.2, fsevents@~2.3.3: version "2.3.3" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== @@ -3382,6 +3567,13 @@ get-symbol-description@^1.0.2: es-errors "^1.3.0" get-intrinsic "^1.2.4" +get-tsconfig@^4.7.2: + version "4.7.3" + resolved "https://registry.yarnpkg.com/get-tsconfig/-/get-tsconfig-4.7.3.tgz#0498163d98f7b58484dd4906999c0c9d5f103f83" + integrity sha512-ZvkrzoUA0PQZM6fy6+/Hce561s+faD1rsNwhnO5FelNjyy7EMGJ3Rz1AQ8GYDWjhRs/7dBLOEJvhK8MiEJOAFg== + dependencies: + resolve-pkg-maps "^1.0.0" + git-raw-commits@^2.0.8: version "2.0.11" resolved "https://registry.yarnpkg.com/git-raw-commits/-/git-raw-commits-2.0.11.tgz#bc3576638071d18655e1cc60d7f524920008d723" @@ -3438,6 +3630,17 @@ glob-parent@^6.0.2: dependencies: is-glob "^4.0.3" +glob@^10.3.12: + version "10.3.12" + resolved "https://registry.yarnpkg.com/glob/-/glob-10.3.12.tgz#3a65c363c2e9998d220338e88a5f6ac97302960b" + integrity sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg== + dependencies: + foreground-child "^3.1.0" + jackspeak "^2.3.6" + minimatch "^9.0.1" + minipass "^7.0.4" + path-scurry "^1.10.2" + glob@^7.1.2, glob@^7.1.3, glob@^7.1.4: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" @@ -3450,28 +3653,15 @@ glob@^7.1.2, glob@^7.1.3, glob@^7.1.4: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^8.0.3: - version "8.1.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-8.1.0.tgz#d388f656593ef708ee3e34640fdfb99a9fd1c33e" - integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^5.0.1" - once "^1.3.0" - globals@^11.1.0: version "11.12.0" resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== -globals@^13.19.0: - version "13.24.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.24.0.tgz#8432a19d78ce0c1e833949c36adb345400bb1171" - integrity sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ== - dependencies: - type-fest "^0.20.2" +globals@^14.0.0: + version "14.0.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e" + integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ== globalthis@^1.0.3: version "1.0.3" @@ -3944,6 +4134,15 @@ istanbul-reports@^3.1.3: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0" +jackspeak@^2.3.6: + version "2.3.6" + resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-2.3.6.tgz#647ecc472238aee4b06ac0e461acc21a8c505ca8" + integrity sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ== + dependencies: + "@isaacs/cliui" "^8.0.2" + optionalDependencies: + "@pkgjs/parseargs" "^0.11.0" + java-properties@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/java-properties/-/java-properties-1.0.2.tgz#ccd1fa73907438a5b5c38982269d0e771fe78211" @@ -4397,7 +4596,7 @@ jsonparse@^1.2.0: resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" integrity sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg== -keyv@^4.5.3: +keyv@^4.5.4: version "4.5.4" resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" integrity sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw== @@ -4514,6 +4713,11 @@ loupe@^3.1.0: dependencies: get-func-name "^2.0.1" +lru-cache@^10.2.0: + version "10.2.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.0.tgz#0bd445ca57363465900f4d1f9bd8db343a4d95c3" + integrity sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q== + lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" @@ -4614,14 +4818,7 @@ minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: dependencies: brace-expansion "^1.1.7" -minimatch@^5.0.1: - version "5.1.6" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.6.tgz#1cfcb8cf5522ea69952cd2af95ae09477f122a96" - integrity sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g== - dependencies: - brace-expansion "^2.0.1" - -minimatch@^9.0.4: +minimatch@^9.0.1, minimatch@^9.0.4: version "9.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.4.tgz#8e49c731d1749cbec05050ee5145147b32496a51" integrity sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw== @@ -4642,6 +4839,11 @@ minimist@^1.2.0, minimist@^1.2.5: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== +"minipass@^5.0.0 || ^6.0.2 || ^7.0.0", minipass@^7.0.4: + version "7.0.4" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.0.4.tgz#dbce03740f50a4786ba994c1fb908844d27b038c" + integrity sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ== + mkdirp@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" @@ -4908,6 +5110,14 @@ path-parse@^1.0.5, path-parse@^1.0.7: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== +path-scurry@^1.10.2: + version "1.10.2" + resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.10.2.tgz#8f6357eb1239d5fa1da8b9f70e9c080675458ba7" + integrity sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA== + dependencies: + lru-cache "^10.2.0" + minipass "^5.0.0 || ^6.0.2 || ^7.0.0" + path-type@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" @@ -5228,6 +5438,11 @@ resolve-from@^5.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== +resolve-pkg-maps@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz#616b3dc2c57056b5588c31cdf4b3d64db133720f" + integrity sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw== + resolve.exports@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-2.0.2.tgz#f8c934b8e6a13f539e38b7098e2e36134f01e800" @@ -5254,13 +5469,6 @@ reusify@^1.0.4: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - robust-predicates@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/robust-predicates/-/robust-predicates-3.0.2.tgz#d5b28528c4824d20fc48df1928d41d9efa1ad771" @@ -5383,6 +5591,11 @@ signal-exit@^3.0.3, signal-exit@^3.0.7: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== +signal-exit@^4.0.1: + version "4.1.0" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" + integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== + signale@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/signale/-/signale-1.4.0.tgz#c4be58302fb0262ac00fc3d886a7c113759042f1" @@ -5488,6 +5701,15 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" @@ -5497,6 +5719,15 @@ string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.1" +string-width@^5.0.1, string-width@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== + dependencies: + eastasianwidth "^0.2.0" + emoji-regex "^9.2.2" + strip-ansi "^7.0.1" + string.prototype.trim@^1.2.9: version "1.2.9" resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.2.9.tgz#b6fa326d72d2c78b6df02f7759c73f8f6274faa4" @@ -5539,6 +5770,13 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" @@ -5546,6 +5784,13 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1: dependencies: ansi-regex "^5.0.1" +strip-ansi@^7.0.1: + version "7.1.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" + integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== + dependencies: + ansi-regex "^6.0.1" + strip-bom@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" @@ -5726,7 +5971,7 @@ ts-api-utils@^1.3.0: resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.3.0.tgz#4b490e27129f1e8e686b45cc4ab63714dc60eea1" integrity sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ== -ts-node@^10.9.1, ts-node@^10.9.2: +ts-node@^10.9.1: version "10.9.2" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f" integrity sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ== @@ -5772,6 +6017,16 @@ tslib@^2, tslib@^2.5.0, tslib@^2.6.2, tslib@~2.6.2: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== +tsx@^4.7.2: + version "4.7.2" + resolved "https://registry.yarnpkg.com/tsx/-/tsx-4.7.2.tgz#a108b1a6e16876cd4c9a4b4ba263f2a07f9cf562" + integrity sha512-BCNd4kz6fz12fyrgCTEdZHGJ9fWTGeUzXmQysh0RVocDY3h4frk05ZNCXSy4kIenF7y/QnrdiVpTsyNRn6vlAw== + dependencies: + esbuild "~0.19.10" + get-tsconfig "^4.7.2" + optionalDependencies: + fsevents "~2.3.3" + type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" @@ -5789,11 +6044,6 @@ type-fest@^0.18.0: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.18.1.tgz#db4bc151a4a2cf4eebf9add5db75508db6cc841f" integrity sha512-OIAYXk8+ISY+qTOwkHtKqzAuxchoMiD9Udx+FSGQDuiRR+PJKJHc2NJAXlbhkGwTt/4/nKZxELY1w3ReWOL8mw== -type-fest@^0.20.2: - version "0.20.2" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" - integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== - type-fest@^0.21.1, type-fest@^0.21.3: version "0.21.3" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" @@ -5853,12 +6103,21 @@ typed-array-length@^1.0.6: is-typed-array "^1.1.13" possible-typed-array-names "^1.0.0" +typescript-eslint@^7.7.0: + version "7.7.0" + resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-7.7.0.tgz#b755e350dad25bb1e5b3826d11daa973dc0970ac" + integrity sha512-wZZ+7mTQJCn4mGAvzdERtL4vwKGM/mF9cMSMeKUllz3Hgbd1Mdd5L60Q+nJmCio9RB4OyMMr0EX4Ry2Q7jiAyw== + dependencies: + "@typescript-eslint/eslint-plugin" "7.7.0" + "@typescript-eslint/parser" "7.7.0" + "@typescript-eslint/utils" "7.7.0" + typescript-memoize@^1.0.0-alpha.3: version "1.1.1" resolved "https://registry.yarnpkg.com/typescript-memoize/-/typescript-memoize-1.1.1.tgz#02737495d5df6ebf72c07ba0d002e8f4cf5ccfa0" integrity sha512-GQ90TcKpIH4XxYTI2F98yEQYZgjNMOGPpOgdjIBhaLaWji5HPWlRnZ4AeA1hfBxtY7bCGDJsqDDHk/KaHOl5bA== -typescript@~5.4.5: +typescript@^5.4.5: version "5.4.5" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.5.tgz#42ccef2c571fdbd0f6718b1d1f5e6e5ef006f611" integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ== @@ -6370,6 +6629,15 @@ wordwrapjs@^4.0.0: reduce-flatten "^2.0.0" typical "^5.2.0" +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" @@ -6379,6 +6647,15 @@ wrap-ansi@^7.0.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" + integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== + dependencies: + ansi-styles "^6.1.0" + string-width "^5.0.1" + strip-ansi "^7.0.1" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"