question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong behavior of * operator in cli

See original GitHub issue

Given the following files:

./lib/types/ZnsResolutionType.ts:

interface CurrencyResolution {
  address: string
}
export default interface ZnsResolutionType {
  crypto: {
    ADA?: CurrencyResolution,
    BTC?: CurrencyResolution,
    EOS?: CurrencyResolution,
    ETH?: CurrencyResolution,
    XLM?: CurrencyResolution,
    XRP?: CurrencyResolution,
    ZIL?: CurrencyResolution,
  }
}

./lib/types/ResellerOrderType.ts

import ZnsResolutionType from './ZnsResolutionType'

interface OrderItem {
  name: string;
  owner: string;
  resolution?: ZnsResolutionType;
}
export default interface ResellerOrderType {
  domains: OrderItem[]
}

Running the following command results in an error:

$     typescript-json-schema  lib/types/* ResellerOrderType
/Users/bogdan/.nvm/versions/node/v10.15.3/lib/node_modules/typescript-json-schema/dist/typescript-json-schema.js:795
            throw new Error("type " + symbolName + " not found");
            ^

Error: type lib/types/ZnsResolutionType.ts not found
    at JsonSchemaGenerator.getSchemaForSymbol (/Users/bogdan/.nvm/versions/node/v10.15.3/lib/node_modules/typescript-json-schema/dist/typescript-json-schema.js:795:19)
    at generateSchema (/Users/bogdan/.nvm/versions/node/v10.15.3/lib/node_modules/typescript-json-schema/dist/typescript-json-schema.js:967:26)
    at Object.exec (/Users/bogdan/.nvm/versions/node/v10.15.3/lib/node_modules/typescript-json-schema/dist/typescript-json-schema.js:1016:22)
    at Object.run (/Users/bogdan/.nvm/versions/node/v10.15.3/lib/node_modules/typescript-json-schema/dist/typescript-json-schema-cli.js:48:30)
    at Object.<anonymous> (/Users/bogdan/.nvm/versions/node/v10.15.3/lib/node_modules/typescript-json-schema/bin/typescript-json-schema:3:5)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
domoritzcommented, Aug 14, 2019

Yes, you can pass * (make sure to escape for your shell) as the types argument and pass your tsconfig instead of a file.

1reaction
bogdancommented, Aug 14, 2019

I tried that and it seems to be close to what I want. The last problem I have is that ZnsResolutionType is set to definitions.default but not definitions.ZnsResolutionType.

It is weird that ResellerOrderType is exported correctly. Is it possible to define ZnsResolutionType with the matching name but not default?

Here is the command I run:

typescript-json-schema  --required "lib/types/*Type.ts" "*" 

And the output https://gist.github.com/9cc6a571284b561084d50329bb018811

Read more comments on GitHub >

github_iconTop Results From Across the Web

bash - Precedence of the shell logical operators
If a command is terminated by the control operator &, the shell executes the command in the background in a subshell. The shell...
Read more >
Strange behaviour of += operator - help - Octave Discourse
Depending on the naming of variables and the space character after the += operator do I get errors: Example 1: name of variable...
Read more >
bash: && operator behaviour - linux - Stack Overflow
The issue relates to the exit codes. The && operator will execute the second command if the first one indicates that it was...
Read more >
Shell operator && seems to inhibit the normal stop-on-error ...
When a script line contains the operator && (on the top level), this inhibits the normal behaviour when the gitlab CI runner stops...
Read more >
Unix's mysterious && and || | Network World
The reason for this behavior is tied to the Boolean nature of the operators. If a command runs successfully, the result is evaluated...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found