Skip to content

Add Intl defintions #1270

Closed
Closed

Description

@arv

Should go in lib/intl.js or lib/ecma402.js

http://www.ecma-international.org/ecma-402/2.0/

It seems like TypeScript moved this out of .d.ts to make it part of the core compiler.

Activity

  1. added
    Library definitions
    on May 31, 2016
  2. ianp commented on Jun 9, 2016

    @ianp

    Any workaround for this in the meantime?

  3. vanwagonet commented on Jan 18, 2017

    @vanwagonet
    Contributor

    I've been using the following locally. It's not complete, but it's a start.

    declare var Intl: {
      Collator: Class<Collator>,
      DateTimeFormat: Class<DateTimeFormat>,
      NumberFormat: Class<NumberFormat>
    }
    
    declare class Collator {
      constructor (
        locales?: string | string[],
        options?: CollatorOptions
      ): Collator;
    
      static (
        locales?: string | string[],
        options?: CollatorOptions
      ): Collator;
    
      compare (a: string, b: string): number;
    }
    
    type CollatorOptions = {
      localeMatcher?: 'lookup' | 'best fit',
      usage?: 'sort' | 'search',
      sensitivity?: 'base' | 'accent' | 'case' | 'variant',
      ignorePunctuation?: boolean,
      numeric?: boolean,
      caseFirst?: 'upper' | 'lower' | 'false'
    }
    
    declare class DateTimeFormat {
      constructor (
        locales?: string | string[],
        options?: DateTimeFormatOptions
      ): DateTimeFormat;
    
      static (
        locales?: string | string[],
        options?: DateTimeFormatOptions
      ): DateTimeFormat;
    
      format (a: Date | number): string;
    }
    
    type DateTimeFormatOptions = {
      localeMatcher?: 'lookup' | 'best fit',
      timeZone?: string,
      hour12?: boolean,
      formatMatcher?: 'basic' | 'best fit',
      weekday?: 'narrow' | 'short' | 'long',
      era?: 'narrow' | 'short' | 'long',
      year?: 'numeric' | '2-digit',
      month?: 'numeric' | '2-digit' | 'narrow' | 'short' | 'long',
      day?: 'numeric' | '2-digit',
      hour?: 'numeric' | '2-digit',
      minute?: 'numeric' | '2-digit',
      second?: 'numeric' | '2-digit',
      timeZoneName?: 'short' | 'long'
    }
    
    declare class NumberFormat {
      constructor (
        locales?: string | string[],
        options?: NumberFormatOptions
      ): NumberFormat;
    
      static (
        locales?: string | string[],
        options?: NumberFormatOptions
      ): NumberFormat;
    
      format (a: number): string;
    }
    
    type NumberFormatOptions = {
      localeMatcher?: 'lookup' | 'best fit',
      style?: 'decimal' | 'currency' | 'percent',
      currency?: string,
      currencyDisplay?: 'symbol' | 'code' | 'name',
      useGrouping?: boolean,
      minimumIntegerDigits?: number,
      minimumFractionDigits?: number,
      maximumFractionDigits?: number,
      minimumSignificantDigits?: number,
      maximumSignificantDigits?: number
    }
    
  4. arjun-menon commented on Oct 18, 2017

    @arjun-menon

    Any plans to make this part of the Flow built-in library definitions?

  5. mike1808 commented on Mar 16, 2018

    @mike1808
  6. vanwagonet commented on Mar 16, 2018

    @vanwagonet
    Contributor

    @mike1808 yeah you're right. I hadn't covered that case.

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

    Library definitions

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions