React-popper: Update TS typings for Popper

Created on 12 Mar 2018  路  5Comments  路  Source: popperjs/react-popper

I've just update MUI next to beta 37 and with it popper at v1.14 (previously it was v1.12). But not the TS compiler would complain about wrong typings:

node_modules/react-popper/react-popper.d.ts(38,17): error TS2503: Cannot find namespace 'PopperJS'.

I guess instead of:

import PopperJS from "popper.js";
const v: PopperJS.Placement;

we should use:

import {Placement} from "popper.js";
const v: Placement;

or

import * as PopperJS from "popper.js";
const v: PopperJS.Placement;
TypeScript Madness

Most helpful comment

Oh fuck, I hate TypeScript, it's so fucking cryptic... Would it be a solution if a dropped support for it from Popper.js completely? I can't stand it anymore 馃槱

Bloody me and the day I decided to merge the TS support PR...

All 5 comments

This is breaking for us as well. I believe that this is related to the following change in Popper.js released just now in 1.14.0, where Popper is no longer a namespace.

https://github.com/FezVrasta/popper.js/commit/3315a6823f1685684fccf45f3fde407f1ca3716c#diff-01613ef3d5a6b03e140f807e6a8379bb

@FezVrasta @souporserious any hints? :)

Oh fuck, I hate TypeScript, it's so fucking cryptic... Would it be a solution if a dropped support for it from Popper.js completely? I can't stand it anymore 馃槱

Bloody me and the day I decided to merge the TS support PR...

馃槅 @FezVrasta I don't think you need to. Changing the way this lib declares the import should suffice. There is already a PR here that addresses the typings, it just needs to be changed slightly.

I've just testd with import * as PopperJS from "popper.js"; instead of import PopperJS from "popper.js"; and it seems to work.

Ideally you'd always import the necessary exported objects from the lib instead of everything:

// e.g.
import {Placement, Modifiers} from 'popper.js';

The simplest fix for now is to just add "popper.js": "1.12" to your package.json (remove package-lock.json contents for one npm i). This way you will overwrite your 1.14 that gets installed as a dep of mui beta-37 with 1.12!

Fixed in 0.8.3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

linusthe3rd picture linusthe3rd  路  4Comments

bgando picture bgando  路  3Comments

craigsketchley picture craigsketchley  路  3Comments

0xdevalias picture 0xdevalias  路  6Comments

websitesca picture websitesca  路  5Comments