lyft/react-javascript-to-typescript-transform

Cannot read property 'kind' of undefined

ngohungphuc opened this issue · 7 comments

When I run

react-js-to-ts my-react-js-file.js

I got this error

conemu64_2018-12-02_19-59-18

Below is my code

import React from "react";
import PropTypes from "prop-types";

import {validateInput} from "../../Helper/Validation";

import Spinner from "../ACCAnimation/Spinner.jsx";

const ACCButton = props => {
  let isDisabled;
  if (props.validationArr) {
    const errors = validateInput(props.validationArr);
    isDisabled = props.disabled
      ? true
      : Object
        .keys(errors)
        .some(x => errors[x]);
  }

  const className = props.btnBlocked
    ? "btn btn-primary btn-block"
    : "btn btn-primary";

  if (props.loading) {
    return <Spinner/>;
  } else {
    return (
      <button
        className={className}
        type="submit"
        disabled={isDisabled || props.disabled}
        onClick={props.onClick}>
        {props.label}
      </button>
    );
  }
};

ACCButton.propTypes = {
  loading: PropTypes.bool,
  label: PropTypes.string,
  validationArr: PropTypes.array,
  disabled: PropTypes.bool,
  onClick: PropTypes.func,
  btnBlocked: PropTypes.string
};

export default ACCButton;

@mohsen1 @akx any idea ?

The problem is with this line in compiler.ts:
const sourceFiles = program.getSourceFiles().filter(sf => sf.fileName === filePath);
On windows machines, sf.fileName uses "/" as a path separator while filePath uses "\"

so what do you suggest ?

If you must use Windows and just want a super quick and dirty fix - add filePath = filePath.split('\\').join('/'); to D:\cache\npm\node_modules\react-js-to-ts\dist\compiler.js around line 30

@kranse I add this to the code
code_1sr6esuchr

And I get following warning is that ok ?
explorer_behyd51wdu

It's probably fine - there is an issue open for that warning: #48

Thank you