From 9da18a732152743ecdbd7cce20775d0e596e78b7 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Tue, 26 Sep 2023 19:39:09 +0300 Subject: [PATCH] squash! --- Source/Function/File.ts | 13 ++++--------- Source/Interface/File.ts | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 Source/Interface/File.ts diff --git a/Source/Function/File.ts b/Source/Function/File.ts index f9d64335..6219be12 100644 --- a/Source/Function/File.ts +++ b/Source/Function/File.ts @@ -1,15 +1,8 @@ /** - * The function takes a file path as input, checks if it is a TypeScript file, converts the TypeScript - * code to JavaScript, and then imports and returns the default export of the JavaScript file. - * * @module File * - * @param {string} Path - The `Path` parameter is a string that represents the file path of the file - * you want to process. - * - * @returns the default export of the module that is imported using the provided `Path`. */ -export default async (Path: string) => { +export default (async (...[Path]: Parameters) => { if (Path.split(".").pop() === "ts") { const { options } = ( await import("typescript") @@ -51,4 +44,6 @@ export default async (Path: string) => { .replace(".ts", ".js") ) ).default; -}; +}) satisfies Type as Type; + +import type Type from "../Interface/File.js"; diff --git a/Source/Interface/File.ts b/Source/Interface/File.ts new file mode 100644 index 00000000..ddf407da --- /dev/null +++ b/Source/Interface/File.ts @@ -0,0 +1,22 @@ +/** + * @module File + * + */ +export default interface Type { + /** + * This function asynchronously processes a file located at the given path. If the file is a TypeScript + * (.ts) file, it performs the following steps: + * 1. Converts TypeScript code to JavaScript. + * 2. Creates a JavaScript module and emits it. + * 3. Writes the transpiled JavaScript code to a new file with a .js extension. + * + * Finally, it imports and returns the default export of the processed JavaScript module. + * + * @param {string} Path - The 'Path' parameter is a string that represents the file path of the file + * you want to process. + * + * @returns {Promise} A promise that resolves with the default export of the module imported using the provided 'Path'. + */ + // rome-ignore lint/suspicious/noExplicitAny: + (Path: string): Promise; +}