Improve TypeScript monorepo configuration (#226)

* Unify TypeScript configuration

* Fix package.json target fields
This commit is contained in:
Pavel 2022-02-23 16:16:42 +01:00 committed by GitHub
parent 2a2c356807
commit 1a1e86195e
No known key found for this signature in database
GPG Key ID: 0EB8D75C775AB6F1
8 changed files with 56 additions and 106 deletions

View File

@ -9,11 +9,13 @@
"fix": "run-s 'fix:*' && wsrun -e -c -s fix", "fix": "run-s 'fix:*' && wsrun -e -c -s fix",
"build": "wsrun -e -c -s build", "build": "wsrun -e -c -s build",
"format": "prettier --write .", "format": "prettier --write .",
"typecheck": "wsrun -e -c -s typecheck",
"test": "wsrun -e -c -s test" "test": "wsrun -e -c -s test"
}, },
"devDependencies": { "devDependencies": {
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"typescript": "^4.5.5",
"wsrun": "^5.2.4" "wsrun": "^5.2.4"
}, },
"packageManager": "yarn@1.22.17" "packageManager": "yarn@1.22.17"

View File

@ -10,13 +10,14 @@
"bugs": { "bugs": {
"url": "https://github.com/status-im/status-web/issues" "url": "https://github.com/status-im/status-web/issues"
}, },
"main": "dist/cjs/src/index.js", "main": "dist/cjs/index.js",
"module": "dist/esm/src/index.js", "module": "dist/esm/index.js",
"types": "dist/esm/src/index.d.ts", "types": "dist/types/index.d.ts",
"scripts": { "scripts": {
"build": "run-s 'build:*'", "build": "run-s 'build:*'",
"build:esm": "tsc --module es2020 --target es2017 --outDir dist/esm", "build:esm": "tsc --module es2020 --target es2017 --outDir dist/esm",
"build:cjs": "tsc --outDir dist/cjs", "build:cjs": "tsc --outDir dist/cjs",
"build:types": "tsc --emitDeclarationOnly",
"fix": "run-s 'fix:*'", "fix": "run-s 'fix:*'",
"fix:lint": "eslint src --ext .ts --fix", "fix:lint": "eslint src --ext .ts --fix",
"test": "run-s 'test:*'", "test": "run-s 'test:*'",
@ -24,7 +25,8 @@
"test:unit": "mocha", "test:unit": "mocha",
"proto": "run-s 'proto:*'", "proto": "run-s 'proto:*'",
"proto:lint": "buf lint", "proto:lint": "buf lint",
"proto:build": "buf generate" "proto:build": "buf generate",
"typecheck": "tsc --noEmit"
}, },
"devDependencies": { "devDependencies": {
"@types/bn.js": "^5.1.0", "@types/bn.js": "^5.1.0",
@ -46,8 +48,7 @@
"mocha": "^9.1.1", "mocha": "^9.1.1",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"ts-node": "^10.2.1", "ts-node": "^10.2.1",
"ts-proto": "^1.83.0", "ts-proto": "^1.83.0"
"typescript": "^4.4.3"
}, },
"dependencies": { "dependencies": {
"bn.js": "^5.2.0", "bn.js": "^5.2.0",

View File

@ -5,6 +5,7 @@ export { Contacts } from './contacts'
export { Chat } from './chat' export { Chat } from './chat'
export * from './groupChats' export * from './groupChats'
export * as utils from './utils' export * as utils from './utils'
export * from './utils'
export { ApplicationMetadataMessage } from './wire/application_metadata_message' export { ApplicationMetadataMessage } from './wire/application_metadata_message'
export { export {
ChatMessage, ChatMessage,

View File

@ -1,51 +1,8 @@
{ {
"compilerOptions": { "extends": "../../tsconfig.base.json",
"incremental": true,
"target": "es6",
"outDir": "dist",
"rootDir": "src",
"moduleResolution": "node",
"module": "commonjs",
"declaration": true,
"sourceMap": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"composite": true,
"strict": true /* Enable all strict type-checking options. */,
/* Strict Type-Checking Options */
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,
/* Additional Checks */
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": false /* to set at a later stage */,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true,
/* Debugging Options */
"traceResolution": false,
"listEmittedFiles": false,
"listFiles": false,
"pretty": true,
// Due to broken types in indirect dependencies
"skipLibCheck": true,
"lib": ["es6", "dom"],
"typeRoots": [
"./node_modules/@types",
"./src/types",
"../../node_modules/@types"
]
},
"include": ["src"], "include": ["src"],
"exclude": ["node_modules/**"], "compilerOptions": {
"types": ["mocha"], "outDir": "dist",
"compileOnSave": false "declarationDir": "dist/types"
}
} }

View File

@ -11,20 +11,22 @@
"bugs": { "bugs": {
"url": "https://github.com/status-im/status-web/issues" "url": "https://github.com/status-im/status-web/issues"
}, },
"main": "dist/cjs/src/index.js", "main": "dist/cjs/index.js",
"module": "dist/esm/src/index.js", "module": "dist/esm/index.js",
"types": "dist/esm/src/index.d.ts", "types": "dist/types/index.d.ts",
"scripts": { "scripts": {
"build": "run-s 'build:*'", "build": "run-s 'build:*'",
"build:esm": "tsc --module es2020 --target es2017 --outDir dist/esm", "build:esm": "tsc --module es2020 --target es2017 --outDir dist/esm",
"build:cjs": "tsc --outDir dist/cjs", "build:cjs": "tsc --outDir dist/cjs",
"build:types": "tsc --emitDeclarationOnly",
"fix": "run-s 'fix:*'", "fix": "run-s 'fix:*'",
"fix:lint": "eslint './{src,test}/**/*.{ts,tsx}' --fix", "fix:lint": "eslint './{src,test}/**/*.{ts,tsx}' --fix",
"test": "run-s 'test:*'", "test": "run-s 'test:*'",
"test:lint": "eslint './{src,test}/**/*.{ts,tsx}'", "test:lint": "eslint './{src,test}/**/*.{ts,tsx}'",
"proto": "run-s 'proto:*'", "proto": "run-s 'proto:*'",
"proto:lint": "buf lint", "proto:lint": "buf lint",
"proto:build": "buf generate" "proto:build": "buf generate",
"typecheck": "tsc --noEmit"
}, },
"devDependencies": { "devDependencies": {
"@hcaptcha/react-hcaptcha": "^1.0.0", "@hcaptcha/react-hcaptcha": "^1.0.0",
@ -49,8 +51,7 @@
"npm-watch": "^0.11.0", "npm-watch": "^0.11.0",
"qrcode.react": "^1.0.1", "qrcode.react": "^1.0.1",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"ts-node": "^10.1.0", "ts-node": "^10.1.0"
"typescript": "^4.3.5"
}, },
"dependencies": { "dependencies": {
"@status-im/core": "^0.0.0", "@status-im/core": "^0.0.0",

View File

@ -1,48 +1,9 @@
{ {
"compilerOptions": { "extends": "../../tsconfig.base.json",
"target": "es6",
"jsx": "react",
"outDir": "dist",
"moduleResolution": "node",
"module": "commonjs",
"declaration": true,
"sourceMap": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"composite": true,
"strict": true /* Enable all strict type-checking options. */,
/* Strict Type-Checking Options */
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,
/* Additional Checks */
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": false /* to set at a later stage */,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true,
/* Debugging Options */
"traceResolution": false,
"listEmittedFiles": false,
"listFiles": false,
"pretty": true,
// Due to broken types in indirect dependencies
"skipLibCheck": true,
"typeRoots": [
"./node_modules/@types",
"./src/types",
"../../node_modules/@types"
]
},
"include": ["src"], "include": ["src"],
"exclude": ["node_modules/**"], "compilerOptions": {
"types": ["mocha"], "outDir": "./dist",
"compileOnSave": false "declarationDir": "dist/types",
"resolveJsonModule": true
}
} }

27
tsconfig.base.json Normal file
View File

@ -0,0 +1,27 @@
{
"compilerOptions": {
"incremental": true,
"target": "ES2020",
"module": "ES2020",
"moduleResolution": "node",
"jsx": "preserve",
"declaration": true,
"declarationMap": true,
// "emitDeclarationOnly": true,
"sourceMap": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
// "noEmit": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
// "exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
// "noImplicitReturns": true,
// "noUncheckedIndexedAccess": true,
// "noPropertyAccessFromIndexSignature": true /* Enforces using indexed accessors for keys declared using an indexed type */,
"skipLibCheck": true,
"pretty": true
}
}

View File

@ -6572,7 +6572,7 @@ typedarray-to-buffer@^3.1.5:
dependencies: dependencies:
is-typedarray "^1.0.0" is-typedarray "^1.0.0"
typescript@^4.0.0, typescript@^4.3.5, typescript@^4.4.3: typescript@^4.0.0, typescript@^4.5.5:
version "4.5.5" version "4.5.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3"
integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA== integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==