skip to Main Content

I’ve heard about TypeScript and I liked it, because I’ve always liked making annotations on my code. However, I would have to rename all my .js files to .ts files. I would like to add annotations to my functions with all TypeScript capabilities without renaming my files. But, as I learned later, that is not possible. So, my question is: Can I continue typing js code normally after renaming them to .ts extension?

I have already added some annotations like

@param{string} argumentExplanation

and this is helping very much. However I would like to do more than this to help on my code. The reason is that the code annotations will help me to create a future documentation about my project.

2

Answers


  1. Yes, all javascript code runs inside typescript, since typescript is a superset of javascript. But it doesn’t make much sense to use TypeScript to write code like Javascript, but do as you prefer.

    To not need typing, you can go to tsconfig.json and put strict: false

    This way, Typescript will not complain about the lack of typing in the code and everything will work practically the same as Javascript.

    Login or Signup to reply.
  2. Yes, you can continue writing javascript code normally after renaming your .js files to .ts files, TypeScript is a superset of JavaScript, which means it contains all the features of JavaScript and extends them with additional functionality

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search