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: update TypeScript to 5.0 RC #6570

Merged
merged 18 commits into from Mar 13, 2023

Conversation

sosukesuzuki
Copy link
Contributor

@sosukesuzuki sosukesuzuki commented Mar 5, 2023

PR Checklist

Overview

Updates typescript to 5.0.1-rc! Please see commits for details.

Todo

  • Fix tests for eslint-plugin
  • Fix type error for website source code

@nx-cloud
Copy link

nx-cloud bot commented Mar 5, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 43ae7de. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 46 targets

Sent with 💌 from NxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @sosukesuzuki!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

@netlify
Copy link

netlify bot commented Mar 5, 2023

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 43ae7de
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/640cae80c543190008f38c31
😎 Deploy Preview https://deploy-preview-6570--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@@ -21,6 +21,7 @@ describe('convert', () => {
function fakeUnknownKind(node: ts.Node): void {
ts.forEachChild(node, fakeUnknownKind);
// @ts-expect-error -- intentionally writing to a readonly field
// eslint-disable-next-line deprecation/deprecation
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we use other node for testing?

@codecov
Copy link

codecov bot commented Mar 5, 2023

Codecov Report

Merging #6570 (43ae7de) into main (9427b7c) will decrease coverage by 2.04%.
The diff coverage is 84.09%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6570      +/-   ##
==========================================
- Coverage   90.66%   88.62%   -2.04%     
==========================================
  Files         376      382       +6     
  Lines       12851    12883      +32     
  Branches     3783     3787       +4     
==========================================
- Hits        11651    11418     -233     
- Misses        856     1124     +268     
+ Partials      344      341       -3     
Flag Coverage Δ
unittest 88.62% <84.09%> (-2.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/scope-manager/src/lib/dom.iterable.ts 100.00% <ø> (ø)
packages/scope-manager/src/lib/dom.ts 100.00% <ø> (ø)
...s/scope-manager/src/lib/es2015.symbol.wellknown.ts 100.00% <ø> (ø)
packages/scope-manager/src/lib/webworker.ts 100.00% <ø> (ø)
packages/type-utils/src/typeFlagUtils.ts 75.00% <ø> (ø)
packages/typescript-estree/src/convert.ts 84.89% <ø> (ø)
...-estree/src/create-program/createDefaultProgram.ts 78.26% <ø> (ø)
.../src/create-program/getWatchProgramsForProjects.ts 79.08% <ø> (ø)
packages/typescript-estree/src/getModifiers.ts 58.33% <0.00%> (-2.54%) ⬇️
packages/typescript-estree/src/version-check.ts 100.00% <ø> (ø)
... and 13 more

... and 4 files with indirect coverage changes

@@ -113,6 +113,7 @@ export const LoadedEditor: React.FC<LoadedEditorProps> = ({
jsx,
parseTSConfig(tsconfig).compilerOptions,
);
// @ts-expect-error Monaco typescript.CompilerOptions is incompatible with typescript 5.0 types
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can remove this when Monaco updates CompilerOptions type

Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of curiousity, what's incompatible here? I'm trying to get monaco up to date among other things, so I'm curious.

Monaco has to redeclare everything for their public API, so, it's likely that this happens a lot and casing this away forever might be better (unless the problem is trivial).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without @ts-expect-error, TS output the error Type 'ModuleResolutionKind.Classic' is not assignable to type 'ModuleResolutionKind | undefined'.

packages/typescript-estree/src/convert.ts Outdated Show resolved Hide resolved
packages/typescript-estree/src/convert.ts Outdated Show resolved Hide resolved
packages/type-utils/src/typeFlagUtils.ts Outdated Show resolved Hide resolved
packages/typescript-estree/src/getModifiers.ts Outdated Show resolved Hide resolved
packages/typescript-estree/src/getModifiers.ts Outdated Show resolved Hide resolved
@sosukesuzuki sosukesuzuki marked this pull request as ready for review March 6, 2023 13:21
@@ -107,10 +107,10 @@
"ts-node": "10.7.0",
"tslint": "^6.1.3",
"tsx": "^3.12.1",
"typescript": ">=3.3.1 <5.0.0"
"typescript": ">=3.3.1 <4.9.5 || 5.0.1-rc"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to be so strict here? If we release 4.9.6 (however unlikely), that'll cause problems. That and I see basically no future in which we change the APIs post-RC, so it feels pretty safe to just bump this to < 5.1.0.

Though, I also think that you shouldn't specify versions here at all; given ts-eslint prints a very loud warning about using a potentially incompatible TypeScript version, this particular bit IMO only causes pain when trying to get package managers happy in the TypeScript repo or when testing newer releases of TypeScript in other repos...

Copy link
Member

@bradzacher bradzacher Mar 6, 2023

Choose a reason for hiding this comment

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

This is the private package.json for our repo, and is not published to the outside world.
Each package that actually depends on TS uses an optional, unbounded peer dependency on TS:

"peerDependenciesMeta": {
"typescript": {
"optional": true
}
},


This range here is primarily here as our "top level" range to clearly specify the range for the project. At some point we want to automatically flow this value into our docs and package as the single point-of-definition.
It actually doesn't even do anything technically because just below it we have a resolution which forces a specific version of TS (eg this PR sets it to ~5.0.1-rc).

I agree though that we should probably keep it as <5.0.0 instead of dropping it down to <4.9.5

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, yes, oops. I'm conflating this with the fact that prereleases in the tree don't satisfy "*" or "latest" and cause duplication (boo).

Comment on lines 86 to 92
if (typeof type.value === 'object') {
// Print ts.PseudoBigInt
return `${
type.value.negative ? '-' : ''
}${type.value.base10Value.toString()}n`;
}
return type.value.toString();
Copy link
Member

Choose a reason for hiding this comment

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

This should be handled instead by the condition on line 111
We should move that branch up instaed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

this is looking good to me!
I think we can merge this once we have the syntax changes ready

@bradzacher bradzacher merged commit 36ef0e1 into typescript-eslint:main Mar 13, 2023
35 of 40 checks passed
@frank-weindel
Copy link

@sosukesuzuki In my project, I've upgraded to @typescript-eslint/eslint-plugin@5.55.0 and @typescript-eslint/parser@5.55.0 which I understand has this change. My project is also using typescript@5.0.1-rc and using the new verbatimModuleSyntax compiler option. Eslint is giving me is errors at the top of every file it's checking:

0:0  error  Parsing error: Unknown compiler option 'verbatimModuleSyntax'

Is this a bug or do I simply not having something configured correctly?

@jakebailey
Copy link
Collaborator

Semver matching of preleases basically doesn't happen; to use a prerelease you would need to add an "overrides" section to your package.json.

That being said, TS 5.0 was just released, so the best answer will be to get ts-eslint's version change to allow the real deal.

hasparus pushed a commit to hasparus/typescript-eslint that referenced this pull request Mar 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants