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 is not a Type. But is a Function which returns Type when type is recursive

See original GitHub issue

I’ve tried this sample with recursive type. And i found that type is a function, not a Type. I have last version of tst-reflect and ts-node.

import { getType } from 'tst-reflect';

type Settings = {
  users: User[];
};

type User = {
  friends: User[];
};

console.log(
  getType<Settings>()
    .getProperties()[0]
    .type.getTypeArguments()[0]
    .getProperties()[0]
    .type.isObjectLike()) // isObjectLike() is not a function

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ciricccommented, Jul 4, 2022

@Hookyns Thank you very much! Now is working ok

1reaction
Hookynscommented, Jun 22, 2022

Okay, I’ll check it again; this must be something with the Array, cuz I wrote test with:

type Node = {
	left: Node;
	right: Node;
};

it didn’t work too and now it works. I should try your example first, sorry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when using recursive type in a function - Stack Overflow
RecursiveGetIndex <NestedRecord> is the real problem here and this is because of how any works for a conditional type.
Read more >
2.4. Functions — OCaml Programming - GitHub Pages
OCaml functions are not methods: they are not components of objects, and ... Since the if expression has type int , the function's...
Read more >
Documentation - TypeScript 3.7
The other type of assertion signature doesn't check for a condition, but instead tells TypeScript that a specific variable or property has a...
Read more >
4 Types in Typed Racket - Racket Documentation
The first type describes a function that has no mandatory arguments, one optional argument with type Number, and returns a Number.
Read more >
Reading 16, Part 1: Recursive Data Types
Just as a recursive function is defined in terms of itself, a recursive datatype is defined in terms of itself. We'll see the...
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