question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

metadata is undefined (Babel)

See original GitHub issue

I create a simple advice just like Get Started, but advices can’t find metadata.

  • simple react demo project
  • kaop-ts v1.2.0

App.js

import React, {Component} from 'react';
import logo from './logo.svg';
import './App.css';
import {afterMethod} from 'kaop-ts'
import {MyAdvices} from './MyAdvices'

class App extends Component {

  constructor(props) {
    super(props);
    this.handleClick = this.handleClick.bind(this);
  }

  @afterMethod(MyAdvices.doubleResult)
  handleClick() {
    alert('You Click It!');
  }

  render() {
    return (
      <div className="App">
        <div className="App-header" onClick={this.handleClick}>
          <img src={logo} className="App-logo" alt="logo"/>
          <h2>Welcome to React</h2>
        </div>
        <p className="App-intro">
          To get started, edit
          <code>src/App.js</code>
          and save to reload.
        </p>
      </div>
    );
  }
}

export default App;

MyAdvices.js

import { AdvicePool, adviceMetadata } from 'kaop-ts'

export class MyAdvices extends AdvicePool {
  static doubleResult (@adviceMetadata metadata) {
    console.log(metadata);     // always output undefined here
  }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
liangzrcommented, Aug 10, 2017

@k1r0s gread job!

Although I prefer to use typescript now, but there are a lot of people use original javasciprt,which is very useful for them.

1reaction
liangzrcommented, Jul 24, 2017

Thanks a lot @k1r0s ,

It is difficult to replace the whole project into typescript, but I wirte advices files use typescript (that I learned just last weekend 😛) according to your suggestion, use babel for other .js files, it works fine now!

I also will keep an eye on this, thanks for you libarary!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Metadata retention with Typescript, Babel 7, Decorators
In practice this means that : If the type is an interface or a type alias, the type name will be undefined at...
Read more >
babel-plugin-transform-typescript-metadata - npm
Babel plugin to emit decorator metadata like typescript compiler. Latest version: 0.3.2, ... Inject()(Some.prototype, undefined, 0); ...
Read more >
Metadata retention with Typescript, Babel 7, Decorators-babel.js
If the type is an interface or a type alias, the type name will be undefined at runtime, to avoid the undefined we...
Read more >
babel/plugin-transform-typescript
--emitDecoratorMetadata This option isn't supported by an official Babel package since it is ... the reference to V will be undefined resulting in...
Read more >
Code Dive: babel-loader - lik.ai
sourceMaps: loaderOptions.sourceMaps === undefined ? this.sourceMap : loaderOptions.sourceMaps, // Ensure that Webpack will get a full absolute path in the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found