Skip to content

Typescript prevents compilation #5937

Closed
@wafisher

Description

@wafisher

Is this a bug report?

Yes

Did you try recovering your dependencies?

$ yarn --version
1.12.3

Environment

Environment Info:

  System:
    OS: macOS 10.14.1
    CPU: x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  Binaries:
    Node: 11.0.0 - /usr/local/bin/node
    Yarn: 1.12.3 - ~/.yarn/bin/yarn
    npm: 6.4.1 - ~/Desktop/Radar/frontend/node_modules/.bin/npm
  Browsers:
    Chrome: 70.0.3538.110
    Safari: 12.0.1
  npmPackages:
    @types/react: ^16.7.10 => 16.7.10 
    @types/react-dom: ^16.0.11 => 16.0.11 
    react: ^16.6.3 => 16.6.3 
    react-dom: ^16.6.3 => 16.6.3 
    react-scripts: 2.1.1 => 2.1.1 
  npmGlobalPackages:
    create-react-app: Not Found

Expected Behavior

I expect yarn start to compile even with Typescript errors. Typescript is, by my understanding of CRA's philosophy, just an extra layer but won't prevent compilation. yarn start worked fine with Typescript errors a few days ago, not sure what I changed but I came into Typescript pre-2.1.0 and I may have updated accidentally.

Actual Behavior

I get a Typescript compile error. Using a reproducible demo:

I create a simple reproducible demo:

$ yarn create react-app my-app --scripts-version=react-scripts-ts
$ cd my-app
$ yarn add react-bootstrap@next bootstrap

with the following index.tsx:

[imports]
import Form from 'react-bootstrap/es/Form'
...

render() {
  return (
    ...
    <Form></Form>
    ....
  )
}

and I get the following error after yarn start:

(3,18): Could not find a declaration file for module 'react-bootstrap/es/Form'. '/private/tmp/my-app/node_modules/react-bootstrap/es/Form.js' implicitly has an 'any' type.
  Try `npm install @types/react-bootstrap` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-bootstrap/es/Form';`

I've been digging through the webpack configuration (slowly) and it seems like this might be related?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions