mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' of https://github.com/microsoft/TypeScript into bug/38463
This commit is contained in:
+18
-8
@@ -15367,7 +15367,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isEmptyAnonymousObjectType(type: Type) {
|
||||
return !!(getObjectFlags(type) & ObjectFlags.Anonymous) && isEmptyObjectType(type);
|
||||
return !!(getObjectFlags(type) & ObjectFlags.Anonymous && (
|
||||
(<ResolvedType>type).members && isEmptyResolvedType(<ResolvedType>type) ||
|
||||
type.symbol && type.symbol.flags & SymbolFlags.TypeLiteral && getMembersOfSymbol(type.symbol).size === 0));
|
||||
}
|
||||
|
||||
function isStringIndexSignatureOnlyType(type: Type): boolean {
|
||||
@@ -26381,7 +26383,7 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
|
||||
function invocationErrorDetails(apparentType: Type, kind: SignatureKind): { messageChain: DiagnosticMessageChain, relatedMessage: DiagnosticMessage | undefined } {
|
||||
function invocationErrorDetails(errorTarget: Node, apparentType: Type, kind: SignatureKind): { messageChain: DiagnosticMessageChain, relatedMessage: DiagnosticMessage | undefined } {
|
||||
let errorInfo: DiagnosticMessageChain | undefined;
|
||||
const isCall = kind === SignatureKind.Call;
|
||||
const awaitedType = getAwaitedType(apparentType);
|
||||
@@ -26450,16 +26452,24 @@ namespace ts {
|
||||
typeToString(apparentType)
|
||||
);
|
||||
}
|
||||
|
||||
let headMessage = isCall ? Diagnostics.This_expression_is_not_callable : Diagnostics.This_expression_is_not_constructable;
|
||||
|
||||
// Diagnose get accessors incorrectly called as functions
|
||||
if (isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) {
|
||||
const { resolvedSymbol } = getNodeLinks(errorTarget);
|
||||
if (resolvedSymbol && resolvedSymbol.flags & SymbolFlags.GetAccessor) {
|
||||
headMessage = Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
messageChain: chainDiagnosticMessages(
|
||||
errorInfo,
|
||||
isCall ? Diagnostics.This_expression_is_not_callable : Diagnostics.This_expression_is_not_constructable
|
||||
),
|
||||
messageChain: chainDiagnosticMessages(errorInfo, headMessage),
|
||||
relatedMessage: maybeMissingAwait ? Diagnostics.Did_you_forget_to_use_await : undefined,
|
||||
};
|
||||
}
|
||||
function invocationError(errorTarget: Node, apparentType: Type, kind: SignatureKind, relatedInformation?: DiagnosticRelatedInformation) {
|
||||
const { messageChain, relatedMessage: relatedInfo } = invocationErrorDetails(apparentType, kind);
|
||||
const { messageChain, relatedMessage: relatedInfo } = invocationErrorDetails(errorTarget, apparentType, kind);
|
||||
const diagnostic = createDiagnosticForNodeFromMessageChain(errorTarget, messageChain);
|
||||
if (relatedInfo) {
|
||||
addRelatedInfo(diagnostic, createDiagnosticForNode(errorTarget, relatedInfo));
|
||||
@@ -26563,7 +26573,7 @@ namespace ts {
|
||||
|
||||
const headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
|
||||
if (!callSignatures.length) {
|
||||
const errorDetails = invocationErrorDetails(apparentType, SignatureKind.Call);
|
||||
const errorDetails = invocationErrorDetails(node.expression, apparentType, SignatureKind.Call);
|
||||
const messageChain = chainDiagnosticMessages(errorDetails.messageChain, headMessage);
|
||||
const diag = createDiagnosticForNodeFromMessageChain(node.expression, messageChain);
|
||||
if (errorDetails.relatedMessage) {
|
||||
|
||||
@@ -4416,6 +4416,10 @@
|
||||
"category": "Error",
|
||||
"code": 6233
|
||||
},
|
||||
"This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?": {
|
||||
"category": "Error",
|
||||
"code": 6234
|
||||
},
|
||||
|
||||
"Projects to reference": {
|
||||
"category": "Message",
|
||||
|
||||
@@ -4499,10 +4499,11 @@ namespace ts {
|
||||
function getLiteralTextOfNode(node: LiteralLikeNode, neverAsciiEscape: boolean | undefined, jsxAttributeEscape: boolean): string {
|
||||
if (node.kind === SyntaxKind.StringLiteral && (<StringLiteral>node).textSourceNode) {
|
||||
const textSourceNode = (<StringLiteral>node).textSourceNode!;
|
||||
if (isIdentifier(textSourceNode)) {
|
||||
return jsxAttributeEscape ? `"${escapeJsxAttributeString(getTextOfNode(textSourceNode))}"` :
|
||||
neverAsciiEscape || (getEmitFlags(node) & EmitFlags.NoAsciiEscaping) ? `"${escapeString(getTextOfNode(textSourceNode))}"` :
|
||||
`"${escapeNonAsciiString(getTextOfNode(textSourceNode))}"`;
|
||||
if (isIdentifier(textSourceNode) || isNumericLiteral(textSourceNode)) {
|
||||
const text = isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode);
|
||||
return jsxAttributeEscape ? `"${escapeJsxAttributeString(text)}"` :
|
||||
neverAsciiEscape || (getEmitFlags(node) & EmitFlags.NoAsciiEscaping) ? `"${escapeString(text)}"` :
|
||||
`"${escapeNonAsciiString(text)}"`;
|
||||
}
|
||||
else {
|
||||
return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape);
|
||||
|
||||
@@ -2610,23 +2610,23 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function createJSDocAuthorTag(comment?: string) {
|
||||
return createJSDocTag(SyntaxKind.JSDocAuthorTag, "author", comment);
|
||||
return createJSDocTag<JSDocAuthorTag>(SyntaxKind.JSDocAuthorTag, "author", comment);
|
||||
}
|
||||
|
||||
export function createJSDocPublicTag() {
|
||||
return createJSDocTag(SyntaxKind.JSDocPublicTag, "public");
|
||||
return createJSDocTag<JSDocPublicTag>(SyntaxKind.JSDocPublicTag, "public");
|
||||
}
|
||||
|
||||
export function createJSDocPrivateTag() {
|
||||
return createJSDocTag(SyntaxKind.JSDocPrivateTag, "private");
|
||||
return createJSDocTag<JSDocPrivateTag>(SyntaxKind.JSDocPrivateTag, "private");
|
||||
}
|
||||
|
||||
export function createJSDocProtectedTag() {
|
||||
return createJSDocTag(SyntaxKind.JSDocProtectedTag, "protected");
|
||||
return createJSDocTag<JSDocProtectedTag>(SyntaxKind.JSDocProtectedTag, "protected");
|
||||
}
|
||||
|
||||
export function createJSDocReadonlyTag() {
|
||||
return createJSDocTag(SyntaxKind.JSDocReadonlyTag, "readonly");
|
||||
return createJSDocTag<JSDocReadonlyTag>(SyntaxKind.JSDocReadonlyTag, "readonly");
|
||||
}
|
||||
|
||||
export function appendJSDocToContainer(node: JSDocContainer, jsdoc: JSDoc) {
|
||||
|
||||
@@ -3092,6 +3092,12 @@ namespace ts {
|
||||
else if (isStringOrNumericLiteralLike(nameExpression)) {
|
||||
return escapeLeadingUnderscores(nameExpression.text);
|
||||
}
|
||||
else if (isSignedNumericLiteral(nameExpression)) {
|
||||
if (nameExpression.operator === SyntaxKind.MinusToken) {
|
||||
return tokenToString(nameExpression.operator) + nameExpression.operand.text as __String;
|
||||
}
|
||||
return nameExpression.operand.text as __String;
|
||||
}
|
||||
return undefined;
|
||||
default:
|
||||
return Debug.assertNever(name);
|
||||
|
||||
Vendored
+4
-1
@@ -102,8 +102,11 @@ interface Atomics {
|
||||
/**
|
||||
* Wakes up sleeping agents that are waiting on the given index of the array, returning the
|
||||
* number of agents that were awoken.
|
||||
* @param typedArray A shared Int32Array.
|
||||
* @param index The position in the typedArray to wake up on.
|
||||
* @param count The number of sleeping agents to notify. Defaults to +Infinity.
|
||||
*/
|
||||
notify(typedArray: Int32Array, index: number, count: number): number;
|
||||
notify(typedArray: Int32Array, index: number, count?: number): number;
|
||||
|
||||
/**
|
||||
* Stores the bitwise XOR of a value with the value at the given position in the array,
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
tests/cases/compiler/accessorAccidentalCallDiagnostic.ts(6,14): error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?
|
||||
Type 'Number' has no call signatures.
|
||||
|
||||
|
||||
==== tests/cases/compiler/accessorAccidentalCallDiagnostic.ts (1 errors) ====
|
||||
// https://github.com/microsoft/TypeScript/issues/24554
|
||||
class Test24554 {
|
||||
get property(): number { return 1; }
|
||||
}
|
||||
function test24554(x: Test24554) {
|
||||
return x.property();
|
||||
~~~~~~~~
|
||||
!!! error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?
|
||||
!!! error TS6234: Type 'Number' has no call signatures.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//// [accessorAccidentalCallDiagnostic.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/24554
|
||||
class Test24554 {
|
||||
get property(): number { return 1; }
|
||||
}
|
||||
function test24554(x: Test24554) {
|
||||
return x.property();
|
||||
}
|
||||
|
||||
|
||||
//// [accessorAccidentalCallDiagnostic.js]
|
||||
// https://github.com/microsoft/TypeScript/issues/24554
|
||||
var Test24554 = /** @class */ (function () {
|
||||
function Test24554() {
|
||||
}
|
||||
Object.defineProperty(Test24554.prototype, "property", {
|
||||
get: function () { return 1; },
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return Test24554;
|
||||
}());
|
||||
function test24554(x) {
|
||||
return x.property();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/compiler/accessorAccidentalCallDiagnostic.ts ===
|
||||
// https://github.com/microsoft/TypeScript/issues/24554
|
||||
class Test24554 {
|
||||
>Test24554 : Symbol(Test24554, Decl(accessorAccidentalCallDiagnostic.ts, 0, 0))
|
||||
|
||||
get property(): number { return 1; }
|
||||
>property : Symbol(Test24554.property, Decl(accessorAccidentalCallDiagnostic.ts, 1, 17))
|
||||
}
|
||||
function test24554(x: Test24554) {
|
||||
>test24554 : Symbol(test24554, Decl(accessorAccidentalCallDiagnostic.ts, 3, 1))
|
||||
>x : Symbol(x, Decl(accessorAccidentalCallDiagnostic.ts, 4, 19))
|
||||
>Test24554 : Symbol(Test24554, Decl(accessorAccidentalCallDiagnostic.ts, 0, 0))
|
||||
|
||||
return x.property();
|
||||
>x.property : Symbol(Test24554.property, Decl(accessorAccidentalCallDiagnostic.ts, 1, 17))
|
||||
>x : Symbol(x, Decl(accessorAccidentalCallDiagnostic.ts, 4, 19))
|
||||
>property : Symbol(Test24554.property, Decl(accessorAccidentalCallDiagnostic.ts, 1, 17))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
=== tests/cases/compiler/accessorAccidentalCallDiagnostic.ts ===
|
||||
// https://github.com/microsoft/TypeScript/issues/24554
|
||||
class Test24554 {
|
||||
>Test24554 : Test24554
|
||||
|
||||
get property(): number { return 1; }
|
||||
>property : number
|
||||
>1 : 1
|
||||
}
|
||||
function test24554(x: Test24554) {
|
||||
>test24554 : (x: Test24554) => any
|
||||
>x : Test24554
|
||||
|
||||
return x.property();
|
||||
>x.property() : any
|
||||
>x.property : number
|
||||
>x : Test24554
|
||||
>property : number
|
||||
}
|
||||
|
||||
+5
-5
@@ -4272,11 +4272,11 @@ declare namespace ts {
|
||||
function createJSDocParameterTag(typeExpression: JSDocTypeExpression | undefined, name: EntityName, isNameFirst: boolean, isBracketed: boolean, comment?: string): JSDocParameterTag;
|
||||
function createJSDocTypeLiteral(jsDocPropertyTags?: readonly JSDocPropertyLikeTag[], isArrayType?: boolean): JSDocTypeLiteral;
|
||||
function createJSDocImplementsTag(classExpression: JSDocImplementsTag["class"], comment?: string): JSDocImplementsTag;
|
||||
function createJSDocAuthorTag(comment?: string): JSDocTag;
|
||||
function createJSDocPublicTag(): JSDocTag;
|
||||
function createJSDocPrivateTag(): JSDocTag;
|
||||
function createJSDocProtectedTag(): JSDocTag;
|
||||
function createJSDocReadonlyTag(): JSDocTag;
|
||||
function createJSDocAuthorTag(comment?: string): JSDocAuthorTag;
|
||||
function createJSDocPublicTag(): JSDocPublicTag;
|
||||
function createJSDocPrivateTag(): JSDocPrivateTag;
|
||||
function createJSDocProtectedTag(): JSDocProtectedTag;
|
||||
function createJSDocReadonlyTag(): JSDocReadonlyTag;
|
||||
function appendJSDocToContainer(node: JSDocContainer, jsdoc: JSDoc): JSDocContainer;
|
||||
function createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement;
|
||||
function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement;
|
||||
|
||||
+5
-5
@@ -4272,11 +4272,11 @@ declare namespace ts {
|
||||
function createJSDocParameterTag(typeExpression: JSDocTypeExpression | undefined, name: EntityName, isNameFirst: boolean, isBracketed: boolean, comment?: string): JSDocParameterTag;
|
||||
function createJSDocTypeLiteral(jsDocPropertyTags?: readonly JSDocPropertyLikeTag[], isArrayType?: boolean): JSDocTypeLiteral;
|
||||
function createJSDocImplementsTag(classExpression: JSDocImplementsTag["class"], comment?: string): JSDocImplementsTag;
|
||||
function createJSDocAuthorTag(comment?: string): JSDocTag;
|
||||
function createJSDocPublicTag(): JSDocTag;
|
||||
function createJSDocPrivateTag(): JSDocTag;
|
||||
function createJSDocProtectedTag(): JSDocTag;
|
||||
function createJSDocReadonlyTag(): JSDocTag;
|
||||
function createJSDocAuthorTag(comment?: string): JSDocAuthorTag;
|
||||
function createJSDocPublicTag(): JSDocPublicTag;
|
||||
function createJSDocPrivateTag(): JSDocPrivateTag;
|
||||
function createJSDocProtectedTag(): JSDocProtectedTag;
|
||||
function createJSDocReadonlyTag(): JSDocReadonlyTag;
|
||||
function appendJSDocToContainer(node: JSDocContainer, jsdoc: JSDoc): JSDocContainer;
|
||||
function createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement;
|
||||
function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement;
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty_computedName.ts(3,5): error TS2300: Duplicate identifier '[1]'.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty_computedName.ts(8,5): error TS2300: Duplicate identifier '[+1]'.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty_computedName.ts(13,5): error TS2300: Duplicate identifier '[+1]'.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty_computedName.ts(23,5): error TS2300: Duplicate identifier '["+1"]'.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty_computedName.ts(28,5): error TS2300: Duplicate identifier '[-1]'.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty_computedName.ts(33,5): error TS2300: Duplicate identifier '["-1"]'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/duplicateObjectLiteralProperty_computedName.ts (6 errors) ====
|
||||
const t1 = {
|
||||
1: 1,
|
||||
[1]: 0 // duplicate
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier '[1]'.
|
||||
}
|
||||
|
||||
const t2 = {
|
||||
1: 1,
|
||||
[+1]: 0 // duplicate
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier '[+1]'.
|
||||
}
|
||||
|
||||
const t3 = {
|
||||
"1": 1,
|
||||
[+1]: 0 // duplicate
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier '[+1]'.
|
||||
}
|
||||
|
||||
const t4 = {
|
||||
"+1": 1,
|
||||
[+1]: 0 // two different keys, "+1", "1"
|
||||
}
|
||||
|
||||
const t5 = {
|
||||
"+1": 1,
|
||||
["+1"]: 0 // duplicate
|
||||
~~~~~~
|
||||
!!! error TS2300: Duplicate identifier '["+1"]'.
|
||||
}
|
||||
|
||||
const t6 = {
|
||||
"-1": 1,
|
||||
[-1]: 0 // duplicate
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier '[-1]'.
|
||||
}
|
||||
|
||||
const t7 = {
|
||||
"-1": 1,
|
||||
["-1"]: 0 // duplicate
|
||||
~~~~~~
|
||||
!!! error TS2300: Duplicate identifier '["-1"]'.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
//// [duplicateObjectLiteralProperty_computedName.ts]
|
||||
const t1 = {
|
||||
1: 1,
|
||||
[1]: 0 // duplicate
|
||||
}
|
||||
|
||||
const t2 = {
|
||||
1: 1,
|
||||
[+1]: 0 // duplicate
|
||||
}
|
||||
|
||||
const t3 = {
|
||||
"1": 1,
|
||||
[+1]: 0 // duplicate
|
||||
}
|
||||
|
||||
const t4 = {
|
||||
"+1": 1,
|
||||
[+1]: 0 // two different keys, "+1", "1"
|
||||
}
|
||||
|
||||
const t5 = {
|
||||
"+1": 1,
|
||||
["+1"]: 0 // duplicate
|
||||
}
|
||||
|
||||
const t6 = {
|
||||
"-1": 1,
|
||||
[-1]: 0 // duplicate
|
||||
}
|
||||
|
||||
const t7 = {
|
||||
"-1": 1,
|
||||
["-1"]: 0 // duplicate
|
||||
}
|
||||
|
||||
|
||||
//// [duplicateObjectLiteralProperty_computedName.js]
|
||||
var _a, _b, _c, _d, _e, _f, _g;
|
||||
var t1 = (_a = {
|
||||
1: 1
|
||||
},
|
||||
_a[1] = 0 // duplicate
|
||||
,
|
||||
_a);
|
||||
var t2 = (_b = {
|
||||
1: 1
|
||||
},
|
||||
_b[+1] = 0 // duplicate
|
||||
,
|
||||
_b);
|
||||
var t3 = (_c = {
|
||||
"1": 1
|
||||
},
|
||||
_c[+1] = 0 // duplicate
|
||||
,
|
||||
_c);
|
||||
var t4 = (_d = {
|
||||
"+1": 1
|
||||
},
|
||||
_d[+1] = 0 // two different keys, "+1", "1"
|
||||
,
|
||||
_d);
|
||||
var t5 = (_e = {
|
||||
"+1": 1
|
||||
},
|
||||
_e["+1"] = 0 // duplicate
|
||||
,
|
||||
_e);
|
||||
var t6 = (_f = {
|
||||
"-1": 1
|
||||
},
|
||||
_f[-1] = 0 // duplicate
|
||||
,
|
||||
_f);
|
||||
var t7 = (_g = {
|
||||
"-1": 1
|
||||
},
|
||||
_g["-1"] = 0 // duplicate
|
||||
,
|
||||
_g);
|
||||
@@ -0,0 +1,74 @@
|
||||
=== tests/cases/compiler/duplicateObjectLiteralProperty_computedName.ts ===
|
||||
const t1 = {
|
||||
>t1 : Symbol(t1, Decl(duplicateObjectLiteralProperty_computedName.ts, 0, 5))
|
||||
|
||||
1: 1,
|
||||
>1 : Symbol(1, Decl(duplicateObjectLiteralProperty_computedName.ts, 0, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 1, 9))
|
||||
|
||||
[1]: 0 // duplicate
|
||||
>[1] : Symbol(1, Decl(duplicateObjectLiteralProperty_computedName.ts, 0, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 1, 9))
|
||||
>1 : Symbol(1, Decl(duplicateObjectLiteralProperty_computedName.ts, 0, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 1, 9))
|
||||
}
|
||||
|
||||
const t2 = {
|
||||
>t2 : Symbol(t2, Decl(duplicateObjectLiteralProperty_computedName.ts, 5, 5))
|
||||
|
||||
1: 1,
|
||||
>1 : Symbol(1, Decl(duplicateObjectLiteralProperty_computedName.ts, 5, 12))
|
||||
|
||||
[+1]: 0 // duplicate
|
||||
>[+1] : Symbol([+1], Decl(duplicateObjectLiteralProperty_computedName.ts, 6, 9))
|
||||
}
|
||||
|
||||
const t3 = {
|
||||
>t3 : Symbol(t3, Decl(duplicateObjectLiteralProperty_computedName.ts, 10, 5))
|
||||
|
||||
"1": 1,
|
||||
>"1" : Symbol("1", Decl(duplicateObjectLiteralProperty_computedName.ts, 10, 12))
|
||||
|
||||
[+1]: 0 // duplicate
|
||||
>[+1] : Symbol([+1], Decl(duplicateObjectLiteralProperty_computedName.ts, 11, 11))
|
||||
}
|
||||
|
||||
const t4 = {
|
||||
>t4 : Symbol(t4, Decl(duplicateObjectLiteralProperty_computedName.ts, 15, 5))
|
||||
|
||||
"+1": 1,
|
||||
>"+1" : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName.ts, 15, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 16, 12))
|
||||
|
||||
[+1]: 0 // two different keys, "+1", "1"
|
||||
>[+1] : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName.ts, 15, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 16, 12))
|
||||
}
|
||||
|
||||
const t5 = {
|
||||
>t5 : Symbol(t5, Decl(duplicateObjectLiteralProperty_computedName.ts, 20, 5))
|
||||
|
||||
"+1": 1,
|
||||
>"+1" : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName.ts, 20, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 21, 12))
|
||||
|
||||
["+1"]: 0 // duplicate
|
||||
>["+1"] : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName.ts, 20, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 21, 12))
|
||||
>"+1" : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName.ts, 20, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 21, 12))
|
||||
}
|
||||
|
||||
const t6 = {
|
||||
>t6 : Symbol(t6, Decl(duplicateObjectLiteralProperty_computedName.ts, 25, 5))
|
||||
|
||||
"-1": 1,
|
||||
>"-1" : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName.ts, 25, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 26, 12))
|
||||
|
||||
[-1]: 0 // duplicate
|
||||
>[-1] : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName.ts, 25, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 26, 12))
|
||||
}
|
||||
|
||||
const t7 = {
|
||||
>t7 : Symbol(t7, Decl(duplicateObjectLiteralProperty_computedName.ts, 30, 5))
|
||||
|
||||
"-1": 1,
|
||||
>"-1" : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName.ts, 30, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 31, 12))
|
||||
|
||||
["-1"]: 0 // duplicate
|
||||
>["-1"] : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName.ts, 30, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 31, 12))
|
||||
>"-1" : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName.ts, 30, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 31, 12))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
=== tests/cases/compiler/duplicateObjectLiteralProperty_computedName.ts ===
|
||||
const t1 = {
|
||||
>t1 : { 1: number; }
|
||||
>{ 1: 1, [1]: 0 // duplicate} : { 1: number; }
|
||||
|
||||
1: 1,
|
||||
>1 : number
|
||||
>1 : 1
|
||||
|
||||
[1]: 0 // duplicate
|
||||
>[1] : number
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
const t2 = {
|
||||
>t2 : { 1: number; }
|
||||
>{ 1: 1, [+1]: 0 // duplicate} : { 1: number; }
|
||||
|
||||
1: 1,
|
||||
>1 : number
|
||||
>1 : 1
|
||||
|
||||
[+1]: 0 // duplicate
|
||||
>[+1] : number
|
||||
>+1 : 1
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
const t3 = {
|
||||
>t3 : { 1: number; }
|
||||
>{ "1": 1, [+1]: 0 // duplicate} : { 1: number; }
|
||||
|
||||
"1": 1,
|
||||
>"1" : number
|
||||
>1 : 1
|
||||
|
||||
[+1]: 0 // duplicate
|
||||
>[+1] : number
|
||||
>+1 : 1
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
const t4 = {
|
||||
>t4 : { "+1": number; 1: number; }
|
||||
>{ "+1": 1, [+1]: 0 // two different keys, "+1", "1"} : { "+1": number; 1: number; }
|
||||
|
||||
"+1": 1,
|
||||
>"+1" : number
|
||||
>1 : 1
|
||||
|
||||
[+1]: 0 // two different keys, "+1", "1"
|
||||
>[+1] : number
|
||||
>+1 : 1
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
const t5 = {
|
||||
>t5 : { "+1": number; }
|
||||
>{ "+1": 1, ["+1"]: 0 // duplicate} : { "+1": number; }
|
||||
|
||||
"+1": 1,
|
||||
>"+1" : number
|
||||
>1 : 1
|
||||
|
||||
["+1"]: 0 // duplicate
|
||||
>["+1"] : number
|
||||
>"+1" : "+1"
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
const t6 = {
|
||||
>t6 : { [-1]: number; }
|
||||
>{ "-1": 1, [-1]: 0 // duplicate} : { [-1]: number; }
|
||||
|
||||
"-1": 1,
|
||||
>"-1" : number
|
||||
>1 : 1
|
||||
|
||||
[-1]: 0 // duplicate
|
||||
>[-1] : number
|
||||
>-1 : -1
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
const t7 = {
|
||||
>t7 : { [-1]: number; }
|
||||
>{ "-1": 1, ["-1"]: 0 // duplicate} : { [-1]: number; }
|
||||
|
||||
"-1": 1,
|
||||
>"-1" : number
|
||||
>1 : 1
|
||||
|
||||
["-1"]: 0 // duplicate
|
||||
>["-1"] : number
|
||||
>"-1" : "-1"
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(19,16): error TS2349: This expression is not callable.
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(19,16): error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?
|
||||
Type 'Number' has no call signatures.
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(26,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(29,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(41,16): error TS2349: This expression is not callable.
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(41,16): error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?
|
||||
Type 'String' has no call signatures.
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn
|
||||
r.y = 4;
|
||||
var r6 = d.y(); // error
|
||||
~
|
||||
!!! error TS2349: This expression is not callable.
|
||||
!!! error TS2349: Type 'Number' has no call signatures.
|
||||
!!! error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?
|
||||
!!! error TS6234: Type 'Number' has no call signatures.
|
||||
|
||||
}
|
||||
|
||||
@@ -62,6 +62,6 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn
|
||||
r.y = '';
|
||||
var r6 = d.y(); // error
|
||||
~
|
||||
!!! error TS2349: This expression is not callable.
|
||||
!!! error TS2349: Type 'String' has no call signatures.
|
||||
!!! error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?
|
||||
!!! error TS6234: Type 'String' has no call signatures.
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(17,16): error TS2349: This expression is not callable.
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(17,16): error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?
|
||||
Type 'Number' has no call signatures.
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(24,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(27,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(37,16): error TS2349: This expression is not callable.
|
||||
tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(37,16): error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?
|
||||
Type 'String' has no call signatures.
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.t
|
||||
r.y = 4;
|
||||
var r6 = c.y(); // error
|
||||
~
|
||||
!!! error TS2349: This expression is not callable.
|
||||
!!! error TS2349: Type 'Number' has no call signatures.
|
||||
!!! error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?
|
||||
!!! error TS6234: Type 'Number' has no call signatures.
|
||||
|
||||
}
|
||||
|
||||
@@ -58,6 +58,6 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.t
|
||||
r.y = '';
|
||||
var r6 = c.y(); // error
|
||||
~
|
||||
!!! error TS2349: This expression is not callable.
|
||||
!!! error TS2349: Type 'String' has no call signatures.
|
||||
!!! error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?
|
||||
!!! error TS6234: Type 'String' has no call signatures.
|
||||
}
|
||||
@@ -75,6 +75,11 @@ var myChoicesAndEmpty: choices<IMyChoiceList & {}>;
|
||||
|
||||
var unknownChoices: choices<IUnknownChoiceList>;
|
||||
var unknownChoicesAndEmpty: choices<IUnknownChoiceList & {}>;
|
||||
|
||||
// Repro from #38672
|
||||
|
||||
type Foo1 = { x: string } & { [x: number]: Foo1 };
|
||||
type Foo2 = { x: string } & { [K in number]: Foo2 };
|
||||
|
||||
|
||||
//// [intersectionsAndEmptyObjects.js]
|
||||
|
||||
@@ -246,3 +246,17 @@ var unknownChoicesAndEmpty: choices<IUnknownChoiceList & {}>;
|
||||
>choices : Symbol(choices, Decl(intersectionsAndEmptyObjects.ts, 51, 19))
|
||||
>IUnknownChoiceList : Symbol(IUnknownChoiceList, Decl(intersectionsAndEmptyObjects.ts, 64, 2))
|
||||
|
||||
// Repro from #38672
|
||||
|
||||
type Foo1 = { x: string } & { [x: number]: Foo1 };
|
||||
>Foo1 : Symbol(Foo1, Decl(intersectionsAndEmptyObjects.ts, 75, 61))
|
||||
>x : Symbol(x, Decl(intersectionsAndEmptyObjects.ts, 79, 13))
|
||||
>x : Symbol(x, Decl(intersectionsAndEmptyObjects.ts, 79, 31))
|
||||
>Foo1 : Symbol(Foo1, Decl(intersectionsAndEmptyObjects.ts, 75, 61))
|
||||
|
||||
type Foo2 = { x: string } & { [K in number]: Foo2 };
|
||||
>Foo2 : Symbol(Foo2, Decl(intersectionsAndEmptyObjects.ts, 79, 50))
|
||||
>x : Symbol(x, Decl(intersectionsAndEmptyObjects.ts, 80, 13))
|
||||
>K : Symbol(K, Decl(intersectionsAndEmptyObjects.ts, 80, 31))
|
||||
>Foo2 : Symbol(Foo2, Decl(intersectionsAndEmptyObjects.ts, 79, 50))
|
||||
|
||||
|
||||
@@ -206,3 +206,14 @@ var unknownChoices: choices<IUnknownChoiceList>;
|
||||
var unknownChoicesAndEmpty: choices<IUnknownChoiceList & {}>;
|
||||
>unknownChoicesAndEmpty : { shoes: boolean; food: boolean; }
|
||||
|
||||
// Repro from #38672
|
||||
|
||||
type Foo1 = { x: string } & { [x: number]: Foo1 };
|
||||
>Foo1 : Foo1
|
||||
>x : string
|
||||
>x : number
|
||||
|
||||
type Foo2 = { x: string } & { [K in number]: Foo2 };
|
||||
>Foo2 : Foo2
|
||||
>x : string
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [restElementWithNumberPropertyName.ts]
|
||||
const { 0: a, ...b } = [0, 1, 2];
|
||||
|
||||
|
||||
//// [restElementWithNumberPropertyName.js]
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
var _a = [0, 1, 2], a = _a[0], b = __rest(_a, ["0"]);
|
||||
@@ -0,0 +1,5 @@
|
||||
=== tests/cases/compiler/restElementWithNumberPropertyName.ts ===
|
||||
const { 0: a, ...b } = [0, 1, 2];
|
||||
>a : Symbol(a, Decl(restElementWithNumberPropertyName.ts, 0, 7))
|
||||
>b : Symbol(b, Decl(restElementWithNumberPropertyName.ts, 0, 13))
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/restElementWithNumberPropertyName.ts ===
|
||||
const { 0: a, ...b } = [0, 1, 2];
|
||||
>a : number
|
||||
>b : { [n: number]: number; 0: number; 1: number; 2: number; length: 3; toString(): string; toLocaleString(): string; pop(): number; push(...items: number[]): number; concat(...items: ConcatArray<number>[]): number[]; concat(...items: (number | ConcatArray<number>)[]): number[]; join(separator?: string): string; reverse(): number[]; shift(): number; slice(start?: number, end?: number): number[]; sort(compareFn?: (a: number, b: number) => number): [number, number, number]; splice(start: number, deleteCount?: number): number[]; splice(start: number, deleteCount: number, ...items: number[]): number[]; unshift(...items: number[]): number; indexOf(searchElement: number, fromIndex?: number): number; lastIndexOf(searchElement: number, fromIndex?: number): number; every(callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any): void; map<U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; filter<S extends number>(callbackfn: (value: number, index: number, array: number[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any): number[]; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; reduce<U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; reduceRight<U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; }
|
||||
>[0, 1, 2] : [number, number, number]
|
||||
>0 : 0
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
|
||||
@@ -54,5 +54,5 @@ function e() {
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
_a[_i] = arguments[_i];
|
||||
}
|
||||
var _b = _a[0], a = _b === void 0 ? 1 : _b, _c = _a[1], b = _c === void 0 ? true : _c, rest = __rest(_a, [0, 1]);
|
||||
var _b = _a[0], a = _b === void 0 ? 1 : _b, _c = _a[1], b = _c === void 0 ? true : _c, rest = __rest(_a, ["0", "1"]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// @target: es5
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/24554
|
||||
class Test24554 {
|
||||
get property(): number { return 1; }
|
||||
}
|
||||
function test24554(x: Test24554) {
|
||||
return x.property();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
const t1 = {
|
||||
1: 1,
|
||||
[1]: 0 // duplicate
|
||||
}
|
||||
|
||||
const t2 = {
|
||||
1: 1,
|
||||
[+1]: 0 // duplicate
|
||||
}
|
||||
|
||||
const t3 = {
|
||||
"1": 1,
|
||||
[+1]: 0 // duplicate
|
||||
}
|
||||
|
||||
const t4 = {
|
||||
"+1": 1,
|
||||
[+1]: 0 // two different keys, "+1", "1"
|
||||
}
|
||||
|
||||
const t5 = {
|
||||
"+1": 1,
|
||||
["+1"]: 0 // duplicate
|
||||
}
|
||||
|
||||
const t6 = {
|
||||
"-1": 1,
|
||||
[-1]: 0 // duplicate
|
||||
}
|
||||
|
||||
const t7 = {
|
||||
"-1": 1,
|
||||
["-1"]: 0 // duplicate
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
// @target: es5
|
||||
const { 0: a, ...b } = [0, 1, 2];
|
||||
@@ -76,3 +76,8 @@ var myChoicesAndEmpty: choices<IMyChoiceList & {}>;
|
||||
|
||||
var unknownChoices: choices<IUnknownChoiceList>;
|
||||
var unknownChoicesAndEmpty: choices<IUnknownChoiceList & {}>;
|
||||
|
||||
// Repro from #38672
|
||||
|
||||
type Foo1 = { x: string } & { [x: number]: Foo1 };
|
||||
type Foo2 = { x: string } & { [K in number]: Foo2 };
|
||||
|
||||
Reference in New Issue
Block a user