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

Contextual type of methods only in noImplicitAny or JS #50542

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Aug 30, 2022

Fixes #23911, maybe

@sandersn
Copy link
Member Author

sandersn commented Aug 30, 2022

@typescript-bot run dt
@typescript-bot user test this
@typescript-bot run rwc

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 30, 2022

Heya @sandersn, I've started to run the parallelized Definitely Typed test suite on this PR at 04c2fbd. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 30, 2022

Heya @sandersn, I've started to run the diff-based user code test suite on this PR at 04c2fbd. You can monitor the build here.

Update: The results are in!

@sandersn
Copy link
Member Author

sandersn commented Aug 30, 2022

@typescript-bot test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 30, 2022

Heya @sandersn, I've started to run the extended test suite on this PR at 04c2fbd. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 30, 2022

@sandersn Here are the results of running the user test suite comparing main and refs/pull/50542/merge:

Something interesting changed - please have a look.

Details

webpack

tsconfig.json

tsconfig.types.json

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 30, 2022

Heya @sandersn, I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here.

@sandersn sandersn changed the title Contextual type of methods only in noImplicitAny or JSDoc Contextual type of methods only in noImplicitAny or JS Aug 30, 2022
@sandersn
Copy link
Member Author

sandersn commented Aug 30, 2022

User tests show a difference only in webpack, which uses checkJS -- there are two new errors where a parameter now inherits the base type but assumes a derived type. And there are many removed noImplicitAny errors.

The RWC diff is empty. I hope that means there are no diffs. But I don't know how many RWC projects have noImplicitAny turned on.

@@ -9134,6 +9134,26 @@ namespace ts {
if (type) {
return addOptionality(type, /*isProperty*/ false, isOptional);
}
if (isMethodDeclaration(func) && isClassLike(func.parent)
&& (noImplicitAny || isInJSFile(func.parent))) { // TODO: Might want to fiddle with restrictions here
Copy link
Contributor

@Andarist Andarist Aug 31, 2022

Choose a reason for hiding this comment

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

out of curiosity - what's the reasoning to only apply this logic with noImplicitAny (and in JS files)? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants