This project is a simple word transformation tool built with HTML, CSS, and JavaScript. The goal of this exercise is to refactor the existing code into TypeScript.
index.html
: The main HTML filestyles.css
: Contains all the styling for the applicationword-transformer.js
: Contains the JavaScript logic for word transformation
- Set up TypeScript in the project
- Convert
word-transformer.js
to TypeScript - Add type annotations to improve code quality and catch potential errors
- Ensure the refactored TypeScript code works as expected
- Install TypeScript globally:
npm install -g typescript
- Initialize a
tsconfig.json
file:tsc --init
- Adjust
tsconfig.json
as needed (e.g., set"target": "es6"
)
- Rename
word-transformer.js
toword-transformer.ts
- Do the changes to make it Typescript great! 💃🏼
- Run
tsc
to compile the TypeScript file to JavaScript - Update the
<script>
tag inindex.html
to point to the compiled JS file
- Open
index.html
in a browser and test all functionalities - Fix any issues that arise during testing
- Look for opportunities to use more advanced TypeScript features
- Start by adding basic type annotations (string, number, etc.)
- Use the
any
type sparingly and only when necessary - Take advantage of TypeScript's static typing to catch potential errors early
- TypeScript Documentation
- TypeScript Playground for quick experimentation
Good luck with the refactoring!