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.

TS classes have automatic constructors

See original GitHub issue

8.3.3 Automatic Constructors https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#8.3.3

While looking into gRPC https://github.com/fable-compiler/Fable/issues/1183, I had to add the default constructor manually. It should be generated.

ts2fable ..\..\ts\_proto\examplecom\library\book_service_pb.d.ts book_service_pb.fs

It should have:

type [<AllowNullLiteral>] GetBookRequestStatic =
    [<Emit "new $0($1...)">] abstract Create: unit -> GetBookRequest

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ctaggartcommented, Nov 17, 2017

fixed by #86

0reactions
ctaggartcommented, Nov 17, 2017

I was not able to figure out how to navigate using the TypeScript TypeChecker, so I used another solution. I was able to figure out how to get the full name for the references and the classes, so I used that information to copy the constructors.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript Constructor Shorthand
In this case Typescript will automatically generate thore properties. And yes both definitions will produce same Javascript code: var User = /** ...
Read more >
TypeScript: Documentation - Classes
--strictPropertyInitialization. The strictPropertyInitialization setting controls whether class fields need to be initialized in the constructor. ts. class ...
Read more >
Handbook - Classes
You can make properties readonly by using the readonly keyword. Readonly properties must be initialized at their declaration or in the constructor. ts....
Read more >
Does a class NEED a constructor in Typescript?
A class may contain at most one constructor declaration. If a class contains no constructor declaration, an automatic constructor is provided, ...
Read more >
TypeScript Classes and Constructors
A constructor is a special function that exists inside a class, that is called only once when the object is created. Classes are...
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