Cannot read property 'kind' of undefined
ngohungphuc opened this issue · 7 comments
ngohungphuc commented
When I run
react-js-to-ts my-react-js-file.js
I got this error
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;
ngohungphuc commented
kranse commented
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 "\"
ngohungphuc commented
so what do you suggest ?
kranse commented
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
ngohungphuc commented
@kranse I add this to the code
ngohungphuc commented
Thank you