Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../configs/tsconfig.base.json",
"compilerOptions": {
"composite": true,
"allowJs": true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ jobs:
- name: Lint publish code
run: pnpm run publint

- name: Type-check test files
run: pnpm run typecheck:tests
- name: Type-check files
run: pnpm run typecheck

test:
name: 'Test (${{ matrix.TEST_SUITE.name }}): ${{ matrix.os }} (node@${{ matrix.NODE_VERSION }})'
Expand Down
2 changes: 1 addition & 1 deletion benchmark/packages/adapter/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../configs/tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"rootDir": "./src",
Expand Down
2 changes: 1 addition & 1 deletion benchmark/packages/timer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../configs/tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"rootDir": "./src",
Expand Down
6 changes: 5 additions & 1 deletion tsconfig.base.json → configs/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"composite": true,
"declaration": true,
"emitDeclarationOnly": true,
"strict": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "nodenext",
"target": "esnext",
"module": "nodenext",
Expand All @@ -14,7 +17,8 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"outDir": "${configDir}/node_modules/.cache/tsconfig/out",
// Emit declaration and cache files to a directory that would be ignored by tools like Git and ESLint.
"outDir": "${configDir}/node_modules/.cache/ts_base/out",
"types": ["node"]
}
}
12 changes: 12 additions & 0 deletions configs/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.base.json",
"compilerOptions": {
"rootDir": "${configDir}/src",
"outDir": "${configDir}/dist",
// `._cache/` is ignored when publishing to NPM registry, so it's a safe place to put build artifacts that we don't want to publish.
// See https://docs.npmjs.com/cli/v10/configuring-npm/package-json#files
"tsBuildInfoFile": "${configDir}/dist/._cache/ts_build/build.tsbuildinfo"
},
"include": ["${configDir}/src"]
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.build.json",
"compilerOptions": {
"target": "ES2021",
"lib": ["WebWorker", "ES2021"],
"module": "commonjs",
// TODO: when upgrading to TS 6, will need to be set to "bundler"
"moduleResolution": "node",
"declaration": true,
"emitDeclarationOnly": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
"verbatimModuleSyntax": false,
"erasableSyntaxOnly": false
}
}
13 changes: 13 additions & 0 deletions configs/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.base.json",
"compilerOptions": {
"rootDir": "${configDir}",
"noUnusedLocals": false,
"noUnusedParameters": false,
"allowImportingTsExtensions": true,
"outDir": "${configDir}/node_modules/.cache/ts_test/out"
},
"include": ["${configDir}/test/**/*"],
"exclude": ["${configDir}/test/fixtures/**/*"]
}
25 changes: 11 additions & 14 deletions knip.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// @ts-check
const srcEntry = 'src/**/*.{js,ts,cts}';
const dtsEntry = '*.d.ts';
const testEntry = 'test/**/*.test.{js,ts}';

/** @type {import('knip').KnipConfig} */
Expand All @@ -24,12 +26,14 @@ export default {
entry: ['.flue/agents/*.ts', '.flue/workflows/*/WORKFLOW.ts'],
},
'packages/*': {
entry: [testEntry],
entry: [srcEntry, dtsEntry, testEntry],
},
'packages/astro': {
entry: [
// Can't be detected automatically since it's only in package.json#files
'templates/**/*',
srcEntry,
dtsEntry,
testEntry,
'test/types/**/*',
'e2e/**/*.test.{js,ts}',
Expand All @@ -53,37 +57,30 @@ export default {
'rehype-toc',
'remark-code-titles',
'@types/http-cache-semantics',
// Dynamically imported by astro add cloudflare
'@astrojs/cloudflare',
],
},
'packages/db': {
entry: [testEntry, 'test/types/**/*'],
entry: [srcEntry, dtsEntry, testEntry, 'test/types/**/*'],
},
'packages/integrations/*': {
entry: [testEntry],
entry: [srcEntry, dtsEntry, testEntry],
},
'packages/integrations/cloudflare': {
entry: [testEntry],
entry: [srcEntry, dtsEntry, testEntry],
// False positive because of cloudflare:workers
ignoreDependencies: ['cloudflare'],
},
'packages/integrations/mdx': {
entry: [testEntry],
// Required but not imported directly
ignoreDependencies: ['@types/*'],
},
'packages/integrations/netlify': {
entry: [testEntry],
entry: [srcEntry, dtsEntry, testEntry],
ignore: ['test/hosted/**'],
},
'packages/integrations/solid': {
entry: [testEntry],
entry: [srcEntry, dtsEntry, testEntry],
// It's an optional peer dep (triggers a warning) but it's fine in this case
ignoreDependencies: ['solid-devtools'],
},
'packages/markdown/remark': {
entry: [testEntry],
entry: [srcEntry, dtsEntry, testEntry],
// package.json#imports are not resolved at the moment
ignore: ['src/import-plugin-browser.ts', 'src/shiki-engine-workerd.ts'],
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"test:e2e": "cd packages/astro && pnpm playwright install firefox && pnpm run test:e2e",
"test:e2e:match": "cd packages/astro && pnpm playwright install firefox && pnpm run test:e2e:match",
"test:e2e:hosts": "turbo run test:hosted",
"typecheck:tests": "pnpm -r run --sequential typecheck:tests",
"typecheck": "tsc -b",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for reviewers:

We don’t need a standalone typecheck:tests script in each package. The root typecheck already covers both src/ and test/ across all packages.

"benchmark": "astro-benchmark",
"lint": "biome lint && knip && eslint . --report-unused-disable-directives-severity=warn --concurrency=auto",
"lint:ci": "knip && pnpm run eslint:ci",
Expand Down
2 changes: 1 addition & 1 deletion packages/astro-prism/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"homepage": "https://docs.astro.build/en/reference/api-reference/#prism-",
"main": "dist/index.js",
"scripts": {
"build": "astro-scripts build \"src/**/*.ts\" && tsc -p ./tsconfig.json",
"build": "astro-scripts build \"src/**/*.ts\" && tsc -b",
"build:ci": "astro-scripts build \"src/**/*.ts\"",
"dev": "astro-scripts dev \"src/**/*.ts\""
},
Expand Down
3 changes: 3 additions & 0 deletions packages/astro-prism/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../configs/tsconfig.build.json"
}
9 changes: 3 additions & 6 deletions packages/astro-prism/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
}
"extends": "../../configs/tsconfig.base.json",
"files": [],
"references": [{ "path": "./tsconfig.build.json" }]
}
5 changes: 2 additions & 3 deletions packages/astro-rss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
"dist"
],
"scripts": {
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
"build": "astro-scripts build \"src/**/*.ts\" && tsc -b",
"build:ci": "astro-scripts build \"src/**/*.ts\"",
"dev": "astro-scripts dev \"src/**/*.ts\"",
"test": "astro-scripts test \"test/**/*.test.ts\"",
"typecheck:tests": "tsc --build tsconfig.test.json"
"test": "astro-scripts test \"test/**/*.test.ts\""
},
"devDependencies": {
"@types/xml2js": "^0.4.14",
Expand Down
3 changes: 3 additions & 0 deletions packages/astro-rss/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../configs/tsconfig.build.json"
}
9 changes: 3 additions & 6 deletions packages/astro-rss/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
}
"extends": "../../configs/tsconfig.base.json",
"files": [],
"references": [{ "path": "./tsconfig.build.json" }, { "path": "./tsconfig.test.json" }]
}
12 changes: 2 additions & 10 deletions packages/astro-rss/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["test/**/*.ts"],
"exclude": ["test/fixtures/**"],
"compilerOptions": {
"allowJs": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"rewriteRelativeImportExtensions": true
},
"references": [{ "path": "../astro/tsconfig.test.json" }]
"extends": "../../configs/tsconfig.test.json",
"references": [{ "path": "./tsconfig.build.json" }]
}
7 changes: 3 additions & 4 deletions packages/astro/components/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../configs/tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"emitDeclarationOnly": false,
"noEmit": true,
"jsx": "preserve"
}
},
"references": [{ "path": "../tsconfig.build.json" }]
}
3 changes: 1 addition & 2 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
],
"scripts": {
"prebuild": "astro-scripts prebuild --to-string \"src/runtime/server/astro-island.ts\" \"src/runtime/client/{idle,load,media,only,visible}.ts\"",
"build": "pnpm run prebuild && astro-scripts build \"src/**/*.{ts,js}\" --copy-wasm && tsc && astro-check -- -- --root ./components",
"build": "pnpm run prebuild && astro-scripts build \"src/**/*.{ts,js}\" --copy-wasm && tsc -b && astro-check -- -- --root ./components",
"build:ci": "pnpm run prebuild && astro-scripts build \"src/**/*.{ts,js}\" --copy-wasm",
"dev": "astro-scripts dev --copy-wasm --prebuild \"src/runtime/server/astro-island.ts\" --prebuild \"src/runtime/client/{idle,load,media,only,visible}.ts\" \"src/**/*.{ts,js}\"",
"test": "pnpm run test:unit && pnpm run test:integration && pnpm run test:types",
Expand All @@ -123,7 +123,6 @@
"test:e2e:chrome": "playwright test",
"test:e2e:firefox": "playwright test --config playwright.firefox.config.js",
"test:types": "tsc --build test/types/tsconfig.json",
"typecheck:tests": "tsc --build tsconfig.test.json",
"test:unit": "astro-scripts test \"test/units/**/*.test.ts\" --strip-types --teardown ./test/units/teardown.ts",
"test:integration": "pnpm run test:integration:js && pnpm run test:integration:ts",
"test:integration:js": "astro-scripts test \"test/*.test.js\"",
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/cli/check/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ensureProcessNodeEnv } from '../../core/util.js';
import { createLoggerFromFlags, type Flags, flagsToAstroInlineConfig } from '../flags.js';
import { getPackage } from '../install-package.js';

export async function check(flags: Flags) {
export async function check(flags: Flags): Promise<boolean | void> {
ensureProcessNodeEnv('production');
const logger = createLoggerFromFlags(flags);
const getPackageOpts = {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('astro cli', () => {
});
const logs: LogEntry[] = [];

const checkServer = await fixture.check({
const checkServer: boolean | void = await fixture.check({
_: [],
flags: { watch: true },
logging: {
Expand Down
4 changes: 1 addition & 3 deletions packages/astro/test/types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../configs/tsconfig.base.json",
"compilerOptions": {
"composite": true,
"allowJs": true,
"emitDeclarationOnly": false
}
}
12 changes: 12 additions & 0 deletions packages/astro/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../configs/tsconfig.build.json",
"compilerOptions": {
"jsx": "preserve"
},
"include": ["./src", "./dev-only.d.ts"],
"references": [
{ "path": "../internal-helpers/tsconfig.json" },
{ "path": "../telemetry/tsconfig.json" },
{ "path": "../markdown/remark/tsconfig.json" }
]
}
20 changes: 7 additions & 13 deletions packages/astro/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"include": ["src", "dev-only.d.ts"],
"exclude": ["dist"],
"compilerOptions": {
"composite": true,
"rootDir": "./src",
"allowJs": true,
"declarationDir": "./dist",
"outDir": "./dist",
"jsx": "preserve",
"tsBuildInfoFile": "${configDir}/dist/._cache/tsconfig/tsbuildinfo.json",
"erasableSyntaxOnly": true
}
"extends": "../../configs/tsconfig.base.json",
"files": [],
"references": [
{ "path": "./tsconfig.build.json" },
{ "path": "./tsconfig.test.json" },
{ "path": "./components/tsconfig.json" }
]
}
18 changes: 3 additions & 15 deletions packages/astro/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../configs/tsconfig.test.json",
"include": ["test/units/**/*.ts", "test/*.ts", "e2e/*.ts", "package.json"],
"exclude": ["test/units/_temp-fixtures/**", "test/fixtures/**", "e2e/fixtures/**"],
"files": [
Expand All @@ -9,19 +9,7 @@
"./test/fixtures/before-hydration/deps.mjs"
],
"compilerOptions": {
"types": ["vite/client", "node"],
"composite": true,
"allowJs": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"rewriteRelativeImportExtensions": true
"types": ["vite/client", "node"]
},
"references": [
{
"path": "./tsconfig.json"
},
{
"path": "../../scripts/tsconfig.json"
}
]
"references": [{ "path": "./tsconfig.build.json" }, { "path": "../../scripts/tsconfig.json" }]
}
5 changes: 2 additions & 3 deletions packages/create-astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
"create-astro": "./create-astro.mjs"
},
"scripts": {
"build": "astro-scripts build \"src/index.ts\" --bundle && tsc",
"build": "astro-scripts build \"src/index.ts\" --bundle && tsc -b",
"build:ci": "astro-scripts build \"src/index.ts\" --bundle",
"dev": "astro-scripts dev \"src/**/*.ts\"",
"test": "astro-scripts test \"test/**/*.test.ts\"",
"typecheck:tests": "tsc --build tsconfig.test.json"
"test": "astro-scripts test \"test/**/*.test.ts\""
},
"files": [
"dist",
Expand Down
4 changes: 4 additions & 0 deletions packages/create-astro/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../configs/tsconfig.build.json",
"references": [{ "path": "../internal-helpers/tsconfig.json" }]
}
Loading
Loading