-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Import of Intl.Locale from #39664 * Handle updating es2020.intl and add es2021 for new DateTimeFormatOptions options - re: #39664 * Extends DateTimeFormatOptions for new Intl APIs - re: #45420 * Handle migrating Intl.NumberFormat.formatToParts to es2018 (keeping esnext.intl around) * Adds Intl.DisplayNames to es2020 - re: #44022 * Remove attributes added in es2021 from es2020 - re: #42944 * Add a reference to es2021 in the command line parser * Adds some docs about the lib files * Baselines * Allow undefined in Intl inputs to allow for ergonomic usage of exactOptionalPropertyTypes - see #45652 * Adds some tests covering the APIs * Apply suggestions from code review Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> * Handle PR feedback * More review improvements Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
- Loading branch information
Showing
27 changed files
with
891 additions
and
234 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 { | ||
|
||
interface DateTimeFormatOptions { | ||
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 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 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 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 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.