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

feat: bump supported TS version to 5.2 #7535

Merged
merged 2 commits into from
Aug 25, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"ts-node": "10.7.0",
"tslint": "^6.1.3",
"tsx": "^3.12.7",
"typescript": ">=4.3.5 <5.2.0 || 5.2.1-rc"
"typescript": ">=4.3.5 <5.3.0"
},
"resolutions": {
"@jest/create-cache-key-function": "^29",
Expand All @@ -142,7 +142,7 @@
"jest-util": "^29",
"pretty-format": "^29",
"tsx": "^3.12.7",
"typescript": "5.2.1-rc"
"typescript": "5.2.2"
},
"packageManager": "yarn@3.6.2"
}
29 changes: 25 additions & 4 deletions packages/scope-manager/tools/generate-lib.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { TSESTree } from '@typescript-eslint/types';
import { AST_TOKEN_TYPES } from '@typescript-eslint/types';
import { ESLint } from '@typescript-eslint/utils/ts-eslint';
Copy link
Member

@armano2 armano2 Sep 5, 2023

Choose a reason for hiding this comment

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

@bradzacher this seem to be generating some issues on clean install

> yarn build

NX   Could not execute command because the task graph has a circular dependency
rule-schema-to-typescript-types:build --> type-utils:build --> utils:build --> scope-manager:build --> utils:build

import * as fs from 'fs';
import * as path from 'path';
import { format, resolveConfig } from 'prettier';
Expand Down Expand Up @@ -53,6 +54,7 @@ const TYPES_FILE = path.resolve(
'src',
'lib.ts',
);
const BARREL_PATH = path.join(OUTPUT_FOLDER, 'index.ts');

const BASE_CONFIG_MODULE_NAME = 'base-config';
const SHARED_CONFIG_MODULE = path.resolve(
Expand Down Expand Up @@ -110,7 +112,7 @@ function getReferences(
return references;
}

function main(): void {
async function main(): Promise<void> {
try {
rimraf.sync(OUTPUT_FOLDER);
} catch {
Expand All @@ -122,6 +124,12 @@ function main(): void {
// ignored
}

const filesWritten: string[] = [
SHARED_CONFIG_MODULE,
TYPES_FILE,
BARREL_PATH,
];

// the shared
fs.writeFileSync(
SHARED_CONFIG_MODULE,
Expand Down Expand Up @@ -222,7 +230,9 @@ function main(): void {
}

const formattedCode = formatCode(code);
fs.writeFileSync(path.join(OUTPUT_FOLDER, `${libName}.ts`), formattedCode);
const writePath = path.join(OUTPUT_FOLDER, `${libName}.ts`);
fs.writeFileSync(writePath, formattedCode);
filesWritten.push(writePath);

console.log(
'Wrote',
Expand Down Expand Up @@ -254,7 +264,7 @@ function main(): void {

const formattedBarrelCode = formatCode(barrelCode);

fs.writeFileSync(path.join(OUTPUT_FOLDER, 'index.ts'), formattedBarrelCode);
fs.writeFileSync(BARREL_PATH, formattedBarrelCode);
console.log('Wrote barrel file');

// generate a string union type for the lib names
Expand All @@ -270,6 +280,17 @@ function main(): void {

fs.writeFileSync(TYPES_FILE, formattedLibUnionCode);
console.log('Wrote Lib union type file');

const lint = new ESLint({
fix: true,
});
const results = await lint.lintFiles(filesWritten);
await ESLint.outputFixes(results);
console.log('Autofixed lint errors');
}

main();
main().catch(e => {
console.error(e);
// eslint-disable-next-line no-process-exit
process.exit(1);
});
Copy link
Member

Choose a reason for hiding this comment

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

What's going on here? Is it related to #7534?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nah so I ran the generator and noticed that it changed all of the lib files and caused a bunch of lint errors due to unsorted imports and such.

I figured that instead of manually running the linter afterwards was dumb cos we can automate it :)

Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import type { ParseSettings } from './index';
* This needs to be kept in sync with /docs/users/Versioning.mdx
* in the typescript-eslint monorepo
*/
const SUPPORTED_TYPESCRIPT_VERSIONS = '>=4.3.5 <5.2.0';
const SUPPORTED_TYPESCRIPT_VERSIONS = '>=4.3.5 <5.3.0';

/*
* The semver package will ignore prerelease ranges, and we don't want to explicitly document every one
* List them all separately here, so we can automatically create the full string
*/
const SUPPORTED_PRERELEASE_RANGES: string[] = ['5.2.1-rc'];
const SUPPORTED_PRERELEASE_RANGES: string[] = [];
const ACTIVE_TYPESCRIPT_VERSION = ts.version;
const isRunningSupportedTypeScriptVersion = semver.satisfies(
ACTIVE_TYPESCRIPT_VERSION,
Expand Down
1 change: 1 addition & 0 deletions packages/website/src/vendor/sandbox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export declare const createTypeScriptSandbox: (
};
/** A list of TypeScript versions you can use with the TypeScript sandbox */
supportedVersions: readonly [
'5.2.1-rc',
'5.2.0-beta',
'5.1.6',
'5.0.4',
Expand Down
10 changes: 7 additions & 3 deletions packages/website/src/vendor/typescript-vfs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export declare function createVirtualTypeScriptEnvironment(
): VirtualTypeScriptEnvironment;
/**
* Grab the list of lib files for a particular target, will return a bit more than necessary (by including
* the dom) but that's OK
* the dom) but that's OK, we're really working with the constraint that you can't get a list of files
* when running in a browser.
*
* @param target The compiler settings target baseline
* @param ts A copy of the TypeScript module
Expand All @@ -58,10 +59,13 @@ export declare const knownLibFilesForCompilerOptions: (
/**
* Sets up a Map with lib contents by grabbing the necessary files from
* the local copy of typescript via the file system.
*
* The first two args are un-used, but kept around so as to not cause a
* semver major bump for no gain to module users.
*/
export declare const createDefaultMapFromNodeModules: (
compilerOptions: CompilerOptions,
ts?: typeof ts,
_compilerOptions: CompilerOptions,
_ts?: typeof ts,
tsLibDirectory?: string,
) => Map<string, string>;
/**
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6019,7 +6019,7 @@ __metadata:
ts-node: 10.7.0
tslint: ^6.1.3
tsx: ^3.12.7
typescript: ">=4.3.5 <5.2.0 || 5.2.1-rc"
typescript: ">=4.3.5 <5.3.0"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -20017,23 +20017,23 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:5.2.1-rc":
version: 5.2.1-rc
resolution: "typescript@npm:5.2.1-rc"
"typescript@npm:5.2.2":
version: 5.2.2
resolution: "typescript@npm:5.2.2"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 0bea857151b74d76d36af16e77ad348b1fbf9630b0002be4cda9713fee692e50e2faa5d1d63fccbc3e3a4999e0356c0b722d993344ab0d014ecfc4d500b178ca
checksum: 7912821dac4d962d315c36800fe387cdc0a6298dba7ec171b350b4a6e988b51d7b8f051317786db1094bd7431d526b648aba7da8236607febb26cf5b871d2d3c
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A5.2.1-rc#~builtin<compat/typescript>":
version: 5.2.1-rc
resolution: "typescript@patch:typescript@npm%3A5.2.1-rc#~builtin<compat/typescript>::version=5.2.1-rc&hash=f3b441"
"typescript@patch:typescript@npm%3A5.2.2#~builtin<compat/typescript>":
version: 5.2.2
resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin<compat/typescript>::version=5.2.2&hash=f3b441"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 3128667694c92cdafc4683aa3c75c6da4e9d38b95464cad6e9d76732d2a8c55b12fa7d20ccae59c46b2baabbecd04ed8e1ec2bad7fb1da01200b800dfacd2eb7
checksum: 0f4da2f15e6f1245e49db15801dbee52f2bbfb267e1c39225afdab5afee1a72839cd86000e65ee9d7e4dfaff12239d28beaf5ee431357fcced15fb08583d72ca
languageName: node
linkType: hard

Expand Down