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",
"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/src/types/public/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@ export interface AstroUserConfig<
*
* ```js title="astro.config.mjs"
* import { defineConfig, sessionDrivers } from 'astro/config';
*
* export default defineConfig({
* session: {
* driver: sessionDrivers.redis({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.ts';
import { type Fixture, loadFixture } from './test-utils.ts';

// Regression test for https://github.com/withastro/astro/issues/15963
// <style> tags in components imported via tsconfig path aliases should compile correctly.
describe('Style compilation with tsconfig path aliases', () => {
let fixture;
let fixture: Fixture;

before(async () => {
fixture = await loadFixture({
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import { loadFixture } from './test-utils.ts';
import { type DevServer, type Fixture, loadFixture } from './test-utils.ts';

// Regression test for https://github.com/withastro/astro/issues/16291
//
Expand All @@ -19,8 +19,8 @@ import { loadFixture } from './test-utils.ts';
// `@astrojs/cloudflare` does in dev (registers a `prerender` Vite
// environment and flips on the core dev-prerender middleware).
describe('Head propagation across ssr and prerender envs in dev', () => {
let fixture;
let devServer;
let fixture: Fixture;
let devServer: DevServer;

before(async () => {
fixture = await loadFixture({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.ts';
import { type Fixture, loadFixture } from './test-utils.ts';

describe('Partials CSS propagation', () => {
/** @type {import('./test-utils.ts').Fixture} */
let fixture;
let fixture: Fixture;

before(async () => {
fixture = await loadFixture({
Expand All @@ -26,7 +25,7 @@ describe('Partials CSS propagation', () => {
const stylesheetHrefs = $('link[rel="stylesheet"]')
.toArray()
.map((el) => $(el).attr('href'))
.filter((href) => href && href.startsWith('/_astro/'));
.filter((href): href is string => !!href && href.startsWith('/_astro/'));

for (const href of stylesheetHrefs) {
styles += `\n${await fixture.readFile(href)}`;
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" }
]
}
Loading
Loading