Skip to content

Fix #2809: code completion issues in some IDE's#2812

Merged
josdejong merged 5 commits into
developfrom
fix/2809_code_completion_issues
Oct 19, 2022
Merged

Fix #2809: code completion issues in some IDE's#2812
josdejong merged 5 commits into
developfrom
fix/2809_code_completion_issues

Conversation

@josdejong
Copy link
Copy Markdown
Owner

Fixes #2809

@josdejong
Copy link
Copy Markdown
Owner Author

Wow all these Foresight Workflow Reports are causing a lot of noise. I'll see whether I can turn that off.

@gwhitney
Copy link
Copy Markdown
Collaborator

My only worry about this is that I seem to recall that when we initially set up the typescript test, the index.ts would sometimes run ok even when it had typescript errors. I.e. those errors would only surface during the tsc command. But now the tsc is not compiling the tests/testTypes.ts file, so I worry problems might sneak through. So I recommend putting tests/testTypes.ts back into the files parameter of the tsconfig.

Also there is now an unnecessary leading space in the package.json script parameter for the typescript test

Repository owner deleted a comment from runforesight Bot Oct 17, 2022
@josdejong
Copy link
Copy Markdown
Owner Author

Thanks, very sharp. I think you're referring to #2633.

I tried to reproduce this original issue, but could not get the original problem back: both a mistake in index.d.ts as well as in testTypes.ts do throw an exception.

I did the following:

  1. The "test:types" script runs both tsc and ts-node. I remove the tsc part from the script so it only runs ts-node.
  2. I removed the return type from the function simplifyConstant in index.d.ts. Running npm run test:types does not throw an error. this validates that we indeed need to run tsc too to be able to capture those errors.
  3. I reverted the changes of (2) in index.d.ts
  4. Right below the type definition of function testFun() in testTypes.ts (line 1897), I added a function testFun2() with a missing return type. Running npm run test:types does throw an error about the missing return type. So apparently we do not need to run tsc to capture these kind of mistakes in testTypes.ts, we only need that for index.d.ts.

So I think we're safe. Or am I overlooking something?

@gwhitney
Copy link
Copy Markdown
Collaborator

Well I agree your procedure sounds good. I will admit I am confused as to why the tsc command compiles anything since it no longer has any "files" parameter. But clearly from your tests it identifies problems with the index.d.ts file that the ts-node command does not. Hence there's something about the tsc configuration I don't understand, but the process you outline is convincing that the tests are finding problems everywhere we want them to, so I am content with this PR. Would you like me to merge it?

@josdejong
Copy link
Copy Markdown
Owner Author

josdejong commented Oct 18, 2022

I will admit I am confused as to why the tsc command compiles anything since it no longer has any "files" parameter

It's a bit different: apparently ts-node does throw an error on issues in testTypes.ts, so tsc is not needed there. So:

  • We run ts-node to run the tests and detect type issues in testTypes.ts, but ts-node does not complain about all issues in index.d.ts
  • We run tsc to spot issues in index.d.ts

@josdejong josdejong merged commit 5e439be into develop Oct 19, 2022
@josdejong josdejong deleted the fix/2809_code_completion_issues branch October 19, 2022 06:23
@josdejong
Copy link
Copy Markdown
Owner Author

Published now in v11.3.1

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.

2 participants