Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property 'addMessageListener' does not exist on type 'RPC<IframeSchema, ParentSchema>' #28

Open
1 task
phanmn opened this issue Jun 11, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@phanmn
Copy link

phanmn commented Jun 11, 2024

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

  • I would like to try to contribute a fix
@phanmn phanmn added the bug Something isn't working label Jun 11, 2024
@DaniGuardiola
Copy link
Owner

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

@DaniGuardiola
Copy link
Owner

DaniGuardiola commented Jun 11, 2024

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

@phanmn
Copy link
Author

phanmn commented Jun 11, 2024

Thanks @DaniGuardiola , I will try to give you reproduction soon

@phanmn
Copy link
Author

phanmn commented Jun 24, 2024

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"

@DaniGuardiola
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants