Conversation
Changes are in src/compiler.checker.ts only The second arguments to the function "removeOptionalityFromDeclaredType" has been changed from "getRootDeclaration(declaration)" to "declaration".
microsoft#17080 Added testcases from the Github bugreport (all working as intended now). Signed CLA.
| @@ -2,15 +2,16 @@ | |||
| Thank you for submitting a pull request! | |||
There was a problem hiding this comment.
I don’t think this file was supposed to be part of the PR.
| useBar(bar); | ||
| } | ||
|
|
||
| function useBar(bar: number) { |
There was a problem hiding this comment.
You can just declare function useBar(bar: number): void;
| declaration.kind === SyntaxKind.VariableDeclaration && (<VariableDeclaration>declaration).exclamationToken || | ||
| declaration.flags & NodeFlags.Ambient; | ||
| const initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, getRootDeclaration(declaration) as VariableLikeDeclaration) : type) : | ||
| const initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration as VariableLikeDeclaration) : type) : |
There was a problem hiding this comment.
Any idea why getRootDeclaration was here? Was this copied from some other source that would also have an erroneous call to it?
There was a problem hiding this comment.
I tracked it back to #14498, which switched to the current narrowing approach that this PR fixes. From my memory of it, I think that I inserted getRootDeclaration during development, then forgot to remove it after changing other parts of the code. Then none of our test cases caught the bug.
|
Approved after the two small fixes requested. |
Fixed the two requested changes. 1) Deleting the file "pull_request_template.md" 2) Declaring functions in tests, instead of defining
| @@ -1,16 +0,0 @@ | |||
| <!-- | |||
There was a problem hiding this comment.
Now this file is deleted, but shouldn't be.
There was a problem hiding this comment.
Sry about that... :-(
Readded untouched pull_request_template.md
|
Thanks @Lazarus535 ! Our test coverage was pretty bad here and is now much better. |
Changes are in src/compiler.checker.ts only
The second arguments to the function "removeOptionalityFromDeclaredType" has been changed from "getRootDeclaration(declaration)" to "declaration".
Fixes #