Search code examples
angulartypescriptnrwl

Where to put definition file to be accessible in multiple apps in NRWL


I'm using NRWL to manage my projects. Currently, I have two projects that use custom definition files for typescript. Say, I have json-typings.d.ts and custom.d.ts.

Example the json-typings.d.ts definition file is this:

 declare module '*.json' {
  const value: any;
  export default value;
}

Source: https://hackernoon.com/import-json-into-typescript-8d465beded79

So whenever I run app-project-1 or app-project-2 I need to place those two custom definition files in each, making duplicates; or worst just move them whenever I serve a project. I even tried placing them in libs or apps folder but still wouldn't work.

Is there a way to do this?

Thanks


Solution

  • In the root of the workspace, you will be able to see a file tsconfig.json where all definitions are defined, and if you open an app inside the workspace, there is a file tsconfig.app.json, if you open the code for tsconfig.app.json its first line is it extends tsconfig.json, you can do something like that, tsconfig.json is common to complete app and tsconfig.app.json is app specific