diff --git a/.changeset/afraid-onions-pump.md b/.changeset/afraid-onions-pump.md new file mode 100644 index 000000000..550253393 --- /dev/null +++ b/.changeset/afraid-onions-pump.md @@ -0,0 +1,7 @@ +--- +"@hyperdx/common-utils": patch +"@hyperdx/api": patch +"@hyperdx/app": patch +--- + +fix: Update tsconfigs to resolve IDE type errors diff --git a/docker/hyperdx/Dockerfile b/docker/hyperdx/Dockerfile index 01d90c995..818b10f42 100644 --- a/docker/hyperdx/Dockerfile +++ b/docker/hyperdx/Dockerfile @@ -22,10 +22,10 @@ FROM node:${NODE_VERSION}-alpine AS node_base WORKDIR /app COPY .yarn ./.yarn -COPY .yarnrc.yml yarn.lock package.json nx.json .prettierrc .prettierignore ./ +COPY .yarnrc.yml yarn.lock package.json nx.json .prettierrc .prettierignore ./tsconfig.base.json ./ COPY ./packages/common-utils ./packages/common-utils -COPY ./packages/api/jest.config.js ./packages/api/tsconfig.json ./packages/api/package.json ./packages/api/ -COPY ./packages/app/jest.config.js ./packages/app/tsconfig.json ./packages/app/tsconfig.test.json ./packages/app/package.json ./packages/app/next.config.js ./packages/app/mdx.d.ts ./packages/app/.eslintrc.js ./packages/app/ +COPY ./packages/api/jest.config.js ./packages/api/tsconfig.json ./packages/api/tsconfig.build.json ./packages/api/package.json ./packages/api/ +COPY ./packages/app/jest.config.js ./packages/app/tsconfig.json ./packages/app/tsconfig.build.json ./packages/app/package.json ./packages/app/next.config.js ./packages/app/mdx.d.ts ./packages/app/.eslintrc.js ./packages/app/ # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat diff --git a/packages/api/.eslintrc.js b/packages/api/.eslintrc.js index 28d57973e..120f52a0b 100644 --- a/packages/api/.eslintrc.js +++ b/packages/api/.eslintrc.js @@ -5,7 +5,7 @@ module.exports = { plugins: ['@typescript-eslint', 'prettier', 'simple-import-sort'], parserOptions: { tsconfigRootDir: __dirname, - project: ['./tsconfig.json', './tsconfig.test.json'], + project: ['./tsconfig.json'], }, extends: [ 'eslint:recommended', diff --git a/packages/api/Dockerfile b/packages/api/Dockerfile index 61ce19e45..cf1d67b2a 100644 --- a/packages/api/Dockerfile +++ b/packages/api/Dockerfile @@ -4,9 +4,9 @@ FROM node:22.16.0-alpine AS base WORKDIR /app COPY .yarn ./.yarn -COPY .yarnrc.yml yarn.lock package.json nx.json .prettierrc .prettierignore ./ +COPY .yarnrc.yml yarn.lock package.json nx.json .prettierrc .prettierignore ./tsconfig.base.json ./ COPY ./packages/common-utils ./packages/common-utils -COPY ./packages/api/jest.config.js ./packages/api/tsconfig.json ./packages/api/package.json ./packages/api/ +COPY ./packages/api/jest.config.js ./packages/api/tsconfig.json ./packages/api/tsconfig.build.json ./packages/api/package.json ./packages/api/ RUN yarn install --mode=skip-build && yarn cache clean diff --git a/packages/api/package.json b/packages/api/package.json index d13e34cba..90962a984 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -93,7 +93,7 @@ "start": "node ./dist/index.js", "dev": "DOTENV_CONFIG_PATH=.env.development nodemon --signal SIGTERM -e ts,json --exec 'ts-node' --transpile-only -r tsconfig-paths/register -r dotenv-expand/config -r '@hyperdx/node-opentelemetry/build/src/tracing' ./src/index.ts", "dev-task": "DOTENV_CONFIG_PATH=.env.development nodemon --signal SIGTERM -e ts,json --exec 'ts-node' --transpile-only -r tsconfig-paths/register -r dotenv-expand/config -r '@hyperdx/node-opentelemetry/build/src/tracing' ./src/tasks/index.ts", - "build": "tsc && tsc-alias && esbuild ../../node_modules/@hyperdx/node-opentelemetry/build/src/tracing --bundle --minify --platform=node --outfile=dist/tracing.js && esbuild ./build/src/index.js ./build/src/tasks/index.js --bundle --minify --platform=node --target=node22 --outdir=dist --alias:@='./src' && mkdir -p dist/opamp && cp -r src/opamp/proto dist/opamp/proto && rimraf ./build", + "build": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json && esbuild ../../node_modules/@hyperdx/node-opentelemetry/build/src/tracing --bundle --minify --platform=node --outfile=dist/tracing.js && esbuild ./build/src/index.js ./build/src/tasks/index.js --bundle --minify --platform=node --target=node22 --outdir=dist --alias:@='./src' && mkdir -p dist/opamp && cp -r src/opamp/proto dist/opamp/proto && rimraf ./build", "lint": "npx eslint --quiet . --ext .ts", "lint:fix": "npx eslint . --ext .ts --fix", "ci:lint": "yarn lint && yarn tsc --noEmit", @@ -105,4 +105,4 @@ "dev:migrate-ch": "migrate -database 'clickhouse://localhost:9000?database=default&x-multi-statement=true' -path ./migrations/ch up", "docgen": "ts-node scripts/generate-api-docs.ts" } -} +} \ No newline at end of file diff --git a/packages/api/tsconfig.build.json b/packages/api/tsconfig.build.json new file mode 100644 index 000000000..af9b44c61 --- /dev/null +++ b/packages/api/tsconfig.build.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "include": [ + "src", + "migrations", + "scripts" + ], + "exclude": [ + "node_modules", + "**/*.test.ts" + ] +} \ No newline at end of file diff --git a/packages/api/tsconfig.json b/packages/api/tsconfig.json index d1fb5823c..b3a28063c 100644 --- a/packages/api/tsconfig.json +++ b/packages/api/tsconfig.json @@ -1,30 +1,21 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { "baseUrl": "./src", "paths": { - "@/*": ["./*"] + "@/*": [ + "./*" + ] }, "rootDir": ".", - "allowSyntheticDefaultImports": true, - "downlevelIteration": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "importHelpers": true, - "lib": ["ES2022", "dom"], - "module": "Node16", - "moduleResolution": "node", - "noFallthroughCasesInSwitch": true, - "noImplicitAny": false, - "noImplicitReturns": false, - "noImplicitThis": false, - "noUnusedLocals": false, - "noUnusedParameters": false, "outDir": "build", - "skipLibCheck": false, - "sourceMap": true, - "strict": true, - "target": "ES2022" }, - "include": ["src", "migrations", "scripts"], - "exclude": ["node_modules", "**/*.test.ts"] -} + "include": [ + "src", + "migrations", + "scripts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/packages/api/tsconfig.test.json b/packages/api/tsconfig.test.json deleted file mode 100644 index f507e4fa2..000000000 --- a/packages/api/tsconfig.test.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "./tsconfig.json", - "exclude": ["node_modules"] -} diff --git a/packages/app/.eslintrc.js b/packages/app/.eslintrc.js index c10559e3e..91cfb928d 100644 --- a/packages/app/.eslintrc.js +++ b/packages/app/.eslintrc.js @@ -4,7 +4,7 @@ module.exports = { plugins: ['simple-import-sort', '@typescript-eslint', 'prettier'], parserOptions: { tsconfigRootDir: __dirname, - project: ['./tsconfig.json', './tsconfig.test.json'], + project: ['./tsconfig.json'], }, extends: [ 'next', diff --git a/packages/app/Dockerfile b/packages/app/Dockerfile index 0dd7b1d5e..4c7525d2a 100644 --- a/packages/app/Dockerfile +++ b/packages/app/Dockerfile @@ -5,9 +5,9 @@ RUN apk add --no-cache libc6-compat WORKDIR /app COPY .yarn ./.yarn -COPY .yarnrc.yml yarn.lock package.json nx.json .prettierrc .prettierignore ./ +COPY .yarnrc.yml yarn.lock package.json nx.json .prettierrc .prettierignore ./tsconfig.base.json ./ COPY ./packages/common-utils ./packages/common-utils -COPY ./packages/app/jest.config.js ./packages/app/tsconfig.json ./packages/app/tsconfig.test.json ./packages/app/package.json ./packages/app/next.config.js ./packages/app/mdx.d.ts ./packages/app/.eslintrc.js ./packages/app/ +COPY ./packages/app/jest.config.js ./packages/app/tsconfig.json ./packages/app/tsconfig.build.json ./packages/app/package.json ./packages/app/next.config.js ./packages/app/mdx.d.ts ./packages/app/.eslintrc.js ./packages/app/ RUN yarn install --mode=skip-build && yarn cache clean diff --git a/packages/app/next.config.js b/packages/app/next.config.js index 0c7b7e3d9..f4b04a4d5 100644 --- a/packages/app/next.config.js +++ b/packages/app/next.config.js @@ -21,6 +21,9 @@ module.exports = { '@hyperdx/instrumentation-sentry-node', ], }, + typescript: { + tsconfigPath: 'tsconfig.build.json', + }, // Ignore otel pkgs warnings // https://github.com/open-telemetry/opentelemetry-js/issues/4173#issuecomment-1822938936 webpack: ( diff --git a/packages/app/tsconfig.build.json b/packages/app/tsconfig.build.json new file mode 100644 index 000000000..5d4ac8a7b --- /dev/null +++ b/packages/app/tsconfig.build.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.json", + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx" + ], + "exclude": [ + "node_modules", + "**/*.test.ts", + "**/*.test.tsx" + ] +} \ No newline at end of file diff --git a/packages/app/tsconfig.json b/packages/app/tsconfig.json index 1c34b6e0a..418a2dee2 100644 --- a/packages/app/tsconfig.json +++ b/packages/app/tsconfig.json @@ -1,7 +1,11 @@ { "compilerOptions": { "target": "ES2020", - "lib": ["dom", "dom.iterable", "esnext"], + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], "allowJs": true, "sourceMap": true, "skipLibCheck": true, @@ -16,13 +20,26 @@ "isolatedModules": true, "useUnknownInCatchVariables": false, "jsx": "preserve", - "types": ["@types/intercom-web", "jest"], + "types": [ + "@types/intercom-web", + "jest" + ], "baseUrl": ".", "paths": { - "@/*": ["src/*"], - "@styles/*": ["styles/*"] + "@/*": [ + "src/*" + ], + "@styles/*": [ + "styles/*" + ] } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], - "exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"] -} + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/packages/app/tsconfig.test.json b/packages/app/tsconfig.test.json deleted file mode 100644 index f507e4fa2..000000000 --- a/packages/app/tsconfig.test.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "./tsconfig.json", - "exclude": ["node_modules"] -} diff --git a/packages/common-utils/.eslintrc.js b/packages/common-utils/.eslintrc.js index 560f9a02b..63f2ba54b 100644 --- a/packages/common-utils/.eslintrc.js +++ b/packages/common-utils/.eslintrc.js @@ -4,7 +4,7 @@ module.exports = { plugins: ['@typescript-eslint', 'prettier', 'simple-import-sort'], parserOptions: { tsconfigRootDir: __dirname, - project: ['./tsconfig.json', './tsconfig.test.json'], + project: ['./tsconfig.json'], }, extends: [ 'eslint:recommended', diff --git a/packages/common-utils/tsconfig.json b/packages/common-utils/tsconfig.json index f0500f395..38f8198bc 100644 --- a/packages/common-utils/tsconfig.json +++ b/packages/common-utils/tsconfig.json @@ -1,30 +1,19 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { "baseUrl": "./src", "paths": { - "@/*": ["./*"] + "@/*": [ + "./*" + ] }, - "allowSyntheticDefaultImports": true, "declaration": true, - "downlevelIteration": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "importHelpers": true, - "lib": ["ES2022", "dom"], - "module": "Node16", - "moduleResolution": "node", - "noFallthroughCasesInSwitch": true, - "noImplicitAny": false, - "noImplicitReturns": false, - "noImplicitThis": false, - "noUnusedLocals": false, - "noUnusedParameters": false, "outDir": "build", - "skipLibCheck": false, - "sourceMap": true, - "strict": true, - "target": "ES2022" }, - "include": ["src"], - "exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"] -} + "include": [ + "src" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/packages/common-utils/tsconfig.test.json b/packages/common-utils/tsconfig.test.json deleted file mode 100644 index f507e4fa2..000000000 --- a/packages/common-utils/tsconfig.test.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "./tsconfig.json", - "exclude": ["node_modules"] -} diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 000000000..27688f70d --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "Node16", + "moduleResolution": "node", + "lib": [ + "ES2022", + "dom" + ], + "allowSyntheticDefaultImports": true, + "downlevelIteration": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "importHelpers": true, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": false, + "noImplicitReturns": false, + "noImplicitThis": false, + "noUnusedLocals": false, + "noUnusedParameters": false, + "skipLibCheck": false, + "sourceMap": true, + "strict": true, + "target": "ES2022", + } +} \ No newline at end of file