Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exclude single file from --path ? #987

Closed
tomdavidson opened this issue Oct 15, 2021 · 8 comments
Closed

exclude single file from --path ? #987

tomdavidson opened this issue Oct 15, 2021 · 8 comments

Comments

@tomdavidson
Copy link

Hello and thank you!

I'd like to do something along the lines of --path 'src/!(app)*.ts' but am not figuring out a negate option.
Any options to include *.ts but leave out app.ts?

Its a different issue, but the reason I need to exclude app.ts is due to:

Error: Unknown node "() => {" (ts.SyntaxKind = 212)

on err in (with our without the explicit type):

  (err: NodeJS.ErrnoException) => {
    if (err) {
@domoritz
Copy link
Member

Can you use a tsconfig file to load only the files you want?

@tomdavidson
Copy link
Author

Yes, I could have a separate tsconfig for the schema gen. Thanks.

@tomdavidson
Copy link
Author

tomdavidson commented Oct 15, 2021

Didn't quite work, I must be missing something:

{
  "extends": "./tsconfig.json",
  "exclude": ["node_modules", "dist", "src/app.ts"]
}
$ npx ts-json-schema-generator --tsconfig tsconfig-genschemata.json --path src/*.ts --no-type-check --out src/schemata.json
Error: Unknown node "(err: NodeJS.ErrnoException) => {" (ts.SyntaxKind = 212) at src/app.ts(99,2)

$ npx ts-json-schema-generator -f tsconfig-genschemata.json  --no-type-check --out src/schemata.json
NoRootNamesError: No source files found

@tomdavidson
Copy link
Author

aah looks related to #976 and #979

@tomdavidson
Copy link
Author

tomdavidson commented Oct 15, 2021

@domoritz The break happens with v0.94.1. The following works great.

npx ts-json-schema-generator@v0.94.0 --tsconfig tsconfig-genschemata.json  --no-type-check --out src/schemata.json

Is this the same issue in #976 and #979?

@domoritz
Copy link
Member

Could be. Can you try the release from #979?

@tomdavidson
Copy link
Author

Oh cool, I didnt realize there was a released canary. You made getting some feedback super easy. The canary works with path but not with the custom tsconfig.

$ npx ts-json-schema-generator@v0.96.1--canary.979.fe4869a.0 --tsconfig tsconfig-genschemata.json  --no-type-check --out src/schemata.json
Error: Unknown node "() => {" (ts.SyntaxKind = 212) at /home/tom/Documents/affrim-take-home/src/offer.spec.ts(4,29)

$ npx ts-json-schema-generator@v0.96.1--canary.979.fe4869a.0  --path src/*.ts  --no-type-check --out src/schemata.json

But now the schema looks like this with exported functions, not types:

"definitions": {
 "NamedParameters<typeof writeAssignments>": {
      "additionalProperties": false,
      "properties": {
        "filePath": {
          "type": "string"
        }
      },
      "required": [
        "filePath"
      ],
      "type": "object"
    }

Rather than the actual types such as:

"definitions": {
    "Rate": {
      "description": "Rate 0-1",
      "maximum": 1,
      "minimum": 0,
      "type": "number"
    },

@domoritz
Copy link
Member

Thanks for the canaries goes to @hydrosquall for setting it up.

If you could debug the issue, that would be great. I won't have the cycles to dig into it unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants