Git Product home page Git Product logo

Comments (3)

sanex3339 avatar sanex3339 commented on May 20, 2024

Right now in my project i find some workaround with help of gulp.

After typescript compiling but before minification, i parse with regexp current stream content (gulp-data plugin), find any functions arguments matched to pattern like: ISettings, IParams, IInterfaceA. And then push them into array and put that array as except parameter for uglify2 plugin.

let reservedVariables = [];
.pipe(ts({
            out:  'output.js',
            typescript: require('typescript')
        }))
.pipe(data(function(file) {
            let results,
                result,
                res;

            results = String(file.contents).match(/function[^(]*\(([^)]*)\)/g);

            for (result in results) {
                res = results[result].match(/function[^(]*\(([^)]*)\)/)[1].split(',');

                res.forEach((value) => {
                    if (value === '') {
                        return false;
                    }

                    if (/I[A-Z]\w*/.test(value)) {
                        reservedVariables.push(value);
                    }
                });
            }

            reservedVariables = reservedVariables.filter(function (value, index, self) {
                return self.indexOf(value) === index;
            });

            return  reservedVariables;
        }))
.pipe(uglify({
            mangle: {
                except: reservedVariables
            }
        }))

from inversifyjs.

remojansen avatar remojansen commented on May 20, 2024

@sanex3339 thanks for sharing that!

from inversifyjs.

remojansen avatar remojansen commented on May 20, 2024

You can now use:

@inject("IFoo","IBar")
class FooBar implements IFooBar {

  public foo : IFoo;
  public bar : IBar;

  public log() {
    console.log("foobar");
  }

  constructor(foo : IFoo, bar : IBar) {
    this.foo = foo;
    this.bar = bar;
  }
}

For more details check out #33

from inversifyjs.

Related Issues (20)

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.