microsoft / microsoft/TypeScript

Incorrect type handing/reduction

Ouverte
#58,591 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Needs More Info
Langage dominant
Go
Étoiles
111k
Forks
14.3k
Merge moyen
1 j 19 h
PR mergées (30 j)
117

Description

🔎 Search Terms

withTranslation, reduxForm, IntrinsicAttributes

🕗 Version & Regression Information
  • This is the behavior in every version I tried (that supports this type checking), and I reviewed the FAQ for entries about
⏯ Playground Link

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAJQKYEMDG8BmUIjgcilQ3wG4AoUSWOAbziIBMBXADwDFoQAaOASQB2AKyQYkjTlBAAFHGADOcAL5xsuAkzYBaTFzKVw0ePQDuwGAAsAKlBQD5AGxQxgEAbwDq567ftOXbsqqOHiExDBawACMABwCSKww+uQwAJ5gSHBWshAKcAC8dHBgAFxwAswgAEZIUMoUaRlZkiDswEgOjIqF9ADWAPxlFdW19SnpmVYAgg4OOXmF2XKKAGRwXpY2do7OrgINE1lWBVkzc8twa4IiYhJc8-IAPFYtbR1dvNOzDwB8FORoNzyeAAcROAAppGUrFYAJQFH5wR6gADmcBQDhg+VoAGUYFBgAIUZCAHRgWEqAD0fwBQNBLXEJ00HC4z1e7U68k+Z1+4PouikZXwmHwylh4JBsIogPs9K4JzMm18OwCAnB4pBDMYUvI5AS1HgMuBcHYEPh+URj018rA2KiVL+QA

💻 Code
import React from 'react';
import { reduxForm, InjectedFormProps } from 'redux-form';
import { withTranslation, WithTranslation } from 'react-i18next';

type TProps = { p: number };
type TFormFields = { k?: number };
type TAllProps = TProps & WithTranslation;
type TT = TAllProps & InjectedFormProps<TFormFields, TAllProps>;

const G = (P: TT) => <img alt={String(P.p)} />;
const GFormed = reduxForm<TFormFields, TAllProps>({ form: 'f' })(G);
const GForm = withTranslation()(GFormed);

export const F = () => <GForm p={1} />;
🙁 Actual behavior

It complains about the last line, about p={1} -

Type '{ p: number; }' is not assignable to type 'IntrinsicAttributes & Omit<Subtract<DecoratedFormProps<TFormFields, TAllProps, string> | undefined, WithTranslationProps>, keyof WithTranslation<...>> & WithTranslationProps'.
Property 'p' does not exist on type 'IntrinsicAttributes & Omit<Subtract<DecoratedFormProps<TFormFields, TAllProps, string> | undefined, WithTranslationProps>, keyof WithTranslation<...>> & WithTranslationProps'.

It is wrong or non-sensical, as all of those types I used add or omit their high-order-component types from the type I pass, so ComponentType<TProps> should end up being the type of GForm, but it is not

🙂 Expected behavior

No type errors

Additional information about the issue

No response

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par la reproduction liée dans TypeScript Playground et réduisez l’interaction entre reduxForm, withTranslation, IntrinsicAttributes et les props du composant. Comparez le type inféré de GForm avec l’erreur signalée, puis vérifiez que l’utilisation finale de JSX ne produit aucune erreur de typage.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
react, typescript
Domaine
compilers
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.