The productivity improvements an AI-assisted code development tool can bring to your workflow are significant.
If you are not convinced, allow me to give you one recent experience of mine.
Me, like many of you, have a bunch of personal projects that I work on in my spare time. I’m currently building something around AWS, using the AWS JS SDK and Next.js. In one of the pages, I want to list all the EC2 instances in my account. The table should also list the tags for each instance. But the way AWS stores tags is not very convenient to work with when you want to display them in a table.
The Tags[]
property, which is of type EC2.TagList
has the following definition:
type Tags = {
Key: string;
Value: string;
}[];
This definition gives you values in the following format:
[
{ Key: 'Name', Value: 'My EC2 Instance' },
{ Key: 'Environment', Value: 'Production' },
{ Key: 'Owner', Value: 'John Doe' },
]
I will be rendering this in a table, so I would rather have the data in the following format, which is easier to work with.
{
Name: 'My EC2 Instance',
Environment: 'Production',
Owner: 'John Doe',
}
The definition I want for this, would be,
type Tags = {
[key: string]: string;
};
I want to redefine the Tags
property to the format I want, while keeping all the other properties of AWS.EC2
. Or in other words, I want to extend the AWS.EC2
type definition but change the Tags
property to the format I want. This is the code I wrote and the error I got,
interface ExtendedEC2Instance extends AWS.EC2.Instance {
Tags: { [key: string]: string };
Region: string;
}
// Interface 'ExtendedEC2Instance' incorrectly extends interface 'Instance'.
// Types of property 'Tags' are incompatible.
// Type '{ [key: string]: string; }' is missing the following properties from type 'Tag[]'
This is where the AI-assisted code development comes in. Instead of spending time searching and understanding the error message, and then figuring out how to fix it, my IDE can do it for me.
I use Cursor. It understands the code and the context of the code. I asked it to fix the error for me and it gave me the following code,
interface ExtendedEC2Instance extends Omit<AWS.EC2.Instance, 'Tags'> {
Tags: { [key: string]: string };
Region: string;
}
TIL, about Omit
in TypeScript.
Explanation:
It’s the ability of the assistant to explain the code that amazes me every time. If I had to figure out the solution myself, it would have taken quite some time. But with that suggestion, I was able to understand the problem, learn something new, and get back to what I was doing.
Over time, these incremental improvements adds up. You can finish whole modules in a matter of minutes. $20 a month of this kind of productivity is a small price to pay for the time you save.
Cursor or any other AI-assisted code development tool is analyzing your code in real-time and that's how it understands your code and the context of the code.
If you are working on a project that is not open source or sensitive in nature, you might want to check with your organization before adopting any kind of tool.
./J