Conversation
|
The changes in the pull request branch involve several modifications in the functionality and constants used across multiple TypeScript files. Here is a summary of the changes:
Overall, these changes seem to be aimed at expanding the types of scripts that can be handled by the system to include TypeScript files in addition to JavaScript ones. It also includes changes for better tracing of imports. However, the removal of the LGTM 🚀
|
| } | ||
| const { tsImport, register } = await import("tsx/esm/api") | ||
| unregister = register({ onImport }) | ||
| const module = await tsImport(modulePath, { |
There was a problem hiding this comment.
The promise returned by tsImport function is not handled. This could lead to uncaught promise rejection if the promise is rejected.
generated by pr-review-commit
unhandled_promise
| ```js title="summarize.genai.mjs" | ||
| const { summarize } = await import("./summarizer.mjs") | ||
| summarize(env.generator, env.files) | ||
| ``` |
There was a problem hiding this comment.
Duplicate code block detected. The same code appears twice with the title "summarize.genai.mjs".
generated by pr-docs-review-commit
duplicate_code
| ```js title="summarize.genai.mts" | ||
| const { summarize } = await import("./summarizer.mts") | ||
| summarize(env.generator, env.files) | ||
| ``` |
There was a problem hiding this comment.
Incorrect file extension in code block title. TypeScript files should use the .mts extension, not .genai.mts.
generated by pr-docs-review-commit
incorrect_extension
| - `.genai.mjs` use module JavaScript syntax and support imports. (`.genai.js` are eval-ed and do not support imports). | ||
| - `.genai.mjs` use module JavaScript syntax and support imports. | ||
| - `.genai.js` are eval-ed and do not support imports. | ||
| - `.genai.mts` are TypeScript module files and support imports, including dynamic imports of other TypeScript files. |
There was a problem hiding this comment.
Incorrect information. .genai.js files can support imports if they are renamed to .genai.mjs.
generated by pr-docs-review-commit
incorrect_info
| ## Module Imports | ||
|
|
||
| You can import module installed in your project. | ||
| You can import node packages installed in your project. |
There was a problem hiding this comment.
There seems to be a typo here. It should be "modules" instead of "module".
generated by pr-docs-review-commit
typo
| ``` | ||
|
|
||
| ## File imports | ||
| ## JavaScript imports |
There was a problem hiding this comment.
The term "File imports" was more accurate as it is not limited to JavaScript files. The change to "JavaScript imports" is misleading.
generated by pr-docs-review-commit
incorrect_term
|
|
||
| ## TypeScript imports | ||
|
|
||
| TypeScript (`.mts`) files can be imported using **dynamic** import only. |
There was a problem hiding this comment.
The statement "TypeScript (.mts) files can be imported using dynamic import only." is incorrect. TypeScript files can be imported both statically and dynamically, depending on the context and configuration.
generated by pr-docs-review-commit
incorrect_statement
| ## Script files | ||
|
|
||
| - GenAIScript will detect any file matching `*.genai.mjs` in your workspace. | ||
| - GenAIScript will detect any file matching `*.genai.mjs`, `*.genai.js`, `*.genai.mts` in your workspace. |
There was a problem hiding this comment.
The statement is missing information about .genai.ts files, which should be included if TypeScript files are supported.
generated by pr-docs-review-commit
missing_info
| - `.genai.mjs` use module JavaScript syntax and support imports. (`.genai.js` are eval-ed and do not support imports). | ||
| - `.genai.mjs` use module JavaScript syntax and support imports. | ||
| - `.genai.js` are eval-ed and do not support imports. | ||
| - `.genai.mts` are TypeScript module files and support imports, including dynamic imports of other TypeScript files. |
There was a problem hiding this comment.
The statement ".genai.mts are TypeScript module files and support imports, including dynamic imports of other TypeScript files." is misleading because it implies that only dynamic imports are supported for TypeScript files, which is not the case. Static imports are also supported in TypeScript.
generated by pr-docs-review-commit
incorrect_statement
| ## Module Imports | ||
|
|
||
| You can import module installed in your project. | ||
| You can import node packages installed in your project. |
There was a problem hiding this comment.
The term "node packages" should be "Node.js packages" to maintain consistency and accuracy.
generated by pr-docs-review-commit
incorrect_statement
| - `.genai.mjs` use module JavaScript syntax and support imports. (`.genai.js` are eval-ed and do not support imports). | ||
| - `.genai.mjs` use module JavaScript syntax and support imports. | ||
| - `.genai.js` are eval-ed and do not support imports. | ||
| - `.genai.mts` are TypeScript module files and support imports, including dynamic imports of other TypeScript files. |
There was a problem hiding this comment.
The description of file extensions is misleading. It should clarify that .genai.js files do not support ES6 module imports, and .genai.mts files are TypeScript files that support both static and dynamic imports.
generated by pr-docs-review-commit
incorrect_extension_description
| import.meta.url ?? | ||
| new URL(__filename ?? host.projectFolder(), "file://").href | ||
|
|
||
| trace?.itemValue(`import`, `${modulePath}, parent: ${parentURL}`) |
There was a problem hiding this comment.
The promise returned by tsImport function is not properly handled. If it rejects, it will result in an unhandled promise rejection.
generated by pr-review-commit
unhandled_promise
| } | ||
|
|
||
| const current = await tryReadText(host.path.join(folder, defName)) | ||
| if (defName === "tsconfig.json" && !ts) continue |
There was a problem hiding this comment.
The writeText function is async but it's not awaited, this could lead to unexpected behavior.
generated by pr-review-commit
async_without_await
| @@ -111,7 +111,7 @@ async function callExpander( | |||
| } | |||
|
|
|||
| try { | |||
There was a problem hiding this comment.
The condition r.filename && !JS_REGEX.test(r.filename) is complex and could be simplified or broken down for better readability.
generated by pr-review-commit
conditional_complexity
GENAI_JS_GLOBtoGENAI_ANYJS_GLOBto accurately reflect the supported file types (JavaScript and TypeScript).tsconfig.jsonfiles in many directories across the entire project. This configures the TypeScript compiler for each directory, which allows for more targeted settings per directory.Projectclass. This might be part of a larger move towards reducing the class's responsibility or could be part of some refactoring work.summarizer-mts.mtsfile. This seems like an attempt to test or showcase the new TypeScript support.tsconfig.json. The bundle prompts now include configuration for the TypeScript compiler.