I have created a new react project using the command npx create-react-app my-app --template typescript. Then introduced some type errors but yarn build is not catching those.
The changes i made are
- Create a new file
test.tsxunder thesrcdirectory with following contents
type Props = {
message: string
}
export function getValue(props: Props): string {
return props.message1
}
- Call the above function from index.tsx
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import {getValue} from "./test"
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
reportWebVitals();
console.log(getValue({message: "test"}))
- Run
yarn build, its not throwing any typescript errors
Github repo - https://github.com/kanagarajkm/my-app-ts
Any help here is really appreciated. Thanks.
.tsxtest.tsx. you can check it here github.com/kanagarajkm/my-app-ts/blob/main/src/test.tsx