The Scenario:
I recently developed a TypeScript file named String.ts to enhance string functionality:
interface StringConstructor {
isNullOrEmpty(str: string): boolean;
isNullOrWhiteSpace(str: string): boolean;
}
String.isNullOrEmpty = (str: string) => !str;
String.isNullOrWhiteSpace = (str: string) => { return (String.isNullOrEmpty(str)) ? false : str.replace(/\s/g, '').length < 1 };
The tsconfig.json files that I have set up include:
{
"compilerOptions": {
"noImplicitAny": false,
"strict": true,
"noEmitOnError": true,
"module": "amd",
"removeComments": true,
"target": "es5",
"declaration": true,
"outFile": "./Common.js", --> This line only differs in other tsconfig.json files (+ it doesn't exist in the highest located tsconfig.json file)
"inlineSourceMap": true,
"inlineSources": true,
"lib": [
"dom",
"es5",
"es2015.promise"
]
},
"exclude": [
"node_modules",
"wwwroot"
]
}
File Organization:
- Common (folder)
~ String.ts
~ <other files>
~ tsconfig.json - Business (folder)
~ app.ts --> where we utilize String.IsNullOrWhiteSpace
~ <other files>
~ tsconfig.json - tsconfig.json
The Issue(in consecutive order)
1) Compilation works fine with one top-level tsconfig.json file
2) No issues arise when I introduce a tsconfig.json in Common directory
3) Running into a compilation error when adding a tsconfig.json in Business, specifically mentioning that String.isNullOrWhiteSpace cannot be found.
Seeking any insights on what might be causing this issue and potential solutions?
(Feel free to ask for more details if required!)