Include all transparently marshaled classes in type definitions
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 25/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- typescript
Piste de recherche
Commencez par les déclarations TypeScript générées pour NSData et sa méthode dataWithData, puis suivez le chemin de génération des définitions pour les fonctions natives qui acceptent des classes marshalées de manière transparente. C'est terminé lorsque les déclarations exposent les types union applicables, afin que l'exemple ArrayBuffer se compile sans cast vers any.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Is your feature request related to a problem? Please describe.
This doesn't cause any problems except that it's not always clear what types can be passed to a native function. I ran into this when looking at https://github.com/NativeScript/ios-runtime/pull/235/, and am not sure how many other types this would apply to.
Describe the solution you'd like
It would be nice if the type definitions for all native functions which accept JS or native classes in their parameters would reflect that as a union type. For instance the following TypeScript both compiles and runs as expected:
const f = (buffer:ArrayBuffer):NSData => {
return(NSData.dataWithData(buffer as any));
}
However, the any cast is circumventing the type system, so it's not clear whether this would actually work when running on the device. I would rather write it as follows, but this does not currently compile:
const f = (buffer:ArrayBuffer):NSData => {
return(NSData.dataWithData(buffer));
}
I assume the type definitions are generated automatically by some script, but my naive approach would be doing something like this:
declare type NSDataLike = NSData|ArrayBuffer;
declare class NSData extends NSObject implements CKRecordValue, NSCopying, NSMutableCopying, NSSecureCoding {
static dataWithData(data: NSDataLike): NSData;
Describe alternatives you've considered
I realize I could re-declare any native class in my project's code, but it seems like this would need to be done piecemeal, and in any case this would not help the declarations to act as documentation for other users. I'm not familiar enough with the internals of the TypeScript type system to suggest more sophisticated workarounds.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
- Langage dominant
- TypeScript
- Étoiles
- 25.7k
- Forks
- 1.7k
- Merge moyen
- 1 j 5 h
- PR mergées (30 j)
- 35
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de NativeScript/NativeScript
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
NativeScript/NativeScript#11068 ·
-
bug-pending-triage
Difficulté 3/5 1-2 jours Accessibilité débutants 66/100
NativeScript/NativeScript#11436 ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
NativeScript/NativeScript#11421 ·
-
bug-pending-triage
Difficulté 3/5 1-2 jours Accessibilité débutants 52/100
NativeScript/NativeScript#11415 ·
-
bug-pending-triage
Difficulté 3/5 1-2 jours Accessibilité débutants 48/100
NativeScript/NativeScript#11374 ·
Toutes les issues de NativeScript/NativeScript
Issues similaires
-
comp/dashboard P3 type/bug
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
NousResearch/hermes-agent#117722 ·
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulté 1/5 Moins d'une heure Accessibilité débutants 76/100
-
code-quality refactoring
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
langchain-ai/deepagents#6450 ·