Questions tagged [reflect]

123 questions
14
votes
2 answers

Error: Can't resolve all parameters for ApplicationModule: (?)

I want to create Angular application without CLI. After that I get an error: Error: Can't resolve all parameters for ApplicationModule: (?). Project contains couple files, main of this is: • main.ts import 'zone.js/dist/zone' import {…
piecioshka
  • 4,752
  • 2
  • 20
  • 29
12
votes
2 answers

How to merge two Go values of same struct type?

I want to create a function called merge() that takes in two values of the same struct, but of any struct, and returns the merged values of the two structs. I want the first value to take precedence. For example, if there are two structs a and b,…
user2990276
  • 307
  • 1
  • 2
  • 7
5
votes
1 answer

Reflect.getMetadata() returns undefined although metadata is set

I'm trying to use annotations in my TypeScript application. However I must be doing something wrong, as Reflect.getMetadata() always returns undefined, although I can see in the debugger that the metadata seems to be set correctly. my-class.ts with…
Will
  • 86
  • 7
4
votes
1 answer

Go Reflect Array

The structure is like: type Auth_msg struct { Msg_class [2]byte Msg_content_pty [2]byte I am fresh to use Reflect in Go and I encounter this: panic: reflect: call of reflect.Value.Bytes on array Value This occurs when I run…
Steve Yang
  • 37
  • 1
  • 4
4
votes
1 answer

React-Native Realm TypeError: Reflect.construct requires the first argument be a constructor - Error

I reinstalled the MacOs operating system, my working code has failed. I don't understand, it was working before reinstalling. My project detail is; "react": "16.9.0" "react-native": "0.61.1", "realm": "^3.6.5", I was tried realm 3.2.0 and 3.1.0…
Yusuf
  • 77
  • 7
4
votes
2 answers

Kotlin reflect package and get all classes

How it is possible to reflect a package and list all classes as KClass<*>? fun listAllClassesInPackage(pack: String): List> = ... fun main(args: Array) { val classes: List> = listAllClassesInPackage("com.example") …
Jayser
  • 371
  • 4
  • 15
4
votes
0 answers

Javascript: Access metadata of child class inside constructor of parent

I want to access metadata of a child class in its parent's constructor before the super call. See following example: import "reflect-metadata"; const KEY = Symbol() function Decorator(name: string) { return function(target: any) { …
WaeCo
  • 1,155
  • 1
  • 10
  • 21
4
votes
2 answers

Is it possible to know whether an Annotation Method is overriden (boolean values)?

I have tried a lot of things online but nothing seem to work for me. I want to know whether an annotation method has been @Overriden (either with the same value as its default). Take a look at this example: public class AnnoTest { @Anno …
George Z.
  • 6,643
  • 4
  • 27
  • 47
4
votes
1 answer

Ignore case in golang reflection FieldByName

I am trying read from a struct using reflection in golang which I was able to do successfully but I am wondering what can I do to ignore case of a field name. I have the below code type App struct{ AppID string Owner string …
DoIt
  • 3,270
  • 9
  • 51
  • 103
4
votes
1 answer

Deserializing unknown Go's gob blob

I have gobs of unknown type. Is there way to print it to view inside? There might be gob.Debug but it is not available for me https://golang.org/src/encoding/gob/debug.go Googling advices to use DecodeValue but it requires initialised reflect.Value…
user3130782
  • 841
  • 1
  • 6
  • 15
3
votes
1 answer

How to inpect Async/Promise using Reflect.getMetadata

I found this bug when i'm testing https://github.com/ztytotoro/rxjs-extension/blob/master/src/decorators.ts#L20 export const AsyncFunction = async function () {}.constructor; export function isAsyncOrPromise(fn: any): boolean { return fn…
Willin Wang
  • 121
  • 1
  • 7
3
votes
2 answers

panic: reflect: call of reflect.Value.FieldByName on interface Value

I have a variable of type interface{} and I want to change the value of a field using reflection. How can I do it? Variable must be of type interface{} due to other requirements. If the variable isn't of type interface{} all works, otherwise code…
qwerzxcv
  • 49
  • 1
  • 1
  • 2
3
votes
1 answer

Unification in pattern matching case

I was trying to write a function whose type is forall n, option (n = 1). I choose option as an altertnative to reflect avoiding giving the proof of the negative case. So Some plays the role ReflectT and holds the proof, while None doesn't hold the…
12412316
  • 725
  • 7
  • 17
3
votes
1 answer

How to get a function parameter types

I am able to get a method's parameter types easily with ReflectAPI: Reflect.getMetadata('design:paramtypes', target, propertyKey); but, when I try to get a function's parameter types it is always returning undefined. I have tried to do with these…
user7626079
3
votes
2 answers

Java GenericClass< ? extends Interface> as a Parameter

public interface A {} public interface B {} public class Test implements A{} public class Test2 {} I made a method which checks if a class implements an interface. I want my method to only accept generic interfaces and not all class objects.…
1
2 3
8 9