Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

602
Views
Encontrar ResizeObserver con Typescript en Angular 9

Estoy tratando de implementar un ResizeObserver en una aplicación Angular:

 const obs = new ResizeObserver(e => { // ... });

... y me encontré con el error TS:

 TS2304: Cannot find name 'ResizeObserver'.

He intentado actualizar mi definición de tipo con:

 @types/resize-observer-browser

... sin embargo, mi problema persiste. ¿Existe una solución recomendable o una solución común, o sería mejor usar un paquete NPM como 'resize-observer' para seguir avanzando?

Feliz de incluir más información si es necesario.

¡Gracias!

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Tuve el mismo problema porque de la matriz de "tipos" vacía en mi archivo tsconfig. Resuelto agregando "resize-observer-browser" a la matriz de tipos:

 { "extends": "./tsconfig.json", "compilerOptions": { "typeRoots": ["node_modules/@types"], "types": ["resize-observer-browser"], } }
over 4 years ago · Santiago Trujillo Report

0

Sugiero usar resize-observer-polyfill tiene tipos (en el archivo d.ts) y si el navegador es compatible con Resize Observer, solo usa la implementación nativa, pero tiene un mayor soporte porque usa Mutation Observer como un respaldo que tiene un soporte mucho mayor. .

Así que solo usa:

 import ResizeObserver from 'resize-observer-polyfill';

El navegador admite comparar:

  • Redimensionar observador
  • Observador de mutaciones

como puede ver, Mutation Observer incluso funciona en IE 11.

over 4 years ago · Santiago Trujillo Report

0

Instalación de este paquete de nodo

npm i -D @types/resize-observer-browser

resolvió el problema en el proyecto Angular 10.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!