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
{{ message }}
This repository was archived by the owner on Jan 26, 2019. It is now read-only.
If I use const _ = require('lodash') the tests pass, but then yarn start says "require statement not part of an import statement".
If I try import _ = require('lodash'), I get "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.".
If I rename foo.ts to foo.js, the test passes, so the problem seems to be TypeScript-related.
I had the same issue trying to import pouchdb, so it's not just lodash, and they both work in the browser.
Any advice would be appreciated, I just recently started using TypeScript. Thank you.
The text was updated successfully, but these errors were encountered:
Thanks @bagilevi - easy fix. Out of curiosity, would you be able to explain to me why this behavior differs between start and test? The original syntax import _ from 'lodash' behaves fine in the start context.
Is this a bug report?
Yes
Can you also reproduce the problem with npm 4.x?
Yes
Which terms did you search for in User Guide?
test jest import require undefined
Environment
npm ls react-scripts-ts
(if you haven’t ejected): 2.16.0node -v
: v9.7.1npm -v
: 4.6.1 (also 6.1.0)yarn --version
(if you use Yarn): 1.5.1npm ls react-scripts-ts
(if you haven’t ejected): 2.16.0Then, specify:
Steps to Reproduce
lodash
inApp.jsx
and try to call a function on itExpected Behavior
Test should pass.
Actual Behavior
Test suite fails to run:
Reproducible Demo
https://github.com/bagilevi/cra-ts-import
Relevant diff:
bagilevi/cra-ts-import@3b986a0
Notes
If I use
const _ = require('lodash')
the tests pass, but thenyarn start
says "require statement not part of an import statement".If I try
import _ = require('lodash')
, I get "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.".If I rename
foo.ts
tofoo.js
, the test passes, so the problem seems to be TypeScript-related.I had the same issue trying to import
pouchdb
, so it's not justlodash
, and they both work in the browser.Any advice would be appreciated, I just recently started using TypeScript. Thank you.
The text was updated successfully, but these errors were encountered: