4

Within an Angular CLI workspace, I created a library foo. Within library foo, I added a typings.d.ts file. I then managed to reference a type defined in typings.d.ts from foo.module.ts using the Typescript triple-slash directive. Now, I would like to not have to use the triple-slash directive but removing the directive results in the following error:

error TS2304: Cannot find name 'MyLibrary'.

I am a bit surprised that I am receiving this error because typings.d.ts is defined within the src directory and I am using a recent version of Typescript (v3.2.4). I therefore expected the compiler to pick up typings.d.ts out of the box. I also tried adding the following to tsconfig.lib.json:

"include": [
  "src/typings.d.ts"
]

I expected that at least this setting would take effect because the ng-packagr docs mention that within an Angular CLI project the tsconfig.lib.json file may be amended.

So, my specific question is the following: Is it possible to reference types from a typings.d.ts file within an Angular library without needing to use triple-slash references? If no, then why?

My sandbox is here.

Relevant Resources

Sam Herrmann
  • 6,293
  • 4
  • 31
  • 50

0 Answers0