DEV Community

Discussion on: Using Typescript without compilation

Collapse
 
michthebrandofficial profile image
michTheBrandofficial

Very inspiring post. Just tried out the jsdoc comments in my editor right now. The intellisense and type inference both work fine but it does not throw an error when I assign a string type to a number type.

Here is what I mean:

/**
* @param {number} a
*/
function returnNumber(a) {
   return a + 2;
} 

returnNumber('a');
Enter fullscreen mode Exit fullscreen mode

As you know, if I wrote the code above in typescript I would get an error right away, but it doesn't work when I do it in Javascript using jsdoc.

Anyway, thanks for the post. It was really good

Collapse
 
thepassle profile image
Pascal Schilp

You still have to configure your project to use typescript, or enable it globally in your IDE. There's a good post about setting up this way of working linked above in the post itself :)

Image description

Collapse
 
michthebrandofficial profile image
michTheBrandofficial

I tried what I saw in the link and it works very well. Thanks alotπŸ˜….

Thread Thread
 
thepassle profile image
Pascal Schilp

Great :) I was just setting up this for you: github.com/thepassle/uh-oh-typescript

Some comments have been hidden by the post's author - find out more