@pronto-tools-and-more/type-checker 7.6.0 → 7.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/type-checker",
3
- "version": "7.6.0",
3
+ "version": "7.8.0",
4
4
  "description": "",
5
5
  "main": "src/typeCheckerMain.js",
6
6
  "type": "module",
@@ -2,10 +2,17 @@ import { createProject, ts } from "@ts-morph/bootstrap";
2
2
  import * as Assert from "../Assert/Assert.js";
3
3
  import * as FormatError from "../FormatError/FormatError.js";
4
4
 
5
- export const checkTypes = async (code) => {
5
+ export const checkTypes = async (code, path = "index.js") => {
6
6
  Assert.string(code);
7
- const project = await createProject({ useInMemoryFileSystem: true });
8
- project.createSourceFile("MyClass.ts", code);
7
+ const project = await createProject({
8
+ useInMemoryFileSystem: true,
9
+ compilerOptions: {
10
+ allowJs: true,
11
+ checkJs: true,
12
+ noEmit: true,
13
+ },
14
+ });
15
+ project.createSourceFile(path, code);
9
16
  const program = project.createProgram();
10
17
  const diag = ts.getPreEmitDiagnostics(program); // check these
11
18
  const formatted = diag.map(FormatError.formatError);