jacktuck / unfurl

Metadata scraper with support for oEmbed, Twitter Cards and Open Graph Protocol for Node.js :zap:
MIT License
475 stars 51 forks source link

Exports no types for Typescript #42

Closed dimroc closed 5 years ago

dimroc commented 5 years ago

When using unfurl like so, it leads to a complaint by typescript:

import unfurl = require("unfurl.js")
const unfurled = unfurl(last)
2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof import("/Users/dimroc/go/src/github.com/dimroc/storyboard/functions/node_modules/unfurl.js/dist/index")' has no compatible call signatures

This is probably because we don't export types: https://github.com/jacktuck/unfurl/blob/master/dist/index.d.ts

export {};

Let me know if I'm missing an easy step.

jacktuck commented 5 years ago

I've not tested but i think you've got your import wrong.

try import unfurl from "unfurl.js" or const unfurl = require("unfurl.js")

dimroc commented 5 years ago

Thanks for the quick response @jacktuck.

  1. import unfurl from "unfurl.js" has the same issue
  2. const unfurl = require("unfurl.js") works and is what I've ended up doing as a stopgap, but this doesn't import the type into the typescript world, it bypasses the type definition.
jacktuck commented 5 years ago

@dimroc Forgot to say. This should now be fixed :)

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 1.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: