-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
API: inconsistent Type#getProperties involving index signature and union type order #31565
Comments
If there isn't a way to observe this during batch compilation or interactive scenarios, I would just call this a quirk of the API. It's not clearly a defect (i.e. wouldn't accept a PR to "fix" this with any negative perf implications). |
@RyanCavanaugh |
Turns out this bug affects property access completions. I added a test case in PR #31979 |
…ature (#31979) * getPropertiesOfUnionOrIntersectionType: handle types with index signature Fixes: #31565 * fix test * more testing * fix typo in checker.ts Co-authored-by: Nathan Shively-Sanders <[email protected]>
TypeScript Version: 3.4.5, 3.5.0-dev.20190523
Search Terms:
Code
Expected behavior:
type.getProperties()
to return an array of one symbol for each of the type alias declarations.Actual behavior:
For
IndexFirst
type.getProperties()
returns an empty array.For
IndexLast
type.getProperties()
returns an array of one symbol.AFAICT this is caused by an early break in
getPropertiesOfUnionOrIntersectionType
:That's not quite correct if there are index signatures. Iterating through the rest of the union constituents would fix this.
getPropertyOfUnionOrIntersectionType
already strips properties not present in all constituents. So this is probably a performance optimization and shouldn't simply be removed. Maybe we could stop after the first constituent that has no index signature.The text was updated successfully, but these errors were encountered: