0

We have a typescript class,which contains few methods. Sample example of the TypeScript class.

 export class AppointmentListComponent implements OnInit {
    editEvent(event: IEvent): void {
        this._router.navigate(['/appointments', event.id]);
    }
 }

We want to call editEvent method from another (.js) file. How can we achieve this.

2

1 Answer 1

-2

If you are working with ES6 it's pretty simple. In typescript just use import "pathToJSModule"; and you are ready to use it. This is possible because JS is a valid Typescript.

If you are not working with ES6 you can use import * as foo from "pathToFile".

Sign up to request clarification or add additional context in comments.

1 Comment

That's the wrong way round. OP wants to use TypeScript code from JavaScript, not JavaScript code from TypeScript

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.