PromptBase
Close icon
Explore
Marketing & BusinessDown chevron icon
General
Home
Marketplace
Apps
Create
Hire
Login
Sell
Outlined heart icon
🤖 GPT

Senior Typescript Consultant

Senior Typescript Consultant gpt prompt mini thumbnail
11Heart icon
Favorites
58Eye icon
Views
TestedTick icon
TipsTick icon
Why spend years building extensive knowledge and experience in developing modern web applications using Typescript when you can get your personal senior consultant specialized with Typescript for a fraction of the price? This prompt is intended to be a comprehensive guide to all of the programming language’s features and behaviours. Written by a senior professional Typescript consultant.
...more
$3.99
Get prompt
Add to cart icon
After purchasing, you will gain access to the prompt file which you can use with GPT or the app builder. You'll receive 20 free generation credits with this purchase. By purchasing this prompt, you agree to our terms of service.
Updated: 6 months ago

Prompt Details

Model
Chat - GPT-4 (gpt-4)
Token size
240 ($0.00720 / call)
Example input
Refactor the following file: [INSERT FILE HERE] Debug the next function: [INSERT FUNCTION] Explain the succeeding file: [INSERT FILE HERE]
Example output
To create a demo todo list project using TypeScript, we'll use React as the frontend library. Follow these steps: 1. Setup the project: First, make sure you have Node.js installed on your system. Then, open your terminal and run the following command to create a new React project with TypeScript: ``` npx create-react-app todo-list --template typescript ``` This command will create a new folder called `todo-list` with a TypeScript-enabled React app. Navigate to this folder and start the development server: ``` cd todo-list npm start ``` This command will launch the development server and open the default React app in your browser. 2. Create the Todo list components: In the `src` folder, create two new files: `Todo.tsx` and `TodoList.tsx`. These files will represent the Todo item and Todo list components, respectively. 3. Implement the Todo component: Open `Todo.tsx` and add the following code: ```tsx import React from 'react'; interface TodoProps { todo: { id: number; text: string; completed: boolean; }; removeTodo: (id: number) => void; } const Todo: React.FC<TodoProps> = ({ todo, removeTodo }) => { const handleRemove = () => { removeTodo(todo.id); }; return ( <li> <input type="checkbox" checked={todo.completed} readOnly /> <span>{todo.text}</span> <button onClick={handleRemove}>Remove</button> </li> ); }; export default Todo; ``` This component accepts a `todo` object and a `removeTodo` function as props. The `handleRemove` function is called when the user clicks the "Remove" button, and it calls the `removeTodo` function passed from the parent component. 4. Implement the TodoList component: Open `TodoList.tsx` and add the following code: ```tsx import React, { useState } from 'react'; import Todo from './Todo'; interface TodoItem { id: number; text: string; completed: boolean; } const TodoList: React.FC = () => { const [todos, setTodos] = useState<TodoItem[]>([]); const [newTodo, setNewTodo] = useState<string>(''); const addTodo = (e: React.FormEvent) => { e.preventDefault(); if (newTodo.trim()) { setTodos([...todos, { id: Date.now(), text: newTodo, completed: false }]); setNewTodo(''); } }; const removeTodo = (id: number) => { setTodos(todos.filter((todo) => todo.id !== id)); }; return ( <div> <h1>Todo List</h1> <form onSubmit={addTodo}> <input type="text" value={newTodo} onChange={(e) => setNewTodo(e.target.value)} placeholder="Add new todo" /> <button type="submit">Add</button> </form> <ul> {todos.map((todo) => ( <Todo key={todo.id} todo={todo} removeTodo={removeTodo} /> ))} </ul> </div> ); }; export default TodoList; ``` This component imports the `Todo` component and maintains the state of the todo list. It provides the `addTodo` function to add new todos and the `removeTodo` function to remove todos from the list. 5. Update the main App component: Open `src/App.tsx`, remove the existing code, and replace it with the following: ```tsx import React from 'react'; import TodoList from './TodoList'; const App: React.FC = () => { return ( <div className="App"> <TodoList /> </div> ); }; export default App; ```
Browse Marketplace