TypeScript - third-party libraries without definition files - maybe intellisense?

I use an IDE, this is a WebStorm, but my question is about any IDE.


I install some third-party node modules in my project, and some do not have the definition files available in DefinitelyTyped, or the definition files are outdated. The workaround I'm currently using for these libraries is one of the following:

  • declare a third-party namespace / module as type any
  • declare a minimal definition that defines the methods that I use that the library provides. eg:

    declare module 'redux-simple-router' {
      export function syncHistory(history: any): any
    
      export function routeReducer(): any
    }
    

2 slightly exceeds 1 because it gives more information, and I can get autocomplete for method names, for example, both methods are much inferior to what WebStorm offers if I use non - Typescript ES6 with Babel. Is there a way I can combine both intellisense methods in my project?

In other words, what I'm looking for is a way to tell WebStorm: for each import, if you have a type definition, use it if not, use regular intellisense (i.e. search for import in node_modules).

I hope my question is formulated in a way that makes sense if it somehow confuses, let me know.

+4
source share
1 answer
Is there any way that I can combine both intellisense ways in my project?

well... , WebStorm , typescript , node_modules, ( " " ..). node_modules - ( ..), typescript . / , ( ) node_modules /

0

Source: https://habr.com/ru/post/1624914/


All Articles