Skip to content

feat: support TS 5.3 #7968

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

Merged
merged 1 commit into from
Nov 27, 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
84 changes: 0 additions & 84 deletions .yarn/patches/typescript-npm-5.3.1-rc-6c4278ffd3.patch

This file was deleted.

84 changes: 0 additions & 84 deletions .yarn/patches/typescript-npm-5.4.0-dev.20231117-78a04a34c5.patch

This file was deleted.

4 changes: 1 addition & 3 deletions docs/maintenance/Dependency_Version_Upgrades.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ See [chore: drop support for ESLint v6](https://github.com/typescript-eslint/typ
The typescript-eslint repository contains three kinds of version ranges for Node:

- [`.github/workflows/ci.yml`](https://github.com/typescript-eslint/typescript-eslint/blob/main/.github/workflows/ci.yml)'s `PRIMARY_NODE_VERSION`: Set to the highest Node version we support
- `node-version`: Set to a tuple of our [lowest, highest] supported versions for our unit tests in CI
- `node-version`: Set to a tuple of our `[lowest, highest]` supported versions for our unit tests in CI
- `engines` field in all `package.json`s: explicitly lists all supported Node ranges

Change those numbers accordingly when adding support for a new Node version or removing support for an old Node version.
Expand Down Expand Up @@ -97,8 +97,6 @@ We generally start the process of supporting a new TypeScript version just after
- In the root `package.json`, change the `devDependency` on `typescript` to `~X.Y.3`
- Rename and update `patches/typescript*` to the new TypeScript version
- Any other changes made necessary due to changes in TypeScript between the RC version and stable version
- Update the supported version range in [Users > Dependency Versions](../users/Dependency_Versions.mdx)
1. Update [Users > Dependency Versions > TypeScript](../users/Dependency_Versions.mdx#typescript)
1. Send a PR that updates this documentation page to point to your newer issues and PRs
- Also update any of these steps if you go with a different process

Expand Down
2 changes: 1 addition & 1 deletion docs/users/Dependency_Versions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import packageJson from '../../package.json';

## ESLint

> The version range of ESLint currently supported is `^6.0.0 || ^7.0.0 || ^8.0.0`.
> The version range of ESLint currently supported is `^7.0.0 || ^8.0.0`.

We generally support at least the latest two major versions of ESLint.

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"ts-node": "10.7.0",
"tslint": "^6.1.3",
"tsx": "^3.12.7",
"typescript": ">=4.3.5 <5.4.0 || 5.3.0-beta || 5.3.1-rc || 5.4.0-dev.20231117"
"typescript": ">=4.3.5 <5.4.0"
},
"resolutions": {
"@jest/create-cache-key-function": "^29",
Expand All @@ -141,7 +141,7 @@
"pretty-format": "^29",
"react-split-pane@^0.1.92": "patch:react-split-pane@npm%3A0.1.92#./.yarn/patches/react-split-pane-npm-0.1.92-93dbf51dff.patch",
"tsx": "^3.12.7",
"typescript": "patch:typescript@npm%3A5.4.0-dev.20231117#./.yarn/patches/typescript-npm-5.4.0-dev.20231117-78a04a34c5.patch"
"typescript": "5.3.2"
},
"packageManager": "yarn@3.7.0"
}
8 changes: 4 additions & 4 deletions packages/repo-tools/src/generate-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ async function main(): Promise<void> {

// import and spread all of the references
const imports = [
"import { ImplicitLibVariableOptions } from '../variable';",
"import type { ImplicitLibVariableOptions } from '../variable';",
];
for (const reference of references) {
const name = sanitize(reference);
Expand Down Expand Up @@ -245,9 +245,9 @@ async function main(): Promise<void> {

if (requiredBaseImports.size > 0) {
imports.push(
`import {${Array.from(requiredBaseImports).join(
',',
)}} from './${BASE_CONFIG_MODULE_NAME}';`,
`import {${Array.from(requiredBaseImports)
.sort()
.join(',')}} from './${BASE_CONFIG_MODULE_NAME}';`,
);
}

Expand Down
1 change: 1 addition & 0 deletions packages/typescript-estree/src/node-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export function isComment(node: ts.Node): boolean {
* @returns is JSDoc comment
*/
function isJSDocComment(node: ts.Node): node is ts.JSDoc {
// eslint-disable-next-line deprecation/deprecation -- SyntaxKind.JSDoc was only added in TS4.7 so we can't use it yet
return node.kind === SyntaxKind.JSDocComment;
}

Expand Down
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.3.0';
const SUPPORTED_TYPESCRIPT_VERSIONS = '>=4.3.5 <5.4.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.3.1-rc'];
const SUPPORTED_PRERELEASE_RANGES: string[] = [];
const ACTIVE_TYPESCRIPT_VERSION = ts.version;
const isRunningSupportedTypeScriptVersion = semver.satisfies(
ACTIVE_TYPESCRIPT_VERSION,
Expand Down
8 changes: 6 additions & 2 deletions packages/typescript-estree/src/ts-estree/ts-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import type * as ts from 'typescript';
// Eg: https://github.com/typescript-eslint/typescript-eslint/issues/2388, https://github.com/typescript-eslint/typescript-eslint/issues/2784
/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error, @typescript-eslint/no-empty-interface */
declare module 'typescript' {
// @ts-ignore - added in TS 4.5
/** @ts-ignore - added in TS 4.5, deprecated and converted to a type-alias in TS 5.3 */
export interface AssertClause extends ts.Node {}
// @ts-ignore - added in TS 4.5
/** @ts-ignore - added in TS 4.5, deprecated and converted to a type-alias in TS 5.3 */
export interface AssertEntry extends ts.Node {}
Comment on lines +7 to 10
Copy link
Member Author

Choose a reason for hiding this comment

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

microsoft/TypeScript#56477

This is a problem for us.
Testing in the work repo this breaks consumers on TS5.3
Even with the jsdoc style - TS will error on the TS declaration.

screenshot of type error

We don't get this error locally because we use skipLibChecks.

Note that this blocks the full support.

// added in TS 4.9
export interface SatisfiesExpression extends ts.Node {}
Expand All @@ -25,6 +25,10 @@ export type TSNode =
| ts.Identifier
| ts.ImportAttribute
| ts.ImportAttributes
/* eslint-disable-next-line deprecation/deprecation, @typescript-eslint/no-duplicate-type-constituents -- intentional for old TS versions */
| ts.AssertClause
/* eslint-disable-next-line deprecation/deprecation, @typescript-eslint/no-duplicate-type-constituents -- intentional for old TS versions */
| ts.AssertEntry
| ts.PrivateIdentifier
| ts.QualifiedName
| ts.ComputedPropertyName
Expand Down
3 changes: 2 additions & 1 deletion packages/typescript-estree/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"composite": true,
"outDir": "./dist",
"rootDir": "./src",
"resolveJsonModule": true
"resolveJsonModule": true,
"removeComments": false
},
"include": ["src", "typings"],
"references": [
Expand Down
44 changes: 44 additions & 0 deletions packages/typescript-estree/typings/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,48 @@ declare module 'typescript' {
interface JSDocContainer {
jsDoc?: JSDoc[];
}

// add back the deprecated properties that were removed in newer TS versions
// make sure these properties are marked as @ deprecated so they're flagged
// by the `deprecation/deprecation` lint rule

interface PropertySignature {
/** @deprecated removed in 5.0 but we want to keep it for backwards compatibility checks! */
readonly initializer?: Expression | undefined;
}
interface PropertyAssignment {
/** @deprecated removed in 5.0 but we want to keep it for backwards compatibility checks! */
readonly questionToken?: QuestionToken | undefined;
/** @deprecated removed in 5.0 but we want to keep it for backwards compatibility checks! */
readonly exclamationToken?: ExclamationToken | undefined;
}
interface ShorthandPropertyAssignment {
/** @deprecated removed in 5.0 but we want to keep it for backwards compatibility checks! */
readonly modifiers?: NodeArray<Modifier> | undefined;
/** @deprecated removed in 5.0 but we want to keep it for backwards compatibility checks! */
readonly questionToken?: QuestionToken | undefined;
/** @deprecated removed in 5.0 but we want to keep it for backwards compatibility checks! */
readonly exclamationToken?: ExclamationToken | undefined;
}
interface FunctionTypeNode {
/** @deprecated removed in 5.0 but we want to keep it for backwards compatibility checks! */
readonly modifiers?: NodeArray<Modifier> | undefined;
}

/**
* @deprecated don't use this directly as it does not exist pre-4.8; instead use getDecorators from `src/getModifiers.ts`.
*/
function getDecorators(node: HasDecorators): readonly Decorator[] | undefined;
/**
* @deprecated don't use this directly as it does not exist pre-4.8; instead use getModifiers from `src/getModifiers.ts`.
*/
function getModifiers(node: HasModifiers): readonly Modifier[] | undefined;
/**
* @deprecated don't use this directly as it does not exist pre-4.8; instead use getModifiers from `src/getModifiers.ts`.
*/
function canHaveModifiers(node: Node): node is HasModifiers;
/**
* @deprecated don't use this directly as it does not exist pre-4.8; instead use getDecorators from `src/getModifiers.ts`.
*/
function canHaveDecorators(node: Node): node is HasDecorators;
}
Loading