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

88
Views
How to make my TypeScript object available to a third party Javascript

I have an Angular application and need to create an API for a third party javascript that will be added dynamically.

public class MyApi{
   public callSomeFunction():void{...}
   public getSomeValue():any {...}   
}
var publicApi = new MyApi();

How do I get the publicApi object into javascripts global scope?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can add it to the global object of the client-side which is window object.

window.publicApi = new MyApi();
about 4 years ago · Santiago Trujillo Report

0

If by global scope you mean window then: (window as any).publicApi = new MyApi();
If you just want to import it from other packages then export it by adding
export const publicApi = new MyApi();

And then use it depending on which module system you use:
const {publicApi} = require('./path/to/publicApi')
or
import {publicApi} from './path/to/publicApi'

about 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!