whatsapp-api-js
whatsapp-api-js copied to clipboard
Types not working correctly unless module: "presserve"
Describe the bug
Typescript doesn't resolve types correctly unless my tsconfig uses module: Presserve
To Reproduce
Steps to reproduce the behavior:
- Use a tsconfig like this:
{
"compilerOptions": {
"esModuleInterop": true,
"skipLibCheck": true,
"target": "es2022",
"allowJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,
"verbatimModuleSyntax": true,
"allowImportingTsExtensions": true,
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
/* The important option, with module: NodeNext it doesn't work, only with Presserve */
"module": "NodeNext",
"outDir": "dist",
"sourceMap": true,
"lib": ["es2022"]
}
}
- Try the following code:
import type { OnMessageArgs } from "whatsapp-api-js/emitters";
const args = {} as OnMessageArgs;
args.message.type;
// ^? any
The type of args.message.type
is any
.
- If we change the tsconfig compiler option module to
Preserve
the type is correctly resolved:text | audio | ...
Expected behavior Types should just work, the current tsconfig follows this recommendations
Desktop (please complete the following information):
- OS: mac OS
- Runtime: node 22
- Library Version: 4.0.3, typescript 5.3.3
Additional context Add any other context about the problem here.