├── .gitignore ├── README.md ├── package.json ├── server.ts ├── src ├── config │ └── db.config.ts ├── controllers │ ├── home.controller.ts │ └── tutorial.controller.ts ├── db │ └── index.ts ├── index.ts ├── models │ └── tutorial.model.ts ├── repositories │ └── tutorial.repository.ts └── routes │ ├── home.routes.ts │ ├── index.ts │ └── tutorial.routes.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | node_modules 3 | package-lock.json -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Typescript ORM with Postgres example 2 | Sequelize ORM using Typescript with Postgres database - CRUD operations example with Express REST API. 3 | 4 | For more detail, please visit: 5 | > [TypeScript ORM with Postgres example](https://www.bezkoder.com/typescript-orm-postgres/) 6 | 7 | > [Express Typescript example](https://www.bezkoder.com/express-typescript-example/) 8 | 9 | > [TypeScript ORM with MySQL example](https://www.bezkoder.com/typescript-orm-mysql/) 10 | 11 | ## Project setup 12 | ``` 13 | npm install 14 | ``` 15 | 16 | ### Run 17 | ``` 18 | npm run start 19 | ``` 20 | 21 | Front-end that works well with this Back-end 22 | > [Axios Client](https://www.bezkoder.com/axios-request/) 23 | 24 | > [Angular 8](https://www.bezkoder.com/angular-crud-app/) / [Angular 10](https://www.bezkoder.com/angular-10-crud-app/) / [Angular 11](https://www.bezkoder.com/angular-11-crud-app/) / [Angular 12](https://www.bezkoder.com/angular-12-crud-app/) / [Angular 13](https://www.bezkoder.com/angular-13-crud-example/) / [Angular 14](https://www.bezkoder.com/angular-14-crud-example/) / [Angular 15](https://www.bezkoder.com/angular-15-crud-example/) / [Angular 16 Client](https://www.bezkoder.com/angular-16-crud-example/) 25 | 26 | > [Vue 2 Client](https://www.bezkoder.com/vue-typescript-crud/) / [Vue 3 Client](https://www.bezkoder.com/vue-3-typescript-axios/) 27 | 28 | > [React Client](https://www.bezkoder.com/react-typescript-api-call/) 29 | 30 | ## More Practice 31 | > [Node.js Express Pagination with PostgreSQL example](https://bezkoder.com/node-js-pagination-postgresql/) 32 | 33 | > [Node.js Express File Upload Rest API example](https://bezkoder.com/node-js-express-file-upload/) 34 | 35 | > [Node.js Express File Upload with Google Cloud Storage example](https://bezkoder.com/google-cloud-storage-nodejs-upload-file/) 36 | 37 | Security: 38 | > [Node.js JWT Authentication & Authorization with PostgreSQL example](https://bezkoder.com/node-js-jwt-authentication-postgresql/) 39 | 40 | Associations: 41 | > [Sequelize Associations: One-to-Many Relationship example](https://bezkoder.com/sequelize-associate-one-to-many/) 42 | 43 | > [Sequelize Associations: Many-to-Many Relationship example](https://bezkoder.com/sequelize-associate-many-to-many/) 44 | 45 | Fullstack: 46 | > [Vue + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/vue-node-express-postgresql/) 47 | 48 | > [React + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/react-node-express-postgresql/) 49 | 50 | > [Angular 8 + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/angular-node-express-postgresql/) 51 | 52 | > [Angular 10 + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/angular-10-node-express-postgresql/) 53 | 54 | > [Angular 11 + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/angular-11-node-js-express-postgresql/) 55 | 56 | > [Angular 12 + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/angular-12-node-js-express-postgresql/) 57 | 58 | > [Angular 13 + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/angular-13-node-js-express-postgresql/) 59 | 60 | > [Angular 14 + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/angular-14-node-js-express-postgresql/) 61 | 62 | > [Angular 15 + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/angular-15-node-js-express-postgresql/) 63 | 64 | > [Angular 16 + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/angular-16-node-js-express-postgresql/) 65 | 66 | Integration (run back-end & front-end on same server/port) 67 | > [Integrate React with Node.js Restful Services](https://bezkoder.com/integrate-react-express-same-server-port/) 68 | 69 | > [Integrate Angular with Node.js Restful Services](https://bezkoder.com/integrate-angular-10-node-js/) 70 | 71 | > [Integrate Vue with Node.js Restful Services](https://bezkoder.com/serve-vue-app-express/) 72 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typescript-orm-postgres", 3 | "version": "1.0.0", 4 | "description": "Rest API using Node.js, TypeScript ORM Sequelize, Express, Postgres", 5 | "main": "server.ts", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "build": "tsc", 9 | "dev": "node ./build/server.js", 10 | "start": "tsc && npm run dev" 11 | }, 12 | "keywords": [ 13 | "nodejs", 14 | "typescript", 15 | "orm", 16 | "sequelize", 17 | "express", 18 | "postgres", 19 | "postgresql", 20 | "restapi", 21 | "rest", 22 | "api", 23 | "crud" 24 | ], 25 | "author": "bezkoder", 26 | "license": "ISC", 27 | "devDependencies": { 28 | "@types/cors": "^2.8.13", 29 | "@types/express": "^4.17.17", 30 | "@types/node": "^20.4.2", 31 | "ts-node": "^10.9.1", 32 | "typescript": "^5.1.6" 33 | }, 34 | "dependencies": { 35 | "cors": "^2.8.5", 36 | "express": "^4.18.2", 37 | "pg": "^8.11.1", 38 | "sequelize": "^6.32.1", 39 | "sequelize-typescript": "^2.1.5" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /server.ts: -------------------------------------------------------------------------------- 1 | import express, { Application } from "express"; 2 | import Server from "./src/index"; 3 | 4 | const app: Application = express(); 5 | const server: Server = new Server(app); 6 | const PORT: number = process.env.PORT ? parseInt(process.env.PORT, 10) : 8080; 7 | 8 | app 9 | .listen(PORT, "localhost", function () { 10 | console.log(`Server is running on port ${PORT}.`); 11 | }) 12 | .on("error", (err: any) => { 13 | if (err.code === "EADDRINUSE") { 14 | console.log("Error: address already in use"); 15 | } else { 16 | console.log(err); 17 | } 18 | }); 19 | -------------------------------------------------------------------------------- /src/config/db.config.ts: -------------------------------------------------------------------------------- 1 | export const config = { 2 | HOST: "localhost", 3 | USER: "postgres", 4 | PASSWORD: "123", 5 | DB: "testdb", 6 | pool: { 7 | max: 5, 8 | min: 0, 9 | acquire: 30000, 10 | idle: 10000 11 | } 12 | }; 13 | 14 | export const dialect = "postgres"; 15 | -------------------------------------------------------------------------------- /src/controllers/home.controller.ts: -------------------------------------------------------------------------------- 1 | import { Request, Response } from "express"; 2 | 3 | export function welcome(req: Request, res: Response): Response { 4 | return res.json({ message: "Welcome to bezkoder application." }); 5 | } 6 | -------------------------------------------------------------------------------- /src/controllers/tutorial.controller.ts: -------------------------------------------------------------------------------- 1 | import { Request, Response } from "express"; 2 | import Tutorial from "../models/tutorial.model"; 3 | import tutorialRepository from "../repositories/tutorial.repository"; 4 | 5 | export default class TutorialController { 6 | async create(req: Request, res: Response) { 7 | if (!req.body.title) { 8 | res.status(400).send({ 9 | message: "Content can not be empty!" 10 | }); 11 | return; 12 | } 13 | 14 | try { 15 | const tutorial: Tutorial = req.body; 16 | if (!tutorial.published) tutorial.published = false; 17 | 18 | const savedTutorial = await tutorialRepository.save(tutorial); 19 | 20 | res.status(201).send(savedTutorial); 21 | } catch (err) { 22 | res.status(500).send({ 23 | message: "Some error occurred while retrieving tutorials." 24 | }); 25 | } 26 | } 27 | 28 | async findAll(req: Request, res: Response) { 29 | const title = typeof req.query.title === "string" ? req.query.title : ""; 30 | 31 | try { 32 | const tutorials = await tutorialRepository.retrieveAll({ title }); 33 | 34 | res.status(200).send(tutorials); 35 | } catch (err) { 36 | res.status(500).send({ 37 | message: "Some error occurred while retrieving tutorials." 38 | }); 39 | } 40 | } 41 | 42 | async findOne(req: Request, res: Response) { 43 | const id: number = parseInt(req.params.id); 44 | 45 | try { 46 | const tutorial = await tutorialRepository.retrieveById(id); 47 | 48 | if (tutorial) res.status(200).send(tutorial); 49 | else 50 | res.status(404).send({ 51 | message: `Cannot find Tutorial with id=${id}.` 52 | }); 53 | } catch (err) { 54 | res.status(500).send({ 55 | message: `Error retrieving Tutorial with id=${id}.` 56 | }); 57 | } 58 | } 59 | 60 | async update(req: Request, res: Response) { 61 | let tutorial: Tutorial = req.body; 62 | tutorial.id = parseInt(req.params.id); 63 | 64 | try { 65 | const num = await tutorialRepository.update(tutorial); 66 | 67 | if (num == 1) { 68 | res.send({ 69 | message: "Tutorial was updated successfully." 70 | }); 71 | } else { 72 | res.send({ 73 | message: `Cannot update Tutorial with id=${tutorial.id}. Maybe Tutorial was not found or req.body is empty!` 74 | }); 75 | } 76 | } catch (err) { 77 | res.status(500).send({ 78 | message: `Error updating Tutorial with id=${tutorial.id}.` 79 | }); 80 | } 81 | } 82 | 83 | async delete(req: Request, res: Response) { 84 | const id: number = parseInt(req.params.id); 85 | 86 | try { 87 | const num = await tutorialRepository.delete(id); 88 | 89 | if (num == 1) { 90 | res.send({ 91 | message: "Tutorial was deleted successfully!" 92 | }); 93 | } else { 94 | res.send({ 95 | message: `Cannot delete Tutorial with id=${id}. Maybe Tutorial was not found!`, 96 | }); 97 | } 98 | } catch (err) { 99 | res.status(500).send({ 100 | message: `Could not delete Tutorial with id==${id}.` 101 | }); 102 | } 103 | } 104 | 105 | async deleteAll(req: Request, res: Response) { 106 | try { 107 | const num = await tutorialRepository.deleteAll(); 108 | 109 | res.send({ message: `${num} Tutorials were deleted successfully!` }); 110 | } catch (err) { 111 | res.status(500).send({ 112 | message: "Some error occurred while removing all tutorials." 113 | }); 114 | } 115 | } 116 | 117 | async findAllPublished(req: Request, res: Response) { 118 | try { 119 | const tutorials = await tutorialRepository.retrieveAll({ published: true }); 120 | 121 | res.status(200).send(tutorials); 122 | } catch (err) { 123 | res.status(500).send({ 124 | message: "Some error occurred while retrieving tutorials." 125 | }); 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/db/index.ts: -------------------------------------------------------------------------------- 1 | import { Sequelize } from "sequelize-typescript"; 2 | import { config, dialect } from "../config/db.config"; 3 | import Tutorial from "../models/tutorial.model"; 4 | 5 | class Database { 6 | public sequelize: Sequelize | undefined; 7 | 8 | constructor() { 9 | this.connectToDatabase(); 10 | } 11 | 12 | private async connectToDatabase() { 13 | this.sequelize = new Sequelize({ 14 | database: config.DB, 15 | username: config.USER, 16 | password: config.PASSWORD, 17 | host: config.HOST, 18 | dialect: dialect, 19 | pool: { 20 | max: config.pool.max, 21 | min: config.pool.min, 22 | acquire: config.pool.acquire, 23 | idle: config.pool.idle 24 | }, 25 | models: [Tutorial] 26 | }); 27 | 28 | await this.sequelize 29 | .authenticate() 30 | .then(() => { 31 | console.log("Connection has been established successfully."); 32 | }) 33 | .catch((err) => { 34 | console.error("Unable to connect to the Database:", err); 35 | }); 36 | } 37 | } 38 | 39 | export default Database; 40 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import express, { Application } from "express"; 2 | import cors, { CorsOptions } from "cors"; 3 | import Routes from "./routes"; 4 | import Database from "./db"; 5 | 6 | export default class Server { 7 | constructor(app: Application) { 8 | this.config(app); 9 | this.syncDatabase(); 10 | new Routes(app); 11 | } 12 | 13 | private config(app: Application): void { 14 | const corsOptions: CorsOptions = { 15 | origin: "http://localhost:8081" 16 | }; 17 | 18 | app.use(cors(corsOptions)); 19 | app.use(express.json()); 20 | app.use(express.urlencoded({ extended: true })); 21 | } 22 | 23 | private syncDatabase(): void { 24 | const db = new Database(); 25 | db.sequelize?.sync(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/models/tutorial.model.ts: -------------------------------------------------------------------------------- 1 | import { Model, Table, Column, DataType } from "sequelize-typescript"; 2 | 3 | @Table({ 4 | tableName: "tutorials", 5 | }) 6 | export default class Tutorial extends Model { 7 | @Column({ 8 | type: DataType.INTEGER, 9 | primaryKey: true, 10 | autoIncrement: true, 11 | field: "id" 12 | }) 13 | id?: number; 14 | 15 | @Column({ 16 | type: DataType.STRING(255), 17 | field: "title" 18 | }) 19 | title?: string; 20 | 21 | @Column({ 22 | type: DataType.STRING(255), 23 | field: "description" 24 | }) 25 | description?: string; 26 | 27 | @Column({ 28 | type: DataType.BOOLEAN, 29 | field: "published" 30 | }) 31 | published?: boolean; 32 | } 33 | -------------------------------------------------------------------------------- /src/repositories/tutorial.repository.ts: -------------------------------------------------------------------------------- 1 | import { Op } from "sequelize"; 2 | import Tutorial from "../models/tutorial.model"; 3 | 4 | interface ITutorialRepository { 5 | save(tutorial: Tutorial): Promise; 6 | retrieveAll(searchParams: {title: string, published: boolean}): Promise; 7 | retrieveById(tutorialId: number): Promise; 8 | update(tutorial: Tutorial): Promise; 9 | delete(tutorialId: number): Promise; 10 | deleteAll(): Promise; 11 | } 12 | 13 | interface SearchCondition { 14 | [key: string]: any; 15 | } 16 | 17 | class TutorialRepository implements ITutorialRepository { 18 | async save(tutorial: Tutorial): Promise { 19 | try { 20 | return await Tutorial.create({ 21 | title: tutorial.title, 22 | description: tutorial.description, 23 | published: tutorial.published 24 | }); 25 | } catch (err) { 26 | throw new Error("Failed to create Tutorial!"); 27 | } 28 | } 29 | 30 | async retrieveAll(searchParams: {title?: string, published?: boolean}): Promise { 31 | try { 32 | let condition: SearchCondition = {}; 33 | 34 | if (searchParams?.published) condition.published = true; 35 | 36 | if (searchParams?.title) 37 | condition.title = { [Op.iLike]: `%${searchParams.title}%` }; 38 | 39 | return await Tutorial.findAll({ where: condition }); 40 | } catch (error) { 41 | throw new Error("Failed to retrieve Tutorials!"); 42 | } 43 | } 44 | 45 | async retrieveById(tutorialId: number): Promise { 46 | try { 47 | return await Tutorial.findByPk(tutorialId); 48 | } catch (error) { 49 | throw new Error("Failed to retrieve Tutorials!"); 50 | } 51 | } 52 | 53 | async update(tutorial: Tutorial): Promise { 54 | const { id, title, description, published } = tutorial; 55 | 56 | try { 57 | const affectedRows = await Tutorial.update( 58 | { title, description, published }, 59 | { where: { id: id } } 60 | ); 61 | 62 | return affectedRows[0]; 63 | } catch (error) { 64 | throw new Error("Failed to update Tutorial!"); 65 | } 66 | } 67 | 68 | async delete(tutorialId: number): Promise { 69 | try { 70 | const affectedRows = await Tutorial.destroy({ where: { id: tutorialId } }); 71 | 72 | return affectedRows; 73 | } catch (error) { 74 | throw new Error("Failed to delete Tutorial!"); 75 | } 76 | } 77 | 78 | async deleteAll(): Promise { 79 | try { 80 | return Tutorial.destroy({ 81 | where: {}, 82 | truncate: false 83 | }); 84 | } catch (error) { 85 | throw new Error("Failed to delete Tutorials!"); 86 | } 87 | } 88 | } 89 | 90 | export default new TutorialRepository(); 91 | -------------------------------------------------------------------------------- /src/routes/home.routes.ts: -------------------------------------------------------------------------------- 1 | import { Router } from "express"; 2 | import { welcome } from "../controllers/home.controller"; 3 | 4 | class HomeRoutes { 5 | router = Router(); 6 | 7 | constructor() { 8 | this.intializeRoutes(); 9 | } 10 | 11 | intializeRoutes() { 12 | this.router.get("/", welcome); 13 | } 14 | } 15 | 16 | export default new HomeRoutes().router; 17 | -------------------------------------------------------------------------------- /src/routes/index.ts: -------------------------------------------------------------------------------- 1 | import { Application } from "express"; 2 | import tutorialRoutes from "./tutorial.routes"; 3 | import homeRoutes from "./home.routes"; 4 | 5 | export default class Routes { 6 | constructor(app: Application) { 7 | app.use("/api", homeRoutes); 8 | app.use("/api/tutorials", tutorialRoutes); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/routes/tutorial.routes.ts: -------------------------------------------------------------------------------- 1 | import { Router } from "express"; 2 | import TutorialController from "../controllers/tutorial.controller"; 3 | 4 | class TutorialRoutes { 5 | router = Router(); 6 | controller = new TutorialController(); 7 | 8 | constructor() { 9 | this.intializeRoutes(); 10 | } 11 | 12 | intializeRoutes() { 13 | // Create a new Tutorial 14 | this.router.post("/", this.controller.create); 15 | 16 | // Retrieve all Tutorials 17 | this.router.get("/", this.controller.findAll); 18 | 19 | // Retrieve all published Tutorials 20 | this.router.get("/published", this.controller.findAllPublished); 21 | 22 | // Retrieve a single Tutorial with id 23 | this.router.get("/:id", this.controller.findOne); 24 | 25 | // Update a Tutorial with id 26 | this.router.put("/:id", this.controller.update); 27 | 28 | // Delete a Tutorial with id 29 | this.router.delete("/:id", this.controller.delete); 30 | 31 | // Delete all Tutorials 32 | this.router.delete("/", this.controller.deleteAll); 33 | } 34 | } 35 | 36 | export default new TutorialRoutes().router; 37 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 18 | "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "commonjs", /* Specify what module code is generated. */ 29 | // "rootDir": "./", /* Specify the root folder within your source files. */ 30 | // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | "resolveJsonModule": true, /* Enable importing .json files. */ 43 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 53 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | "outDir": "./build", /* Specify an output folder for all emitted files. */ 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 83 | 84 | /* Type Checking */ 85 | "strict": true, /* Enable all strict type-checking options. */ 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | } 109 | } 110 | --------------------------------------------------------------------------------