Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol.metadata is undefined #22111

Closed
sant123 opened this issue Jan 25, 2024 · 6 comments · Fixed by #22282
Closed

Symbol.metadata is undefined #22111

sant123 opened this issue Jan 25, 2024 · 6 comments · Fixed by #22282

Comments

@sant123
Copy link

sant123 commented Jan 25, 2024

Version: Deno 1.40.1

image

Thanks.

@crowlKats
Copy link
Member

What are you expecting this would do? No browser, nor node, implement a Symbol.metadata.

@sant123
Copy link
Author

sant123 commented Jan 25, 2024

Consider this example:

function bind(_: unknown, ctx: ClassMethodDecoratorContext<any>) {
  ctx.addInitializer(function () {
    this[ctx.name] = this[ctx.name].bind(this);
  });
}

class Person {
  constructor(private firstName: string, private lastName: string) {}

  @bind
  greet() {
    console.log(`Hellou ${this.firstName} ${this.lastName}`);
  }

  @bind
  static start() {
    console.log("Hello World!", this);
  }
}

Person.start();

It prints:

image

Perhaps it should print the empty object shown in the console meanwhile?

@bartlomieju
Copy link
Member

I also don't understand what's the problem here. Where is the Symbol(Symbol.metadata) coming from in your example?

@sant123
Copy link
Author

sant123 commented Jan 25, 2024

It comes directly from the runtime, so the metadata exists but is not exposed? I got curious about that data in the console.

@Jamesernator
Copy link

Jamesernator commented Jan 25, 2024

I also don't understand what's the problem here. Where is the Symbol(Symbol.metadata) coming from in your example?

Symbol.metadata is part of decorator metadata, the use of any decorators on a class add the metadata object to the class.

What are you expecting this would do? No browser, nor node, implement a Symbol.metadata.

Given Deno supports decorators in TypeScript it should expose the symbol, Deno already supports Symbol.dispose/Symbol.asyncDispose which are from another proposal not implemented in browsers either.

@lucacasonato
Copy link
Member

Yeah, I checked and SWC does transpile decorator metadata. We should polyfill Symbol.metadata like we do for Symbol.dispose

bartlomieju added a commit that referenced this issue Feb 6, 2024
This commit adds support for "Symbol.metadata" which was 
omitted when adding support for the Decorators Proposal.

Closes #22111
littledivy pushed a commit that referenced this issue Feb 8, 2024
This commit adds support for "Symbol.metadata" which was 
omitted when adding support for the Decorators Proposal.

Closes #22111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants