1

I need to extract Props interface from my React component to get documentation see this typescript wiki issue https://github.com/Microsoft/TypeScript-wiki/issues/65

.net analog How to get base class's generic type parameter?

Community
  • 1
  • 1
stepancar
  • 23
  • 3

1 Answers1

-3

Typescript is just Javascript. There is no reflection. It's not C#, it's not a real object oriented language.

So if you want to extract the properties of your js object you have to use javascript.

Check this link to see how to.

Community
  • 1
  • 1
Guillaume
  • 844
  • 7
  • 25
  • 2
    Why is it "not a real object oriented language"? – Matthew Layton Apr 15 '16 at 07:53
  • In Javascript you can't create class, you can't use inheritance or any feature of the OOP. When you create a class in Typescript, the transpiled code is just a set of JS tricks to simulate an OO class. – Guillaume Apr 15 '16 at 08:47
  • From Wikipedia: "Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic." - It is true that JavaScript does not have classes, but you can instantiate types, since objects can have constructors. Data and functions can be scoped to an object, and exist per-object instance. You can DEFINITELY use inheritance in JavaScript (otherwise it wouldn't be possible in TypeScript either). I would argue that whilst JavaScript is not a "classical" OOP language (with classes/interfaces etc), it is a prototypical OOP language. – Matthew Layton Apr 15 '16 at 08:56
  • Javascript has some OOP features but not all (like polymorphism). This is why for me it is "not a real object oriented language". I don't want to go further on this classic debate and it's off-topic. – Guillaume Apr 15 '16 at 09:16
  • 2
    Oh dear, this is rapidly turning into a battle of wits with the unarmed. Since JavaScript can use inheritance, by definition it can also use polymorphism. – Matthew Layton Apr 15 '16 at 09:35
  • 1
    You dont understand me, i think. I want to get interface data. Not object data. Not in run-time. What does OOP, Inheritance to do with it. I just want to get info from parser/analyzer For example, https://github.com/reactjs/react-docgen extract info about props fron javascript NOT IN RUN-TIME – stepancar Apr 16 '16 at 09:42