Open phanmn opened 5 months ago
I can't reproduce this issue. Did you copy the iframe example as-is? Here's a TypeScript playground I created that shows it all working: https://tsplay.dev/m3dpyW
This might be relevant to you: docs
The schema types affect the rpc
instance types. If the remote schema type doesn't declare any messages it can send, then your local rpc
instance type won't have an addMessageListener
method, since there's no message to listen to. The README example does have it though, so I'm not sure what's going on in your case.
It would easier for me to debug if you could share a more complete reproduction of the issue, using the TypeScript playground or a sandbox service like Stackblitz
Thanks @DaniGuardiola , I will try to give you reproduction soon
I found the reason, because the tsconfig.json
My original config (from nuxt3)
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json",
"vueCompilerOptions": {
"plugins": ["@vue/language-plugin-pug"]
},
"compilerOptions": {
"sourceMap": true,
"strict": false,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"resolveJsonModule": true,
"isolatedModules": true,
"types": []
}
}
Missing config
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"declaration": true,
"target": "ES2017",
"module": "ESNext"
Interesting. Could you find the specific config value that makes it break/work? It'd help to get a narrowed-down version so I can investigate.
In which versions of the package (and relevant enviroment tools such as Node.js) have you observed the bug?
1.7.0
What steps will reproduce the bug?
Follow README
What behavior did you expect?
No ts error
What actually happened?
Property 'addMessageListener' does not exist on type 'RPC<IframeSchema, ParentSchema>'
Workaround
No response
Proposed fix
No response
Other remarks
No response
Contribution