typescript-json-schema
typescript-json-schema copied to clipboard
Cannot exclude "@types/mocha" issues
/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?
I have to remove node_modules
to get the script to run
Just ran into this issue myself, anyone know why its loading stuff out of node_modules even for TypeScript source files with no imports?
Same issue. Can't run unless I delete the node_modules
directory.
I seem to have the same issue on latest version too 0.52.0
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 how did you configure nohoist
to get your monorepo working?
@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"
]
},
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 😿
This project is like a pure black box that nothing could be controlled properly
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.
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!