-
Notifications
You must be signed in to change notification settings - Fork 12.9k
fix: update types for RTF.p.formatToParts() result #46508
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
fix: update types for RTF.p.formatToParts() result #46508
Conversation
It looks like you've sent a pull request to update our 'lib' files. These files aren't meant to be edited by hand, as they consist of last-known good states of the compiler and are generated from 'src'. Unless this is necessary, consider closing the pull request and sending a separate PR to update 'src'. |
I was a little confused by these dual files because only the |
You'll need to make the update in |
@DanielRosenwasser the |
Still hoping to get an answer to this question. |
Sorry, if they're not from |
I've updated the bot's message for the future, thanks for pointing out that it wasn't clear, and sorry for the confusion! |
@DanielRosenwasser - Sorry I still don't understand what are the right next steps in this PR.
The specific spec link I'm concerned about is https://tc39.es/ecma402/#sec-singularrelativetimeunit which is the most relevant link for the |
Okay, I reread the changes - a double apology for the misunderstanding. You'll need to back out |
@DanielRosenwasser - OK that answers question (1) above, but not the other two questions:
|
If it's important, would it just make more sense to add content to MDN than to deep link to the spec? I don't think most users are interested in parsing spec text. |
This commit updates the type of `RelativeTimeFormatPart` to clarify that the `unit` prop is always singular, unlike the plural or singular values that are accepted as inputs. This also changes `RelativeTimeFormatPart` to be a discriminated union type because the `unit` prop is only present if the `type` prop's value is not "literal". Fixes microsoft#46245
ef5fc0c
to
150ccd1
Compare
I assumed it was mostly needed for the TS team to verify that the types match the spec. Anyway, sounds like it's not needed so I just reverted the changes to |
es2020.intl refers to NumberFormatPartTypes declared in es2018.intl as of #46508. I'm not sure how to test this; it repros on Definitely Typed in types/ndarray, but when I copy the same files into a compiler test it passes without a problem.
* Add es2018.intl ref to es2020.intl es2020.intl refers to NumberFormatPartTypes declared in es2018.intl as of #46508. I'm not sure how to test this; it repros on Definitely Typed in types/ndarray, but when I copy the same files into a compiler test it passes without a problem. * Add a test that shows the change works It doesn't actually show that the original bug has been fixed, though.
This PR:
RelativeTimeFormatPart
to clarify that theunit
prop is always singular in the result's array elements, unlike the plural or singular values that are accepted as inputs. Spec: https://tc39.es/ecma402/#sec-PartitionRelativeTimePattern step 5RelativeTimeFormatPart
to be a discriminated union type because theunit
prop is only present if thetype
prop's value is not "literal". Spec: https://tc39.es/ecma402/#sec-makepartslist step 3Fixes #46245
@orta - what are the right tests to add for this kind of change?