Giter Site home page Giter Site logo

temp-react-ts-js-issue's Introduction

This repo is meant as a repro indicative of some JS-to-TS conversion issues - where converting a single file is impossible without converting yet more files, causing yak shaving.

This is a bad TS - JS interop issue - inferred properties in JS are inferred as required, but there is no way to opt out of it.

  • we have allowJs: true
  • index.tsx imports Button.js
  • Button.js has a Button component with a destructured prop color. this is inferred as a REQUIRED prop... but actually is optional because of code lower down
  • my goal is to be able to work on index.tsx with NO CHANGE to Button.js, and have a successful TS build

run yarn ts to see failure.

$ tsc
src/index.tsx:11:8 - error TS2741: Property 'color' is missing in type '{}' but required in type '{ color: any; }'.

11       <Button />
          ~~~~~~


Found 1 error.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

this is a hurdle for converting JS codebases to TS by the "just rename it" strategy because it causes cascading errors.

temp-react-ts-js-issue's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.