Search code examples
angulartypescripttypescript-typingstype-hintingleaflet-geoman

How to use / declare an external module, which won't pass strict and noImplicitReturns TypeScript settings in Angular 11?


We have an Angular 11 application with strict mode turned on. It has these values in the compilerOptions configurtation in tsconfig.json:

"strict": true,
"noImplicitReturns": true,

Now we want to use an external library (leaflet geoman). The library is imported like this:

import * as L from 'leaflet';
import '@geoman-io/leaflet-geoman-free';

Unfortunately it includes implicit any types as well as implicit any return types:

Parameter 'options' implicitly has an 'any' type.
'setLang', which lacks return-type annotation, implicitly has an 'any' return type

How can I tell the compiler to ignore these errors from the module during compilation but keep strict mode turned on for the rest of the project?


Solution

  • You could call the compiler and use the --skipLibCheck flag to achieve what you want.

    --skipLibCheck is added in TypeScript 2.0: skiplibcheck

    tsc --skipLibCheck

    You can read more about why to use it in this thread:

    Usage of the TypeScript compiler argument 'skipLibCheck'