Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

413
Vistas
Injecting script with chrome.scripting in TypeScript

I am trying to make chrome extension js code work with typescript:

    const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
    let result;
    try {
        [{ result }] = await chrome.scripting.executeScript({
            target: { tabId: tab.id },
            function: () => getSelection().toString(),
        });
    } catch (e) {
        return;
    }
    console.log('Selection: ' + result);
};

This logs user's selection on click of a button. However, when trying to work with this in typescript, it throws a cascade of errors at me. The first one is Property 'result' does not exist on type Property 'result' does not exist on type 'InjectionResult<unknown> | undefined'.

I have tried fiddling around with ! and ? operators, sending executeScript to a different function via func: but have not been able to get this to a working state. I also tried to make result and ordinary variable, but in this case No overload matches this call. exception is thrown on line 6. How do I go about resolving this? Also, can I find type reference for InjectionResult anywhere?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda