TS classes have automatic constructors
See original GitHub issue8.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:
- Created 6 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
fixed by #86
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.