Skip to content

Intl.DisplayNames missing #41338

Closed
Closed
@MichalBryxi

Description

@MichalBryxi

Search Terms: Intl.DisplayNames, "Property 'DisplayNames' does not exist on type 'typeof Intl'."

Code

let languageNames = new Intl.DisplayNames(['en'], { type: 'language' });

Expected behavior: TS knows DisplayNames and does appropriate type checking.

Actual behavior: TS displays error: Property 'DisplayNames' does not exist on type 'typeof Intl'.

Playground Link: https://www.typescriptlang.org/play?ts=4.1.0-dev.20201030#code/DYUwLgBMCGB2DmBXa8QDloFsQGcIF4JYQB3CASVjGADoARASxwAcYBPDbHACgG0ByELH4BdADQQA3hDBtmIAFwR+MBMlT8IAXwCUAbgBQECEA
Related Issues: N/A

Respective MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames
Respective TC39: https://tc39.es/proposal-intl-displaynames/

Activity

MartinJohns

MartinJohns commented on Oct 30, 2020

@MartinJohns
Contributor

Type definitions for drafts are usually not added to the type definitions provided by TypeScript.

In the TypeScript-DOM-lib-generator project they list as a requirement for additions:

  • Is the IDL source from WHATWG?
    • Are the additions available in at least two of Firefox, Safari and Chromium?
  • Is the IDL source from W3C?
    • What stage of the W3C process is the proposal for these changes: We aim for Proposed recommendation, but can accept Candidate recommendation for stable looking proposals.
    • If it's at Working draft the additions available in all three of Firefox, Safari and Chromium

Neither Firefox nor Safari support this feature. There's no mention of TC39, but it's likely that the same principle applies.


You can use declaration merging to make the types available in your code base.

typescript-bot

typescript-bot commented on Nov 12, 2020

@typescript-bot
Collaborator

This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

added 2 commits that reference this issue on May 10, 2021
afd68db
5616d77
TimvdLippe

TimvdLippe commented on May 29, 2021

@TimvdLippe
Contributor

Can we reopen this issue for #44022 ?

sroucheray

sroucheray commented on Jul 18, 2022

@sroucheray
Contributor

It is now supported in all major browser versions https://caniuse.com/?search=Intl.DisplayNames and is referenced in ECMA402 https://tc39.es/ecma402/#intl-displaynames-objects. I think this might be time to reopen this issue.

SchmidtDawid

SchmidtDawid commented on Sep 26, 2022

@SchmidtDawid

Why this is still causing problems? How to fix it?

j-ulrich

j-ulrich commented on Apr 12, 2023

@j-ulrich

Should be fixed with TypeScript 4.5 according to PR #45647

MichalBryxi

MichalBryxi commented on May 31, 2023

@MichalBryxi
Author

TS playground v5.0.4 still says:

Property 'DisplayNames' does not exist on type 'typeof Intl'

MartinJohns

MartinJohns commented on Jun 1, 2023

@MartinJohns
Contributor

@MichalBryxi It works just fine in the Playground when you target an ES version that supports it.

MichalBryxi

MichalBryxi commented on Jun 1, 2023

@MichalBryxi
Author

Ah! So for future travelers: Minimum requirements that seem to work:

  • TS v4.5.5 (supposedly v4.5 should be enough, but can't verify in the live playground)
  • Target: ES2020
added a commit that references this issue on Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @sroucheray@MichalBryxi@j-ulrich@MartinJohns@TimvdLippe

      Issue actions

        Intl.DisplayNames missing · Issue #41338 · microsoft/TypeScript