'Share same variable value in attributes of package.json and tsconfig.json

In tsconfig.json I define the property outdir, for instance like this

tsconfig.json

{
    ....
    "compilerOptions": {
        "outDir": "my-outdir"
     }
}

Now, I need to use the same value, my-outdir, in some scripts of package.json.

What I have been able to do so far is to define a custom property in my package.json where I store the value my-outdir and reference it in the scripts section, like this

{
    ...
    "scripts": {
        "version": "npm run tsc && git add -A ${npm_package_my_app_outdir}",
        ...
    }
    "my_app": {
        "outdir": "my-outdir"
    }
}

What I am missing though is a way to reference the same value in tsconfig.json. Is there a way to have only one place where I define the value my-outdir and reference it both in tsconfig.json and package.json?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source