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(typescript-estree): add type checker wrapper APIs to ParserServicesWithTypeInformation #6404


Copy link

PR Checklist


Adds to ParserServicesWithTypeInformation the two most commonly used TypeScript type checking APIs: getSymbolAtLocation and getTypeAtLocation. Then converts all places in code that I could find that used either after immediately retrieving the TS node for an ES node.

Also applies a few standardizations that helped me find-and-replace:

  • const services = util.getParserServices(context) - not a variable named parserServices, or variables from { ... }
  • const checker = services.program.getTypeChecker() - not a variable named typeChecker or types, and not an intermediate program variable

Updates the Custom Rules docs page to reflect this.

Copy link

Thanks for the PR, @JoshuaKGoldberg!

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

Copy link

nx-cloud bot commented Jan 31, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit e7977f1. 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 47 targets

Sent with 💌 from NxCloud.

Copy link

codecov bot commented Jan 31, 2023

Codecov Report

Merging #6404 (506bf57) into v6 (1c3f470) will decrease coverage by 0.28%.
The diff coverage is 97.73%.

❗ Current head 506bf57 differs from pull request most recent head e7977f1. Consider uploading reports for the commit e7977f1 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##               v6    #6404      +/-   ##
- Coverage   91.87%   91.60%   -0.28%     
  Files         359      355       -4     
  Lines       12400    12155     -245     
  Branches     3653     3581      -72     
- Hits        11393    11134     -259     
- Misses        703      723      +20     
+ Partials      304      298       -6     
Flag Coverage Δ
unittest 91.60% <97.73%> (-0.28%) ⬇️

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

Impacted Files Coverage Δ
...ges/type-utils/src/getConstrainedTypeAtLocation.ts 0.00% <0.00%> (ø)
packages/type-utils/src/getDeclaration.ts 0.00% <0.00%> (ø)
...ages/typescript-estree/src/createParserServices.ts 71.42% <71.42%> (ø)
...gin-internal/src/rules/no-poorly-typed-ts-props.ts 87.50% <100.00%> (-1.39%) ⬇️
...lugin-internal/src/rules/plugin-test-formatting.ts 79.76% <100.00%> (ø)
packages/eslint-plugin-tslint/src/rules/config.ts 97.22% <100.00%> (ø)
packages/eslint-plugin/src/rules/await-thenable.ts 100.00% <100.00%> (ø)
...eslint-plugin/src/rules/consistent-type-exports.ts 97.67% <100.00%> (-0.03%) ⬇️
packages/eslint-plugin/src/rules/dot-notation.ts 96.29% <100.00%> (-0.14%) ⬇️
...gin/src/rules/naming-convention-utils/validator.ts 96.79% <100.00%> (-0.03%) ⬇️
... and 62 more

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review January 31, 2023 21:35
@JoshuaKGoldberg JoshuaKGoldberg added this to the 6.0.0 milestone Jan 31, 2023
Copy link

@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.

I'm happy with this! Noice

@JoshuaKGoldberg JoshuaKGoldberg merged commit 62d5755 into typescript-eslint:v6 Feb 5, 2023
31 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the services-type-checker-wrappers branch February 5, 2023 05:13
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants