GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add empty tuple type by lefb766 · Pull Request #14646 · microsoft/TypeScript Conversation
|
| return !!getPropertyOfType(type, "0") || isEmptyTupleType(type); | ||
| } | ||
|
|
||
| function isEmptyTupleType(type: Type): boolean { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
you should be to use === directly, so I think you should drop isEmptyTupleType and just add || type === emptyTupleType on line 8914
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // Grammar checking | ||
| const hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); | ||
| if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { | ||
| grammarErrorOnNode(node, Diagnostics.A_tuple_type_element_list_cannot_be_empty); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You can delete this error from diagnosticsMessages.json since this is the only usage.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| var et0 = et[0]; // never | ||
| var et0: never; | ||
|
|
||
| et = []; // Ok |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
can you add this same check in a new file, something like tupleTypesStrictNullCheck.ts, with the first line // @strictNullChecks: true to turn on strict null checks?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
0e7ffda to
61ac5be
Compare
|
Nathan Shively-Sanders (@sandersn) Your comments are already reflected |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (elementTypes.length) { | ||
| return createTupleType(elementTypes); | ||
| } | ||
| return createTupleType(elementTypes); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think you should update the createTupleType function to return the emptyTupleType singleton if elementTypes is empty.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Agreed. We need to make the condition persistent over future updates. A fix is pushed!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Ryan Cavanaugh (@RyanCavanaugh) or Anders Hejlsberg (@ahejlsberg) can you take a look too?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| function createTupleType(elementTypes: Type[]) { | ||
| function createTupleType(elementTypes: Type[]): TypeReference { | ||
| // We have to ensure that we get same instance for empty tuple type, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
getTupleTypeOfArity caches the resulting tuple type, so not sure why we need special handling here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
usage of getTupleTypeOfArity should be sufficient
Sorry, something went wrong.
There was an error while loading. Please reload this page.
e02dcf3 to
1476eb4
Compare
|
I've made an attempt to revive this PR taking into account the requested changes at #17762. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@tycho01 oh, great! but my bad! I left this PR untouched for so long time and was even unnoticed the update on the original issue until today. I appreciate you reused my code! Thanks! Just wondering. Are you going to update them further and implement the additional restrictions you mentioned in #13126 (comment) ? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Nobuhiro Nakamura (@lefb766): right, I hadn't included those in there. To answer by sub-topic there:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@tycho01 Thanks for explaining. I see, you have another PR. It turns out it will be harder to find difference between #17762 and this one if I happen to solve the conflict. Your investigation on the sup-topic looks interesting though. Nice work. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Nobuhiro Nakamura (@lefb766): wanna just stick with your PR then? If you follow mhegazy's change you may be done. :) I'd be interested in your take on the topic, but I think the others in #13126 would be too! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@tycho01 Fair point. I'll continue this work. Sorry for bothering you and others. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
1476eb4 to
5cffdb2
Compare
|
Should be ready for review now. Mohamed Hegazy (@mhegazy) can you take a look? I've selectively adopted @tycho01 's work. Note: #6524 can also be closed after merge this PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Mohamed Hegazy (@mhegazy): conflict aside, is there more that could be done to improve this PR? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for your contribution. This PR has not been updated in a while and cannot be automatically merged at the time being. For housekeeping purposes we are closing stale PRs. If you'd still like to continue working on this PR, please leave a message and one of the maintainers can reopen it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.