-
Notifications
You must be signed in to change notification settings - Fork 95
Open
Description
Description
When attempting to import types from the @stomp/stompjs package in a NestJS application within an Nx monorepo, TypeScript fails to find declaration files and defaults to any type.
Environment
- Framework: NestJS
- Language: TypeScript
- Build System: Nx (monorepo)
- Package:
@stomp/stompjs - Module Resolution:
nodenext - Target:
es2022
Import Usage
import {
IFrame,
IMessage,
Client as StompClient,
StompConfig,
StompSubscription,
} from '@stomp/stompjs';Error Message
Could not find a declaration file for module '@stomp/stompjs'. '/Users/mishabredewold/Documents/Code/trading-powertrader-intraday/node_modules/@stomp/stompjs/bundles/stomp.umd.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/stomp__stompjs` if it exists or add a new declaration (.d.ts) file containing `declare module '@stomp/stompjs';`
Configuration
tsconfig.base.json
app/tsconfig.json
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "NodeNext",
"forceConsistentCasingInFileNames": true,
"strict": true,
"importHelpers": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noPropertyAccessFromIndexSignature": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}Attempted Solutions
- Verified that @stomp/stompjs is properly installed
- Checked for existence of @types/stomp__stompjs (not available)
- Reviewed TypeScript configuration settings
Questions
- Is this a known compatibility issue with moduleResolution: "nodenext"?
- Could Nx have any impact on this issue?
- I have tried resolving this by manually making a module definition but this seemed to not retain Type hinting. Are there any best practices or guidelines I could follow for this?
Additional Context
- The error specifically points to the UMD bundle (stomp.umd.js) rather than ESM exports, which might be related to the module resolution strategy in use.
cj-christoph-gysin
Metadata
Metadata
Assignees
Labels
No labels
{ "compilerOptions": { "rootDir": ".", "composite": true, "declarationMap": true, "emitDeclarationOnly": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "importHelpers": true, "lib": ["es2022"], "module": "nodenext", "moduleResolution": "nodenext", "esModuleInterop": true, "noEmitOnError": true, "noFallthroughCasesInSwitch": true, "noImplicitOverride": true, "noImplicitReturns": true, "noUnusedLocals": true, "resolveJsonModule": true, "skipLibCheck": true, "skipDefaultLibCheck": true, "strict": true, "useUnknownInCatchVariables": false, "target": "es2022", "customConditions": ["development"], "baseUrl": ".", "paths": { // paths to local libraries } }, "exclude": ["infra/**", "node_modules", "tmp"] }