1. Compiling in "loose mode"
- Start with all tests passing
- Rename all .js to .ts, allowing implicit any
- Fix only things that are not type-checking, or causing compile errors
- Be careful to avoid changing behavior of function
- Get test passing again.
# rename all JSX files in src/ to TSX
find src -name '*.jsx' -exec bash -c 'git mv "$0" "${0%.jsx}.tsx"' "{}" \;
# rename all JS files in src/ to TS
find src -name '*.js' -exec bash -c 'git mv "$0" "${0%.js}.ts"' "{}" \;
# rename all JSX files in src/ to TSX
find tests -name '*.jsx' -exec bash -c 'git mv "$0" "${0%.jsx}.tsx"' "{}" \;
# rename all JSX files in src/ to TSX
find tests -name '*.jsx.snap' -exec bash -c 'git mv "$0" "${0%.jsx.snap}.tsx.snap"' "{}" \;
# rename all JS files in tests/ to TS
find tests -name '*.js' -exec bash -c 'git mv "$0" "${0%.js}.ts"' "{}" \;
and don't forget to make this small change to index.html
```diff
--- a/index.html
+++ b/index.html
@@ -8,6 +8,6 @@
</head>
<body class="font-sans antialiased h-screen">
<div id="appContainer" class="w-full h-full"></div>
- <script src="src/index.js" type="text/javascript"></script>
+ <script src="src/index.ts" type="text/javascript"></script>
</body>
</html>
```
and this change to tsconfig for step 1.
2. Explicit Any
- Start with tests passing
- Ban implicit any
"noImplicityAny": true,
- Where possible, provide a specific and appropriate type
- Import types for dependencies from DefinitelyTypes
- otherwise explicit any
- Get tests passing again
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。