microsoft / microsoft/reflect-metadata

reflect-metadata with an angular rc5 app error localhost/:24 Error: TypeError: Cannot read property 'type' of null(…)

Open
#42 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.4k
Forks
190
Avg merge
13h 52m
Merged PRs (30d)
1

Description

hello Ron,

I was using reflect-metadata 0.1.3 in an angular rc4 app in a project.
Now I use reflect-metadata 0.1.8 and angular rc5.

The way I was using it was the following.

  • systemjs.config.js
    map['reflect-metadata'] = 'node_modules/reflect-metadata/Reflect.js';
  • main.ts
    import "reflect-metadata";

-In my application
`export class MapUtils {

static getClazz(target:any, propertyKey:string):any {
    return Reflect.getMetadata("design:type", target, propertyKey)
}

static getJsonProperty<T>(target:any, propertyKey:string):IJsonMetaData<T> {
    return Reflect.getMetadata(jsonMetadataKey, target, propertyKey);
}`

But now I have the error:
Error: TypeError: Cannot read property 'type' of null(…)

I suspect I'm not mapping properly in the systemjs.config.js but with rc4 and angular rc4 that worked.

If you could guide me into the right direction that would be great

thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with systemjs.config.js and main.ts, then reproduce the metadata call in MapUtils.getClazz or getJsonProperty in the Angular RC5 application. Compare the reflect-metadata 0.1.8 mapping and import behavior with the reported null-type error; done means the application loads without that error and the metadata calls work.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.