Atom TypeScript linting in .js files

We have two options to fix this problem in Atom.

First and most important you need to tell the TypeScript service to consume JavaScript files like so:

jsconfig.json

{
    "compilerOptions": {
        "allowJs": true,
        "checkJs": true
    }
}

Solution 1

Create a symbolic link like so:

ln -s tsconfig.json jsconfig.json

Atom will read the jsconfig.json file and everybody will be happy.

Solution 2

A preferable solution, so you don't have to remember to create a symbolic link every time you checkout this project and want to use Atom, is to simply rename the tsconfig.json file to jsconfig.json file.

It works on Atom, Visual Studio Code but not WebStorm. At least at the time of this post.

jsconfig.json

{
    "compilerOptions": {
        "allowJs": true,
        "checkJs": true
    }
}

Example

Use the following code to test your changes.

/**
 * myFunction
 *
 * @param  {string} param1
 * @returns {boolean}
 */
function myFunction(param1) {
  return param1.name; // Error here
}

Resources

About Rick

Senior Front-end Software Engineer from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

Leave a Reply

Add <code> Some Code </code> by using this tags.

*
*