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.

Type has multiple definitions when reused in union

See original GitHub issue
export type s = string
export type n = number
export type sn = s | n

Type "s" has multiple definitions.

I don’t think this schema has name conflict. sn should only create a new name sn and get compiled into something like this

...
"sn": {"anyOf": [{"$ref": "#definitions/s"}, {"$ref": "#definitions/n"}]}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tommitytomcommented, Oct 11, 2019
0reactions
domoritzcommented, Oct 19, 2020

The original test case now works.

export type S = string;
export type N = number;
export type MyType = S | N;

{
  "$ref": "#/definitions/MyType",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "definitions": {
    "MyType": {
      "anyOf": [
        {
          "$ref": "#/definitions/S"
        },
        {
          "$ref": "#/definitions/N"
        }
      ]
    },
    "N": {
      "type": "number"
    },
    "S": {
      "type": "string"
    }
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

symbol 'Flags' has multiple definitions using union/struct
Error - symbol 'Flags' has multiple definitions. I placed a union/struct in my main.h desiring to access the Flags.bit.xx from various c ...
Read more >
Mypy errors with variable reuse with different types · Issue #1174
Sounds like a common theme is that if variables are defined and redefined at the same indentation level ("in the same block") and...
Read more >
multiple definitions error in c++ and solution to solve this issue
I have declared a class in the header file and I have defined the class in each of the .cpp files but the...
Read more >
Performance Tips · The Julia Language
It leads to more reusable code and clarifies what the inputs and outputs are. ... If items[i+1] has a different type than item[i]...
Read more >
C++ Core Guidelines - GitHub Pages
The C++ Core Guidelines are a set of tried-and-true guidelines, rules, and best practices about coding in C++.
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