TypeScript Transformer for injection-js

Overview

TypeScript Transformer for injection-js

build codecov

TypeScript Transformer for injection-js, inspired by angular-cli.

Why need this

  1. No more emitDecoratorMetadata needed.
  2. No more reflection, reflect-metadata or core-js needed.
  3. Make your code tree-shakeable.

How it works

The transformer would convert the following code:

import { Injectable, Optional, SkipSelf } from "injection-js";

@Injectable()
export class DependencyService {}

@Injectable()
export class DIService {
  constructor(
    @SkipSelf()
    @Optional()
    private dependencyService: DependencyService
  ) {}
}

into

import { Injectable, Optional, SkipSelf, Inject } from "injection-js";
export class DependencyService {
}
export class DIService {
    constructor(private dependencyService: DependencyService) { }
    static parameters = [[new Optional(), new SkipSelf(), new Inject(DependencyService)]];
}

How to use it with webpack

npm install injection-js-transformer
import { resolve } from "path";
import { Program } from "typescript";
import injectionTransformer from "injection-js-transformer";

const config = {
  module: {
    rules: [
      {
        test: /.ts$/,
        use: [
          {
            loader: "ts-loader",
            options: {
              configFile: resolve(__dirname, "./tsconfig.json"),
              getCustomTransformers: (program: Program) => {
                return {
                  before: [injectionTransformer(program)],
                };
              },
            },
          },
        ],
      },
    ],
  },
};

export default config;

License

MIT

You might also like...

:books: The definitive guide to TypeScript and possibly the best TypeScript book :book:. Free and Open Source 🌹

TypeScript Deep Dive I've been looking at the issues that turn up commonly when people start using TypeScript. This is based on the lessons from Stack

Jan 4, 2023

Variant types in Roblox TypeScript - Ported from Vanilla TypeScript

Variant types in Roblox TypeScript - Ported from Vanilla TypeScript

Variant (for Roblox) This is a roblox typescript variant (heh, pun) of Variant. See the Variant documentation on how to use Variant. A variant type is

Jun 3, 2022

A Lua plugin, written in TypeScript, to write TypeScript (Lua optional).

typescript.nvim A minimal typescript-language-server integration plugin to set up the language server via nvim-lspconfig and add commands for convenie

Dec 29, 2022

typescript-to-jsonschema generates JSON Schema files from your Typescript sources.

fast-typescript-to-jsonschema English | 简体中文 a tool generate json schema from typescript. Feature compile Typescript to get all type information conve

Nov 28, 2022

Convert some JavaScript/TypeScript code string into a .d.ts TypeScript Declaration code string

convert-to-dts Converts the source code for any .js or .ts file into the equivalent .d.ts code TypeScript would generate. Usage import { convertToDecl

Mar 3, 2022

Screeps Typescript Starter is a starting point for a Screeps AI written in Typescript.

Screeps Typescript Starter Screeps Typescript Starter is a starting point for a Screeps AI written in Typescript. It provides everything you need to s

Jan 27, 2022

Movehat is a TypeScript SDK for Move on Sui built on top of Sui's TypeScript SDK and our fork of Ian Macalinao's `move-ts`.

Movehat Movehat is a TypeScript SDK for Move on Sui built on top of Sui's TypeScript SDK and our fork of Ian Macalinao's move-ts. Movehat aspires to b

Sep 30, 2022

🐬 A simplified implementation of TypeScript's type system written in TypeScript's type system

🐬 A simplified implementation of TypeScript's type system written in TypeScript's type system

🐬 HypeScript Introduction This is a simplified implementation of TypeScript's type system that's written in TypeScript's type annotations. This means

Dec 20, 2022

A CLI tool to create a NodeJS project with TypeScript CTSP is a CLI tool to make easier to start a new NodeJS project and configure Typescript on it.

A CLI tool to create a NodeJS project with TypeScript CTSP is a CLI tool to make easier to start a new NodeJS project and configure Typescript on it.

CTSP- Create TS Project A CLI tool to create a NodeJS project with TypeScript CTSP is a CLI tool to make easier to start a new NodeJS project and conf

Sep 13, 2022
Owner
Yadong Xie
I remember I was here not because the way in front of me, but the way behind me. NG-ZORRO Creator / Google Developer Expert / Apache Committer
Yadong Xie
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
This is another Express + TypeScript + DDD (Domain Driven Design patterns) + IoC/DI (Inversion of control and Dependency injection) + Primsa ORM + API REST boilerplate.

Express-TS-DDD REST API This is another Express + TypeScript + DDD (Domain Driven Design patterns) + IoC/DI (Inversion of control and Dependency injec

J.D. 6 Nov 3, 2022
Font-end app to test the transformer model translation from Cape Verdian Creole to English

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Roberto Carlos 5 Sep 28, 2022
A JSX transformer with extra hints around interpolations and outer templates.

@ungap/babel-plugin-transform-hinted-jsx This plugin is a follow up of this post and it can be used together with @babel/plugin-transform-react-jsx. A

ungap 12 Nov 12, 2022
Markdown Transformer. Transform markdown files to different formats

Mdtx Inspired by generative programming and weed :). So I was learning Elm language at home usually in the evening and now I am missing all this gener

Aexol 13 Jan 2, 2023
Test for client-side script injection via NFTs

Rektosaurus A test suite to check for client-side script injection via NFTs. Overview NFTs contain a variety of metadata and content that gets process

Bernhard Mueller 42 Jun 28, 2022
A simpliest DI(Dependency Injection) example

di-example A simpliest DI(Dependency Injection) example showing how dependency injection actually works. How to Run Install dependency with your favor

Kelly 4 Dec 6, 2022
GPU Drops' captcha solving extension without affiliate tracking code injection

Noptcha, without affiliate link injection Noptcha is a reCaptcha and hCaptcha solving extension created by GPU Drops. This fork was made because I hat

Sqaaakoi 201 Dec 26, 2022
A functional, immutable, type safe and simple dependency injection library inspired by angular.

func-di English | 简体中文 A functional, immutable, type safe and simple dependency injection library inspired by Angular. Why func-di Installation Usage

null 24 Dec 11, 2022