Property assignments in Typescript (#26368)
* Allow special property assignments in TS But only for functions and constant variable declarations initialised with functions. This specifically excludes class declarations and class expressions, which differs from Javascript. That's because Typescript supports `static` properties, which are equivalent to property assignments to a class. * Improve contextual typing predicate Don't think it's right yet, but probably closer? * More fixes. The code is still fantastically ugly, but everything works the way it should. Also update baselines, even where it is ill-advised. * Cleanup * Remove extra whitespace * Some kind of fix to isAnyDeclarationName It's not done yet. Specifically, in TS: Special property assignments are supposed to be declaration sites (but not all top-level assignments), and I think I got them to be. (But not sure). In JS: Special property assignments are supposed to be declaration sites (but not all top-level assignments), and I'm pretty sure ALL top-level assignments have been declaration sites for some time. This is incorrect, and probably means the predicate needs to be the same for both dialects. * Add fourslash and improve isAnyDeclarationName Now JS behaves the same as TS. * Cleanup from PR comments
This commit is contained in:
parent
08eb99d8ec
commit
cc67ce1141
|
@ -2480,6 +2480,11 @@ namespace ts {
|
|||
|
||||
function bindSpecialPropertyAssignment(node: BinaryExpression) {
|
||||
const lhs = node.left as PropertyAccessEntityNameExpression;
|
||||
// Class declarations in Typescript do not allow property declarations
|
||||
const parentSymbol = lookupSymbolForPropertyAccess(lhs.expression);
|
||||
if (!isInJavaScriptFile(node) && !isFunctionSymbol(parentSymbol)) {
|
||||
return;
|
||||
}
|
||||
// Fix up parent pointers since we're going to use these nodes before we bind into them
|
||||
node.left.parent = node;
|
||||
node.right.parent = node;
|
||||
|
|
|
@ -4821,48 +4821,45 @@ namespace ts {
|
|||
}
|
||||
|
||||
/** If we don't have an explicit JSDoc type, get the type from the initializer. */
|
||||
function getInitializerTypeFromSpecialDeclarations(symbol: Symbol, resolvedSymbol: Symbol | undefined, expression: Expression, special: SpecialPropertyAssignmentKind) {
|
||||
if (isBinaryExpression(expression)) {
|
||||
const type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right));
|
||||
if (type.flags & TypeFlags.Object &&
|
||||
special === SpecialPropertyAssignmentKind.ModuleExports &&
|
||||
symbol.escapedName === InternalSymbolName.ExportEquals) {
|
||||
const exportedType = resolveStructuredTypeMembers(type as ObjectType);
|
||||
const members = createSymbolTable();
|
||||
copyEntries(exportedType.members, members);
|
||||
if (resolvedSymbol && !resolvedSymbol.exports) {
|
||||
resolvedSymbol.exports = createSymbolTable();
|
||||
}
|
||||
(resolvedSymbol || symbol).exports!.forEach((s, name) => {
|
||||
if (members.has(name)) {
|
||||
const exportedMember = exportedType.members.get(name)!;
|
||||
const union = createSymbol(s.flags | exportedMember.flags, name);
|
||||
union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]);
|
||||
members.set(name, union);
|
||||
}
|
||||
else {
|
||||
members.set(name, s);
|
||||
}
|
||||
});
|
||||
const result = createAnonymousType(
|
||||
exportedType.symbol,
|
||||
members,
|
||||
exportedType.callSignatures,
|
||||
exportedType.constructSignatures,
|
||||
exportedType.stringIndexInfo,
|
||||
exportedType.numberIndexInfo);
|
||||
result.objectFlags |= (getObjectFlags(type) & ObjectFlags.JSLiteral); // Propagate JSLiteral flag
|
||||
return result;
|
||||
function getInitializerTypeFromSpecialDeclarations(symbol: Symbol, resolvedSymbol: Symbol | undefined, expression: BinaryExpression, special: SpecialPropertyAssignmentKind) {
|
||||
const type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right));
|
||||
if (type.flags & TypeFlags.Object &&
|
||||
special === SpecialPropertyAssignmentKind.ModuleExports &&
|
||||
symbol.escapedName === InternalSymbolName.ExportEquals) {
|
||||
const exportedType = resolveStructuredTypeMembers(type as ObjectType);
|
||||
const members = createSymbolTable();
|
||||
copyEntries(exportedType.members, members);
|
||||
if (resolvedSymbol && !resolvedSymbol.exports) {
|
||||
resolvedSymbol.exports = createSymbolTable();
|
||||
}
|
||||
if (isEmptyArrayLiteralType(type)) {
|
||||
if (noImplicitAny) {
|
||||
reportImplicitAnyError(expression, anyArrayType);
|
||||
(resolvedSymbol || symbol).exports!.forEach((s, name) => {
|
||||
if (members.has(name)) {
|
||||
const exportedMember = exportedType.members.get(name)!;
|
||||
const union = createSymbol(s.flags | exportedMember.flags, name);
|
||||
union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]);
|
||||
members.set(name, union);
|
||||
}
|
||||
return anyArrayType;
|
||||
}
|
||||
return type;
|
||||
else {
|
||||
members.set(name, s);
|
||||
}
|
||||
});
|
||||
const result = createAnonymousType(
|
||||
exportedType.symbol,
|
||||
members,
|
||||
exportedType.callSignatures,
|
||||
exportedType.constructSignatures,
|
||||
exportedType.stringIndexInfo,
|
||||
exportedType.numberIndexInfo);
|
||||
result.objectFlags |= (getObjectFlags(type) & ObjectFlags.JSLiteral); // Propagate JSLiteral flag
|
||||
return result;
|
||||
}
|
||||
return neverType;
|
||||
if (isEmptyArrayLiteralType(type)) {
|
||||
if (noImplicitAny) {
|
||||
reportImplicitAnyError(expression, anyArrayType);
|
||||
}
|
||||
return anyArrayType;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
function isDeclarationInConstructor(expression: Expression) {
|
||||
|
@ -5085,7 +5082,9 @@ namespace ts {
|
|||
if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) {
|
||||
return getTypeOfFuncClassEnumModule(symbol);
|
||||
}
|
||||
type = tryGetTypeFromEffectiveTypeNode(declaration) || anyType;
|
||||
type = isBinaryExpression(declaration.parent) ?
|
||||
getWidenedTypeFromJSPropertyAssignments(symbol) :
|
||||
tryGetTypeFromEffectiveTypeNode(declaration) || anyType;
|
||||
}
|
||||
else if (isPropertyAssignment(declaration)) {
|
||||
type = tryGetTypeFromEffectiveTypeNode(declaration) || checkPropertyAssignment(declaration);
|
||||
|
@ -16025,7 +16024,24 @@ namespace ts {
|
|||
case SpecialPropertyAssignmentKind.PrototypeProperty:
|
||||
// If `binaryExpression.left` was assigned a symbol, then this is a new declaration; otherwise it is an assignment to an existing declaration.
|
||||
// See `bindStaticPropertyAssignment` in `binder.ts`.
|
||||
return !binaryExpression.left.symbol || binaryExpression.left.symbol.valueDeclaration && !!getJSDocTypeTag(binaryExpression.left.symbol.valueDeclaration);
|
||||
if (!binaryExpression.left.symbol) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
const decl = binaryExpression.left.symbol.valueDeclaration;
|
||||
if (!decl) {
|
||||
return false;
|
||||
}
|
||||
if (isInJavaScriptFile(decl)) {
|
||||
return !!getJSDocTypeTag(decl);
|
||||
}
|
||||
else if (isIdentifier((binaryExpression.left as PropertyAccessExpression).expression)) {
|
||||
const id = (binaryExpression.left as PropertyAccessExpression).expression as Identifier;
|
||||
const parentSymbol = resolveName(id, id.escapedText, SymbolFlags.Value, undefined, id.escapedText, /*isUse*/ true);
|
||||
return !isFunctionSymbol(parentSymbol);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case SpecialPropertyAssignmentKind.ThisProperty:
|
||||
case SpecialPropertyAssignmentKind.ModuleExports:
|
||||
return !binaryExpression.symbol || binaryExpression.symbol.valueDeclaration && !!getJSDocTypeTag(binaryExpression.symbol.valueDeclaration);
|
||||
|
|
|
@ -1725,12 +1725,15 @@ namespace ts {
|
|||
}
|
||||
|
||||
export function getDeclarationOfJSInitializer(node: Node): Node | undefined {
|
||||
if (!isInJavaScriptFile(node) || !node.parent) {
|
||||
if (!node.parent) {
|
||||
return undefined;
|
||||
}
|
||||
let name: Expression | BindingName | undefined;
|
||||
let decl: Node | undefined;
|
||||
if (isVariableDeclaration(node.parent) && node.parent.initializer === node) {
|
||||
if (!isInJavaScriptFile(node) && !isVarConst(node.parent)) {
|
||||
return undefined;
|
||||
}
|
||||
name = node.parent.name;
|
||||
decl = node.parent;
|
||||
}
|
||||
|
@ -1892,8 +1895,12 @@ namespace ts {
|
|||
/// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property
|
||||
/// assignments we treat as special in the binder
|
||||
export function getSpecialPropertyAssignmentKind(expr: BinaryExpression): SpecialPropertyAssignmentKind {
|
||||
if (!isInJavaScriptFile(expr) ||
|
||||
expr.operatorToken.kind !== SyntaxKind.EqualsToken ||
|
||||
const special = getSpecialPropertyAssignmentKindWorker(expr);
|
||||
return special === SpecialPropertyAssignmentKind.Property || isInJavaScriptFile(expr) ? special : SpecialPropertyAssignmentKind.None;
|
||||
}
|
||||
|
||||
function getSpecialPropertyAssignmentKindWorker(expr: BinaryExpression): SpecialPropertyAssignmentKind {
|
||||
if (expr.operatorToken.kind !== SyntaxKind.EqualsToken ||
|
||||
!isPropertyAccessExpression(expr.left)) {
|
||||
return SpecialPropertyAssignmentKind.None;
|
||||
}
|
||||
|
@ -1954,6 +1961,14 @@ namespace ts {
|
|||
!!getJSDocTypeTag(expr.parent);
|
||||
}
|
||||
|
||||
export function isFunctionSymbol(symbol: Symbol | undefined) {
|
||||
if (!symbol || !symbol.valueDeclaration) {
|
||||
return false;
|
||||
}
|
||||
const decl = symbol.valueDeclaration;
|
||||
return decl.kind === SyntaxKind.FunctionDeclaration || isVariableDeclaration(decl) && decl.initializer && isFunctionLike(decl.initializer);
|
||||
}
|
||||
|
||||
export function importFromModuleSpecifier(node: StringLiteralLike): AnyValidImportOrReExport {
|
||||
return tryGetImportFromModuleSpecifier(node) || Debug.fail(Debug.showSyntaxKind(node.parent));
|
||||
}
|
||||
|
@ -2354,7 +2369,10 @@ namespace ts {
|
|||
}
|
||||
else {
|
||||
const binExp = name.parent.parent;
|
||||
return isBinaryExpression(binExp) && getSpecialPropertyAssignmentKind(binExp) !== SpecialPropertyAssignmentKind.None && getNameOfDeclaration(binExp) === name;
|
||||
return isBinaryExpression(binExp) &&
|
||||
getSpecialPropertyAssignmentKind(binExp) !== SpecialPropertyAssignmentKind.None &&
|
||||
(binExp.left.symbol || binExp.symbol) &&
|
||||
getNameOfDeclaration(binExp) === name;
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -24,7 +24,6 @@ tests/cases/conformance/fixSignatureCaching.ts(474,38): error TS2339: Property '
|
|||
tests/cases/conformance/fixSignatureCaching.ts(481,22): error TS2339: Property 'findMatch' does not exist on type '{}'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(481,37): error TS2339: Property 'mobileDetectRules' does not exist on type '{}'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(489,18): error TS2339: Property 'isMobileFallback' does not exist on type '{}'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(490,39): error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(492,37): error TS2339: Property 'FALLBACK_MOBILE' does not exist on type '{}'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(495,51): error TS2339: Property 'FALLBACK_PHONE' does not exist on type '{}'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(498,52): error TS2339: Property 'FALLBACK_TABLET' does not exist on type '{}'.
|
||||
|
@ -49,13 +48,8 @@ tests/cases/conformance/fixSignatureCaching.ts(872,25): error TS2339: Property '
|
|||
tests/cases/conformance/fixSignatureCaching.ts(893,25): error TS2339: Property 'getVersionStr' does not exist on type '{}'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(915,36): error TS2339: Property 'findMatches' does not exist on type '{}'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(915,53): error TS2339: Property 'mobileDetectRules' does not exist on type '{}'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(944,33): error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(955,42): error TS2339: Property 'mobileGrade' does not exist on type '{}'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(963,22): error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(964,57): error TS2339: Property 'getDeviceSmallerSide' does not exist on type '{}'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(967,22): error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(971,18): error TS2339: Property '_impl' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(973,18): error TS2339: Property 'version' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(978,16): error TS2304: Cannot find name 'module'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(978,42): error TS2304: Cannot find name 'module'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(979,37): error TS2304: Cannot find name 'module'.
|
||||
|
@ -65,7 +59,7 @@ tests/cases/conformance/fixSignatureCaching.ts(981,16): error TS2304: Cannot fin
|
|||
tests/cases/conformance/fixSignatureCaching.ts(983,44): error TS2339: Property 'MobileDetect' does not exist on type 'Window'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/fixSignatureCaching.ts (65 errors) ====
|
||||
==== tests/cases/conformance/fixSignatureCaching.ts (59 errors) ====
|
||||
// Repro from #10697
|
||||
|
||||
(function (define, undefined) {
|
||||
|
@ -608,8 +602,6 @@ tests/cases/conformance/fixSignatureCaching.ts(983,44): error TS2339: Property '
|
|||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'isMobileFallback' does not exist on type '{}'.
|
||||
phoneSized = MobileDetect.isPhoneSized(maxPhoneWidth);
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'.
|
||||
if (phoneSized === undefined) {
|
||||
cache.mobile = impl.FALLBACK_MOBILE;
|
||||
~~~~~~~~~~~~~~~
|
||||
|
@ -1112,8 +1104,6 @@ tests/cases/conformance/fixSignatureCaching.ts(983,44): error TS2339: Property '
|
|||
*/
|
||||
isPhoneSized: function (maxPhoneWidth) {
|
||||
return MobileDetect.isPhoneSized(maxPhoneWidth || this.maxPhoneWidth);
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'.
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1135,26 +1125,18 @@ tests/cases/conformance/fixSignatureCaching.ts(983,44): error TS2339: Property '
|
|||
// environment-dependent
|
||||
if (typeof window !== 'undefined' && window.screen) {
|
||||
MobileDetect.isPhoneSized = function (maxPhoneWidth) {
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'.
|
||||
return maxPhoneWidth < 0 ? undefined : impl.getDeviceSmallerSide() <= maxPhoneWidth;
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'getDeviceSmallerSide' does not exist on type '{}'.
|
||||
};
|
||||
} else {
|
||||
MobileDetect.isPhoneSized = function () {};
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'.
|
||||
}
|
||||
|
||||
// should not be replaced by a completely new object - just overwrite existing methods
|
||||
MobileDetect._impl = impl;
|
||||
~~~~~
|
||||
!!! error TS2339: Property '_impl' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'.
|
||||
|
||||
MobileDetect.version = '1.3.3 2016-07-31';
|
||||
~~~~~~~
|
||||
!!! error TS2339: Property 'version' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'.
|
||||
|
||||
return MobileDetect;
|
||||
}); // end of call of define()
|
||||
|
@ -1183,4 +1165,5 @@ tests/cases/conformance/fixSignatureCaching.ts(983,44): error TS2339: Property '
|
|||
// please file a bug if you get this error!
|
||||
throw new Error('unknown environment');
|
||||
}
|
||||
})());
|
||||
})());
|
||||
|
|
@ -986,7 +986,8 @@ define(function () {
|
|||
// please file a bug if you get this error!
|
||||
throw new Error('unknown environment');
|
||||
}
|
||||
})());
|
||||
})());
|
||||
|
||||
|
||||
//// [fixSignatureCaching.js]
|
||||
// Repro from #10697
|
||||
|
|
|
@ -1317,7 +1317,9 @@ define(function () {
|
|||
|
||||
phoneSized = MobileDetect.isPhoneSized(maxPhoneWidth);
|
||||
>phoneSized : Symbol(phoneSized, Decl(fixSignatureCaching.ts, 470, 26))
|
||||
>MobileDetect.isPhoneSized : Symbol(MobileDetect.isPhoneSized, Decl(fixSignatureCaching.ts, 961, 57), Decl(fixSignatureCaching.ts, 965, 12))
|
||||
>MobileDetect : Symbol(MobileDetect, Decl(fixSignatureCaching.ts, 644, 6))
|
||||
>isPhoneSized : Symbol(MobileDetect.isPhoneSized, Decl(fixSignatureCaching.ts, 961, 57), Decl(fixSignatureCaching.ts, 965, 12))
|
||||
>maxPhoneWidth : Symbol(maxPhoneWidth, Decl(fixSignatureCaching.ts, 466, 60))
|
||||
|
||||
if (phoneSized === undefined) {
|
||||
|
@ -2015,7 +2017,9 @@ define(function () {
|
|||
>maxPhoneWidth : Symbol(maxPhoneWidth, Decl(fixSignatureCaching.ts, 942, 32))
|
||||
|
||||
return MobileDetect.isPhoneSized(maxPhoneWidth || this.maxPhoneWidth);
|
||||
>MobileDetect.isPhoneSized : Symbol(MobileDetect.isPhoneSized, Decl(fixSignatureCaching.ts, 961, 57), Decl(fixSignatureCaching.ts, 965, 12))
|
||||
>MobileDetect : Symbol(MobileDetect, Decl(fixSignatureCaching.ts, 644, 6))
|
||||
>isPhoneSized : Symbol(MobileDetect.isPhoneSized, Decl(fixSignatureCaching.ts, 961, 57), Decl(fixSignatureCaching.ts, 965, 12))
|
||||
>maxPhoneWidth : Symbol(maxPhoneWidth, Decl(fixSignatureCaching.ts, 942, 32))
|
||||
|
||||
},
|
||||
|
@ -2047,7 +2051,9 @@ define(function () {
|
|||
>screen : Symbol(Window.screen, Decl(lib.dom.d.ts, --, --))
|
||||
|
||||
MobileDetect.isPhoneSized = function (maxPhoneWidth) {
|
||||
>MobileDetect.isPhoneSized : Symbol(MobileDetect.isPhoneSized, Decl(fixSignatureCaching.ts, 961, 57), Decl(fixSignatureCaching.ts, 965, 12))
|
||||
>MobileDetect : Symbol(MobileDetect, Decl(fixSignatureCaching.ts, 644, 6))
|
||||
>isPhoneSized : Symbol(MobileDetect.isPhoneSized, Decl(fixSignatureCaching.ts, 961, 57), Decl(fixSignatureCaching.ts, 965, 12))
|
||||
>maxPhoneWidth : Symbol(maxPhoneWidth, Decl(fixSignatureCaching.ts, 962, 46))
|
||||
|
||||
return maxPhoneWidth < 0 ? undefined : impl.getDeviceSmallerSide() <= maxPhoneWidth;
|
||||
|
@ -2059,16 +2065,22 @@ define(function () {
|
|||
};
|
||||
} else {
|
||||
MobileDetect.isPhoneSized = function () {};
|
||||
>MobileDetect.isPhoneSized : Symbol(MobileDetect.isPhoneSized, Decl(fixSignatureCaching.ts, 961, 57), Decl(fixSignatureCaching.ts, 965, 12))
|
||||
>MobileDetect : Symbol(MobileDetect, Decl(fixSignatureCaching.ts, 644, 6))
|
||||
>isPhoneSized : Symbol(MobileDetect.isPhoneSized, Decl(fixSignatureCaching.ts, 961, 57), Decl(fixSignatureCaching.ts, 965, 12))
|
||||
}
|
||||
|
||||
// should not be replaced by a completely new object - just overwrite existing methods
|
||||
MobileDetect._impl = impl;
|
||||
>MobileDetect._impl : Symbol(MobileDetect._impl, Decl(fixSignatureCaching.ts, 967, 5))
|
||||
>MobileDetect : Symbol(MobileDetect, Decl(fixSignatureCaching.ts, 644, 6))
|
||||
>_impl : Symbol(MobileDetect._impl, Decl(fixSignatureCaching.ts, 967, 5))
|
||||
>impl : Symbol(impl, Decl(fixSignatureCaching.ts, 6, 7))
|
||||
|
||||
MobileDetect.version = '1.3.3 2016-07-31';
|
||||
>MobileDetect.version : Symbol(MobileDetect.version, Decl(fixSignatureCaching.ts, 970, 30))
|
||||
>MobileDetect : Symbol(MobileDetect, Decl(fixSignatureCaching.ts, 644, 6))
|
||||
>version : Symbol(MobileDetect.version, Decl(fixSignatureCaching.ts, 970, 30))
|
||||
|
||||
return MobileDetect;
|
||||
>MobileDetect : Symbol(MobileDetect, Decl(fixSignatureCaching.ts, 644, 6))
|
||||
|
@ -2098,3 +2110,4 @@ define(function () {
|
|||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
})());
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -3,12 +3,11 @@ tests/cases/compiler/targetTypeTest1.ts(6,43): error TS2304: Cannot find name 'P
|
|||
tests/cases/compiler/targetTypeTest1.ts(7,22): error TS2304: Cannot find name 'Point'.
|
||||
tests/cases/compiler/targetTypeTest1.ts(14,10): error TS2300: Duplicate identifier 'Point'.
|
||||
tests/cases/compiler/targetTypeTest1.ts(19,18): error TS2384: Overload signatures must all be ambient or non-ambient.
|
||||
tests/cases/compiler/targetTypeTest1.ts(26,7): error TS2339: Property 'origin' does not exist on type '(x: any, y: any) => void'.
|
||||
tests/cases/compiler/targetTypeTest1.ts(53,15): error TS2300: Duplicate identifier 'C'.
|
||||
tests/cases/compiler/targetTypeTest1.ts(60,10): error TS2300: Duplicate identifier 'C'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/targetTypeTest1.ts (8 errors) ====
|
||||
==== tests/cases/compiler/targetTypeTest1.ts (7 errors) ====
|
||||
declare class Point
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'Point'.
|
||||
|
@ -45,8 +44,6 @@ tests/cases/compiler/targetTypeTest1.ts(60,10): error TS2300: Duplicate identifi
|
|||
|
||||
// Point.origin declared as type Point
|
||||
Point.origin = new Point(0, 0);
|
||||
~~~~~~
|
||||
!!! error TS2339: Property 'origin' does not exist on type '(x: any, y: any) => void'.
|
||||
|
||||
// Point.prototype declared as type Point
|
||||
// this inferred as Point because of obj.prop assignment
|
||||
|
|
|
@ -55,7 +55,9 @@ var x = EF1(1,2);
|
|||
|
||||
// Point.origin declared as type Point
|
||||
Point.origin = new Point(0, 0);
|
||||
>Point.origin : Symbol(Point.origin, Decl(targetTypeTest1.ts, 22, 17))
|
||||
>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1))
|
||||
>origin : Symbol(Point.origin, Decl(targetTypeTest1.ts, 22, 17))
|
||||
>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1))
|
||||
|
||||
// Point.prototype declared as type Point
|
||||
|
|
|
@ -26,7 +26,7 @@ declare class Point
|
|||
// Because Point is a constructor function, this is inferred
|
||||
// to be Point and return type is inferred to be void
|
||||
function Point(x, y) {
|
||||
>Point : (x: any, y: any) => void
|
||||
>Point : { (x: any, y: any): void; origin: any; }
|
||||
>x : any
|
||||
>y : any
|
||||
|
||||
|
@ -69,10 +69,10 @@ var x = EF1(1,2);
|
|||
Point.origin = new Point(0, 0);
|
||||
>Point.origin = new Point(0, 0) : any
|
||||
>Point.origin : any
|
||||
>Point : (x: any, y: any) => void
|
||||
>Point : { (x: any, y: any): void; origin: any; }
|
||||
>origin : any
|
||||
>new Point(0, 0) : any
|
||||
>Point : (x: any, y: any) => void
|
||||
>Point : { (x: any, y: any): void; origin: any; }
|
||||
>0 : 0
|
||||
>0 : 0
|
||||
|
||||
|
@ -83,7 +83,7 @@ Point.prototype.add = function(dx, dy) {
|
|||
>Point.prototype.add = function(dx, dy) { return new Point(this.x + dx, this.y + dy);} : (dx: any, dy: any) => any
|
||||
>Point.prototype.add : any
|
||||
>Point.prototype : any
|
||||
>Point : (x: any, y: any) => void
|
||||
>Point : { (x: any, y: any): void; origin: any; }
|
||||
>prototype : any
|
||||
>add : any
|
||||
>function(dx, dy) { return new Point(this.x + dx, this.y + dy);} : (dx: any, dy: any) => any
|
||||
|
@ -92,7 +92,7 @@ Point.prototype.add = function(dx, dy) {
|
|||
|
||||
return new Point(this.x + dx, this.y + dy);
|
||||
>new Point(this.x + dx, this.y + dy) : any
|
||||
>Point : (x: any, y: any) => void
|
||||
>Point : { (x: any, y: any): void; origin: any; }
|
||||
>this.x + dx : any
|
||||
>this.x : any
|
||||
>this : any
|
||||
|
@ -116,7 +116,7 @@ var f : number = 5;
|
|||
Point.prototype = {
|
||||
>Point.prototype = { x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }} : { x: number; y: number; add: (dx: any, dy: any) => any; }
|
||||
>Point.prototype : any
|
||||
>Point : (x: any, y: any) => void
|
||||
>Point : { (x: any, y: any): void; origin: any; }
|
||||
>prototype : any
|
||||
>{ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }} : { x: number; y: number; add: (dx: any, dy: any) => any; }
|
||||
|
||||
|
@ -136,7 +136,7 @@ Point.prototype = {
|
|||
|
||||
return new Point(this.x + dx, this.y + dy);
|
||||
>new Point(this.x + dx, this.y + dy) : any
|
||||
>Point : (x: any, y: any) => void
|
||||
>Point : { (x: any, y: any): void; origin: any; }
|
||||
>this.x + dx : any
|
||||
>this.x : any
|
||||
>this : any
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts(30,14): error TS2339: Property 'prop' does not exist on type '(n: number) => string'.
|
||||
tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts(31,14): error TS2339: Property 'm' does not exist on type '(n: number) => string'.
|
||||
tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts(34,22): error TS2339: Property 'prop' does not exist on type '(n: number) => string'.
|
||||
tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts(34,42): error TS2339: Property 'm' does not exist on type '(n: number) => string'.
|
||||
tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts(40,14): error TS2339: Property 'prop' does not exist on type 'typeof ExpandoClass'.
|
||||
tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts(41,14): error TS2339: Property 'm' does not exist on type 'typeof ExpandoClass'.
|
||||
tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts(44,22): error TS2339: Property 'prop' does not exist on type 'typeof ExpandoClass'.
|
||||
tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts(44,42): error TS2339: Property 'm' does not exist on type 'typeof ExpandoClass'.
|
||||
tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts(50,14): error TS2339: Property 'prop' does not exist on type 'typeof ExpandoExpr3'.
|
||||
tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts(51,14): error TS2339: Property 'm' does not exist on type 'typeof ExpandoExpr3'.
|
||||
tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts(54,22): error TS2339: Property 'prop' does not exist on type 'typeof ExpandoExpr3'.
|
||||
tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts(54,42): error TS2339: Property 'm' does not exist on type 'typeof ExpandoExpr3'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts (12 errors) ====
|
||||
function ExpandoDecl(n: number) {
|
||||
return n.toString();
|
||||
}
|
||||
ExpandoDecl.prop = 2
|
||||
ExpandoDecl.m = function(n: number) {
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoDecl.prop + ExpandoDecl.m(12) + ExpandoDecl(101).length
|
||||
|
||||
const ExpandoExpr = function (n: number) {
|
||||
return n.toString();
|
||||
}
|
||||
ExpandoExpr.prop = 2
|
||||
ExpandoExpr.m = function(n: number) {
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoExpr.prop + ExpandoExpr.m(12) + ExpandoExpr(101).length
|
||||
|
||||
const ExpandoArrow = (n: number) => n.toString();
|
||||
ExpandoArrow.prop = 2
|
||||
ExpandoArrow.m = function(n: number) {
|
||||
return n + 1;
|
||||
|
||||
}
|
||||
|
||||
// Should not work in Typescript -- must be const
|
||||
var ExpandoExpr2 = function (n: number) {
|
||||
return n.toString();
|
||||
}
|
||||
ExpandoExpr2.prop = 2
|
||||
~~~~
|
||||
!!! error TS2339: Property 'prop' does not exist on type '(n: number) => string'.
|
||||
ExpandoExpr2.m = function(n: number) {
|
||||
~
|
||||
!!! error TS2339: Property 'm' does not exist on type '(n: number) => string'.
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoExpr2.prop + ExpandoExpr2.m(12) + ExpandoExpr2(101).length
|
||||
~~~~
|
||||
!!! error TS2339: Property 'prop' does not exist on type '(n: number) => string'.
|
||||
~
|
||||
!!! error TS2339: Property 'm' does not exist on type '(n: number) => string'.
|
||||
|
||||
// Should not work in typescript -- classes already have statics
|
||||
class ExpandoClass {
|
||||
n = 1001;
|
||||
}
|
||||
ExpandoClass.prop = 2
|
||||
~~~~
|
||||
!!! error TS2339: Property 'prop' does not exist on type 'typeof ExpandoClass'.
|
||||
ExpandoClass.m = function(n: number) {
|
||||
~
|
||||
!!! error TS2339: Property 'm' does not exist on type 'typeof ExpandoClass'.
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoClass.prop + ExpandoClass.m(12) + new ExpandoClass().n
|
||||
~~~~
|
||||
!!! error TS2339: Property 'prop' does not exist on type 'typeof ExpandoClass'.
|
||||
~
|
||||
!!! error TS2339: Property 'm' does not exist on type 'typeof ExpandoClass'.
|
||||
|
||||
// Class expressions shouldn't work in typescript either
|
||||
var ExpandoExpr3 = class {
|
||||
n = 10001;
|
||||
}
|
||||
ExpandoExpr3.prop = 3
|
||||
~~~~
|
||||
!!! error TS2339: Property 'prop' does not exist on type 'typeof ExpandoExpr3'.
|
||||
ExpandoExpr3.m = function(n: number) {
|
||||
~
|
||||
!!! error TS2339: Property 'm' does not exist on type 'typeof ExpandoExpr3'.
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoExpr3.prop + ExpandoExpr3.m(13) + new ExpandoExpr3().n
|
||||
~~~~
|
||||
!!! error TS2339: Property 'prop' does not exist on type 'typeof ExpandoExpr3'.
|
||||
~
|
||||
!!! error TS2339: Property 'm' does not exist on type 'typeof ExpandoExpr3'.
|
||||
|
||||
|
113
tests/baselines/reference/typeFromPropertyAssignment29.js
Normal file
113
tests/baselines/reference/typeFromPropertyAssignment29.js
Normal file
|
@ -0,0 +1,113 @@
|
|||
//// [typeFromPropertyAssignment29.ts]
|
||||
function ExpandoDecl(n: number) {
|
||||
return n.toString();
|
||||
}
|
||||
ExpandoDecl.prop = 2
|
||||
ExpandoDecl.m = function(n: number) {
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoDecl.prop + ExpandoDecl.m(12) + ExpandoDecl(101).length
|
||||
|
||||
const ExpandoExpr = function (n: number) {
|
||||
return n.toString();
|
||||
}
|
||||
ExpandoExpr.prop = 2
|
||||
ExpandoExpr.m = function(n: number) {
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoExpr.prop + ExpandoExpr.m(12) + ExpandoExpr(101).length
|
||||
|
||||
const ExpandoArrow = (n: number) => n.toString();
|
||||
ExpandoArrow.prop = 2
|
||||
ExpandoArrow.m = function(n: number) {
|
||||
return n + 1;
|
||||
|
||||
}
|
||||
|
||||
// Should not work in Typescript -- must be const
|
||||
var ExpandoExpr2 = function (n: number) {
|
||||
return n.toString();
|
||||
}
|
||||
ExpandoExpr2.prop = 2
|
||||
ExpandoExpr2.m = function(n: number) {
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoExpr2.prop + ExpandoExpr2.m(12) + ExpandoExpr2(101).length
|
||||
|
||||
// Should not work in typescript -- classes already have statics
|
||||
class ExpandoClass {
|
||||
n = 1001;
|
||||
}
|
||||
ExpandoClass.prop = 2
|
||||
ExpandoClass.m = function(n: number) {
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoClass.prop + ExpandoClass.m(12) + new ExpandoClass().n
|
||||
|
||||
// Class expressions shouldn't work in typescript either
|
||||
var ExpandoExpr3 = class {
|
||||
n = 10001;
|
||||
}
|
||||
ExpandoExpr3.prop = 3
|
||||
ExpandoExpr3.m = function(n: number) {
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoExpr3.prop + ExpandoExpr3.m(13) + new ExpandoExpr3().n
|
||||
|
||||
|
||||
|
||||
//// [typeFromPropertyAssignment29.js]
|
||||
function ExpandoDecl(n) {
|
||||
return n.toString();
|
||||
}
|
||||
ExpandoDecl.prop = 2;
|
||||
ExpandoDecl.m = function (n) {
|
||||
return n + 1;
|
||||
};
|
||||
var n = ExpandoDecl.prop + ExpandoDecl.m(12) + ExpandoDecl(101).length;
|
||||
var ExpandoExpr = function (n) {
|
||||
return n.toString();
|
||||
};
|
||||
ExpandoExpr.prop = 2;
|
||||
ExpandoExpr.m = function (n) {
|
||||
return n + 1;
|
||||
};
|
||||
var n = ExpandoExpr.prop + ExpandoExpr.m(12) + ExpandoExpr(101).length;
|
||||
var ExpandoArrow = function (n) { return n.toString(); };
|
||||
ExpandoArrow.prop = 2;
|
||||
ExpandoArrow.m = function (n) {
|
||||
return n + 1;
|
||||
};
|
||||
// Should not work in Typescript -- must be const
|
||||
var ExpandoExpr2 = function (n) {
|
||||
return n.toString();
|
||||
};
|
||||
ExpandoExpr2.prop = 2;
|
||||
ExpandoExpr2.m = function (n) {
|
||||
return n + 1;
|
||||
};
|
||||
var n = ExpandoExpr2.prop + ExpandoExpr2.m(12) + ExpandoExpr2(101).length;
|
||||
// Should not work in typescript -- classes already have statics
|
||||
var ExpandoClass = /** @class */ (function () {
|
||||
function ExpandoClass() {
|
||||
this.n = 1001;
|
||||
}
|
||||
return ExpandoClass;
|
||||
}());
|
||||
ExpandoClass.prop = 2;
|
||||
ExpandoClass.m = function (n) {
|
||||
return n + 1;
|
||||
};
|
||||
var n = ExpandoClass.prop + ExpandoClass.m(12) + new ExpandoClass().n;
|
||||
// Class expressions shouldn't work in typescript either
|
||||
var ExpandoExpr3 = /** @class */ (function () {
|
||||
function class_1() {
|
||||
this.n = 10001;
|
||||
}
|
||||
return class_1;
|
||||
}());
|
||||
ExpandoExpr3.prop = 3;
|
||||
ExpandoExpr3.m = function (n) {
|
||||
return n + 1;
|
||||
};
|
||||
var n = ExpandoExpr3.prop + ExpandoExpr3.m(13) + new ExpandoExpr3().n;
|
173
tests/baselines/reference/typeFromPropertyAssignment29.symbols
Normal file
173
tests/baselines/reference/typeFromPropertyAssignment29.symbols
Normal file
|
@ -0,0 +1,173 @@
|
|||
=== tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts ===
|
||||
function ExpandoDecl(n: number) {
|
||||
>ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 3, 20))
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 0, 21))
|
||||
|
||||
return n.toString();
|
||||
>n.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 0, 21))
|
||||
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
ExpandoDecl.prop = 2
|
||||
>ExpandoDecl.prop : Symbol(ExpandoDecl.prop, Decl(typeFromPropertyAssignment29.ts, 2, 1))
|
||||
>ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 3, 20))
|
||||
>prop : Symbol(ExpandoDecl.prop, Decl(typeFromPropertyAssignment29.ts, 2, 1))
|
||||
|
||||
ExpandoDecl.m = function(n: number) {
|
||||
>ExpandoDecl.m : Symbol(ExpandoDecl.m, Decl(typeFromPropertyAssignment29.ts, 3, 20))
|
||||
>ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 3, 20))
|
||||
>m : Symbol(ExpandoDecl.m, Decl(typeFromPropertyAssignment29.ts, 3, 20))
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 4, 25))
|
||||
|
||||
return n + 1;
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 4, 25))
|
||||
}
|
||||
var n = ExpandoDecl.prop + ExpandoDecl.m(12) + ExpandoDecl(101).length
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 7, 3), Decl(typeFromPropertyAssignment29.ts, 16, 3), Decl(typeFromPropertyAssignment29.ts, 33, 3), Decl(typeFromPropertyAssignment29.ts, 43, 3), Decl(typeFromPropertyAssignment29.ts, 53, 3))
|
||||
>ExpandoDecl.prop : Symbol(ExpandoDecl.prop, Decl(typeFromPropertyAssignment29.ts, 2, 1))
|
||||
>ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 3, 20))
|
||||
>prop : Symbol(ExpandoDecl.prop, Decl(typeFromPropertyAssignment29.ts, 2, 1))
|
||||
>ExpandoDecl.m : Symbol(ExpandoDecl.m, Decl(typeFromPropertyAssignment29.ts, 3, 20))
|
||||
>ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 3, 20))
|
||||
>m : Symbol(ExpandoDecl.m, Decl(typeFromPropertyAssignment29.ts, 3, 20))
|
||||
>ExpandoDecl(101).length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 3, 20))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
const ExpandoExpr = function (n: number) {
|
||||
>ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 12, 20))
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 9, 30))
|
||||
|
||||
return n.toString();
|
||||
>n.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 9, 30))
|
||||
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
ExpandoExpr.prop = 2
|
||||
>ExpandoExpr.prop : Symbol(ExpandoExpr.prop, Decl(typeFromPropertyAssignment29.ts, 11, 1))
|
||||
>ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 12, 20))
|
||||
>prop : Symbol(ExpandoExpr.prop, Decl(typeFromPropertyAssignment29.ts, 11, 1))
|
||||
|
||||
ExpandoExpr.m = function(n: number) {
|
||||
>ExpandoExpr.m : Symbol(ExpandoExpr.m, Decl(typeFromPropertyAssignment29.ts, 12, 20))
|
||||
>ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 12, 20))
|
||||
>m : Symbol(ExpandoExpr.m, Decl(typeFromPropertyAssignment29.ts, 12, 20))
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 13, 25))
|
||||
|
||||
return n + 1;
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 13, 25))
|
||||
}
|
||||
var n = ExpandoExpr.prop + ExpandoExpr.m(12) + ExpandoExpr(101).length
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 7, 3), Decl(typeFromPropertyAssignment29.ts, 16, 3), Decl(typeFromPropertyAssignment29.ts, 33, 3), Decl(typeFromPropertyAssignment29.ts, 43, 3), Decl(typeFromPropertyAssignment29.ts, 53, 3))
|
||||
>ExpandoExpr.prop : Symbol(ExpandoExpr.prop, Decl(typeFromPropertyAssignment29.ts, 11, 1))
|
||||
>ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 12, 20))
|
||||
>prop : Symbol(ExpandoExpr.prop, Decl(typeFromPropertyAssignment29.ts, 11, 1))
|
||||
>ExpandoExpr.m : Symbol(ExpandoExpr.m, Decl(typeFromPropertyAssignment29.ts, 12, 20))
|
||||
>ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 12, 20))
|
||||
>m : Symbol(ExpandoExpr.m, Decl(typeFromPropertyAssignment29.ts, 12, 20))
|
||||
>ExpandoExpr(101).length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 12, 20))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
const ExpandoArrow = (n: number) => n.toString();
|
||||
>ExpandoArrow : Symbol(ExpandoArrow, Decl(typeFromPropertyAssignment29.ts, 18, 5), Decl(typeFromPropertyAssignment29.ts, 19, 21))
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 18, 22))
|
||||
>n.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 18, 22))
|
||||
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
ExpandoArrow.prop = 2
|
||||
>ExpandoArrow.prop : Symbol(ExpandoArrow.prop, Decl(typeFromPropertyAssignment29.ts, 18, 49))
|
||||
>ExpandoArrow : Symbol(ExpandoArrow, Decl(typeFromPropertyAssignment29.ts, 18, 5), Decl(typeFromPropertyAssignment29.ts, 19, 21))
|
||||
>prop : Symbol(ExpandoArrow.prop, Decl(typeFromPropertyAssignment29.ts, 18, 49))
|
||||
|
||||
ExpandoArrow.m = function(n: number) {
|
||||
>ExpandoArrow.m : Symbol(ExpandoArrow.m, Decl(typeFromPropertyAssignment29.ts, 19, 21))
|
||||
>ExpandoArrow : Symbol(ExpandoArrow, Decl(typeFromPropertyAssignment29.ts, 18, 5), Decl(typeFromPropertyAssignment29.ts, 19, 21))
|
||||
>m : Symbol(ExpandoArrow.m, Decl(typeFromPropertyAssignment29.ts, 19, 21))
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 20, 26))
|
||||
|
||||
return n + 1;
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 20, 26))
|
||||
|
||||
}
|
||||
|
||||
// Should not work in Typescript -- must be const
|
||||
var ExpandoExpr2 = function (n: number) {
|
||||
>ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 26, 3), Decl(typeFromPropertyAssignment29.ts, 29, 21))
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 26, 29))
|
||||
|
||||
return n.toString();
|
||||
>n.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 26, 29))
|
||||
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
ExpandoExpr2.prop = 2
|
||||
>ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 26, 3), Decl(typeFromPropertyAssignment29.ts, 29, 21))
|
||||
|
||||
ExpandoExpr2.m = function(n: number) {
|
||||
>ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 26, 3), Decl(typeFromPropertyAssignment29.ts, 29, 21))
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 30, 26))
|
||||
|
||||
return n + 1;
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 30, 26))
|
||||
}
|
||||
var n = ExpandoExpr2.prop + ExpandoExpr2.m(12) + ExpandoExpr2(101).length
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 7, 3), Decl(typeFromPropertyAssignment29.ts, 16, 3), Decl(typeFromPropertyAssignment29.ts, 33, 3), Decl(typeFromPropertyAssignment29.ts, 43, 3), Decl(typeFromPropertyAssignment29.ts, 53, 3))
|
||||
>ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 26, 3), Decl(typeFromPropertyAssignment29.ts, 29, 21))
|
||||
>ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 26, 3), Decl(typeFromPropertyAssignment29.ts, 29, 21))
|
||||
>ExpandoExpr2(101).length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 26, 3), Decl(typeFromPropertyAssignment29.ts, 29, 21))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
// Should not work in typescript -- classes already have statics
|
||||
class ExpandoClass {
|
||||
>ExpandoClass : Symbol(ExpandoClass, Decl(typeFromPropertyAssignment29.ts, 33, 73))
|
||||
|
||||
n = 1001;
|
||||
>n : Symbol(ExpandoClass.n, Decl(typeFromPropertyAssignment29.ts, 36, 20))
|
||||
}
|
||||
ExpandoClass.prop = 2
|
||||
>ExpandoClass : Symbol(ExpandoClass, Decl(typeFromPropertyAssignment29.ts, 33, 73))
|
||||
|
||||
ExpandoClass.m = function(n: number) {
|
||||
>ExpandoClass : Symbol(ExpandoClass, Decl(typeFromPropertyAssignment29.ts, 33, 73))
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 40, 26))
|
||||
|
||||
return n + 1;
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 40, 26))
|
||||
}
|
||||
var n = ExpandoClass.prop + ExpandoClass.m(12) + new ExpandoClass().n
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 7, 3), Decl(typeFromPropertyAssignment29.ts, 16, 3), Decl(typeFromPropertyAssignment29.ts, 33, 3), Decl(typeFromPropertyAssignment29.ts, 43, 3), Decl(typeFromPropertyAssignment29.ts, 53, 3))
|
||||
>ExpandoClass : Symbol(ExpandoClass, Decl(typeFromPropertyAssignment29.ts, 33, 73))
|
||||
>ExpandoClass : Symbol(ExpandoClass, Decl(typeFromPropertyAssignment29.ts, 33, 73))
|
||||
>new ExpandoClass().n : Symbol(ExpandoClass.n, Decl(typeFromPropertyAssignment29.ts, 36, 20))
|
||||
>ExpandoClass : Symbol(ExpandoClass, Decl(typeFromPropertyAssignment29.ts, 33, 73))
|
||||
>n : Symbol(ExpandoClass.n, Decl(typeFromPropertyAssignment29.ts, 36, 20))
|
||||
|
||||
// Class expressions shouldn't work in typescript either
|
||||
var ExpandoExpr3 = class {
|
||||
>ExpandoExpr3 : Symbol(ExpandoExpr3, Decl(typeFromPropertyAssignment29.ts, 46, 3))
|
||||
|
||||
n = 10001;
|
||||
>n : Symbol(ExpandoExpr3.n, Decl(typeFromPropertyAssignment29.ts, 46, 26))
|
||||
}
|
||||
ExpandoExpr3.prop = 3
|
||||
>ExpandoExpr3 : Symbol(ExpandoExpr3, Decl(typeFromPropertyAssignment29.ts, 46, 3))
|
||||
|
||||
ExpandoExpr3.m = function(n: number) {
|
||||
>ExpandoExpr3 : Symbol(ExpandoExpr3, Decl(typeFromPropertyAssignment29.ts, 46, 3))
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 50, 26))
|
||||
|
||||
return n + 1;
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 50, 26))
|
||||
}
|
||||
var n = ExpandoExpr3.prop + ExpandoExpr3.m(13) + new ExpandoExpr3().n
|
||||
>n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 7, 3), Decl(typeFromPropertyAssignment29.ts, 16, 3), Decl(typeFromPropertyAssignment29.ts, 33, 3), Decl(typeFromPropertyAssignment29.ts, 43, 3), Decl(typeFromPropertyAssignment29.ts, 53, 3))
|
||||
>ExpandoExpr3 : Symbol(ExpandoExpr3, Decl(typeFromPropertyAssignment29.ts, 46, 3))
|
||||
>ExpandoExpr3 : Symbol(ExpandoExpr3, Decl(typeFromPropertyAssignment29.ts, 46, 3))
|
||||
>new ExpandoExpr3().n : Symbol(ExpandoExpr3.n, Decl(typeFromPropertyAssignment29.ts, 46, 26))
|
||||
>ExpandoExpr3 : Symbol(ExpandoExpr3, Decl(typeFromPropertyAssignment29.ts, 46, 3))
|
||||
>n : Symbol(ExpandoExpr3.n, Decl(typeFromPropertyAssignment29.ts, 46, 26))
|
||||
|
||||
|
271
tests/baselines/reference/typeFromPropertyAssignment29.types
Normal file
271
tests/baselines/reference/typeFromPropertyAssignment29.types
Normal file
|
@ -0,0 +1,271 @@
|
|||
=== tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts ===
|
||||
function ExpandoDecl(n: number) {
|
||||
>ExpandoDecl : typeof ExpandoDecl
|
||||
>n : number
|
||||
|
||||
return n.toString();
|
||||
>n.toString() : string
|
||||
>n.toString : (radix?: number) => string
|
||||
>n : number
|
||||
>toString : (radix?: number) => string
|
||||
}
|
||||
ExpandoDecl.prop = 2
|
||||
>ExpandoDecl.prop = 2 : 2
|
||||
>ExpandoDecl.prop : number
|
||||
>ExpandoDecl : typeof ExpandoDecl
|
||||
>prop : number
|
||||
>2 : 2
|
||||
|
||||
ExpandoDecl.m = function(n: number) {
|
||||
>ExpandoDecl.m = function(n: number) { return n + 1;} : (n: number) => number
|
||||
>ExpandoDecl.m : (n: number) => number
|
||||
>ExpandoDecl : typeof ExpandoDecl
|
||||
>m : (n: number) => number
|
||||
>function(n: number) { return n + 1;} : (n: number) => number
|
||||
>n : number
|
||||
|
||||
return n + 1;
|
||||
>n + 1 : number
|
||||
>n : number
|
||||
>1 : 1
|
||||
}
|
||||
var n = ExpandoDecl.prop + ExpandoDecl.m(12) + ExpandoDecl(101).length
|
||||
>n : number
|
||||
>ExpandoDecl.prop + ExpandoDecl.m(12) + ExpandoDecl(101).length : number
|
||||
>ExpandoDecl.prop + ExpandoDecl.m(12) : number
|
||||
>ExpandoDecl.prop : number
|
||||
>ExpandoDecl : typeof ExpandoDecl
|
||||
>prop : number
|
||||
>ExpandoDecl.m(12) : number
|
||||
>ExpandoDecl.m : (n: number) => number
|
||||
>ExpandoDecl : typeof ExpandoDecl
|
||||
>m : (n: number) => number
|
||||
>12 : 12
|
||||
>ExpandoDecl(101).length : number
|
||||
>ExpandoDecl(101) : string
|
||||
>ExpandoDecl : typeof ExpandoDecl
|
||||
>101 : 101
|
||||
>length : number
|
||||
|
||||
const ExpandoExpr = function (n: number) {
|
||||
>ExpandoExpr : { (n: number): string; prop: number; m(n: number): number; }
|
||||
>function (n: number) { return n.toString();} : { (n: number): string; prop: number; m(n: number): number; }
|
||||
>n : number
|
||||
|
||||
return n.toString();
|
||||
>n.toString() : string
|
||||
>n.toString : (radix?: number) => string
|
||||
>n : number
|
||||
>toString : (radix?: number) => string
|
||||
}
|
||||
ExpandoExpr.prop = 2
|
||||
>ExpandoExpr.prop = 2 : 2
|
||||
>ExpandoExpr.prop : number
|
||||
>ExpandoExpr : { (n: number): string; prop: number; m(n: number): number; }
|
||||
>prop : number
|
||||
>2 : 2
|
||||
|
||||
ExpandoExpr.m = function(n: number) {
|
||||
>ExpandoExpr.m = function(n: number) { return n + 1;} : (n: number) => number
|
||||
>ExpandoExpr.m : (n: number) => number
|
||||
>ExpandoExpr : { (n: number): string; prop: number; m(n: number): number; }
|
||||
>m : (n: number) => number
|
||||
>function(n: number) { return n + 1;} : (n: number) => number
|
||||
>n : number
|
||||
|
||||
return n + 1;
|
||||
>n + 1 : number
|
||||
>n : number
|
||||
>1 : 1
|
||||
}
|
||||
var n = ExpandoExpr.prop + ExpandoExpr.m(12) + ExpandoExpr(101).length
|
||||
>n : number
|
||||
>ExpandoExpr.prop + ExpandoExpr.m(12) + ExpandoExpr(101).length : number
|
||||
>ExpandoExpr.prop + ExpandoExpr.m(12) : number
|
||||
>ExpandoExpr.prop : number
|
||||
>ExpandoExpr : { (n: number): string; prop: number; m(n: number): number; }
|
||||
>prop : number
|
||||
>ExpandoExpr.m(12) : number
|
||||
>ExpandoExpr.m : (n: number) => number
|
||||
>ExpandoExpr : { (n: number): string; prop: number; m(n: number): number; }
|
||||
>m : (n: number) => number
|
||||
>12 : 12
|
||||
>ExpandoExpr(101).length : number
|
||||
>ExpandoExpr(101) : string
|
||||
>ExpandoExpr : { (n: number): string; prop: number; m(n: number): number; }
|
||||
>101 : 101
|
||||
>length : number
|
||||
|
||||
const ExpandoArrow = (n: number) => n.toString();
|
||||
>ExpandoArrow : { (n: number): string; prop: number; m(n: number): number; }
|
||||
>(n: number) => n.toString() : { (n: number): string; prop: number; m(n: number): number; }
|
||||
>n : number
|
||||
>n.toString() : string
|
||||
>n.toString : (radix?: number) => string
|
||||
>n : number
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
ExpandoArrow.prop = 2
|
||||
>ExpandoArrow.prop = 2 : 2
|
||||
>ExpandoArrow.prop : number
|
||||
>ExpandoArrow : { (n: number): string; prop: number; m(n: number): number; }
|
||||
>prop : number
|
||||
>2 : 2
|
||||
|
||||
ExpandoArrow.m = function(n: number) {
|
||||
>ExpandoArrow.m = function(n: number) { return n + 1;} : (n: number) => number
|
||||
>ExpandoArrow.m : (n: number) => number
|
||||
>ExpandoArrow : { (n: number): string; prop: number; m(n: number): number; }
|
||||
>m : (n: number) => number
|
||||
>function(n: number) { return n + 1;} : (n: number) => number
|
||||
>n : number
|
||||
|
||||
return n + 1;
|
||||
>n + 1 : number
|
||||
>n : number
|
||||
>1 : 1
|
||||
|
||||
}
|
||||
|
||||
// Should not work in Typescript -- must be const
|
||||
var ExpandoExpr2 = function (n: number) {
|
||||
>ExpandoExpr2 : (n: number) => string
|
||||
>function (n: number) { return n.toString();} : (n: number) => string
|
||||
>n : number
|
||||
|
||||
return n.toString();
|
||||
>n.toString() : string
|
||||
>n.toString : (radix?: number) => string
|
||||
>n : number
|
||||
>toString : (radix?: number) => string
|
||||
}
|
||||
ExpandoExpr2.prop = 2
|
||||
>ExpandoExpr2.prop = 2 : 2
|
||||
>ExpandoExpr2.prop : any
|
||||
>ExpandoExpr2 : (n: number) => string
|
||||
>prop : any
|
||||
>2 : 2
|
||||
|
||||
ExpandoExpr2.m = function(n: number) {
|
||||
>ExpandoExpr2.m = function(n: number) { return n + 1;} : (n: number) => number
|
||||
>ExpandoExpr2.m : any
|
||||
>ExpandoExpr2 : (n: number) => string
|
||||
>m : any
|
||||
>function(n: number) { return n + 1;} : (n: number) => number
|
||||
>n : number
|
||||
|
||||
return n + 1;
|
||||
>n + 1 : number
|
||||
>n : number
|
||||
>1 : 1
|
||||
}
|
||||
var n = ExpandoExpr2.prop + ExpandoExpr2.m(12) + ExpandoExpr2(101).length
|
||||
>n : number
|
||||
>ExpandoExpr2.prop + ExpandoExpr2.m(12) + ExpandoExpr2(101).length : any
|
||||
>ExpandoExpr2.prop + ExpandoExpr2.m(12) : any
|
||||
>ExpandoExpr2.prop : any
|
||||
>ExpandoExpr2 : (n: number) => string
|
||||
>prop : any
|
||||
>ExpandoExpr2.m(12) : any
|
||||
>ExpandoExpr2.m : any
|
||||
>ExpandoExpr2 : (n: number) => string
|
||||
>m : any
|
||||
>12 : 12
|
||||
>ExpandoExpr2(101).length : number
|
||||
>ExpandoExpr2(101) : string
|
||||
>ExpandoExpr2 : (n: number) => string
|
||||
>101 : 101
|
||||
>length : number
|
||||
|
||||
// Should not work in typescript -- classes already have statics
|
||||
class ExpandoClass {
|
||||
>ExpandoClass : ExpandoClass
|
||||
|
||||
n = 1001;
|
||||
>n : number
|
||||
>1001 : 1001
|
||||
}
|
||||
ExpandoClass.prop = 2
|
||||
>ExpandoClass.prop = 2 : 2
|
||||
>ExpandoClass.prop : any
|
||||
>ExpandoClass : typeof ExpandoClass
|
||||
>prop : any
|
||||
>2 : 2
|
||||
|
||||
ExpandoClass.m = function(n: number) {
|
||||
>ExpandoClass.m = function(n: number) { return n + 1;} : (n: number) => number
|
||||
>ExpandoClass.m : any
|
||||
>ExpandoClass : typeof ExpandoClass
|
||||
>m : any
|
||||
>function(n: number) { return n + 1;} : (n: number) => number
|
||||
>n : number
|
||||
|
||||
return n + 1;
|
||||
>n + 1 : number
|
||||
>n : number
|
||||
>1 : 1
|
||||
}
|
||||
var n = ExpandoClass.prop + ExpandoClass.m(12) + new ExpandoClass().n
|
||||
>n : number
|
||||
>ExpandoClass.prop + ExpandoClass.m(12) + new ExpandoClass().n : any
|
||||
>ExpandoClass.prop + ExpandoClass.m(12) : any
|
||||
>ExpandoClass.prop : any
|
||||
>ExpandoClass : typeof ExpandoClass
|
||||
>prop : any
|
||||
>ExpandoClass.m(12) : any
|
||||
>ExpandoClass.m : any
|
||||
>ExpandoClass : typeof ExpandoClass
|
||||
>m : any
|
||||
>12 : 12
|
||||
>new ExpandoClass().n : number
|
||||
>new ExpandoClass() : ExpandoClass
|
||||
>ExpandoClass : typeof ExpandoClass
|
||||
>n : number
|
||||
|
||||
// Class expressions shouldn't work in typescript either
|
||||
var ExpandoExpr3 = class {
|
||||
>ExpandoExpr3 : typeof ExpandoExpr3
|
||||
>class { n = 10001;} : typeof ExpandoExpr3
|
||||
|
||||
n = 10001;
|
||||
>n : number
|
||||
>10001 : 10001
|
||||
}
|
||||
ExpandoExpr3.prop = 3
|
||||
>ExpandoExpr3.prop = 3 : 3
|
||||
>ExpandoExpr3.prop : any
|
||||
>ExpandoExpr3 : typeof ExpandoExpr3
|
||||
>prop : any
|
||||
>3 : 3
|
||||
|
||||
ExpandoExpr3.m = function(n: number) {
|
||||
>ExpandoExpr3.m = function(n: number) { return n + 1;} : (n: number) => number
|
||||
>ExpandoExpr3.m : any
|
||||
>ExpandoExpr3 : typeof ExpandoExpr3
|
||||
>m : any
|
||||
>function(n: number) { return n + 1;} : (n: number) => number
|
||||
>n : number
|
||||
|
||||
return n + 1;
|
||||
>n + 1 : number
|
||||
>n : number
|
||||
>1 : 1
|
||||
}
|
||||
var n = ExpandoExpr3.prop + ExpandoExpr3.m(13) + new ExpandoExpr3().n
|
||||
>n : number
|
||||
>ExpandoExpr3.prop + ExpandoExpr3.m(13) + new ExpandoExpr3().n : any
|
||||
>ExpandoExpr3.prop + ExpandoExpr3.m(13) : any
|
||||
>ExpandoExpr3.prop : any
|
||||
>ExpandoExpr3 : typeof ExpandoExpr3
|
||||
>prop : any
|
||||
>ExpandoExpr3.m(13) : any
|
||||
>ExpandoExpr3.m : any
|
||||
>ExpandoExpr3 : typeof ExpandoExpr3
|
||||
>m : any
|
||||
>13 : 13
|
||||
>new ExpandoExpr3().n : number
|
||||
>new ExpandoExpr3() : ExpandoExpr3
|
||||
>ExpandoExpr3 : typeof ExpandoExpr3
|
||||
>n : number
|
||||
|
||||
|
|
@ -985,4 +985,4 @@ define(function () {
|
|||
// please file a bug if you get this error!
|
||||
throw new Error('unknown environment');
|
||||
}
|
||||
})());
|
||||
})());
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
function ExpandoDecl(n: number) {
|
||||
return n.toString();
|
||||
}
|
||||
ExpandoDecl.prop = 2
|
||||
ExpandoDecl.m = function(n: number) {
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoDecl.prop + ExpandoDecl.m(12) + ExpandoDecl(101).length
|
||||
|
||||
const ExpandoExpr = function (n: number) {
|
||||
return n.toString();
|
||||
}
|
||||
ExpandoExpr.prop = 2
|
||||
ExpandoExpr.m = function(n: number) {
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoExpr.prop + ExpandoExpr.m(12) + ExpandoExpr(101).length
|
||||
|
||||
const ExpandoArrow = (n: number) => n.toString();
|
||||
ExpandoArrow.prop = 2
|
||||
ExpandoArrow.m = function(n: number) {
|
||||
return n + 1;
|
||||
|
||||
}
|
||||
|
||||
// Should not work in Typescript -- must be const
|
||||
var ExpandoExpr2 = function (n: number) {
|
||||
return n.toString();
|
||||
}
|
||||
ExpandoExpr2.prop = 2
|
||||
ExpandoExpr2.m = function(n: number) {
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoExpr2.prop + ExpandoExpr2.m(12) + ExpandoExpr2(101).length
|
||||
|
||||
// Should not work in typescript -- classes already have statics
|
||||
class ExpandoClass {
|
||||
n = 1001;
|
||||
}
|
||||
ExpandoClass.prop = 2
|
||||
ExpandoClass.m = function(n: number) {
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoClass.prop + ExpandoClass.m(12) + new ExpandoClass().n
|
||||
|
||||
// Class expressions shouldn't work in typescript either
|
||||
var ExpandoExpr3 = class {
|
||||
n = 10001;
|
||||
}
|
||||
ExpandoExpr3.prop = 3
|
||||
ExpandoExpr3.m = function(n: number) {
|
||||
return n + 1;
|
||||
}
|
||||
var n = ExpandoExpr3.prop + ExpandoExpr3.m(13) + new ExpandoExpr3().n
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////var x = { "[|{| "isWriteAccess": true, "isDefinition": true |}someProperty|]": 0 }
|
||||
////x["[|someProperty|]"] = 3;
|
||||
////x.[|{| "isWriteAccess": true, "isDefinition": false |}someProperty|] = 5;
|
||||
|
||||
const ranges = test.ranges();
|
||||
const [r0, r1, r2] = ranges;
|
||||
verify.referenceGroups(r0, [{ definition: '(property) "someProperty": number', ranges }]);
|
||||
verify.referenceGroups([r1, r2], [
|
||||
{ definition: '(property) "someProperty": number', ranges: [r0, r1, r2] },
|
||||
]);
|
|
@ -0,0 +1,12 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////const x = function () { return 111111; }
|
||||
////x.[|{| "isWriteAccess": true, "isDefinition": true |}someProperty|] = 5;
|
||||
////x["[|someProperty|]"] = 3;
|
||||
|
||||
const ranges = test.ranges();
|
||||
const [r0, r1] = ranges;
|
||||
verify.referenceGroups(r0, [{ definition: '(property) x.someProperty: number', ranges }]);
|
||||
verify.referenceGroups([r1], [
|
||||
{ definition: '(property) x.someProperty: number', ranges: [r0, r1] },
|
||||
]);
|
|
@ -0,0 +1,16 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
// @Filename: foo.js
|
||||
// @noEmit: true
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
|
||||
////var x = { "[|{| "isWriteAccess": true, "isDefinition": true |}someProperty|]": 0 }
|
||||
////x["[|someProperty|]"] = 3;
|
||||
////x.[|{| "isWriteAccess": true, "isDefinition": false |}someProperty|] = 5;
|
||||
|
||||
const ranges = test.ranges();
|
||||
const [r0, r1, r2] = ranges;
|
||||
verify.referenceGroups(r0, [{ definition: '(property) "someProperty": number', ranges }]);
|
||||
verify.referenceGroups([r1, r2], [
|
||||
{ definition: '(property) "someProperty": number', ranges: [r0, r1, r2] },
|
||||
]);
|
Loading…
Reference in a new issue