etienne-martin/device-detector-js

How to import library?

pqr opened this issue · 1 comments

pqr commented

How to import the library into my typescript code?

  1. When I write
import DeviceDetector from 'device-detector-js';

I get an error "no default export".

  1. When I try
import * as DeviceDetector from 'device-detector-js';

It also shows an error and does not work.

  1. Third attempt:
import { DeviceDetector }  from 'device-detector-js';

Error: there is no exported member "DeviceDetector"

Example in README.md shows require syntax, but I want to use ES6 modules syntax.
Could you please and an example with ES6 modules syntax into README.md?

Hi there,

You need to use the CommonJS-style import syntax to use this module with typescript:

import DeviceDetector = require("device-detector-js");

I will update the README with instruction on how to use this module with typescript.

Thanks for the feedback.