Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Typescript type errors

Abierto
#167 19 comentarios 2 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
typescript
Área
web-dev

Línea de trabajo

Reproduce los errores con TypeScript e inspecciona las declaraciones de types/dom/parser.d.ts, types/html/anchor-element.d.ts y types/html/document.d.ts junto con lib.dom.d.ts de TypeScript. Compara las firmas heredadas e implementadas indicadas para determinar si los tipos pueden conciliarse con las interfaces DOM globales. Se considera terminado cuando los errores de tipos indicados ya no requieren tsc --skipLibCheck.

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

Descripción

Hi there,
I'm running into loads of type errors from linkedom when using the library in a typescript project.

These type errors appear to all be either missing properties or incorrect implementations of base class methods (due to parameter types or return types not matching).

The errors are too long to send but I will send a few:

node_modules/linkedom/types/dom/parser.d.ts:12:5 - error TS2416: Property 'parseFromString' in type 'DOMParser' is not assignable to the same property in base type 'DOMParser'.
  Type '<MIME extends "image/svg+xml" | "text/html" | "text/xml">(markupLanguage: string, mimeType: MIME) => { "text/html": HTMLDocument; "image/svg+xml": SVGDocument; "text/xml": XMLDocument; }[MIME]' is not assignable to type '(string: string, type: DOMParserSupportedType) => Document'.
    Type 'HTMLDocument | SVGDocument | XMLDocument' is not assignable to type 'Document'.
      Type 'HTMLDocument' is missing the following properties from type 'Document': URL, alinkColor, anchors, applets, and 181 more.

12     parseFromString<MIME extends keyof {
       ~~~~~~~~~~~~~~~

node_modules/linkedom/types/html/anchor-element.d.ts:4:14 - error TS2420: Class 'import("C:/Users/felis/home/projects/test-linkedom/node_modules/linkedom/types/html/anchor-element").HTMLAnchorElement' incorrectly implements interface 'HTMLAnchorElement'.
  Type 'HTMLAnchorElement' is missing the following properties from type 'HTMLAnchorElement': charset, coords, hreflang, name, and 132 more.

4 export class HTMLAnchorElement extends HTMLElement implements globalThis.HTMLAnchorElement {
               ~~~~~~~~~~~~~~~~~

...

node_modules/linkedom/types/html/document.d.ts:6:9 - error TS2416: Property 'all' in type 'HTMLDocument' is not assignable to the same property in base type 'HTMLDocument'.
  Property 'namedItem' is missing in type 'NodeList' but required in type 'HTMLAllCollection'.

6     get all(): NodeList;
          ~~~

  ../../../AppData/Roaming/npm/node_modules/typescript/lib/lib.dom.d.ts:5953:5
    5953     namedItem(name: string): HTMLCollection | Element | null;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'namedItem' is declared here.

node_modules/linkedom/types/html/document.d.ts:15:9 - error TS2416: Property 'title' in type 'HTMLDocument' is not assignable to the same property in base type 'HTMLDocument'.
  Type 'HTMLTitleElement' is not assignable to type 'string'.

15     set title(arg: HTMLTitleElement);
           ~~~~~

...

Workaround: tsc --skipLibCheck

It'd be great to get the types correct here so --skipLibCheck isn't needed. I would make a PR for this however it seems design decisions would need to be made to fix the types. I'm not sure if the types can be reconciled while still extending / implementing globalThis.DOMParser, globalThis.HTMLElement, /globalThis\.HTML.*Element/, etc.

Lenguaje dominante
HTML
Estrellas
2.1k
Forks
104
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Aún no hemos revisado los archivos de configuración de este proyecto. Empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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.

Más de WebReflection/linkedom

Todos los issues de WebReflection/linkedom

Issues similares

Más issues de Web Dev

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.