Archived
1
0
Fork 0

fix: declarations

This commit is contained in:
Dmitriy Pleshevskiy 2022-03-17 11:53:53 +03:00
parent 71b81704e6
commit 30de5b9423
11 changed files with 21 additions and 11 deletions

1
.gitignore vendored
View file

@ -19,6 +19,7 @@
# sources # sources
!/src !/src
!/scripts
# builded # builded
!/lib !/lib

View file

@ -1,3 +0,0 @@
export * from "./str.mjs";
export * from "./nodes.mjs";
export * from "./types.mjs";

3
lib/index.d.ts vendored Normal file
View file

@ -0,0 +1,3 @@
export * from "./str.js";
export * from "./nodes.js";
export * from "./types.js";

View file

View file

@ -1,4 +1,4 @@
import { Nilable } from "./lang.mjs"; import { Nilable } from "./lang.js";
export declare type AnyNode = AnySyncNode | AnyAsyncNode; export declare type AnyNode = AnySyncNode | AnyAsyncNode;
export declare type AnyAsyncNode = Promise<AnySyncNode>; export declare type AnyAsyncNode = Promise<AnySyncNode>;
export declare type AnySyncNode = TextNode | Elem | Frag; export declare type AnySyncNode = TextNode | Elem | Frag;

View file

@ -1,5 +1,5 @@
import { Renderer } from "./types.mjs"; import { Renderer } from "./types.js";
import { Elem } from "./nodes.mjs"; import { Elem } from "./nodes.js";
export declare class StrRenderer implements Renderer<string> { export declare class StrRenderer implements Renderer<string> {
render(node: Elem | Promise<Elem>): Promise<string>; render(node: Elem | Promise<Elem>): Promise<string>;
} }

View file

@ -1,4 +1,4 @@
import { Elem } from "./nodes.mjs"; import { Elem } from "./nodes.js";
export interface Renderer<T> { export interface Renderer<T> {
render(node: Elem | Promise<Elem>): Promise<T>; render(node: Elem | Promise<Elem>): Promise<T>;
} }

View file

@ -1,9 +1,12 @@
ts: ts:
npx tsc npx tsc && make fix-decl
ts-w: ts-w:
npx tsc-watch npx tsc-watch --onSuccess "make fix-decl"
fix-decl:
./scripts/fix_decl.sh
clean: clean:
rm -rf lib rm -rf lib

View file

@ -3,7 +3,7 @@
"description": "", "description": "",
"version": "0.0.1", "version": "0.0.1",
"main": "lib/index.mjs", "main": "lib/index.mjs",
"types": "lib/index.d.mts", "types": "lib/index.d.ts",
"directories": { "directories": {
"lib": "lib", "lib": "lib",
"src": "src" "src": "src"

6
scripts/fix_decl.sh Executable file
View file

@ -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

View file

@ -17,6 +17,6 @@
"noImplicitAny": true "noImplicitAny": true
}, },
"include": [ "include": [
"src/**/*" "src/**/*.mts"
], ],
} }