diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index d3353e965..000000000 --- a/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "proseWrap": "always", - "printWidth": 120 -} diff --git a/jest.config.js b/jest.config.js index 761e0e52c..8ae2b468f 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,7 @@ module.exports = { globals: { "ts-jest": { - tsconfig: "tsconfig.jest.json", + tsconfig: "tsconfig.esm.json", }, }, preset: "ts-jest", diff --git a/package.json b/package.json index ef2cf9ba5..696d42599 100644 --- a/package.json +++ b/package.json @@ -43,14 +43,14 @@ }, "homepage": "https://github.com/drwpow/openapi-typescript#readme", "scripts": { - "build": "rm -rf dist && tsc --build tsconfig.json && tsc --build tsconfig.cjs.json", + "build": "rm -rf dist && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json", "format": "npm run prettier -w .", "lint": "eslint .", "prepare": "npm run build", "pregenerate": "npm run build", "test": "npm run build && jest --no-cache", "test:coverage": "npm run build && jest --no-cache --coverage && codecov", - "typecheck": "tsc --noEmit", + "typecheck": "tsc --noEmit --project tsconfig.esm.json", "version": "npm run build" }, "dependencies": { diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 000000000..794d85c24 --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,4 @@ +module.exports = { + printWidth: 120, + proseWrap: "always", +}; diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 000000000..ac82ec025 --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "baseUrl": "./src", + "declaration": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "lib": ["ES2018"], + "moduleResolution": "Node", + "noImplicitReturns": true, + "removeComments": true, + "sourceMap": true, + "strict": true, + "target": "ES2018", + "useDefineForClassFields": true + }, + "exclude": ["examples/*", "tests/**/*"], + "include": ["src"] +} diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json index cce4819eb..6b873a4f2 100644 --- a/tsconfig.cjs.json +++ b/tsconfig.cjs.json @@ -1,21 +1,7 @@ { "compilerOptions": { - "baseUrl": "./src", - "declaration": true, - "esModuleInterop": true, - "lib": ["ESNext"], "module": "CommonJS", - "moduleResolution": "node", - "noImplicitAny": true, - "noImplicitReturns": true, - "noUnusedLocals": true, - "outDir": "./dist/cjs", - "removeComments": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "target": "ES2018" + "outDir": "./dist/cjs" }, - "include": ["src"], - "exclude": ["examples/*", "tests/**/*"] + "extends": "./tsconfig.base.json" } diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 000000000..2086f3280 --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "module": "ES2020", + "outDir": "./dist/esm" + }, + "extends": "./tsconfig.base.json" +} diff --git a/tsconfig.jest.json b/tsconfig.jest.json deleted file mode 100644 index e31ca0d7e..000000000 --- a/tsconfig.jest.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "baseUrl": "./src", - "declaration": true, - "esModuleInterop": true, - "lib": ["ESNext"], - "module": "ESNext", - "moduleResolution": "node", - "noImplicitAny": true, - "noImplicitReturns": true, - "noUnusedLocals": true, - "outDir": "./dist/esm", - "removeComments": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "target": "ES2018" - }, - "include": ["src"], - "exclude": ["examples/*", "tests/**/*"] -} diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index f0f1cd66f..000000000 --- a/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "baseUrl": "./src", - "declaration": true, - "esModuleInterop": true, - "lib": ["ESNext"], - "module": "ESNext", - "moduleResolution": "node", - "noImplicitAny": true, - "noImplicitReturns": true, - "noUnusedLocals": true, - "outDir": "./dist/esm", - "removeComments": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "target": "ES2020" - }, - "include": ["src"], - "exclude": ["examples/*", "tests/**/*"] -}