File: spreadOverwritesPropertyStrict.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (57 lines) | stat: -rw-r--r-- 3,567 bytes parent folder | download | duplicates (3)
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
tests/cases/conformance/types/spread/spreadOverwritesPropertyStrict.ts(3,17): error TS2783: 'b' is specified more than once, so this usage will be overwritten.
tests/cases/conformance/types/spread/spreadOverwritesPropertyStrict.ts(9,14): error TS2783: 'x' is specified more than once, so this usage will be overwritten.
tests/cases/conformance/types/spread/spreadOverwritesPropertyStrict.ts(15,14): error TS2783: 'x' is specified more than once, so this usage will be overwritten.
tests/cases/conformance/types/spread/spreadOverwritesPropertyStrict.ts(24,14): error TS2783: 'command' is specified more than once, so this usage will be overwritten.
tests/cases/conformance/types/spread/spreadOverwritesPropertyStrict.ts(28,14): error TS2783: 'a' is specified more than once, so this usage will be overwritten.


==== tests/cases/conformance/types/spread/spreadOverwritesPropertyStrict.ts (5 errors) ====
    declare var ab: { a: number, b: number };
    declare var abq: { a: number, b?: number };
    var unused1 = { b: 1, ...ab } // error
                    ~~~~
!!! error TS2783: 'b' is specified more than once, so this usage will be overwritten.
!!! related TS2785 tests/cases/conformance/types/spread/spreadOverwritesPropertyStrict.ts:3:23: This spread always overwrites this property.
    var unused2 = { ...ab, ...ab } // ok, overwritten error doesn't apply to spreads
    var unused3 = { b: 1, ...abq } // ok, abq might have b: undefined
    var unused4 = { ...ab, b: 1 } // ok, we don't care that b in ab is overwritten
    var unused5 = { ...abq, b: 1 } // ok
    function g(obj: { x: number | undefined }) {
        return { x: 1, ...obj }; // ok, obj might have x: undefined
                 ~~~~
!!! error TS2783: 'x' is specified more than once, so this usage will be overwritten.
!!! related TS2785 tests/cases/conformance/types/spread/spreadOverwritesPropertyStrict.ts:9:20: This spread always overwrites this property.
    }
    function f(obj: { x: number } | undefined) {
        return { x: 1, ...obj }; // ok, obj might be undefined
    }
    function h(obj: { x: number } | { x: string }) {
        return { x: 1, ...obj } // error
                 ~~~~
!!! error TS2783: 'x' is specified more than once, so this usage will be overwritten.
!!! related TS2785 tests/cases/conformance/types/spread/spreadOverwritesPropertyStrict.ts:15:20: This spread always overwrites this property.
    }
    function i(b: boolean, t: { command: string, ok: string }) {
        return { command: "hi", ...(b ? t : {}) } // ok
    }
    function j() {
        return { ...{ command: "hi" } , ...{ command: "bye" } } // ok
    }
    function k(t: { command: string, ok: string }) {
        return { command: "hi", ...{ spoiler: true }, spoiler2: true, ...t } // error
                 ~~~~~~~~~~~~~
!!! error TS2783: 'command' is specified more than once, so this usage will be overwritten.
!!! related TS2785 tests/cases/conformance/types/spread/spreadOverwritesPropertyStrict.ts:24:67: This spread always overwrites this property.
    }
    
    function l(anyrequired: { a: any }) {
        return { a: 'zzz', ...anyrequired } // error
                 ~~~~~~~~
!!! error TS2783: 'a' is specified more than once, so this usage will be overwritten.
!!! related TS2785 tests/cases/conformance/types/spread/spreadOverwritesPropertyStrict.ts:28:24: This spread always overwrites this property.
    }
    function m(anyoptional: { a?: any }) {
        return { a: 'zzz', ...anyoptional } // ok
    }