Giter Site home page Giter Site logo

Comments (5)

PierreLouer avatar PierreLouer commented on August 28, 2024 1

Hello @mortend I still have the same error

from transpiler.

mortend avatar mortend commented on August 28, 2024

We added decorators support in #2.

Can you elaborate on what needs to be supported by transpiler?

from transpiler.

PierreLouer avatar PierreLouer commented on August 28, 2024

Hello @mortend Sorry for the late reply. In fact actually the transpiler supports decorators, but when i added metadata as below, it does not work

import "reflect-metadata";
const formatMetadataKey = Symbol("format");

function format(formatString: string) {
    return Reflect.metadata(formatMetadataKey, formatString);
}

function getFormat(target: any, propertyKey: string) {
    return Reflect.getMetadata(formatMetadataKey, target, propertyKey);
}

class Greeter {
    @format("Hello, %s")
    greeting: string;

    constructor(message: string) {
        this.greeting = message;
    }

    greet() {
        let formatString = getFormat(this, "greeting");
        console.log('metadata => ' + formatString)
        return formatString.replace("%s", this.greeting);
    }
}

console.log('Greeting => ' + new Greeter('Pierre').greet())

Output of app

metadata => undefined
Error: TypeError: Cannot read property 'replace' of undefined: Uncaught TypeError: Cannot read property 'replace' of undefined
	In: Fuse.Scripting.DiagnosticSubject
	Fuse: Index.js:206

Outout of ts-node

metadata => Hello, %s
Greeting => Hello, Pierre

I suggest in this case to add metadata support by plugin such as babel-plugin-transform-typescript-metadata.

from transpiler.

mortend avatar mortend commented on August 28, 2024

Aha, I see. Thanks for clarifying. I think it should be possible for us to support metadata as well.

from transpiler.

mortend avatar mortend commented on August 28, 2024

@PierreLouer Syntax works now and the metadata is persisted in generated output code.

It looks like we need to polyfill reflect-metadata to make this fully work in Fuse. When trying out the new version of transpiler in Fuse Studio I get the following errors.

[Viewport]: Error: : Uncaught require(): module not found: reflect-metadata
	In: Fuse.Scripting.DiagnosticSubject
	Fuse: Logic.js:8
[Viewport]: Error: TypeError: Reflect.metadata is not a function: Uncaught TypeError: Reflect.metadata is not a function
	In: Fuse.Scripting.DiagnosticSubject
	Fuse: Logic.js:54

You can install the new version of transpiler and try it out. If you are using Fuse Studio I think you can cd into your @fuse-x/studio module directory and install it there.

npm i @fuse-open/transpiler

from transpiler.

Related Issues (2)

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.