Skip to content
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

[es5.d.ts] Intl NumberFormat format function value can be string. #17737

Closed
wants to merge 1 commit into from

Conversation

DeividasBakanas
Copy link

@DeividasBakanas DeividasBakanas commented Aug 11, 2017

https://github.com/Microsoft/TypeScript/blob/a6a27ab66132087d889ded64373d42174e85f2fe/src/lib/es5.d.ts#L3970

Link to documentation.

Link to specification.

According to es5.d.ts interface Intl NumberFormat format function can only accept number value, but actually it can accept string too.

For example:

Intl.NumberFormat("en", {
	style: "currency",
	currency: "EUR"
}).format("20.17");

Result:

"€20.17"

Fixes #

  • Intl NumberFormat format function value type changed to number | string.

https://github.com/Microsoft/TypeScript/blob/a6a27ab66132087d889ded64373d42174e85f2fe/src/lib/es5.d.ts#L3970

Link to [documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format).

According to `es5.d.ts` interface Intl NumberFormat format function can only accept `number` value, but actually it can accept `string` too.

For example:
```ts
Intl.NumberFormat("en", {
	style: "currency",
	currency: "EUR"
}).format("20.17");
```

Result:
```ts
"€20.17"
```
@msftclas
Copy link

This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

@mhegazy
Copy link
Contributor

mhegazy commented Sep 7, 2017

The type is limited to number intentionally. this applies to almost all operations in the ES spec when implicit conversion is used. Please see relevant discussion in #4002.

@mhegazy mhegazy closed this Sep 7, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants