Git Product home page Git Product logo

Comments (2)

jveres avatar jveres commented on September 26, 2024

Further investigating this issue I found, that using the test.ts above Deno.transpileOnly(...) is responsible to give the following and obviously faulty result:

function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
    var desc = {
    };
    Object.keys(descriptor).forEach(function(key) {
        desc[key] = descriptor[key];
    });
    desc.enumerable = !!desc.enumerable;
    desc.configurable = !!desc.configurable;
    if ("value" in desc || desc.initializer) {
        desc.writable = true;
    }
    desc = decorators.slice().reverse().reduce(function(desc, decorator) {
        return decorator(target, property, desc) || desc;
    }, desc);
    if (context && desc.initializer !== void 0) {
        desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
        desc.initializer = undefined;
    }
    if (desc.initializer === void 0) {
        Object.defineProperty(target, property, desc);
        desc = null;
    }
    return desc;
}
var _class, _dec, _dec;
function A() {
    console.log("@A evaluated");
    return function(target, propertyKey, descriptor) {
        console.log("@A called");
        const fn = descriptor.value;
        descriptor.value = function() {
            console.log("fn() called from @A");
            fn();
        };
    };
}
function B() {
    console.log("@B evaluated");
    return function(target, propertyKey, descriptor) {
        console.log("@B called");
        const fn = descriptor.value;
        descriptor.value = function() {
            console.log("fn() called from @B");
            fn();
        };
    };
}
let C = ((_class = class C {
    static test() {
        console.log("C.test() called");
    }
}) || _class, _dec = A(), _dec = B(), _applyDecoratedDescriptor(_class, "test", [_dec, _dec], Object.getOwnPropertyDescriptor(_class, "test"), _class), _class);
C.test();

However, Deno.compile(...) emits properly working code:

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
function A() {
    console.log("@A evaluated");
    return function (target, propertyKey, descriptor) {
        console.log("@A called");
        const fn = descriptor.value;
        descriptor.value = function () {
            console.log("fn() called from @A");
            fn();
        };
    };
}
function B() {
    console.log("@B evaluated");
    return function (target, propertyKey, descriptor) {
        console.log("@B called");
        const fn = descriptor.value;
        descriptor.value = function () {
            console.log("fn() called from @B");
            fn();
        };
    };
}
class C {
    static test() {
        console.log("C.test() called");
    }
}
__decorate([
    A(),
    B()
], C, "test", null);
C.test();

The default in denopack is to use Deno.transpileOnly.
Using pluginTypescriptCompile gives error:

error: Uncaught (in promise) TypeError: Cannot read property 'includes' of undefined
  if (!files.includes(jsFile)) {
             ^
    at resolveFromModules (mod.ts:21:14)
    at Object.transform (mod.ts:72:35)
    at https://unpkg.com/[email protected]/dist/es/rollup.browser.js:11:334078

from denopack.

jveres avatar jveres commented on September 26, 2024

Related Deno issue denoland/deno#8412

from denopack.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.