mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 12:32:08 -06:00
Add a test case for lack of duplicate property errors (#56348)
This commit is contained in:
parent
9063d7b41d
commit
dac1da8434
@ -0,0 +1,47 @@
|
||||
//// [tests/cases/compiler/duplicateObjectLiteralProperty_computedNameNegative1.ts] ////
|
||||
|
||||
=== duplicateObjectLiteralProperty_computedNameNegative1.ts ===
|
||||
// repro from https://github.com/microsoft/TypeScript/issues/56341
|
||||
|
||||
function bar(props: { x?: string; y?: string }) {
|
||||
>bar : Symbol(bar, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 0, 0))
|
||||
>props : Symbol(props, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 2, 13))
|
||||
>x : Symbol(x, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 2, 21))
|
||||
>y : Symbol(y, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 2, 33))
|
||||
|
||||
const { x = "", y = "" } = props;
|
||||
>x : Symbol(x, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 3, 9))
|
||||
>y : Symbol(y, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 3, 17))
|
||||
>props : Symbol(props, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 2, 13))
|
||||
|
||||
return {
|
||||
[x]: 1,
|
||||
>[x] : Symbol([x], Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 4, 10))
|
||||
>x : Symbol(x, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 3, 9))
|
||||
|
||||
[y]: 2,
|
||||
>[y] : Symbol([y], Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 5, 11))
|
||||
>y : Symbol(y, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 3, 17))
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
function foo({ x = "", y = "" }: { x?: string; y?: string }) {
|
||||
>foo : Symbol(foo, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 8, 1))
|
||||
>x : Symbol(x, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 10, 14))
|
||||
>y : Symbol(y, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 10, 22))
|
||||
>x : Symbol(x, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 10, 34))
|
||||
>y : Symbol(y, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 10, 46))
|
||||
|
||||
return {
|
||||
[x]: 1,
|
||||
>[x] : Symbol([x], Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 11, 10))
|
||||
>x : Symbol(x, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 10, 14))
|
||||
|
||||
[y]: 2,
|
||||
>[y] : Symbol([y], Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 12, 11))
|
||||
>y : Symbol(y, Decl(duplicateObjectLiteralProperty_computedNameNegative1.ts, 10, 22))
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@ -0,0 +1,59 @@
|
||||
//// [tests/cases/compiler/duplicateObjectLiteralProperty_computedNameNegative1.ts] ////
|
||||
|
||||
=== duplicateObjectLiteralProperty_computedNameNegative1.ts ===
|
||||
// repro from https://github.com/microsoft/TypeScript/issues/56341
|
||||
|
||||
function bar(props: { x?: string; y?: string }) {
|
||||
>bar : (props: { x?: string | undefined; y?: string | undefined; }) => { [x: string]: number; }
|
||||
>props : { x?: string | undefined; y?: string | undefined; }
|
||||
>x : string | undefined
|
||||
>y : string | undefined
|
||||
|
||||
const { x = "", y = "" } = props;
|
||||
>x : string
|
||||
>"" : ""
|
||||
>y : string
|
||||
>"" : ""
|
||||
>props : { x?: string | undefined; y?: string | undefined; }
|
||||
|
||||
return {
|
||||
>{ [x]: 1, [y]: 2, } : { [x: string]: number; }
|
||||
|
||||
[x]: 1,
|
||||
>[x] : number
|
||||
>x : string
|
||||
>1 : 1
|
||||
|
||||
[y]: 2,
|
||||
>[y] : number
|
||||
>y : string
|
||||
>2 : 2
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
function foo({ x = "", y = "" }: { x?: string; y?: string }) {
|
||||
>foo : ({ x, y }: { x?: string; y?: string;}) => { [x: string]: number; }
|
||||
>x : string
|
||||
>"" : ""
|
||||
>y : string
|
||||
>"" : ""
|
||||
>x : string | undefined
|
||||
>y : string | undefined
|
||||
|
||||
return {
|
||||
>{ [x]: 1, [y]: 2, } : { [x: string]: number; }
|
||||
|
||||
[x]: 1,
|
||||
>[x] : number
|
||||
>x : string
|
||||
>1 : 1
|
||||
|
||||
[y]: 2,
|
||||
>[y] : number
|
||||
>y : string
|
||||
>2 : 2
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
// @strict: true
|
||||
// @noEmit: true
|
||||
|
||||
// repro from https://github.com/microsoft/TypeScript/issues/56341
|
||||
|
||||
function bar(props: { x?: string; y?: string }) {
|
||||
const { x = "", y = "" } = props;
|
||||
return {
|
||||
[x]: 1,
|
||||
[y]: 2,
|
||||
};
|
||||
}
|
||||
|
||||
function foo({ x = "", y = "" }: { x?: string; y?: string }) {
|
||||
return {
|
||||
[x]: 1,
|
||||
[y]: 2,
|
||||
};
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user