Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including folder outside src for TypeScript compiler

Tags:

typescript

I need to add a generated folder, which is neither part of global ambient nor in the src, to supply modules for the source files as valid namespaces, such as below:

root
|- src
   |-- component
       |-- test.model.ts ( import { IBuilding } from 'api/interfaces.ts' );
|- generated
   |-- api
       | interfaces.ts ( export interface IBuilding {} )

I have read about Modules and Module Resolution in official documentation but none of the options below see to apply:

  • tsconfig.json -> compilerOptions.paths (path mapping)
  • tsconfig.json -> compilerOptions.rootDirs (virtual directory)
  • tsconfig.json -> include (file name patterns)

In my case it would be very much similar to what CLASSPATH and PYTHON_PATH do for Java and Python respectively.

Anyone can help?

like image 918
Marinho Brandão Avatar asked Oct 16 '25 16:10

Marinho Brandão


1 Answers

Seems like you could do this in your tsconfig.json with a filesGlob:

"filesGlob": [
    "**/*.ts", //Local source, this is the default
    "../generated/**/*.ts" //generated source
], //Add as many directories to the above list as needed
like image 196
Pace Avatar answered Oct 18 '25 13:10

Pace



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!