You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In most cases, it works fine. However, when the inherited object has multiple constructor functions with different parameter counts, it cannot accurately match, for example:
JavaAdapter(android.widget.Button,{setOnClickListener(view){console.log(view);},},activity,// new android.util.AttributeSet());
This usage is correct and matches one of the constructor functions, but TypeScript prompts "Expected 4 arguments, but got 3." It works only when I add new android.util.AttributeSet(). The partial declaration of android.widget.Button is as follows:
🔍 Search Terms
I have implemented a function
JavaAdapter
to inherit classes and return instantiated objects. Now I'm creating a declaration for it.In most cases, it works fine. However, when the inherited object has multiple constructor functions with different parameter counts, it cannot accurately match, for example:
This usage is correct and matches one of the constructor functions, but TypeScript prompts "Expected 4 arguments, but got 3." It works only when I add new android.util.AttributeSet(). The partial declaration of
android.widget.Button
is as follows:Besides changing to
constructor(context: android.content.Context, attribute?: android.util.AttributeSet);
, can TypeScript better adapt?✅ Viability Checklist
⭐ Suggestion
TypeScript matches correctly based on parameters
📃 Motivating Example
Enhance the user experience of typescript
💻 Use Cases
The text was updated successfully, but these errors were encountered: