typescript-json-schema icon indicating copy to clipboard operation
typescript-json-schema copied to clipboard

Cannot exclude "@types/mocha" issues

Open reggi opened this issue 4 years ago • 11 comments

/Users/thomas/Desktop/agnostic/node_modules/@types/mocha/index.d.ts (2514,13): Subsequent variable declarations must have the same type.  Variable 'beforeEach' must be of type 'Lifecycle', but here has type 'HookFunction'.
/Users/thomas/Desktop/agnostic/node_modules/@types/mocha/index.d.ts (2532,13): Subsequent variable declarations must have the same type.  Variable 'afterEach' must be of type 'Lifecycle', but here has type 'HookFunction'.
/Users/thomas/Desktop/agnostic/node_modules/@types/mocha/index.d.ts (2548,13): Subsequent variable declarations must have the same type.  Variable 'describe' must be of type 'Describe', but here has type 'SuiteFunction'.
/Users/thomas/Desktop/agnostic/node_modules/@types/mocha/index.d.ts (2569,13): Subsequent variable declarations must have the same type.  Variable 'xdescribe' must be of type 'Describe', but here has type 'PendingSuiteFunction'.
/Users/thomas/Desktop/agnostic/node_modules/@types/mocha/index.d.ts (2583,13): Subsequent variable declarations must have the same type.  Variable 'it' must be of type 'It', but here has type 'TestFunction'.
/Users/thomas/Desktop/agnostic/node_modules/@types/mocha/index.d.ts (2597,13): Subsequent variable declarations must have the same type.  Variable 'test' must be of type 'It', but here has type 'TestFunction'.
/Users/thomas/Desktop/agnostic/node_modules/@types/mocha/index.d.ts (2604,13): Subsequent variable declarations must have the same type.  Variable 'xit' must be of type 'It', but here has type 'PendingTestFunction'.
No output definition. Probably caused by errors prior to this?

reggi avatar Sep 15 '20 02:09 reggi

I have to remove node_modules to get the script to run

reggi avatar Sep 15 '20 02:09 reggi

Just ran into this issue myself, anyone know why its loading stuff out of node_modules even for TypeScript source files with no imports?

abecks avatar Nov 04 '20 19:11 abecks

Same issue. Can't run unless I delete the node_modules directory.

adelsz avatar Oct 26 '21 07:10 adelsz

I seem to have the same issue on latest version too 0.52.0

valerioleo avatar Nov 22 '21 19:11 valerioleo

hopefully this can help somebody. in my case, I was running the code from within a monorepo, where some packages were using mocha. It has been sufficient to use the nohoist feature in yarn workspaces to make it work again 👍🏻

valerioleo avatar Nov 23 '21 17:11 valerioleo

@valerioleo how did you configure nohoist to get your monorepo working?

jwstanly avatar Jan 13 '22 16:01 jwstanly

@valerioleo how did you configure nohoist to get your monorepo working?

@jwstanly I did this in my root package.json:

  "workspaces": {
    "packages": [
      ... all packages here
    ],
    "nohoist": [
      "**/mocha",
      "**/jest"
    ]
  },

valerioleo avatar Jan 17 '22 13:01 valerioleo

I'm also having a similar issue when working with a monorepo with yarn workspaces.

Generating Schema from src/models/Scenario.ts 📜
<mono_repo_root>/node_modules/@types/eslint-scope/node_modules/@types/eslint/helpers.d.ts (1,6): Duplicate identifier 'Prepend'.
<mono_repo_root>/node_modules/@types/eslint/helpers.d.ts (1,6): Duplicate identifier 'Prepend'.
<mono_repo_root>/node_modules/typescript-json-schema/dist/typescript-json-schema.js:1297
                throw new Error("No output definition. Probably caused by errors prior to this?");
                      ^

Error: No output definition. Probably caused by errors prior to this?
    at <mono_repo_root>/node_modules/typescript-json-schema/dist/typescript-json-schema.js:1297:23
    at step (<mono_repo_root>/node_modules/typescript-json-schema/dist/typescript-json-schema.js:44:23)
    at Object.next (<mono_repo_root>/node_modules/typescript-json-schema/dist/typescript-json-schema.js:25:53)
    at <mono_repo_root>/node_modules/typescript-json-schema/dist/typescript-json-schema.js:19:71
    at new Promise (<anonymous>)
    at __awaiter (<mono_repo_root>/node_modules/typescript-json-schema/dist/typescript-json-schema.js:15:12)
    at exec (<mono_repo_root>/node_modules/typescript-json-schema/dist/typescript-json-schema.js:1275:12)
    at Object.run (<mono_repo_root>/node_modules/typescript-json-schema/dist/typescript-json-schema-cli.js:55:39)
    at Object.<anonymous> (<mono_repo_root>/node_modules/typescript-json-schema/bin/typescript-json-schema:3:5)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
<mono_repo_root>/node_modules/@types/eslint-scope/node_modules/@types/eslint/helpers.d.ts (1,6): Duplicate identifier 'Prepend'.
<mono_repo_root>/node_modules/@types/eslint/helpers.d.ts (1,6): Duplicate identifier 'Prepend'.
<mono_repo_root>/node_modules/typescript-json-schema/dist/typescript-json-schema.js:1297
                throw new Error("No output definition. Probably caused by errors prior to this?");

I tried playing around with nohoist but couldn't get it to work 😿

kaveenr avatar Feb 26 '22 10:02 kaveenr

This project is like a pure black box that nothing could be controlled properly

reorx avatar Mar 27 '22 17:03 reorx

For the record: Did you check out working with vega/ts-json-schema-generator? It takes a far more sophisticated approach by walking the AST itself (in contrast to this project which effectively just asks the compiler for the type at point). It therefore sometimes lags behind with very recent additions to the type system, but for me it works far more reliable.

MarcusRiemer avatar Mar 28 '22 08:03 MarcusRiemer

For the record: Did you check out working with vega/ts-json-schema-generator? It takes a far more sophisticated approach by walking the AST itself (in contrast to this project which effectively just asks the compiler for the type at point). It therefore sometimes lags behind with very recent additions to the type system, but for me it works far more reliable.

This package solved all my problems, thanks!

Arik13 avatar Apr 26 '22 20:04 Arik13