File: es2020IntlAPIs.errors.txt

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (79 lines) | stat: -rw-r--r-- 4,086 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
tests/cases/conformance/es2020/es2020IntlAPIs.ts(45,1): error TS2554: Expected 1-2 arguments, but got 0.
tests/cases/conformance/es2020/es2020IntlAPIs.ts(48,1): error TS2554: Expected 2 arguments, but got 0.
tests/cases/conformance/es2020/es2020IntlAPIs.ts(49,1): error TS2554: Expected 2 arguments, but got 1.
tests/cases/conformance/es2020/es2020IntlAPIs.ts(50,29): error TS2345: Argument of type '{}' is not assignable to parameter of type 'DisplayNamesOptions'.
  Property 'type' is missing in type '{}' but required in type 'DisplayNamesOptions'.


==== tests/cases/conformance/es2020/es2020IntlAPIs.ts (4 errors) ====
    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation
    const count = 26254.39;
    const date = new Date("2012-05-24");
    
    function log(locale: string) {
      console.log(
        `${new Intl.DateTimeFormat(locale).format(date)} ${new Intl.NumberFormat(locale).format(count)}`
      );
    }
    
    log("en-US");
    // expected output: 5/24/2012 26,254.39
    
    log("de-DE");
    // expected output: 24.5.2012 26.254,39
    
    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat
    const rtf1 = new Intl.RelativeTimeFormat('en', { style: 'narrow' });
    
    console.log(rtf1.format(3, 'quarter'));
    //expected output: "in 3 qtrs."
    
    console.log(rtf1.format(-1, 'day'));
    //expected output: "1 day ago"
    
    const rtf2 = new Intl.RelativeTimeFormat('es', { numeric: 'auto' });
    
    console.log(rtf2.format(2, 'day'));
    //expected output: "pasado mañana"
    
    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames
    const regionNamesInEnglish = new Intl.DisplayNames(['en'], { type: 'region' });
    const regionNamesInTraditionalChinese = new Intl.DisplayNames(['zh-Hant'], { type: 'region' });
    
    console.log(regionNamesInEnglish.of('US'));
    // expected output: "United States"
    
    console.log(regionNamesInTraditionalChinese.of('US'));
    // expected output: "美國"
    
    const locales1 = ['ban', 'id-u-co-pinyin', 'de-ID'];
    const options1 = { localeMatcher: 'lookup' } as const;
    console.log(Intl.DisplayNames.supportedLocalesOf(locales1, options1).join(', '));
    
    new Intl.Locale(); // should error
    ~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1-2 arguments, but got 0.
!!! related TS6210 /.ts/lib.es2020.intl.d.ts:336:14: An argument for 'tag' was not provided.
    new Intl.Locale(new Intl.Locale('en-US'));
    
    new Intl.DisplayNames(); // TypeError: invalid_argument
    ~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 2 arguments, but got 0.
!!! related TS6210 /.ts/lib.es2020.intl.d.ts:415:13: An argument for 'locales' was not provided.
    new Intl.DisplayNames('en'); // TypeError: invalid_argument
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 2 arguments, but got 1.
!!! related TS6210 /.ts/lib.es2020.intl.d.ts:415:39: An argument for 'options' was not provided.
    new Intl.DisplayNames('en', {}); // TypeError: invalid_argument
                                ~~
!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'DisplayNamesOptions'.
!!! error TS2345:   Property 'type' is missing in type '{}' but required in type 'DisplayNamesOptions'.
!!! related TS2728 /.ts/lib.es2020.intl.d.ts:358:9: 'type' is declared here.
    console.log((new Intl.DisplayNames(undefined, {type: 'language'})).of('en-GB')); // "British English"
    
    const localesArg = ["es-ES", new Intl.Locale("en-US")];
    console.log((new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions().locale); // "es-ES"
    console.log(Intl.DisplayNames.supportedLocalesOf(localesArg)); // ["es-ES", "en-US"]
    console.log(Intl.DisplayNames.supportedLocalesOf()); // []
    console.log(Intl.DisplayNames.supportedLocalesOf(localesArg, {})); // ["es-ES", "en-US"]