Skip to content

TypeScript: strongly typed lookup function #544

@paralin

Description

@paralin

I'm finding myself doing this a lot:

(<any>tree.lookup('mynamespace.MyMessage')).encode...

The reason is that lookup returns a ReflectionObject which I cannot directly cast to any of its children (I can cast a Type -> ReflectionObject but not the other way around).

I'm proposing doing something like:

tree.lookupService('mynamespace.MyService'); // ok -> ProtoBuf.Service
tree.lookupType('mynamespace.MyService'); // throws -> MyService is not a Type

Strongly typed with exceptions if you attempt to lookup the wrong type (or just return null)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions