How to import plain JS into TypeScript (without Typings)

前端 未结 1 379
说谎
说谎 2021-02-04 10:36

We have a project using TypeScript with ts-loader in Webpack, for most of the things we\'ve used now there were type definitions in Definitely Types (via typings),

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-04 11:04

    # declarations.d.ts
    declare module '*';
    
    # someFile.ts
    import * as $ from 'jquery';
    import * as _ from 'lodash';
    

    If you have types for one module code completion should work and the compiler will assume you know what you are doing. I think ts loader should respect that as well. Please test and let me know.

    0 讨论(0)
提交回复
热议问题