cmd-johnson / deno-reflect-metadata

A Deno-compatible copy of the TypeScript Metadata Reflection API my Microsoft
Apache License 2.0
11 stars 4 forks source link

reflect-metadata error Deno 1.14.0 #4

Closed hermy991 closed 3 years ago

hermy991 commented 3 years ago

Hello, I got a error using the below code:

import { Reflect } from "https://deno.land/x/reflect_metadata@v0.1.12/mod.ts";

// deno-lint-ignore no-explicit-any
type Constructor<T = unknown> = new (...args: any[]) => T;

function decorator<T>(_: Constructor<T>): void {}

@decorator
class Example {
  constructor(a: string, b: number, c: Example) {}
}

console.log(Reflect.getMetadata("design:paramtypes", Example));

Error:

error: TS2339 [ERROR]: Property 'toPrimitive' does not exist on type 'never'.
    const toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive";
                                                              ~~~~~~~~~~~
    at https://deno.land/x/reflect_metadata@v0.1.12-1/Reflect.ts:670:63

TS2339 [ERROR]: Property 'toPrimitive' does not exist on type 'never'.
    const toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive";
                                                                                                   ~~~~~~~~~~~
    at https://deno.land/x/reflect_metadata@v0.1.12-1/Reflect.ts:670:100

TS2339 [ERROR]: Property 'iterator' does not exist on type 'never'.
    const iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator";    
                                                           ~~~~~~~~
    at https://deno.land/x/reflect_metadata@v0.1.12-1/Reflect.ts:671:60

TS2339 [ERROR]: Property 'iterator' does not exist on type 'never'.
    const iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator";    
                                                                                             ~~~~~~~~
    at https://deno.land/x/reflect_metadata@v0.1.12-1/Reflect.ts:671:94

Found 4 errors.

Is it a Deno ?

cmd-johnson commented 3 years ago

Thanks for reporting this! I've merged #5, which should fix this in version v0.1.12-2. Could you give it a try and let me know if this issue is fixed for you?

hermy991 commented 3 years ago

Works ok, and thank you for this library.