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

chore: use @tsconfig/node16 #14547

Merged
merged 4 commits into from
Sep 20, 2023
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@jest/test-utils": "workspace:^",
"@lerna-lite/cli": "1.13.0",
"@microsoft/api-extractor": "^7.35.0",
"@tsconfig/node14": "^14.1.0",
"@tsconfig/node16": "^16.1.0",
"@tsd/typescript": "^5.0.4",
"@types/babel__core": "^7.1.14",
"@types/babel__generator": "^7.0.0",
Expand Down
2 changes: 0 additions & 2 deletions packages/jest-core/src/collectHandles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function stackIsFromUser(stack: string) {

const alwaysActive = () => true;

// @ts-expect-error: doesn't exist in v12 typings
const hasWeakRef = typeof WeakRef === 'function';

const asyncSleep = promisify(setTimeout);
Expand Down Expand Up @@ -106,7 +105,6 @@ export default function collectHandles(): HandleCollectionResult {
// Handle that supports hasRef
if ('hasRef' in resource) {
if (hasWeakRef) {
// @ts-expect-error: doesn't exist in v12 typings
const ref = new WeakRef(resource);
isActive = () => {
return ref.deref()?.hasRef() ?? false;
Expand Down
29 changes: 16 additions & 13 deletions scripts/verifyOldTs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,22 @@ import chalk from 'chalk';
import execa from 'execa';
import fs from 'graceful-fs';
import stripJsonComments from 'strip-json-comments';
/* eslint-disable import/order */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The require()s below are are triggering this.

import tempy from 'tempy';
const require = createRequire(import.meta.url);

const rootPackageJson = require('../package.json');

const currentTsdTypescriptVersion =
rootPackageJson.devDependencies['@tsd/typescript'];
const currentTypescriptVersion = rootPackageJson.devDependencies['typescript'];
const tsconfigBasePackage = Object.keys(rootPackageJson.devDependencies).find(
packageName => packageName.startsWith('@tsconfig'),
);
const apiExtractorTypescriptVersion =
require('@microsoft/api-extractor/package.json').dependencies['typescript'];
/* eslint-enable import/order */

const baseTsConfig = JSON.parse(
stripJsonComments(
fs.readFileSync(require.resolve('../tsconfig.json'), 'utf8'),
Expand All @@ -31,7 +44,7 @@ const tsConfig = {
noEmit: true,
},
};
/* eslint-enable */
/* eslint-enable sort-keys */

const tsVersion = '5.0';

Expand All @@ -51,8 +64,7 @@ function smoketest() {
execa.sync('yarn', ['init', '--yes'], {cwd, stdio: 'inherit'});
execa.sync(
'yarn',
// TODO: do not set version of @tsconfig/node14 after we upgrade to a version of TS that supports `"moduleResolution": "node16"` (https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/)
['add', `typescript@~${tsVersion}`, '@tsconfig/node14@1'],
['add', `typescript@~${tsVersion}`, tsconfigBasePackage],
{cwd, stdio: 'inherit'},
);
fs.writeFileSync(
Expand All @@ -77,14 +89,6 @@ function smoketest() {

function typeTests() {
const cwd = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../');
const rootPackageJson = require('../package.json');

const currentTsdTypescriptVersion =
rootPackageJson.devDependencies['@tsd/typescript'];
const currentTypescriptVersion =
rootPackageJson.devDependencies['typescript'];
const apiExtractorTypescriptVersion =
require('@microsoft/api-extractor/package.json').dependencies['typescript'];

try {
const {stdout: statusStdout} = execa.sync(
Expand All @@ -99,8 +103,7 @@ function typeTests() {
);
}

// TODO: do not set version of @tsconfig/node14 after we upgrade to a version of TS that supports `"moduleResolution": "node16"` (https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/)
execa.sync('yarn', ['add', '@tsconfig/node14@1'], {cwd});
execa.sync('yarn', ['add', tsconfigBasePackage], {cwd});

execa.sync(
'yarn',
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@tsconfig/node14/tsconfig.json",
"extends": "@tsconfig/node16/tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2933,7 +2933,7 @@ __metadata:
"@jest/test-utils": "workspace:^"
"@lerna-lite/cli": 1.13.0
"@microsoft/api-extractor": ^7.35.0
"@tsconfig/node14": ^14.1.0
"@tsconfig/node16": ^16.1.0
"@tsd/typescript": ^5.0.4
"@types/babel__core": ^7.1.14
"@types/babel__generator": ^7.0.0
Expand Down Expand Up @@ -4618,20 +4618,20 @@ __metadata:
languageName: node
linkType: hard

"@tsconfig/node14@npm:^14.1.0":
version: 14.1.0
resolution: "@tsconfig/node14@npm:14.1.0"
checksum: 8342dc30edbfaed11d1659b1a9819779bb69df210974a9e8a337b0624b1d9f5026f37e2dcc1d555adb3e4246a0ec35896b3ae5fe3fc69f3382d3bc11069cecc1
languageName: node
linkType: hard

"@tsconfig/node16@npm:^1.0.2":
version: 1.0.4
resolution: "@tsconfig/node16@npm:1.0.4"
checksum: 202319785901f942a6e1e476b872d421baec20cf09f4b266a1854060efbf78cde16a4d256e8bc949d31e6cd9a90f1e8ef8fb06af96a65e98338a2b6b0de0a0ff
languageName: node
linkType: hard

"@tsconfig/node16@npm:^16.1.0":
version: 16.1.1
resolution: "@tsconfig/node16@npm:16.1.1"
checksum: 26d83db06866083b543e73eda33585464362fd0835229b9a5b1185f0353b9b5db9ca4f66a4be53d4ec5d4c219be42b0a7582f8bcc7268f2f77b1c643375e490f
languageName: node
linkType: hard

"@tsd/typescript@npm:^5.0.4":
version: 5.2.2
resolution: "@tsd/typescript@npm:5.2.2"
Expand Down