-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Intl 2021 Updates #45647
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
Merged
Merged
Intl 2021 Updates #45647
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ad15e54
Import of Intl.Locale from #39664
orta 872894d
Handle updating es2020.intl and add es2021 for new DateTimeFormatOpti…
orta 2656cd8
Extends DateTimeFormatOptions for new Intl APIs - re: #45420
orta f481743
Handle migrating Intl.NumberFormat.formatToParts to es2018 (keeping e…
orta 2e2f755
Adds Intl.DisplayNames to es2020 - re: #44022
orta df508a0
Remove attributes added in es2021 from es2020 - re: #42944
orta ff94585
Add a reference to es2021 in the command line parser
orta 9edc1f7
Adds some docs about the lib files
orta 5f67f65
Baselines
orta 689bf6f
Allow undefined in Intl inputs to allow for ergonomic usage of exactO…
orta fdbc99a
Adds some tests covering the APIs
orta 01a6f78
Apply suggestions from code review
orta aecec76
Handle PR feedback
orta d09f8c8
Merge
orta e79c4cd
More review improvements
orta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
# Read this! | ||
|
||
The files within this directory are used to generate `lib.d.ts` and `lib.es6.d.ts`. | ||
The files within this directory are copied and deployed with TypeScript as the set of APIs available as a part of the JavaScript language. | ||
|
||
There are three main domains of APIs in `src/lib`: | ||
|
||
- **ECMAScript language features** - e.g. JavaScript APIs like functions on Array etc which are documented in [ECMA-262](https://tc39.es/ecma262/) | ||
- **DOM APIs** - e.g. APIs which are available in web browsers | ||
- **Intl APIs** - e.g. APIs scoped to `Intl` which are documented in [ECMA-402](https://www.ecma-international.org/publications-and-standards/standards/ecma-402/) | ||
|
||
## How do we figure out when to add something? | ||
|
||
TypeScript has a rule-of-thumb to only add something when it has got far enough through the standards process that it is more or less confirmed. For JavaScript APIs and language features, that means the proposal is at stage 3 or later. | ||
|
||
You can find the source of truth for modern language features and Intl APIs in these completed proposal lists: | ||
|
||
- [JavaScript](https://github.com/tc39/proposals/blob/master/finished-proposals.md) | ||
- [Intl](https://github.com/tc39/proposals/blob/master/ecma402/finished-proposals.md) | ||
|
||
For the DOM APIs, which are a bit more free-form, we have asked that APIs are available un-prefixed/flagged in at least 2 browser _engines_ (i.e. not just 2 chromium browsers.) | ||
|
||
## Generated files | ||
|
||
Any files ending in `.generated.d.ts` aren't meant to be edited by hand. | ||
If you need to make changes to such files, make a change to the input files for [**our library generator**](https://github.com/Microsoft/TSJS-lib-generator). | ||
The DOM files ending in `.generated.d.ts` aren't meant to be edited by hand. | ||
|
||
If you need to make changes to such files, make a change to the input files for [**our library generator**](https://github.com/microsoft/TypeScript-DOM-lib-generator). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
declare namespace Intl { | ||
orta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
interface DateTimeFormatOptions { | ||
orta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
formatMatcher?: "basic" | "best fit" | "best fit" | undefined; | ||
dateStyle?: "full" | "long" | "medium" | "short" | undefined; | ||
timeStyle?: "full" | "long" | "medium" | "short" | undefined; | ||
dayPeriod?: "narrow" | "short" | "long" | undefined; | ||
fractionalSecondDigits?: 0 | 1 | 2 | 3 | undefined; | ||
} | ||
|
||
interface NumberFormat { | ||
formatRange(startDate: number | bigint, endDate: number | bigint): string; | ||
formatRangeToParts(startDate: number | bigint, endDate: number | bigint): NumberFormatPart[]; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,3 @@ | ||
declare namespace Intl { | ||
type NumberFormatPartTypes = "compact" | "currency" | "decimal" | "exponentInteger" | "exponentMinusSign" | "exponentSeparator" | "fraction" | "group" | "infinity" | "integer" | "literal" | "minusSign" | "nan" | "plusSign" | "percentSign" | "unit" | "unknown"; | ||
|
||
interface NumberFormatPart { | ||
type: NumberFormatPartTypes; | ||
value: string; | ||
} | ||
|
||
interface NumberFormat { | ||
formatToParts(number?: number | bigint): NumberFormatPart[]; | ||
} | ||
// Empty for now | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.