From 413110065d79a4999e400fdf93355f0fa36c4a78 Mon Sep 17 00:00:00 2001 From: Danielo Rodriguez Date: Wed, 3 Jul 2024 21:01:05 +0200 Subject: [PATCH] WIP: typescript types are working, jest refuses --- package-lock.json | 86 +++++++++++++---------------- package.json | 8 +-- src/core/template/templateParser.ts | 12 ++-- src/std/index.ts | 6 +- tsconfig.json | 3 +- 5 files changed, 52 insertions(+), 63 deletions(-) diff --git a/package-lock.json b/package-lock.json index 764a8f68..c7b37629 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-modal-form", - "version": "1.46.0", + "version": "1.48.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-modal-form", - "version": "1.46.0", + "version": "1.48.0", "license": "MIT", "dependencies": { "fp-ts": "^2.16.1", @@ -17,7 +17,7 @@ }, "devDependencies": { "@stylistic/eslint-plugin": "^1.4.1", - "@tsconfig/svelte": "^5.0.2", + "@tsconfig/svelte": "^5.0.4", "@types/jest": "^29.5.6", "@types/node": "^16.11.6", "@typescript-eslint/eslint-plugin": "^6.7.0", @@ -33,12 +33,12 @@ "prettier": "^3.0.3", "prettier-plugin-svelte": "^3.0.3", "svelte": "^4.2.0", - "svelte-check": "^3.5.2", + "svelte-check": "^3.8.4", "svelte-preprocess": "^5.0.4", - "ts-jest": "^29.1.1", + "ts-jest": "^29.1.5", "ts-node": "^10.9.1", "tslib": "2.4.0", - "typescript": "^5.2.2", + "typescript": "^5.5.3", "yaml": "^2.3.3" } }, @@ -1885,9 +1885,9 @@ "dev": true }, "node_modules/@tsconfig/svelte": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/@tsconfig/svelte/-/svelte-5.0.2.tgz", - "integrity": "sha512-BRbo1fOtyVbhfLyuCWw6wAWp+U8UQle+ZXu84MYYWzYSEB28dyfnRBIE99eoG+qdAC0po6L2ScIEivcT07UaMA==", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/svelte/-/svelte-5.0.4.tgz", + "integrity": "sha512-BV9NplVgLmSi4mwKzD8BD/NQ8erOY/nUE/GpgWe2ckx+wIQF5RyRirn/QsSSCPeulVpc3RA/iJt6DpfTIZps0Q==", "dev": true }, "node_modules/@types/babel__core": { @@ -3904,6 +3904,7 @@ "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, + "peer": true, "dependencies": { "parent-module": "^1.0.0", "resolve-from": "^4.0.0" @@ -4860,15 +4861,12 @@ } }, "node_modules/magic-string": { - "version": "0.30.3", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.3.tgz", - "integrity": "sha512-B7xGbll2fG/VjP+SWg4sX3JynwIU0mjoTc6MPpKNuIvftk6u6vqhDnk1R80b8C2GBR6ywqy+1DcKBrevBg+bmw==", + "version": "0.30.10", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.10.tgz", + "integrity": "sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ==", "dev": true, "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.15" - }, - "engines": { - "node": ">=12" } }, "node_modules/make-dir": { @@ -5150,6 +5148,7 @@ "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, + "peer": true, "dependencies": { "callsites": "^3.0.0" }, @@ -5535,6 +5534,7 @@ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true, + "peer": true, "engines": { "node": ">=4" } @@ -5897,54 +5897,52 @@ } }, "node_modules/svelte-check": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-3.5.2.tgz", - "integrity": "sha512-5a/YWbiH4c+AqAUP+0VneiV5bP8YOk9JL3jwvN+k2PEPLgpu85bjQc5eE67+eIZBBwUEJzmO3I92OqKcqbp3fw==", + "version": "3.8.4", + "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-3.8.4.tgz", + "integrity": "sha512-61aHMkdinWyH8BkkTX9jPLYxYzaAAz/FK/VQqdr2FiCQQ/q04WCwDlpGbHff1GdrMYTmW8chlTFvRWL9k0A8vg==", "dev": true, "dependencies": { "@jridgewell/trace-mapping": "^0.3.17", "chokidar": "^3.4.1", - "fast-glob": "^3.2.7", - "import-fresh": "^3.2.1", "picocolors": "^1.0.0", "sade": "^1.7.4", - "svelte-preprocess": "^5.0.4", + "svelte-preprocess": "^5.1.3", "typescript": "^5.0.3" }, "bin": { "svelte-check": "bin/svelte-check" }, "peerDependencies": { - "svelte": "^3.55.0 || ^4.0.0-next.0 || ^4.0.0" + "svelte": "^3.55.0 || ^4.0.0-next.0 || ^4.0.0 || ^5.0.0-next.0" } }, "node_modules/svelte-preprocess": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/svelte-preprocess/-/svelte-preprocess-5.0.4.tgz", - "integrity": "sha512-ABia2QegosxOGsVlsSBJvoWeXy1wUKSfF7SWJdTjLAbx/Y3SrVevvvbFNQqrSJw89+lNSsM58SipmZJ5SRi5iw==", + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/svelte-preprocess/-/svelte-preprocess-5.1.4.tgz", + "integrity": "sha512-IvnbQ6D6Ao3Gg6ftiM5tdbR6aAETwjhHV+UKGf5bHGYR69RQvF1ho0JKPcbUON4vy4R7zom13jPjgdOWCQ5hDA==", "dev": true, "hasInstallScript": true, "dependencies": { "@types/pug": "^2.0.6", "detect-indent": "^6.1.0", - "magic-string": "^0.27.0", + "magic-string": "^0.30.5", "sorcery": "^0.11.0", "strip-indent": "^3.0.0" }, "engines": { - "node": ">= 14.10.0" + "node": ">= 16.0.0" }, "peerDependencies": { "@babel/core": "^7.10.2", "coffeescript": "^2.5.1", "less": "^3.11.3 || ^4.0.0", "postcss": "^7 || ^8", - "postcss-load-config": "^2.1.0 || ^3.0.0 || ^4.0.0", + "postcss-load-config": "^2.1.0 || ^3.0.0 || ^4.0.0 || ^5.0.0", "pug": "^3.0.0", "sass": "^1.26.8", "stylus": "^0.55.0", "sugarss": "^2.0.0 || ^3.0.0 || ^4.0.0", - "svelte": "^3.23.0 || ^4.0.0-next.0 || ^4.0.0", + "svelte": "^3.23.0 || ^4.0.0-next.0 || ^4.0.0 || ^5.0.0-next.0", "typescript": ">=3.9.5 || ^4.0.0 || ^5.0.0" }, "peerDependenciesMeta": { @@ -5980,18 +5978,6 @@ } } }, - "node_modules/svelte-preprocess/node_modules/magic-string": { - "version": "0.27.0", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.27.0.tgz", - "integrity": "sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA==", - "dev": true, - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.4.13" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", @@ -6053,9 +6039,9 @@ } }, "node_modules/ts-jest": { - "version": "29.1.1", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz", - "integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==", + "version": "29.1.5", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.5.tgz", + "integrity": "sha512-UuClSYxM7byvvYfyWdFI+/2UxMmwNyJb0NPkZPQE2hew3RurV7l7zURgOHAd/1I1ZdPpe3GUsXNXAcN8TFKSIg==", "dev": true, "dependencies": { "bs-logger": "0.x", @@ -6071,10 +6057,11 @@ "ts-jest": "cli.js" }, "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + "node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0" }, "peerDependencies": { "@babel/core": ">=7.0.0-beta.0 <8", + "@jest/transform": "^29.0.0", "@jest/types": "^29.0.0", "babel-jest": "^29.0.0", "jest": "^29.0.0", @@ -6084,6 +6071,9 @@ "@babel/core": { "optional": true }, + "@jest/transform": { + "optional": true + }, "@jest/types": { "optional": true }, @@ -6199,9 +6189,9 @@ } }, "node_modules/typescript": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", - "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", + "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index 85138119..ea99189c 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "license": "MIT", "devDependencies": { "@stylistic/eslint-plugin": "^1.4.1", - "@tsconfig/svelte": "^5.0.2", + "@tsconfig/svelte": "^5.0.4", "@types/jest": "^29.5.6", "@types/node": "^16.11.6", "@typescript-eslint/eslint-plugin": "^6.7.0", @@ -33,12 +33,12 @@ "prettier": "^3.0.3", "prettier-plugin-svelte": "^3.0.3", "svelte": "^4.2.0", - "svelte-check": "^3.5.2", + "svelte-check": "^3.8.4", "svelte-preprocess": "^5.0.4", - "ts-jest": "^29.1.1", + "ts-jest": "^29.1.5", "ts-node": "^10.9.1", "tslib": "2.4.0", - "typescript": "^5.2.2", + "typescript": "^5.5.3", "yaml": "^2.3.3" }, "dependencies": { diff --git a/src/core/template/templateParser.ts b/src/core/template/templateParser.ts index 2a601981..e47c400a 100644 --- a/src/core/template/templateParser.ts +++ b/src/core/template/templateParser.ts @@ -1,15 +1,15 @@ -import * as R from "fp-ts/Record"; +import { Either, O, pipe } from "@std"; +import * as A from "fp-ts/Array"; import * as E from "fp-ts/Either"; +import * as R from "fp-ts/Record"; +import { absurd, identity } from "fp-ts/function"; import * as St from "fp-ts/string"; +import { stringifyYaml } from "obsidian"; import * as P from "parser-ts/Parser"; import * as C from "parser-ts/char"; import * as S from "parser-ts/string"; -import * as A from "fp-ts/Array"; -import { Either, O, pipe } from "@std"; -import { TemplateText, TemplateVariable, FrontmatterCommand } from "./templateSchema"; -import { absurd, identity } from "fp-ts/function"; import { ModalFormData } from "../FormResult"; -import { stringifyYaml } from "obsidian"; +import type { FrontmatterCommand, TemplateText, TemplateVariable } from "./templateSchema"; type Token = TemplateText | TemplateVariable | FrontmatterCommand; export type ParsedTemplate = Token[]; diff --git a/src/std/index.ts b/src/std/index.ts index 8d8fea1f..2dab344f 100644 --- a/src/std/index.ts +++ b/src/std/index.ts @@ -84,10 +84,8 @@ export type ParsingFn = ( * Concatenates two parsing functions that return Either into one. * If the first function returns a Right, the second function is not called. */ -class _EFunSemigroup - implements Semigroup> -{ - concat(f: ParsingFn, g: ParsingFn): (i: unknown) => Either { +class _EFunSemigroup implements Semigroup> { + concat(f: ParsingFn, g: ParsingFn): (i: unknown) => Either { return (i) => { const fRes = f(i); if (isRight(fRes)) return fRes; diff --git a/tsconfig.json b/tsconfig.json index 85d3af87..c9bcebdb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -95,6 +95,7 @@ ] }, "include": [ - "src/**/*" + "src/**/*", + "jest.config.ts" ] }