DEV Community

Cover image for Do you use TypeScript with projects only you will touch?
Junior Batista
Junior Batista

Posted on

Do you use TypeScript with projects only you will touch?

It's very easy to see the benefits of using TypeScript in projects with multiple programmers. Is it still worth it if you're the only one that will ever touch that project?

Top comments (11)

Collapse
 
jamesvanderpump profile image
James Vanderpump

Of course. If you come back to a project in a couple of months, you will be very pleased you wrote some types and interfaces around your classes/functions. You probably come back for a quick refactor, tada!, this is now super trivial and you are probably done much faster and can go out for a drink with your friends instead of starting up the debugger.

Collapse
 
jesusantguerrero profile image
Jesus Guerrero

For my TS is not my default option because most of the projects I start is for solving a problem I currently have and I need to advance fast. But if is a short project like a library that I am starting with TS to build the habit and not getting bored.

Collapse
 
pengeszikra profile image
Peter Vivo

I'm on early phase of typescript use. I wittingly change my default - hobby - languages from JS to TS. That process sometimes faces some difficulty, on the contrary definitions part is really help, even middle sized project.

But sometimes I found TS is don't really understund every JS declaration.

For example:

interface Message { 
  id:string; 
  msg: string; 
  name?: string;
  avatar?: string;
}

type TBlogMap = (content:Message, index:number, list:Message[]) => Message;

// JS is fine but TS dosent know the ...rest part - which is obviously: {id, msg}
export const blogSameUserHeaderMap:TBlogMap 
= ({name, avatar, ...rest}, index, postList) => postList?.[index - 1]?.name === name
  ? {...rest}
  : {name, avatar, ...rest}
;

// working version
export const blogSameUserHeaderMap:TBlogMap 
= (content, index, postList) => postList?.[index - 1]?.name === content?.name
  ? ({msg:content.msg, id: content.id})
  : content
;
Enter fullscreen mode Exit fullscreen mode
Collapse
 
brense profile image
Rense Bakker

Why would you not start with TS? Just copy paste a tsconfig into your JS project and tada now its a TS project

Collapse
 
noxasch profile image
Alexander Dischberg

JSdoc with minimal typescript to utilized the typehint and lint for personal project since i work with other language as well and it makes more sense to me. eg: ruby YARD, python docstring, dart doc comments, javadoc.

Collapse
 
marcel_cremer profile image
Marcel Cremer

Sure, typing is kind of a documentation and a safety net at the same time. Usually the projects who were not "worth the effort" to be initialized with it, are the ones that are timewasters anyway - especially if you have plenty of boilerplates available to make the setup super fastπŸ™‚

Collapse
 
dennistobar profile image
Dennis Tobar

Sure, the code could have less errors and you could read it in the future and still understand your code (before smile and rewrite it πŸ˜‰)

Collapse
 
miketalbot profile image
Mike Talbot ⭐

No chance I'd use TypeScript on smaller things, can't be bothered to type all the extra bloat if only I or a few people will work on it.

Collapse
 
nstvnsn profile image
Nathan Stevenson • Edited

Trying to. I like maintaining good habits, as they are hard to form in the first place. I am liable to use my indicators when I'm the only one on the road too, though, so I'm just weird 😁

Collapse
 
jonrandy profile image
Jon Randy πŸŽ–οΈ

I personally don't see the benefits at all - personal project or otherwise