serverless / serverless-plugin-typescript

Serverless plugin for zero-config Typescript support
MIT License
783 stars 223 forks source link

How to overwrite tsconfig options? #229

Closed universalhandle closed 3 years ago

universalhandle commented 3 years ago

The README states:

The default tsconfig.json file used by the plugin looks like this:

 "compilerOptions": {
   "preserveConstEnums": true,
   "strictNullChecks": true,
   "sourceMap": true,
   "allowJs": true,
   "target": "es5",
   "outDir": ".build",
   "moduleResolution": "node",
   "lib": ["es2015"],
   "rootDir": "./"
 }
}

Note 1: The outDir and rootDir options cannot be overwritten.

This implies that other tsconfig options can be overwritten. However, the documentation doesn't state how. If this is possible, could you please elaborate on how?

Thanks!

universalhandle commented 3 years ago

I found that creating a tsconfig.json file as a sibling of package.json causes configs from the former to be read.

Without a tsconfig.json, starting a local instance yields output (abridged) like:

> serverless offline start

Serverless: Compiling with Typescript...
Serverless: Typescript compiled.
Serverless: Watching typescript files...

When the file is present, this is acknowledged in the output:

> serverless offline start

Serverless: Compiling with Typescript...
Serverless: Using local tsconfig.json
Serverless: Typescript compiled.
Serverless: Watching typescript files...

I'm going to close this issue. If there's a desire for a pull request to update the README, I'm happy to do it -- just reopen this issue.