Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

[TypeScript] Some issues  #5737

Closed
Closed

Description

@ficristo

I copy and pasted the React types in https://codemirror.net/mode/javascript/typescript.html and found some issues.


Issue 1:

type ReactType<P = any> =
        {
            [K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K] ? K : never
        }[keyof JSX.IntrinsicElements] |
        ComponentType<P>;

any, JSX.IntrinsicElements, P, K, never, ComponentType should be highlighted as type
keyof should be highlighted as keyword


Issue 2:

interface FunctionComponentElement<P> extends ReactElement<P> {
    ref?: 'ref' extends keyof P ? P extends { ref?: infer R } ? R : never : never;
}

P, R, never should be highlighted as type
infer should be highlighted as keyword


Issue 3:

type Factory<P> = (props?: Attributes & P, ...children: ReactNode[]) => ReactElement<P>;

ReactNode, ReactElement, P should be highlighted as type


Issue 4:

interface ExoticComponent<P = {}> {
        (props: P): (ReactElement<any>|null)
        readonly $$typeof: symbol
}

If the property is between round bracket highlighting is not correct.


Issue 5:

type ContextType<C extends Context<any>> = C extends Context<infer T> ? T : never;
type Provider<T> = ProviderExoticComponent<ProviderProps<T>>;

infer should be highlighted as keyword
T, never should be highlighted as type
Highlighting of second line is broken but it seems because the previous line is not rendered correctly.


Issue 6:

    class Component {
        setState<K extends keyof S>(
            state: ((prevState: Readonly<S>, props: Readonly<P>) => (Pick<S, K> | S | null)) | (Pick<S, K> | S | null),
            callback?: () => void
        ): void;
        forceUpdate(callBack?: () => void): void;
        render(): ReactNode;
    }

setState is not highlighted properly so forceUpdate and render are not rendered correctly.

Activity

  1. ficristo commented on Jan 20, 2019

    @ficristo
    ContributorAuthor

    Issue 7:

    interface HTMLAttributes<T> extends DOMAttributes<T> {
            /** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */
            'aria-activedescendant'?: string;
            /** Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. */
    	'aria-atomic'?: boolean | 'false' | 'true';
    }
    interface IntrinsicElements {
      "var": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
      switch: React.SVGProps<SVGSwitchElement>;
    }

    Types after quoted properties in interfaces aren't handled correctly.

  2. ficristo commented on Jan 21, 2019

    @ficristo
    ContributorAuthor

    Thank you!

  3. added 2 commits that reference this issue on Jan 6, 2020
    414dbe7
    c4d8d5d
  4. added a commit that references this issue on Jan 21, 2020
    2e3f6d4
  5. added a commit that references this issue on Sep 5, 2024
    e68dd64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions