From 30de5b942378f0b73ea95004a19a05a96d445b38 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Thu, 17 Mar 2022 11:53:53 +0300 Subject: [PATCH] fix: declarations --- .gitignore | 1 + lib/index.d.mts | 3 --- lib/index.d.ts | 3 +++ lib/{lang.d.mts => lang.d.ts} | 0 lib/{nodes.d.mts => nodes.d.ts} | 2 +- lib/{str.d.mts => str.d.ts} | 4 ++-- lib/{types.d.mts => types.d.ts} | 2 +- makefile | 7 +++++-- package.json | 2 +- scripts/fix_decl.sh | 6 ++++++ tsconfig.json | 2 +- 11 files changed, 21 insertions(+), 11 deletions(-) delete mode 100644 lib/index.d.mts create mode 100644 lib/index.d.ts rename lib/{lang.d.mts => lang.d.ts} (100%) rename lib/{nodes.d.mts => nodes.d.ts} (96%) rename lib/{str.d.mts => str.d.ts} (61%) rename lib/{types.d.mts => types.d.ts} (70%) create mode 100755 scripts/fix_decl.sh diff --git a/.gitignore b/.gitignore index 3d241e8..f0ccf1b 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ # sources !/src +!/scripts # builded !/lib diff --git a/lib/index.d.mts b/lib/index.d.mts deleted file mode 100644 index 0edde7f..0000000 --- a/lib/index.d.mts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./str.mjs"; -export * from "./nodes.mjs"; -export * from "./types.mjs"; diff --git a/lib/index.d.ts b/lib/index.d.ts new file mode 100644 index 0000000..d2c6477 --- /dev/null +++ b/lib/index.d.ts @@ -0,0 +1,3 @@ +export * from "./str.js"; +export * from "./nodes.js"; +export * from "./types.js"; diff --git a/lib/lang.d.mts b/lib/lang.d.ts similarity index 100% rename from lib/lang.d.mts rename to lib/lang.d.ts diff --git a/lib/nodes.d.mts b/lib/nodes.d.ts similarity index 96% rename from lib/nodes.d.mts rename to lib/nodes.d.ts index acbac54..4d0e114 100644 --- a/lib/nodes.d.mts +++ b/lib/nodes.d.ts @@ -1,4 +1,4 @@ -import { Nilable } from "./lang.mjs"; +import { Nilable } from "./lang.js"; export declare type AnyNode = AnySyncNode | AnyAsyncNode; export declare type AnyAsyncNode = Promise; export declare type AnySyncNode = TextNode | Elem | Frag; diff --git a/lib/str.d.mts b/lib/str.d.ts similarity index 61% rename from lib/str.d.mts rename to lib/str.d.ts index c97add4..e602328 100644 --- a/lib/str.d.mts +++ b/lib/str.d.ts @@ -1,5 +1,5 @@ -import { Renderer } from "./types.mjs"; -import { Elem } from "./nodes.mjs"; +import { Renderer } from "./types.js"; +import { Elem } from "./nodes.js"; export declare class StrRenderer implements Renderer { render(node: Elem | Promise): Promise; } diff --git a/lib/types.d.mts b/lib/types.d.ts similarity index 70% rename from lib/types.d.mts rename to lib/types.d.ts index fd25db7..3db235b 100644 --- a/lib/types.d.mts +++ b/lib/types.d.ts @@ -1,4 +1,4 @@ -import { Elem } from "./nodes.mjs"; +import { Elem } from "./nodes.js"; export interface Renderer { render(node: Elem | Promise): Promise; } diff --git a/makefile b/makefile index f01afd3..4631d09 100644 --- a/makefile +++ b/makefile @@ -1,9 +1,12 @@ ts: - npx tsc + npx tsc && make fix-decl ts-w: - npx tsc-watch + npx tsc-watch --onSuccess "make fix-decl" + +fix-decl: + ./scripts/fix_decl.sh clean: rm -rf lib diff --git a/package.json b/package.json index 4a26304..dc0ad92 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "", "version": "0.0.1", "main": "lib/index.mjs", - "types": "lib/index.d.mts", + "types": "lib/index.d.ts", "directories": { "lib": "lib", "src": "src" diff --git a/scripts/fix_decl.sh b/scripts/fix_decl.sh new file mode 100755 index 0000000..abe6db6 --- /dev/null +++ b/scripts/fix_decl.sh @@ -0,0 +1,6 @@ +#!/bin/bash +for f in lib/*.d.mts; +do + sed -i 's/.mjs"/.js"/' "$f" + mv "$f" "${f//\.d\.mts/.d.ts}" +done diff --git a/tsconfig.json b/tsconfig.json index 33398dc..2724bb4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,6 @@ "noImplicitAny": true }, "include": [ - "src/**/*" + "src/**/*.mts" ], }