Constructor(Type.ctor) type problems
See original GitHub issueNot sure if this is a known issue or not, was going to figure a way to fix it if so. Also saw some TODO in the code, so I’m not sure if you have some issues in mind etc.
This is my TS:
import {SomeServiceClass} from "./tests/Classes/ControllerSetup/SomeServiceClass";
import {getType} from "tst-reflect";
const someServiceClass = getType<SomeServiceClass>();
const ctor = someServiceClass.ctor;
const t = Reflect.construct(ctor, []);
This is the generated JS:
"use strict";
Object.defineProperty(exports, "__esModule", {value : true});
const tst_reflect_1 = require("tst-reflect");
(0, tst_reflect_1.getType)({
k : 0,
n : "SomeServiceInterface",
fn : "@envuso/container/src/tests/Classes/ControllerSetup/SomeServiceInterface.ts:SomeServiceInterface#21493",
props : [{n : "propertyName", t : (0, tst_reflect_1.getType)({n : "string", k : 2}), am : 2, acs : 0, ro : false, o : false}],
meths : [{n : "randomMethod", params : [], rt : (0, tst_reflect_1.getType)({n : "any", k : 2}), tp : [], o : false, am : 2}],
}, 21493);
(0, tst_reflect_1.getType)({
k : 1,
n : "SomeServiceClass",
fn : "@envuso/container/src/tests/Classes/ControllerSetup/SomeServiceClass.ts:SomeServiceClass#21497",
props : [{n : "propertyName", t : (0, tst_reflect_1.getType)({n : "string", k : 2}), am : 2, acs : 0, ro : false, o : false}],
meths : [{
n : "getMessage",
params : [],
rt : (0, tst_reflect_1.getType)({n : "string", k : 2}),
tp : [],
o : false,
am : 2,
}, {n : "randomMethod", params : [], rt : (0, tst_reflect_1.getType)({n : "void", k : 2}), tp : [], o : false, am : 2}],
ctors : [{params : []}],
ctor : () => SomeServiceClass_1.SomeServiceClass,
iface : (0, tst_reflect_1.getType)(21493),
}, 21497);
const someServiceClass = (0, tst_reflect_1.getType)(21497);
const ctor = someServiceClass.ctor;
const t = Reflect.construct(ctor, []);
//# sourceMappingURL=Test.js.map
Essentially the import for “SomeServiceClass” is removed from the file
So when we call Reflect.construct(ctor, []) it cannot reference the actual module and this error is thrown:
ReferenceError: SomeServiceClass_1 is not defined
When I use the metadata file, it just becomes null instead 🤔
Issue Analytics
- State:
- Created 2 years ago
- Comments:17 (17 by maintainers)
Top Results From Across the Web
Constructor on type not found - Stack Overflow
Exception Message: Constructor on type StateLog not found . I have the following code that does not work for only one class: List<T>...
Read more >Each parameter in constructor 'Void .ctor(System.Guid, System ...
Hi, I'm facing an issue when using System.Text. ... String)' on type 'xxxxxxx' must bind to an object property or field on deserialization....
Read more >Constructors, C++ FAQ
This question covers the C++11 feature of constructors that call same-type constructors. Nope. Let's work an example. Suppose you want your constructor Foo:: ......
Read more >Constructors in C++ - GeeksforGeeks
Constructor in C++ is a special method that is invoked automatically at the time of object creation. It is used to initialize the...
Read more >Writing a constructor in TypeScript - LogRocket Blog
With a constructor on the interface, you can specify that all of your types must have certain methods/properties (normal interface compliance) ...
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
Ahh… its not far off working, just a couple of things to work out 😄
Merged in #18