I'm using FastClick with FastClick.d.ts. TSC is using module: "commonjs"
and I'm bundling with Webpack. I can't figure out how to reference FastClick.
How can I import FastClick into TypeScript? If I do this:
import {FastClick} from 'fastclick'
FastClick.attach(document.body);
I get no TSC compile errors, but the transpiled code looks like this:
var fastclick_1 = require('fastclick');
fastclick_1.FastClick.attach(document.body)
Which doesn't work. fastclick_1
appears to be the FastClick
function itself.
If I do this:
import * as FastClick from 'fastclick'
FastClick.attach(document.body)
I get a compile error Error:(6, 49) TS2339: Property 'attach' does not exist on type 'typeof fastclick'
, but the emitted JS works:
var FastClick = require('fastclick');
FastClick.attach(document.body);
So how can I get TSC and the emitted JS to both work? Is the FastClick.d.ts
wrong? Am I importing the module wrong?