In my app, I have created a type definition file that exposes all dto objects to the global scope.
DtoGenerator.d.ts
declare module MyApp.Rest.Dto {
interface IAJsonDto {
}
}
declare module MyApp.Rest.Dto.Post {
interface ITest1PostDto extends MyApp.Rest.Dto.IAJsonDto {
code: string;
}
interface ITest2PostDto extends MyApp.Rest.Dto.IAJsonDto {
id: number;
}
interface ITest3PostDto extends MyApp.Rest.Dto.IAJsonDto {
id: number;
}
....
}
This setup is used in the following way:
file1.service.ts
import { ITest3PostDto } from MyApp.Rest.Dto.Post;
Recently, I migrated my app from Angular 8 and Typescript 3.5.3 to Angular 9 and Typescript 3.6.4. Before the migration, everything was working fine without any errors related to the consumption of Dto objects. However, after the migration, while building the app in watch mode using
ng build --extractCss=true --watch
, I started getting an error message 'Cannot find namespace 'MyApp'. Adding
/// <reference path="../../../../DtosGenerator.d.ts" />
at the top of the file resolved the issue. Is there a way to avoid adding this reference path and keep the code as it was before the migration?
Can anyone help me understand what might be causing this issue?