Skip to content

feat(47698): Detect uncalled function statements #47719

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

Closed
wants to merge 1 commit into from

Conversation

a-tarasyuk
Copy link
Contributor

Fixes #47698

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Feb 3, 2022
@RyanCavanaugh
Copy link
Member

Curious
@typescript-bot test this
@typescript-bot user test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 3, 2022

Heya @RyanCavanaugh, I've started to run the extended test suite on this PR at 5fb24d1. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 3, 2022

Heya @RyanCavanaugh, I've started to run the parallelized community code test suite on this PR at 5fb24d1. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

@a-tarasyuk
Copy link
Contributor Author

@a-tarasyuk a-tarasyuk marked this pull request as ready for review February 4, 2022 20:12
@typescript-bot
Copy link
Collaborator

The TypeScript team hasn't accepted the linked issue #47698. If you can get it accepted, this PR will have a better chance of being reviewed.

@jakebailey
Copy link
Member

@typescript-bot user test this inline

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 16, 2022

Heya @jakebailey, I've started to run the diff-based community code test suite on this PR at 5fb24d1. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@jakebailey
The results of the user tests run you requested are in!

Here they are:

Comparison Report - main..refs/pull/47719/merge

fp-ts

3 of 4 projects failed to build with the old tsc

/mnt/ts_downloads/fp-ts/dtslint/ts3.5/tsconfig.json

  • error TS2823: This expression refers to function. Did you mean to call it instead?
    • /mnt/ts_downloads/fp-ts/dtslint/ts3.5/Applicative.ts(12,1)

@jakebailey
Copy link
Member

This seems great, though I have no clue where the above code is in fp-ts to check that user test diff; AFAIK the user tests pull whatever's latest in their git repo and line 12 is a comment.

@a-tarasyuk
Copy link
Contributor Author

@jakebailey I think the error is related to this uncalled function

@jakebailey
Copy link
Member

Oh, duh, I was in the wrong folder.

I guess that would turn into a message now, even though they are using it just for checking expected types. I wonder if this will cause oddities for the DT tests?

@jakebailey
Copy link
Member

@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 16, 2022

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

@jakebailey
Copy link
Member

DT run finished, and it does seem like this causes loads of issues with the DT tests, like:

Error in validator
Error: /home/vsts/work/1/s/DefinitelyTyped-tools/packages/dtslint-runner/DefinitelyTyped/types/validator/validator-tests.ts:126:5
ERROR: 126:5  expect  TypeScript@local compile error: 
This expression refers to function. Did you mean to call it instead?
ERROR: 127:5  expect  TypeScript@local compile error: 
This expression refers to function. Did you mean to call it instead?
ERROR: 133:5  expect  TypeScript@local compile error: 
This expression refers to function. Did you mean to call it instead?
ERROR: 134:5  expect  TypeScript@local compile error: 
This expression refers to function. Did you mean to call it instead?
ERROR: 169:5  expect  TypeScript@local compile error: 
This expression refers to function. Did you mean to call it instead?
ERROR: 170:5  expect  TypeScript@local compile error: 
This expression refers to function. Did you mean to call it instead?
ERROR: 226:5  expect  TypeScript@local compile error: 
This expression refers to function. Did you mean to call it instead?
ERROR: 227:5  expect  TypeScript@local compile error: 
This expression refers to function. Did you mean to call it instead?

@jakebailey
Copy link
Member

Also, if merged, I think this PR also closes #47699, right?

@a-tarasyuk
Copy link
Contributor Author

DT run finished, and it does seem like this causes loads of issues with the DT tests, like:

All errors seem to be related to uncalled functions and located in tests, not in .d files 1 2 3 4 5 6. Another question is that in the DefinitelyTyped it is ok to check the type without calling a function (expectRule) 😄

@jakebailey
Copy link
Member

If we're going to accept this, I'm assuming we'll need some sort of change in dtslint to ignore it (since ExpectType is clearly not going away any time soon). Is that doable, given this check isn't a compiler option (so we may read the build as "failing"?). I'm also sort of wary of the change where someone's using ExpectType externally, since now their build will end up failing too.

@a-tarasyuk
Copy link
Contributor Author

What about adding a new strictUncalledFunctions option to control this check?

@RyanCavanaugh
Copy link
Member

Discussed at the design meeting and we'd prefer to leave this Awaiting More Feedback for now -- the sorts of errors this can detect can be equally picked up by a non-type-aware linter, this interacts quite badly with dts-lint, and more annoyingly it would bring up a lot of false errors as you're typing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Detect uncalled function statements
5 participants