microsoft / microsoft/TypeScript

Incorrect type handing/reduction

Abierto
#58,591 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Needs More Info
Lenguaje dominante
Go
Estrellas
111k
Forks
14.4k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

Descripción

🔎 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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con la reproducción vinculada de TypeScript Playground y reduce la interacción entre reduxForm, withTranslation, IntrinsicAttributes y las props del componente. Compara el tipo inferido de GForm con el error reportado y verifica después que el uso final de JSX no produzca errores de tipo.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
react, typescript
Área
compilers
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.