typescriptes6-modulestypescript-definitions

How to write typescript definition of 3rd party module so that it I can import anything


I have a 3rd party library without typescript definitions.

Can I write module declaration that will allow me to import anything from that module?

import { Anything } from 'untypedexternalmodule';

Solution

  • Yes. Just add a global.d.ts file to your project containing

    declare module 'untypedexternalmodule';
    

    If you try running the code you wrote you will get information asking you to do exactly this.