You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is not recognized when I import computer-name, it gives the standard warning about no types. When I add the suggested declare module 'computer-name':
TS now gives this warning: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.. esModuleInterop is on, so it seems to be the star import.
When I use const computerName = require('computer-name'), computerName will be typed as any, so that works for now, but it would be nice if I could get it correct.
The text was updated successfully, but these errors were encountered:
I tried to create TypeScript types for this module, but couldn't figure out how to do it in combination with importing it as a module:
I need to use the
* as
otherwise I get an error at runtime telling metab3.tsx? [sm]:16 Uncaught TypeError: computer_name_1.default is not a function
.I can't manage to type this import and get
computerName
to be a function returning a string. Has someone done this?Here is what I tried so far (content of my
src/types/computer-name.d.ts
):It is not recognized when I import
computer-name
, it gives the standard warning about no types. When I add the suggesteddeclare module 'computer-name'
:TS now gives this warning:
This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
.esModuleInterop
is on, so it seems to be the star import.When I use
const computerName = require('computer-name')
,computerName
will be typed asany
, so that works for now, but it would be nice if I could get it correct.The text was updated successfully, but these errors were encountered: