Not quite familiar with custom modules. No idea how to resolve this issue. I am trying to migrate a code and I am stuck at this.
Module file in root of the folder - settings.d.ts
type Settings = {
group: {
field1: string;
field2: string;
...
};
};
declare module 'settings' {
const s: Settings;
export = s;
}
In tsconfig.json (same location as the settings.d.ts)
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"types": ["@emotion/react"],
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
},
"include": [
"src",
"settings.d.ts",
],
"exclude": [
"node_modules",
"build"
]
}
Imported in my-code.ts
. Tried the following imports with no typescript errors. I can also "go to file" to the actual settings.d.ts in vscode
import * as settings from 'settings';
import settings from 'settings';
import { field } from 'settings';
But the compilation fails with error
./src/.../folder/my-code.ts Module not found: Can't resolve 'settings' in '/Users/.../folder'
UPDATE A missing package in node_modules that my settings.d.ts is trying to augment with declarations. Far more complicated to add that package -- the way it was added in the legacy codebase. Wanna puke. Anyways, there's nothing wrong with the snippets above.