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
This is because there's a "discrepancy" between the typescript declaration file (dist/tiny-invariant.d.ts) and the CJS distribution (dist/tiny-invariant.cjs.js) - the first specifying a default export (-> which is why your IDE thinks you can only use a default import) and the latter specifying a CJS root export (module.exports = invariant).
When you now convert your code to CJS before running it (due to target being set to es5), tsc will import invariant using const invariant = require('tiny-invariant').default - which won't work, due to it being exported directly (not as default) in tiny-invariant.cjs.js.
Unless there's some specific reason for you not to do it, this is easily fixed by enabling the esModuleInterop ts compiler option.
It seems this was different in the past, leading to issue #60 😂
I have a ts serverless repo with the following
tsconfig.json
:When I import
tiny-invariant
with its default import (import invariant from 'tiny-invariant'
) , my serverless crashes:But if I import it using named import (
import * as invariant from 'tiny-invariant'
), it works fine except now my vscode starts complaining:Is there something wrong with my configuration?
The text was updated successfully, but these errors were encountered: