itsdouges/typescript-transformer-handbook

How can I share a custom argument from a user's `tsconfig.json` to my custom plugin?

aloisdg opened this issue · 1 comments

How can I share a custom argument from a user's tsconfig.json to my custom plugin?

To install a plugin we do:

{
  "compilerOptions": {
    "plugins": [
      {
        "name": "typescript-my-plugin"
      }
    ]
  }
}

I would love to be able to write something akin to:

{
  "compilerOptions": {
    "plugins": [
      {
        "name": "typescript-my-plugin",
        "foo": "bar",
        "options": ["verbose", "production"]
      }
    ]
  }
}

or even

{
  "compilerOptions": {
    "plugins": [
      {
        "name": "typescript-my-plugin"
      }
    ],
    "foo": "bar",
    "options": ["verbose", "production"]
  }
}

I checked the Intro to the TSConfig Reference without finding what I was looking for.

I also posted this question on Stack Overflow: https://stackoverflow.com/questions/71255330/how-can-i-share-a-custom-argument-from-a-users-tsconfig-json-to-my-custom-plu

AFAIK there is no official support in tsconfig.json for that, so you have to use for example ttypescript which provides more options like you want:

https://github.com/madou/typescript-transformer-handbook#consuming-transformers
https://github.com/cevek/ttypescript#compileroptions