jonhobbs
jonhobbs

Reputation: 27972

Stop Typescript compiler putting semicolons in src

I am creating a Node/Express API using Microsoft's Typescript Node Starter Project - https://github.com/microsoft/TypeScript-Node-Starter

When I build the project it's inserting semicolons in all my code. Not the compiled code in /dist, but the source code in /src which I don't want semicolons in.

The package.json has the following scripts (abbreviated)

"scripts": {
    ...
    "build": "npm run build-ts && npm run lint && npm run copy-static-assets",
    "build-ts": "tsc",
    "copy-static-assets": "ts-node copyStaticAssets.ts",
    "lint": "tsc --noEmit && eslint \"**/*.{js,ts}\" --quiet --fix",
    ...
},

This is the content of my tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "target": "es6",
        "lib": ["es2019", "dom"],
        "noImplicitAny": true,
        "moduleResolution": "node",
        "sourceMap": true,
        "outDir": "dist",
        "baseUrl": ".",
        "paths": {
            "*": [
                "node_modules/*",
                "src/types/*"
            ]
        }
    },
    "include": [
        "src/**/*"
    ]
}

Is there a flag I can use to switch this behavior off?

Upvotes: 1

Views: 1132

Answers (2)

Mahmoud Ashraf
Mahmoud Ashraf

Reputation: 134

In .eslintrc file change the rule semi to

"rules" : {
  ...,
  "semi": ["error", "never"],
}

Upvotes: 2

sroes
sroes

Reputation: 15053

It's not the TypeScript compiler, it's probably the --fix flag of the eslint (in the lint script). See the semi rule in the file .eslintrc. You could change it to ["error", "never"].

Upvotes: 2

Related Questions