'Namespace split in multiple files not able to recognize class in same namespace
Hello folks I am working on a backend service using typescript and trying do something like following:
a.ts
export namespace X {
export abstract class A {
}
}
b.ts
/// <reference path="a.ts" />
export namespace X {
export class B extends A {
}
}
When I run npm run build I get an error saying Cannot find name A for b.ts
Here's my tsconfig.json
{
"extends": "@tsconfig/node16-strictest-esm/tsconfig.json",
"compilerOptions": {
"target": "es2018",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"moduleResolution": "node"
}
}
I also tried adding outFile property as explained in typescript namespaces handbook in tsconfig.json and specificed the file name where all ts files with same namespace should be merged together but that did not help either. I also checked this git issue created by someone which kind of explains similar issue but they were using a js file as reference. I also looked at the stackoverflow link mentioned in the issue comments but that doesn't work. Could you please help?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
