Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match @types/node to TS version for each run of npm test:types #655

Merged
merged 1 commit into from
Oct 1, 2024
Merged
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
32 changes: 11 additions & 21 deletions tests/types/scripts/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import fs from 'fs';
import 'zx/globals';

const VERSIONS = [
'next',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

adding this back, it was removed yesterday to unblock master merges

'beta',
'latest',
'5.2',
Expand All @@ -19,19 +20,6 @@ const VERSIONS = [
'4.2.4',
'4.1.6',
'4.0.6',
'3.9.10',
'3.8.3',
'3.7.4',
'3.6.3',
'3.5.1',
'3.4.4',
'3.3.3',
'3.2.1',

// Attempting to test on 3.1.1 currently fails. I believe it is not a
// fundamental incompatibility with the types, just some tsconfig.json changes
// that are needed. Skipping for now
// '3.1.1',
];

const TYPE_TESTS_DIR = `${__dirname}/..`;
Expand All @@ -48,13 +36,15 @@ await $`yarn init -sy`;
for (const version of VERSIONS) {
console.log(`--- Testing with TypeScript version ${version}`);
await $`yarn add -s --no-progress typescript@${version}`;
await $`yarn run tsc --strict --noEmit src/valid.ts`;

// TypeScript versions >= 3.9.0 support [@ts-expect-error][0], which lets us
// write tests for types that we expect to cause errors
//
// [0]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#-ts-expect-error-comments
if (version >= '3.9.0') {
await $`yarn run tsc --strict --noEmit src/invalid.ts`;
}
// Definitely Typed only supports TS versions 2 years in the past.
// To make this check more stable, install @types/node to match
// the version we are testing.
const tag = ['next', 'beta', 'latest'].includes(version)
? 'latest'
: `ts${version.substring(0, 3)}`;
await $`yarn add -s --no-progress @types/node@${tag}`;

await $`yarn run tsc --strict --noEmit src/valid.ts`;
await $`yarn run tsc --strict --noEmit src/invalid.ts`;
}
Loading