Vienna Vienna - 4 months ago 44
TypeScript Question

Angular2 & Typescript: Error TS2339: Property 'selectpicker' does not exist on type 'ElementFinder'

Unfortunately we have to use old libraries in the current project, that require jQuery. The activation of those happen in the lifecycle hook section "ngAfterViewChecked". Due to fact, that TypeScript cannot resolve it at the right time, it outputs the error:

Error TS2339:
Property 'selectpicker' does not exist
on type 'ElementFinder'.

That is the concerned code block:

ngAfterViewChecked () {
if ( {
//noinspection TypeScriptUnresolvedFunction

I've added the line
//noinspection TypeScriptUnresolvedFunction
before the selectpicker activation, but it did not help.

We have a preconfigured build-system and because of such of errors it "bounces" us. How can I get rid of this problem?


You have to extend the type definitions of jQuery. Which means merging the jQuery namespace with your custom .d.ts that defined the .selectpicker() method. See the documentation for help:

Depending on your jQuery definition files this might work:

interface JQuery {
  selectpicker: () => void;