mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into map5
This commit is contained in:
+1
-1
@@ -60,7 +60,7 @@
|
||||
"gulp-insert": "latest",
|
||||
"gulp-newer": "latest",
|
||||
"gulp-sourcemaps": "latest",
|
||||
"gulp-typescript": "latest",
|
||||
"gulp-typescript": "3.1.3",
|
||||
"into-stream": "latest",
|
||||
"istanbul": "latest",
|
||||
"jake": "latest",
|
||||
|
||||
+157
-136
@@ -165,6 +165,7 @@ namespace ts {
|
||||
anyFunctionType.flags |= TypeFlags.ContainsAnyFunctionType;
|
||||
|
||||
const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
const circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
|
||||
const anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
|
||||
const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
|
||||
@@ -1560,9 +1561,7 @@ namespace ts {
|
||||
* Not passing `lookupTable` and `exportNode` disables this collection, and just extends the tables
|
||||
*/
|
||||
function extendExportSymbols(target: SymbolTable, source: SymbolTable, lookupTable?: Map<ExportCollisionTracker>, exportNode?: ExportDeclaration) {
|
||||
if (!source) return;
|
||||
|
||||
source.forEach((sourceSymbol, id) => {
|
||||
source && source.forEach((sourceSymbol, id) => {
|
||||
if (id === "default") return;
|
||||
|
||||
const targetSymbol = target.get(id);
|
||||
@@ -4148,9 +4147,6 @@ namespace ts {
|
||||
if (!links.declaredType) {
|
||||
const type = <TypeParameter>createType(TypeFlags.TypeParameter);
|
||||
type.symbol = symbol;
|
||||
if (!(<TypeParameterDeclaration>getDeclarationOfKind(symbol, SyntaxKind.TypeParameter)).constraint) {
|
||||
type.constraint = noConstraintType;
|
||||
}
|
||||
links.declaredType = type;
|
||||
}
|
||||
return <TypeParameter>links.declaredType;
|
||||
@@ -4618,7 +4614,7 @@ namespace ts {
|
||||
// Create a mapper from T to the current iteration type constituent. Then, if the
|
||||
// mapped type is itself an instantiated type, combine the iteration mapper with the
|
||||
// instantiation mapper.
|
||||
const iterationMapper = createUnaryTypeMapper(typeParameter, t);
|
||||
const iterationMapper = createTypeMapper([typeParameter], [t]);
|
||||
const templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper;
|
||||
const propType = instantiateType(templateType, templateMapper);
|
||||
// If the current iteration type constituent is a string literal type, create a property.
|
||||
@@ -4678,7 +4674,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getErasedTemplateTypeFromMappedType(type: MappedType) {
|
||||
return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType));
|
||||
return instantiateType(getTemplateTypeFromMappedType(type), createTypeEraser([getTypeParameterFromMappedType(type)]));
|
||||
}
|
||||
|
||||
function isGenericMappedType(type: Type) {
|
||||
@@ -4767,19 +4763,79 @@ namespace ts {
|
||||
getPropertiesOfObjectType(type);
|
||||
}
|
||||
|
||||
function getConstraintOfTypeVariable(type: TypeVariable): Type {
|
||||
return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(<TypeParameter>type) : getBaseConstraintOfTypeVariable(type);
|
||||
}
|
||||
|
||||
function getConstraintOfTypeParameter(typeParameter: TypeParameter): Type {
|
||||
return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined;
|
||||
}
|
||||
|
||||
function getBaseConstraintOfTypeVariable(type: TypeVariable): Type {
|
||||
const constraint = getResolvedBaseConstraint(type);
|
||||
return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined;
|
||||
}
|
||||
|
||||
function hasNonCircularBaseConstraint(type: TypeVariable): boolean {
|
||||
return getResolvedBaseConstraint(type) !== circularConstraintType;
|
||||
}
|
||||
|
||||
/**
|
||||
* The apparent type of a type parameter is the base constraint instantiated with the type parameter
|
||||
* as the type argument for the 'this' type.
|
||||
* Return the resolved base constraint of a type variable. The noConstraintType singleton is returned if the
|
||||
* type variable has no constraint, and the circularConstraintType singleton is returned if the constraint
|
||||
* circularly references the type variable.
|
||||
*/
|
||||
function getApparentTypeOfTypeVariable(type: TypeVariable) {
|
||||
function getResolvedBaseConstraint(type: TypeVariable): Type {
|
||||
let typeStack: Type[];
|
||||
let circular: boolean;
|
||||
if (!type.resolvedApparentType) {
|
||||
let constraintType = getConstraintOfTypeVariable(type);
|
||||
while (constraintType && constraintType.flags & TypeFlags.TypeParameter) {
|
||||
constraintType = getConstraintOfTypeVariable(<TypeVariable>constraintType);
|
||||
}
|
||||
type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type);
|
||||
typeStack = [];
|
||||
const constraint = getBaseConstraint(type);
|
||||
type.resolvedApparentType = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type);
|
||||
}
|
||||
return type.resolvedApparentType;
|
||||
|
||||
function getBaseConstraint(t: Type): Type {
|
||||
if (contains(typeStack, t)) {
|
||||
circular = true;
|
||||
return undefined;
|
||||
}
|
||||
typeStack.push(t);
|
||||
const result = computeBaseConstraint(t);
|
||||
typeStack.pop();
|
||||
return result;
|
||||
}
|
||||
|
||||
function computeBaseConstraint(t: Type): Type {
|
||||
if (t.flags & TypeFlags.TypeParameter) {
|
||||
const constraint = getConstraintFromTypeParameter(<TypeParameter>t);
|
||||
return (<TypeParameter>t).isThisType ? constraint :
|
||||
constraint ? getBaseConstraint(constraint) : undefined;
|
||||
}
|
||||
if (t.flags & TypeFlags.UnionOrIntersection) {
|
||||
const types = (<UnionOrIntersectionType>t).types;
|
||||
const baseTypes: Type[] = [];
|
||||
for (const type of types) {
|
||||
const baseType = getBaseConstraint(type);
|
||||
if (baseType) {
|
||||
baseTypes.push(baseType);
|
||||
}
|
||||
}
|
||||
return t.flags & TypeFlags.Union && baseTypes.length === types.length ? getUnionType(baseTypes) :
|
||||
t.flags & TypeFlags.Intersection && baseTypes.length ? getIntersectionType(baseTypes) :
|
||||
undefined;
|
||||
}
|
||||
if (t.flags & TypeFlags.Index) {
|
||||
return stringType;
|
||||
}
|
||||
if (t.flags & TypeFlags.IndexedAccess) {
|
||||
const baseObjectType = getBaseConstraint((<IndexedAccessType>t).objectType);
|
||||
const baseIndexType = getBaseConstraint((<IndexedAccessType>t).indexType);
|
||||
const baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined;
|
||||
return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4788,7 +4844,7 @@ namespace ts {
|
||||
* type itself. Note that the apparent type of a union type is the union type itself.
|
||||
*/
|
||||
function getApparentType(type: Type): Type {
|
||||
const t = type.flags & TypeFlags.TypeVariable ? getApparentTypeOfTypeVariable(<TypeVariable>type) : type;
|
||||
const t = type.flags & TypeFlags.TypeVariable ? getBaseConstraintOfTypeVariable(<TypeVariable>type) || emptyObjectType : type;
|
||||
return t.flags & TypeFlags.StringLike ? globalStringType :
|
||||
t.flags & TypeFlags.NumberLike ? globalNumberType :
|
||||
t.flags & TypeFlags.BooleanLike ? globalBooleanType :
|
||||
@@ -5069,9 +5125,10 @@ namespace ts {
|
||||
if (!links.resolvedSignature) {
|
||||
const parameters: Symbol[] = [];
|
||||
let hasLiteralTypes = false;
|
||||
let minArgumentCount = -1;
|
||||
let minArgumentCount = 0;
|
||||
let thisParameter: Symbol = undefined;
|
||||
let hasThisParameter: boolean;
|
||||
const iife = getImmediatelyInvokedFunctionExpression(declaration);
|
||||
const isJSConstructSignature = isJSDocConstructSignature(declaration);
|
||||
|
||||
// If this is a JSDoc construct signature, then skip the first parameter in the
|
||||
@@ -5098,14 +5155,12 @@ namespace ts {
|
||||
hasLiteralTypes = true;
|
||||
}
|
||||
|
||||
if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) {
|
||||
if (minArgumentCount < 0) {
|
||||
minArgumentCount = i - (hasThisParameter ? 1 : 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// If we see any required parameters, it means the prior ones were not in fact optional.
|
||||
minArgumentCount = -1;
|
||||
// Record a new minimum argument count if this is not an optional parameter
|
||||
const isOptionalParameter = param.initializer || param.questionToken || param.dotDotDotToken ||
|
||||
iife && parameters.length > iife.arguments.length && !param.type ||
|
||||
isJSDocOptionalParameter(param);
|
||||
if (!isOptionalParameter) {
|
||||
minArgumentCount = parameters.length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5120,13 +5175,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
if (minArgumentCount < 0) {
|
||||
minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0);
|
||||
}
|
||||
if (isJSConstructSignature) {
|
||||
minArgumentCount--;
|
||||
}
|
||||
|
||||
const classType = declaration.kind === SyntaxKind.Constructor ?
|
||||
getDeclaredTypeOfClassOrInterface(getMergedSymbol((<ClassDeclaration>declaration.parent).symbol))
|
||||
: undefined;
|
||||
@@ -5347,20 +5395,7 @@ namespace ts {
|
||||
return (<TypeParameterDeclaration>getDeclarationOfKind(type.symbol, SyntaxKind.TypeParameter)).constraint;
|
||||
}
|
||||
|
||||
function hasConstraintReferenceTo(type: Type, target: TypeParameter): boolean {
|
||||
let checked: Type[];
|
||||
while (type && type.flags & TypeFlags.TypeParameter && !((type as TypeParameter).isThisType) && !contains(checked, type)) {
|
||||
if (type === target) {
|
||||
return true;
|
||||
}
|
||||
(checked || (checked = [])).push(type);
|
||||
const constraintDeclaration = getConstraintDeclaration(<TypeParameter>type);
|
||||
type = constraintDeclaration && getTypeFromTypeNode(constraintDeclaration);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getConstraintOfTypeParameter(typeParameter: TypeParameter): Type {
|
||||
function getConstraintFromTypeParameter(typeParameter: TypeParameter): Type {
|
||||
if (!typeParameter.constraint) {
|
||||
if (typeParameter.target) {
|
||||
const targetConstraint = getConstraintOfTypeParameter(typeParameter.target);
|
||||
@@ -5368,23 +5403,12 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
const constraintDeclaration = getConstraintDeclaration(typeParameter);
|
||||
let constraint = getTypeFromTypeNode(constraintDeclaration);
|
||||
if (hasConstraintReferenceTo(constraint, typeParameter)) {
|
||||
error(constraintDeclaration, Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter));
|
||||
constraint = unknownType;
|
||||
}
|
||||
typeParameter.constraint = constraint;
|
||||
typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType;
|
||||
}
|
||||
}
|
||||
return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint;
|
||||
}
|
||||
|
||||
function getConstraintOfTypeVariable(type: TypeVariable): Type {
|
||||
return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(<TypeParameter>type) :
|
||||
type.flags & TypeFlags.IndexedAccess ? (<IndexedAccessType>type).constraint :
|
||||
undefined;
|
||||
}
|
||||
|
||||
function getParentSymbolOfTypeParameter(typeParameter: TypeParameter): Symbol {
|
||||
return getSymbolOfNode(getDeclarationOfKind(typeParameter.symbol, SyntaxKind.TypeParameter).parent);
|
||||
}
|
||||
@@ -6067,24 +6091,6 @@ namespace ts {
|
||||
const type = <IndexedAccessType>createType(TypeFlags.IndexedAccess);
|
||||
type.objectType = objectType;
|
||||
type.indexType = indexType;
|
||||
// We eagerly compute the constraint of the indexed access type such that circularity
|
||||
// errors are immediately caught and reported. For example, class C { x: this["x"] }
|
||||
// becomes an error only when the constraint is eagerly computed.
|
||||
if (type.objectType.flags & TypeFlags.StructuredType) {
|
||||
// The constraint of T[K], where T is an object, union, or intersection type,
|
||||
// is the type of the string index signature of T, if any.
|
||||
type.constraint = getIndexTypeOfType(type.objectType, IndexKind.String);
|
||||
}
|
||||
else if (type.objectType.flags & TypeFlags.TypeVariable) {
|
||||
// The constraint of T[K], where T is a type variable, is A[K], where A is the
|
||||
// apparent type of T.
|
||||
const apparentType = getApparentTypeOfTypeVariable(<TypeVariable>type.objectType);
|
||||
if (apparentType !== emptyObjectType) {
|
||||
type.constraint = isTypeOfKind((<IndexedAccessType>type).indexType, TypeFlags.StringLike) ?
|
||||
getIndexedAccessType(apparentType, (<IndexedAccessType>type).indexType) :
|
||||
getIndexTypeOfType(apparentType, IndexKind.String);
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -6157,7 +6163,7 @@ namespace ts {
|
||||
error(accessExpression, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type));
|
||||
return unknownType;
|
||||
}
|
||||
const mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType);
|
||||
const mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]);
|
||||
const templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper;
|
||||
return instantiateType(getTemplateTypeFromMappedType(type), templateMapper);
|
||||
}
|
||||
@@ -6175,13 +6181,6 @@ namespace ts {
|
||||
if (objectType.flags & TypeFlags.Any) {
|
||||
return objectType;
|
||||
}
|
||||
// We first check that the index type is assignable to 'keyof T' for the object type.
|
||||
if (accessNode) {
|
||||
if (!isTypeAssignableTo(indexType, getIndexType(objectType))) {
|
||||
error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
|
||||
return unknownType;
|
||||
}
|
||||
}
|
||||
// If the object type is a mapped type { [P in K]: E }, we instantiate E using a mapper that substitutes
|
||||
// the index type for P. For example, for an index access { [P in K]: Box<T[P]> }[X], we construct the
|
||||
// type Box<T[X]>.
|
||||
@@ -6267,7 +6266,7 @@ namespace ts {
|
||||
* this function should be called in a left folding style, with left = previous result of getSpreadType
|
||||
* and right = the new element to be spread.
|
||||
*/
|
||||
function getSpreadType(left: Type, right: Type, isFromObjectLiteral: boolean): Type {
|
||||
function getSpreadType(left: Type, right: Type): Type {
|
||||
if (left.flags & TypeFlags.Any || right.flags & TypeFlags.Any) {
|
||||
return anyType;
|
||||
}
|
||||
@@ -6280,10 +6279,10 @@ namespace ts {
|
||||
return left;
|
||||
}
|
||||
if (left.flags & TypeFlags.Union) {
|
||||
return mapType(left, t => getSpreadType(t, right, isFromObjectLiteral));
|
||||
return mapType(left, t => getSpreadType(t, right));
|
||||
}
|
||||
if (right.flags & TypeFlags.Union) {
|
||||
return mapType(right, t => getSpreadType(left, t, isFromObjectLiteral));
|
||||
return mapType(right, t => getSpreadType(left, t));
|
||||
}
|
||||
|
||||
const members = createMap<Symbol>();
|
||||
@@ -6302,18 +6301,18 @@ namespace ts {
|
||||
|
||||
for (const rightProp of getPropertiesOfType(right)) {
|
||||
// we approximate own properties as non-methods plus methods that are inside the object literal
|
||||
const isOwnProperty = !(rightProp.flags & SymbolFlags.Method) || isFromObjectLiteral;
|
||||
const isSetterWithoutGetter = rightProp.flags & SymbolFlags.SetAccessor && !(rightProp.flags & SymbolFlags.GetAccessor);
|
||||
if (getDeclarationModifierFlagsFromSymbol(rightProp) & (ModifierFlags.Private | ModifierFlags.Protected)) {
|
||||
skippedPrivateMembers.set(rightProp.name, true);
|
||||
}
|
||||
else if (isOwnProperty && !isSetterWithoutGetter) {
|
||||
else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) {
|
||||
members.set(rightProp.name, rightProp);
|
||||
}
|
||||
}
|
||||
for (const leftProp of getPropertiesOfType(left)) {
|
||||
if (leftProp.flags & SymbolFlags.SetAccessor && !(leftProp.flags & SymbolFlags.GetAccessor)
|
||||
|| skippedPrivateMembers.has(leftProp.name)) {
|
||||
|| skippedPrivateMembers.has(leftProp.name)
|
||||
|| isClassMethod(leftProp)) {
|
||||
continue;
|
||||
}
|
||||
if (members.has(leftProp.name)) {
|
||||
@@ -6338,6 +6337,10 @@ namespace ts {
|
||||
return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo);
|
||||
}
|
||||
|
||||
function isClassMethod(prop: Symbol) {
|
||||
return prop.flags & SymbolFlags.Method && find(prop.declarations, decl => isClassLike(decl.parent));
|
||||
}
|
||||
|
||||
function createLiteralType(flags: TypeFlags, text: string) {
|
||||
const type = <LiteralType>createType(flags);
|
||||
type.text = text;
|
||||
@@ -6532,16 +6535,16 @@ namespace ts {
|
||||
return <T>instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper));
|
||||
}
|
||||
|
||||
function createUnaryTypeMapper(source: Type, target: Type): TypeMapper {
|
||||
return t => t === source ? target : t;
|
||||
function makeUnaryTypeMapper(source: Type, target: Type) {
|
||||
return (t: Type) => t === source ? target : t;
|
||||
}
|
||||
|
||||
function createBinaryTypeMapper(source1: Type, target1: Type, source2: Type, target2: Type): TypeMapper {
|
||||
return t => t === source1 ? target1 : t === source2 ? target2 : t;
|
||||
function makeBinaryTypeMapper(source1: Type, target1: Type, source2: Type, target2: Type) {
|
||||
return (t: Type) => t === source1 ? target1 : t === source2 ? target2 : t;
|
||||
}
|
||||
|
||||
function createArrayTypeMapper(sources: Type[], targets: Type[]): TypeMapper {
|
||||
return t => {
|
||||
function makeArrayTypeMapper(sources: Type[], targets: Type[]) {
|
||||
return (t: Type) => {
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
if (t === sources[i]) {
|
||||
return targets ? targets[i] : anyType;
|
||||
@@ -6552,11 +6555,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createTypeMapper(sources: Type[], targets: Type[]): TypeMapper {
|
||||
const count = sources.length;
|
||||
const mapper: TypeMapper =
|
||||
count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) :
|
||||
count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) :
|
||||
createArrayTypeMapper(sources, targets);
|
||||
const mapper: TypeMapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) :
|
||||
sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) :
|
||||
makeArrayTypeMapper(sources, targets);
|
||||
mapper.mappedTypes = sources;
|
||||
return mapper;
|
||||
}
|
||||
@@ -6590,7 +6591,13 @@ namespace ts {
|
||||
|
||||
function combineTypeMappers(mapper1: TypeMapper, mapper2: TypeMapper): TypeMapper {
|
||||
const mapper: TypeMapper = t => instantiateType(mapper1(t), mapper2);
|
||||
mapper.mappedTypes = mapper1.mappedTypes;
|
||||
mapper.mappedTypes = concatenate(mapper1.mappedTypes, mapper2.mappedTypes);
|
||||
return mapper;
|
||||
}
|
||||
|
||||
function createReplacementMapper(source: Type, target: Type, baseMapper: TypeMapper) {
|
||||
const mapper: TypeMapper = t => t === source ? target : baseMapper(t);
|
||||
mapper.mappedTypes = baseMapper.mappedTypes;
|
||||
return mapper;
|
||||
}
|
||||
|
||||
@@ -6692,10 +6699,7 @@ namespace ts {
|
||||
if (typeVariable !== mappedTypeVariable) {
|
||||
return mapType(mappedTypeVariable, t => {
|
||||
if (isMappableType(t)) {
|
||||
const replacementMapper = createUnaryTypeMapper(typeVariable, t);
|
||||
const combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper);
|
||||
combinedMapper.mappedTypes = mapper.mappedTypes;
|
||||
return instantiateMappedObjectType(type, combinedMapper);
|
||||
return instantiateMappedObjectType(type, createReplacementMapper(typeVariable, t, mapper));
|
||||
}
|
||||
return t;
|
||||
});
|
||||
@@ -7238,7 +7242,7 @@ namespace ts {
|
||||
return related === RelationComparisonResult.Succeeded;
|
||||
}
|
||||
}
|
||||
if (source.flags & TypeFlags.StructuredOrTypeParameter || target.flags & TypeFlags.StructuredOrTypeParameter) {
|
||||
if (source.flags & TypeFlags.StructuredOrTypeVariable || target.flags & TypeFlags.StructuredOrTypeVariable) {
|
||||
return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined);
|
||||
}
|
||||
return false;
|
||||
@@ -7477,8 +7481,9 @@ namespace ts {
|
||||
}
|
||||
// A type S is related to a type T[K] if S is related to A[K], where K is string-like and
|
||||
// A is the apparent type of S.
|
||||
if ((<IndexedAccessType>target).constraint) {
|
||||
if (result = isRelatedTo(source, (<IndexedAccessType>target).constraint, reportErrors)) {
|
||||
const constraint = getBaseConstraintOfTypeVariable(<IndexedAccessType>target);
|
||||
if (constraint) {
|
||||
if (result = isRelatedTo(source, constraint, reportErrors)) {
|
||||
errorInfo = saveErrorInfo;
|
||||
return result;
|
||||
}
|
||||
@@ -7516,8 +7521,9 @@ namespace ts {
|
||||
else if (source.flags & TypeFlags.IndexedAccess) {
|
||||
// A type S[K] is related to a type T if A[K] is related to T, where K is string-like and
|
||||
// A is the apparent type of S.
|
||||
if ((<IndexedAccessType>source).constraint) {
|
||||
if (result = isRelatedTo((<IndexedAccessType>source).constraint, target, reportErrors)) {
|
||||
const constraint = getBaseConstraintOfTypeVariable(<IndexedAccessType>source);
|
||||
if (constraint) {
|
||||
if (result = isRelatedTo(constraint, target, reportErrors)) {
|
||||
errorInfo = saveErrorInfo;
|
||||
return result;
|
||||
}
|
||||
@@ -10970,23 +10976,23 @@ namespace ts {
|
||||
const func = parameter.parent;
|
||||
if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
|
||||
const iife = getImmediatelyInvokedFunctionExpression(func);
|
||||
if (iife) {
|
||||
if (iife && iife.arguments) {
|
||||
const indexOfParameter = indexOf(func.parameters, parameter);
|
||||
if (iife.arguments && indexOfParameter < iife.arguments.length) {
|
||||
if (parameter.dotDotDotToken) {
|
||||
const restTypes: Type[] = [];
|
||||
for (let i = indexOfParameter; i < iife.arguments.length; i++) {
|
||||
restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i])));
|
||||
}
|
||||
return createArrayType(getUnionType(restTypes));
|
||||
if (parameter.dotDotDotToken) {
|
||||
const restTypes: Type[] = [];
|
||||
for (let i = indexOfParameter; i < iife.arguments.length; i++) {
|
||||
restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i])));
|
||||
}
|
||||
const links = getNodeLinks(iife);
|
||||
const cached = links.resolvedSignature;
|
||||
links.resolvedSignature = anySignature;
|
||||
const type = getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter]));
|
||||
links.resolvedSignature = cached;
|
||||
return type;
|
||||
return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined;
|
||||
}
|
||||
const links = getNodeLinks(iife);
|
||||
const cached = links.resolvedSignature;
|
||||
links.resolvedSignature = anySignature;
|
||||
const type = indexOfParameter < iife.arguments.length ?
|
||||
getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) :
|
||||
parameter.initializer ? undefined : undefinedWideningType;
|
||||
links.resolvedSignature = cached;
|
||||
return type;
|
||||
}
|
||||
const contextualSignature = getContextualSignature(func);
|
||||
if (contextualSignature) {
|
||||
@@ -11695,7 +11701,7 @@ namespace ts {
|
||||
checkExternalEmitHelpers(memberDecl, ExternalEmitHelpers.Assign);
|
||||
}
|
||||
if (propertiesArray.length > 0) {
|
||||
spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true);
|
||||
spread = getSpreadType(spread, createObjectLiteralType());
|
||||
propertiesArray = [];
|
||||
propertiesTable = createMap<Symbol>();
|
||||
hasComputedStringProperty = false;
|
||||
@@ -11707,7 +11713,7 @@ namespace ts {
|
||||
error(memberDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types);
|
||||
return unknownType;
|
||||
}
|
||||
spread = getSpreadType(spread, type, /*isFromObjectLiteral*/ false);
|
||||
spread = getSpreadType(spread, type);
|
||||
offset = i + 1;
|
||||
continue;
|
||||
}
|
||||
@@ -11752,7 +11758,7 @@ namespace ts {
|
||||
|
||||
if (spread !== emptyObjectType) {
|
||||
if (propertiesArray.length > 0) {
|
||||
spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true);
|
||||
spread = getSpreadType(spread, createObjectLiteralType());
|
||||
}
|
||||
if (spread.flags & TypeFlags.Object) {
|
||||
// only set the symbol and flags if this is a (fresh) object type
|
||||
@@ -12574,7 +12580,7 @@ namespace ts {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
return getIndexedAccessType(objectType, indexType, node);
|
||||
return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node);
|
||||
}
|
||||
|
||||
function checkThatExpressionIsProperSymbolReference(expression: Expression, expressionType: Type, reportError: boolean): boolean {
|
||||
@@ -15236,14 +15242,14 @@ namespace ts {
|
||||
function isLiteralContextualType(contextualType: Type) {
|
||||
if (contextualType) {
|
||||
if (contextualType.flags & TypeFlags.TypeVariable) {
|
||||
const apparentType = getApparentTypeOfTypeVariable(<TypeVariable>contextualType);
|
||||
const constraint = getBaseConstraintOfTypeVariable(<TypeVariable>contextualType) || emptyObjectType;
|
||||
// If the type parameter is constrained to the base primitive type we're checking for,
|
||||
// consider this a literal context. For example, given a type parameter 'T extends string',
|
||||
// this causes us to infer string literal types for T.
|
||||
if (apparentType.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum)) {
|
||||
if (constraint.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum)) {
|
||||
return true;
|
||||
}
|
||||
contextualType = apparentType;
|
||||
contextualType = constraint;
|
||||
}
|
||||
return maybeTypeOfKind(contextualType, (TypeFlags.Literal | TypeFlags.Index));
|
||||
}
|
||||
@@ -15441,6 +15447,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
checkSourceElement(node.constraint);
|
||||
const typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
|
||||
if (!hasNonCircularBaseConstraint(typeParameter)) {
|
||||
error(node.constraint, Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter));
|
||||
}
|
||||
getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)));
|
||||
if (produceDiagnostics) {
|
||||
checkTypeNameIsReserved(node.name, Diagnostics.Type_parameter_name_cannot_be_0);
|
||||
@@ -16064,8 +16074,20 @@ namespace ts {
|
||||
forEach(node.types, checkSourceElement);
|
||||
}
|
||||
|
||||
function checkIndexedAccessIndexType(type: Type, accessNode: ElementAccessExpression | IndexedAccessTypeNode) {
|
||||
if (type.flags & TypeFlags.IndexedAccess) {
|
||||
// Check that the index type is assignable to 'keyof T' for the object type.
|
||||
const objectType = (<IndexedAccessType>type).objectType;
|
||||
const indexType = (<IndexedAccessType>type).indexType;
|
||||
if (!isTypeAssignableTo(indexType, getIndexType(objectType))) {
|
||||
error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
function checkIndexedAccessType(node: IndexedAccessTypeNode) {
|
||||
getTypeFromIndexedAccessTypeNode(node);
|
||||
checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node);
|
||||
}
|
||||
|
||||
function checkMappedType(node: MappedTypeNode) {
|
||||
@@ -16073,8 +16095,7 @@ namespace ts {
|
||||
checkSourceElement(node.type);
|
||||
const type = <MappedType>getTypeFromMappedTypeNode(node);
|
||||
const constraintType = getConstraintTypeFromMappedType(type);
|
||||
const keyType = constraintType.flags & TypeFlags.TypeVariable ? getApparentTypeOfTypeVariable(<TypeVariable>constraintType) : constraintType;
|
||||
checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint);
|
||||
checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint);
|
||||
}
|
||||
|
||||
function isPrivateWithinAmbient(node: Node): boolean {
|
||||
|
||||
@@ -212,8 +212,8 @@ namespace ts {
|
||||
shortName: "p",
|
||||
type: "string",
|
||||
isFilePath: true,
|
||||
description: Diagnostics.Compile_the_project_in_the_given_directory,
|
||||
paramType: Diagnostics.DIRECTORY
|
||||
description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json,
|
||||
paramType: Diagnostics.FILE_OR_DIRECTORY
|
||||
},
|
||||
{
|
||||
name: "removeComments",
|
||||
@@ -517,7 +517,7 @@ namespace ts {
|
||||
include: typeAcquisition.include || [],
|
||||
exclude: typeAcquisition.exclude || []
|
||||
};
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
return typeAcquisition;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
entries() {
|
||||
return new MapIterator(this.data, (data, key) => [key, data[key]]);
|
||||
return new MapIterator(this.data, (data, key) => [key, data[key]] as [string, T]);
|
||||
}
|
||||
|
||||
forEach(action: (value: T, key: string) => void): void {
|
||||
|
||||
@@ -2513,7 +2513,7 @@
|
||||
"category": "Message",
|
||||
"code": 6019
|
||||
},
|
||||
"Compile the project in the given directory.": {
|
||||
"Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'": {
|
||||
"category": "Message",
|
||||
"code": 6020
|
||||
},
|
||||
@@ -2573,6 +2573,10 @@
|
||||
"category": "Message",
|
||||
"code": 6039
|
||||
},
|
||||
"FILE OR DIRECTORY": {
|
||||
"category": "Message",
|
||||
"code": 6040
|
||||
},
|
||||
"Compilation complete. Watching for file changes.": {
|
||||
"category": "Message",
|
||||
"code": 6042
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Array that is only intended to be pushed to, never read. */
|
||||
interface Push<T> {
|
||||
export interface Push<T> {
|
||||
push(value: T): void;
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ namespace ts {
|
||||
* Then it computes the set of parent folders for 'directory' that should have the same module resolution result
|
||||
* and for every parent folder in set it adds entry: parent -> module resolution. .
|
||||
* Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts.
|
||||
* Set of parent folders that should have the same result will be:
|
||||
* Set of parent folders that should have the same result will be:
|
||||
* [
|
||||
* /a/b/c/d, /a/b/c, /a/b
|
||||
* ]
|
||||
@@ -1023,7 +1023,7 @@ namespace ts {
|
||||
|
||||
/**
|
||||
* Represents result of search. Normally when searching among several alternatives we treat value `undefined` as indicator
|
||||
* that search fails and we should try another option.
|
||||
* that search fails and we should try another option.
|
||||
* However this does not allow us to represent final result that should be used instead of further searching (i.e. a final result that was found in cache).
|
||||
* SearchResult is used to deal with this issue, its values represents following outcomes:
|
||||
* - undefined - not found, continue searching
|
||||
|
||||
@@ -2825,7 +2825,7 @@
|
||||
EnumLike = Enum | EnumLiteral,
|
||||
UnionOrIntersection = Union | Intersection,
|
||||
StructuredType = Object | Union | Intersection,
|
||||
StructuredOrTypeParameter = StructuredType | TypeParameter | Index,
|
||||
StructuredOrTypeVariable = StructuredType | TypeParameter | Index | IndexedAccess,
|
||||
TypeVariable = TypeParameter | IndexedAccess,
|
||||
|
||||
// 'Narrowable' types are types where narrowing actually narrows.
|
||||
|
||||
+32
-16
@@ -536,53 +536,66 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
public verifyGoToDefinitionIs(endMarker: string | string[]) {
|
||||
this.verifyGoToDefinitionWorker(endMarker instanceof Array ? endMarker : [endMarker]);
|
||||
this.verifyGoToXWorker(endMarker instanceof Array ? endMarker : [endMarker], () => this.getGoToDefinition());
|
||||
}
|
||||
|
||||
public verifyGoToDefinition(arg0: any, endMarkerNames?: string | string[]) {
|
||||
this.verifyGoToX(arg0, endMarkerNames, () => this.getGoToDefinition());
|
||||
}
|
||||
|
||||
private getGoToDefinition(): ts.DefinitionInfo[] {
|
||||
return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition)
|
||||
}
|
||||
|
||||
public verifyGoToType(arg0: any, endMarkerNames?: string | string[]) {
|
||||
this.verifyGoToX(arg0, endMarkerNames, () =>
|
||||
this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition));
|
||||
}
|
||||
|
||||
private verifyGoToX(arg0: any, endMarkerNames: string | string[] | undefined, getDefs: () => ts.DefinitionInfo[] | undefined) {
|
||||
if (endMarkerNames) {
|
||||
this.verifyGoToDefinitionPlain(arg0, endMarkerNames);
|
||||
this.verifyGoToXPlain(arg0, endMarkerNames, getDefs);
|
||||
}
|
||||
else if (arg0 instanceof Array) {
|
||||
const pairs: [string | string[], string | string[]][] = arg0;
|
||||
for (const [start, end] of pairs) {
|
||||
this.verifyGoToDefinitionPlain(start, end);
|
||||
this.verifyGoToXPlain(start, end, getDefs);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const obj: { [startMarkerName: string]: string | string[] } = arg0;
|
||||
for (const startMarkerName in obj) {
|
||||
if (ts.hasProperty(obj, startMarkerName)) {
|
||||
this.verifyGoToDefinitionPlain(startMarkerName, obj[startMarkerName]);
|
||||
this.verifyGoToXPlain(startMarkerName, obj[startMarkerName], getDefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private verifyGoToDefinitionPlain(startMarkerNames: string | string[], endMarkerNames: string | string[]) {
|
||||
private verifyGoToXPlain(startMarkerNames: string | string[], endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | undefined) {
|
||||
if (startMarkerNames instanceof Array) {
|
||||
for (const start of startMarkerNames) {
|
||||
this.verifyGoToDefinitionSingle(start, endMarkerNames);
|
||||
this.verifyGoToXSingle(start, endMarkerNames, getDefs);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.verifyGoToDefinitionSingle(startMarkerNames, endMarkerNames);
|
||||
this.verifyGoToXSingle(startMarkerNames, endMarkerNames, getDefs);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyGoToDefinitionForMarkers(markerNames: string[]) {
|
||||
for (const markerName of markerNames) {
|
||||
this.verifyGoToDefinitionSingle(`${markerName}Reference`, `${markerName}Definition`);
|
||||
this.verifyGoToXSingle(`${markerName}Reference`, `${markerName}Definition`, () => this.getGoToDefinition());
|
||||
}
|
||||
}
|
||||
|
||||
private verifyGoToDefinitionSingle(startMarkerName: string, endMarkerNames: string | string[]) {
|
||||
private verifyGoToXSingle(startMarkerName: string, endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | undefined) {
|
||||
this.goToMarker(startMarkerName);
|
||||
this.verifyGoToDefinitionWorker(endMarkerNames instanceof Array ? endMarkerNames : [endMarkerNames]);
|
||||
this.verifyGoToXWorker(endMarkerNames instanceof Array ? endMarkerNames : [endMarkerNames], getDefs);
|
||||
}
|
||||
|
||||
private verifyGoToDefinitionWorker(endMarkers: string[]) {
|
||||
const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition) || [];
|
||||
private verifyGoToXWorker(endMarkers: string[], getDefs: () => ts.DefinitionInfo[] | undefined) {
|
||||
const definitions = getDefs() || [];
|
||||
|
||||
if (endMarkers.length !== definitions.length) {
|
||||
this.raiseError(`goToDefinitions failed - expected to find ${endMarkers.length} definitions but got ${definitions.length}`);
|
||||
@@ -3038,10 +3051,6 @@ namespace FourSlashInterface {
|
||||
this.state.goToEOF();
|
||||
}
|
||||
|
||||
public type(definitionIndex = 0) {
|
||||
this.state.goToTypeDefinition(definitionIndex);
|
||||
}
|
||||
|
||||
public implementation() {
|
||||
this.state.goToImplementation();
|
||||
}
|
||||
@@ -3209,6 +3218,13 @@ namespace FourSlashInterface {
|
||||
this.state.verifyGoToDefinition(arg0, endMarkerName);
|
||||
}
|
||||
|
||||
public goToType(startMarkerName: string | string[], endMarkerName: string | string[]): void;
|
||||
public goToType(startsAndEnds: [string | string[], string | string[]][]): void;
|
||||
public goToType(startsAndEnds: { [startMarkerName: string]: string | string[] }): void;
|
||||
public goToType(arg0: any, endMarkerName?: string | string[]) {
|
||||
this.state.verifyGoToType(arg0, endMarkerName);
|
||||
}
|
||||
|
||||
public goToDefinitionForMarkers(...markerNames: string[]) {
|
||||
this.state.verifyGoToDefinitionForMarkers(markerNames);
|
||||
}
|
||||
|
||||
+18
-20
@@ -1,8 +1,6 @@
|
||||
/// <reference path='../compiler/utilities.ts' />
|
||||
|
||||
/* @internal */
|
||||
namespace ts.Completions {
|
||||
export function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo {
|
||||
export function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo | undefined {
|
||||
if (isInReferenceComment(sourceFile, position)) {
|
||||
return getTripleSlashReferenceCompletion(sourceFile, position);
|
||||
}
|
||||
@@ -134,7 +132,7 @@ namespace ts.Completions {
|
||||
return uniqueNames;
|
||||
}
|
||||
|
||||
function getStringLiteralCompletionEntries(sourceFile: SourceFile, position: number) {
|
||||
function getStringLiteralCompletionEntries(sourceFile: SourceFile, position: number): CompletionInfo | undefined {
|
||||
const node = findPrecedingToken(position, sourceFile);
|
||||
if (!node || node.kind !== SyntaxKind.StringLiteral) {
|
||||
return undefined;
|
||||
@@ -174,7 +172,7 @@ namespace ts.Completions {
|
||||
return getStringLiteralCompletionEntriesFromModuleNames(<StringLiteral>node);
|
||||
}
|
||||
else {
|
||||
const argumentInfo = SignatureHelp.getContainingArgumentInfo(node, position, sourceFile);
|
||||
const argumentInfo = SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile);
|
||||
if (argumentInfo) {
|
||||
// Get string literal completions from specialized signatures of the target
|
||||
// i.e. declare function f(a: 'A');
|
||||
@@ -188,7 +186,7 @@ namespace ts.Completions {
|
||||
}
|
||||
}
|
||||
|
||||
function getStringLiteralCompletionEntriesFromPropertyAssignment(element: ObjectLiteralElement) {
|
||||
function getStringLiteralCompletionEntriesFromPropertyAssignment(element: ObjectLiteralElement): CompletionInfo | undefined {
|
||||
const type = typeChecker.getContextualType((<ObjectLiteralExpression>element.parent));
|
||||
const entries: CompletionEntry[] = [];
|
||||
if (type) {
|
||||
@@ -199,7 +197,7 @@ namespace ts.Completions {
|
||||
}
|
||||
}
|
||||
|
||||
function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo) {
|
||||
function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo): CompletionInfo | undefined {
|
||||
const candidates: Signature[] = [];
|
||||
const entries: CompletionEntry[] = [];
|
||||
|
||||
@@ -219,7 +217,7 @@ namespace ts.Completions {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getStringLiteralCompletionEntriesFromElementAccess(node: ElementAccessExpression) {
|
||||
function getStringLiteralCompletionEntriesFromElementAccess(node: ElementAccessExpression): CompletionInfo | undefined {
|
||||
const type = typeChecker.getTypeAtLocation(node.expression);
|
||||
const entries: CompletionEntry[] = [];
|
||||
if (type) {
|
||||
@@ -231,7 +229,7 @@ namespace ts.Completions {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getStringLiteralCompletionEntriesFromContextualType(node: StringLiteral) {
|
||||
function getStringLiteralCompletionEntriesFromContextualType(node: StringLiteral): CompletionInfo | undefined {
|
||||
const type = typeChecker.getContextualType(node);
|
||||
if (type) {
|
||||
const entries: CompletionEntry[] = [];
|
||||
@@ -243,7 +241,7 @@ namespace ts.Completions {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function addStringLiteralCompletionsFromType(type: Type, result: CompletionEntry[]): void {
|
||||
function addStringLiteralCompletionsFromType(type: Type, result: Push<CompletionEntry>): void {
|
||||
if (type && type.flags & TypeFlags.TypeParameter) {
|
||||
type = typeChecker.getApparentType(type);
|
||||
}
|
||||
@@ -251,18 +249,18 @@ namespace ts.Completions {
|
||||
return;
|
||||
}
|
||||
if (type.flags & TypeFlags.Union) {
|
||||
forEach((<UnionType>type).types, t => addStringLiteralCompletionsFromType(t, result));
|
||||
}
|
||||
else {
|
||||
if (type.flags & TypeFlags.StringLiteral) {
|
||||
result.push({
|
||||
name: (<LiteralType>type).text,
|
||||
kindModifiers: ScriptElementKindModifier.none,
|
||||
kind: ScriptElementKind.variableElement,
|
||||
sortText: "0"
|
||||
});
|
||||
for (const t of (<UnionType>type).types) {
|
||||
addStringLiteralCompletionsFromType(t, result);
|
||||
}
|
||||
}
|
||||
else if (type.flags & TypeFlags.StringLiteral) {
|
||||
result.push({
|
||||
name: (<LiteralType>type).text,
|
||||
kindModifiers: ScriptElementKindModifier.none,
|
||||
kind: ScriptElementKind.variableElement,
|
||||
sortText: "0"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral): CompletionInfo {
|
||||
|
||||
@@ -325,7 +325,7 @@ namespace ts.FindAllReferences {
|
||||
fileName: targetLabel.getSourceFile().fileName,
|
||||
kind: ScriptElementKind.label,
|
||||
name: labelName,
|
||||
textSpan: createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()),
|
||||
textSpan: createTextSpanFromNode(targetLabel, sourceFile),
|
||||
displayParts: [displayPart(labelName, SymbolDisplayPartKind.text)]
|
||||
};
|
||||
|
||||
@@ -872,7 +872,7 @@ namespace ts.FindAllReferences {
|
||||
fileName: node.getSourceFile().fileName,
|
||||
kind: ScriptElementKind.variableElement,
|
||||
name: "this",
|
||||
textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()),
|
||||
textSpan: createTextSpanFromNode(node),
|
||||
displayParts
|
||||
},
|
||||
references: references
|
||||
@@ -943,7 +943,7 @@ namespace ts.FindAllReferences {
|
||||
fileName: node.getSourceFile().fileName,
|
||||
kind: ScriptElementKind.variableElement,
|
||||
name: type.text,
|
||||
textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()),
|
||||
textSpan: createTextSpanFromNode(node),
|
||||
displayParts: [displayPart(getTextOfNode(node), SymbolDisplayPartKind.stringLiteral)]
|
||||
},
|
||||
references: references
|
||||
|
||||
@@ -15,10 +15,8 @@ namespace ts.GoToDefinition {
|
||||
const typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
|
||||
if (typeReferenceDirective) {
|
||||
const referenceFile = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName);
|
||||
if (referenceFile && referenceFile.resolvedFileName) {
|
||||
return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)];
|
||||
}
|
||||
return undefined;
|
||||
return referenceFile && referenceFile.resolvedFileName &&
|
||||
[getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)];
|
||||
}
|
||||
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
@@ -30,7 +28,7 @@ namespace ts.GoToDefinition {
|
||||
if (isJumpStatementTarget(node)) {
|
||||
const labelName = (<Identifier>node).text;
|
||||
const label = getTargetLabel((<BreakOrContinueStatement>node.parent), (<Identifier>node).text);
|
||||
return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined;
|
||||
return label ? [createDefinitionInfoFromName(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined;
|
||||
}
|
||||
|
||||
const typeChecker = program.getTypeChecker();
|
||||
@@ -171,33 +169,38 @@ namespace ts.GoToDefinition {
|
||||
|
||||
function tryAddSignature(signatureDeclarations: Declaration[], selectConstructors: boolean, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) {
|
||||
const declarations: Declaration[] = [];
|
||||
let definition: Declaration;
|
||||
let definition: Declaration | undefined;
|
||||
|
||||
forEach(signatureDeclarations, d => {
|
||||
if ((selectConstructors && d.kind === SyntaxKind.Constructor) ||
|
||||
(!selectConstructors && (d.kind === SyntaxKind.FunctionDeclaration || d.kind === SyntaxKind.MethodDeclaration || d.kind === SyntaxKind.MethodSignature))) {
|
||||
for (const d of signatureDeclarations) {
|
||||
if (selectConstructors ? d.kind === SyntaxKind.Constructor : isSignatureDeclaration(d)) {
|
||||
declarations.push(d);
|
||||
if ((<FunctionLikeDeclaration>d).body) definition = d;
|
||||
}
|
||||
});
|
||||
|
||||
if (definition) {
|
||||
result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName));
|
||||
return true;
|
||||
}
|
||||
else if (declarations.length) {
|
||||
result.push(createDefinitionInfo(lastOrUndefined(declarations), symbolKind, symbolName, containerName));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (declarations.length) {
|
||||
result.push(createDefinitionInfo(definition || lastOrUndefined(declarations), symbolKind, symbolName, containerName));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function createDefinitionInfo(node: Node, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo {
|
||||
function isSignatureDeclaration(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature
|
||||
}
|
||||
|
||||
/** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
|
||||
function createDefinitionInfo(node: Declaration, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo {
|
||||
return createDefinitionInfoFromName(node.name || node, symbolKind, symbolName, containerName);
|
||||
}
|
||||
|
||||
/** Creates a DefinitionInfo directly from the name of a declaration. */
|
||||
function createDefinitionInfoFromName(name: Node, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo {
|
||||
const sourceFile = name.getSourceFile();
|
||||
return {
|
||||
fileName: node.getSourceFile().fileName,
|
||||
textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()),
|
||||
fileName: sourceFile.fileName,
|
||||
textSpan: createTextSpanFromNode(name, sourceFile),
|
||||
kind: symbolKind,
|
||||
name: symbolName,
|
||||
containerKind: undefined,
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace ts.NavigateTo {
|
||||
matchKind: PatternMatchKind[rawItem.matchKind],
|
||||
isCaseSensitive: rawItem.isCaseSensitive,
|
||||
fileName: rawItem.fileName,
|
||||
textSpan: createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()),
|
||||
textSpan: createTextSpanFromNode(declaration),
|
||||
// TODO(jfreeman): What should be the containerName when the container has a computed name?
|
||||
containerName: container && container.name ? (<Identifier>container.name).text : "",
|
||||
containerKind: container && container.name ? getNodeKind(container) : ""
|
||||
|
||||
@@ -591,7 +591,7 @@ namespace ts.NavigationBar {
|
||||
function getNodeSpan(node: Node): TextSpan {
|
||||
return node.kind === SyntaxKind.SourceFile
|
||||
? createTextSpanFromBounds(node.getFullStart(), node.getEnd())
|
||||
: createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd());
|
||||
: createTextSpanFromNode(node, curSourceFile);
|
||||
}
|
||||
|
||||
function getFunctionOrClassName(node: FunctionExpression | FunctionDeclaration | ArrowFunction | ClassLikeDeclaration): string {
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace ts.OutliningElementsCollector {
|
||||
if (hintSpanNode && startElement && endElement) {
|
||||
const span: OutliningSpan = {
|
||||
textSpan: createTextSpanFromBounds(startElement.pos, endElement.end),
|
||||
hintSpan: createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end),
|
||||
hintSpan: createTextSpanFromNode(hintSpanNode, sourceFile),
|
||||
bannerText: collapseText,
|
||||
autoCollapse: autoCollapse
|
||||
};
|
||||
@@ -135,7 +135,7 @@ namespace ts.OutliningElementsCollector {
|
||||
|
||||
// Block was a standalone block. In this case we want to only collapse
|
||||
// the span of the block, independent of any parent span.
|
||||
const span = createTextSpanFromBounds(n.getStart(), n.end);
|
||||
const span = createTextSpanFromNode(n);
|
||||
elements.push({
|
||||
textSpan: span,
|
||||
hintSpan: span,
|
||||
|
||||
@@ -260,7 +260,7 @@ namespace ts.SignatureHelp {
|
||||
* Returns relevant information for the argument list and the current argument if we are
|
||||
* in the argument of an invocation; returns undefined otherwise.
|
||||
*/
|
||||
function getImmediatelyContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo {
|
||||
export function getImmediatelyContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo {
|
||||
if (node.parent.kind === SyntaxKind.CallExpression || node.parent.kind === SyntaxKind.NewExpression) {
|
||||
const callExpression = <CallExpression>node.parent;
|
||||
// There are 3 cases to handle:
|
||||
|
||||
@@ -1112,6 +1112,10 @@ namespace ts {
|
||||
return !tripleSlashDirectivePrefixRegex.test(commentText);
|
||||
}
|
||||
}
|
||||
|
||||
export function createTextSpanFromNode(node: Node, sourceFile?: SourceFile): TextSpan {
|
||||
return createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd());
|
||||
}
|
||||
}
|
||||
|
||||
// Display-part writer helpers
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(3,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(7,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(15,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(19,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(23,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(27,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(28,5): error TS2502: 'y' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(29,5): error TS2502: 'z' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(38,24): error TS2313: Type parameter 'T' has a circular constraint.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(38,30): error TS2536: Type '"hello"' cannot be used to index type 'T'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (8 errors) ====
|
||||
==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (6 errors) ====
|
||||
|
||||
type T1 = {
|
||||
x: T1["x"]; // Error
|
||||
@@ -27,9 +25,7 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(29,5): error
|
||||
let x2x = x2.x;
|
||||
|
||||
interface T3<T extends T3<T>> {
|
||||
x: T["x"]; // Error
|
||||
~~~~~~~~~~
|
||||
!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
x: T["x"];
|
||||
}
|
||||
|
||||
interface T4<T extends T4<T>> {
|
||||
@@ -45,13 +41,21 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(29,5): error
|
||||
}
|
||||
|
||||
class C2 {
|
||||
x: this["y"]; // Error
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
y: this["z"]; // Error
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2502: 'y' is referenced directly or indirectly in its own type annotation.
|
||||
z: this["x"]; // Error
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2502: 'z' is referenced directly or indirectly in its own type annotation.
|
||||
}
|
||||
x: this["y"];
|
||||
y: this["z"];
|
||||
z: this["x"];
|
||||
}
|
||||
|
||||
// Repro from #12627
|
||||
|
||||
interface Foo {
|
||||
hello: boolean;
|
||||
}
|
||||
|
||||
function foo<T extends Foo | T["hello"]>() {
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2313: Type parameter 'T' has a circular constraint.
|
||||
~~~~~~~~~~
|
||||
!!! error TS2536: Type '"hello"' cannot be used to index type 'T'.
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ declare let x2: T2<"x">;
|
||||
let x2x = x2.x;
|
||||
|
||||
interface T3<T extends T3<T>> {
|
||||
x: T["x"]; // Error
|
||||
x: T["x"];
|
||||
}
|
||||
|
||||
interface T4<T extends T4<T>> {
|
||||
@@ -25,10 +25,20 @@ class C1 {
|
||||
}
|
||||
|
||||
class C2 {
|
||||
x: this["y"]; // Error
|
||||
y: this["z"]; // Error
|
||||
z: this["x"]; // Error
|
||||
}
|
||||
x: this["y"];
|
||||
y: this["z"];
|
||||
z: this["x"];
|
||||
}
|
||||
|
||||
// Repro from #12627
|
||||
|
||||
interface Foo {
|
||||
hello: boolean;
|
||||
}
|
||||
|
||||
function foo<T extends Foo | T["hello"]>() {
|
||||
}
|
||||
|
||||
|
||||
//// [circularIndexedAccessErrors.js]
|
||||
var x2x = x2.x;
|
||||
@@ -42,6 +52,8 @@ var C2 = (function () {
|
||||
}
|
||||
return C2;
|
||||
}());
|
||||
function foo() {
|
||||
}
|
||||
|
||||
|
||||
//// [circularIndexedAccessErrors.d.ts]
|
||||
@@ -68,3 +80,7 @@ declare class C2 {
|
||||
y: this["z"];
|
||||
z: this["x"];
|
||||
}
|
||||
interface Foo {
|
||||
hello: boolean;
|
||||
}
|
||||
declare function foo<T extends Foo | T["hello"]>(): void;
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
// contextually typed parameters.
|
||||
let twelve = (f => f(12))(i => i);
|
||||
let eleven = (o => o.a(11))({ a: function(n) { return n; } });
|
||||
// missing arguments
|
||||
(function(x, undefined) { return x; })(42);
|
||||
((x, y, z) => 42)();
|
||||
|
||||
|
||||
//// [contextuallyTypedIife.js]
|
||||
@@ -102,3 +105,6 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } });
|
||||
// contextually typed parameters.
|
||||
var twelve = (function (f) { return f(12); })(function (i) { return i; });
|
||||
var eleven = (function (o) { return o.a(11); })({ a: function (n) { return n; } });
|
||||
// missing arguments
|
||||
(function (x, undefined) { return x; })(42);
|
||||
(function (x, y, z) { return 42; })();
|
||||
|
||||
@@ -119,3 +119,14 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } });
|
||||
>n : Symbol(n, Decl(contextuallyTypedIife.ts, 28, 42))
|
||||
>n : Symbol(n, Decl(contextuallyTypedIife.ts, 28, 42))
|
||||
|
||||
// missing arguments
|
||||
(function(x, undefined) { return x; })(42);
|
||||
>x : Symbol(x, Decl(contextuallyTypedIife.ts, 30, 10))
|
||||
>undefined : Symbol(undefined, Decl(contextuallyTypedIife.ts, 30, 12))
|
||||
>x : Symbol(x, Decl(contextuallyTypedIife.ts, 30, 10))
|
||||
|
||||
((x, y, z) => 42)();
|
||||
>x : Symbol(x, Decl(contextuallyTypedIife.ts, 31, 2))
|
||||
>y : Symbol(y, Decl(contextuallyTypedIife.ts, 31, 4))
|
||||
>z : Symbol(z, Decl(contextuallyTypedIife.ts, 31, 7))
|
||||
|
||||
|
||||
@@ -250,3 +250,22 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } });
|
||||
>n : any
|
||||
>n : any
|
||||
|
||||
// missing arguments
|
||||
(function(x, undefined) { return x; })(42);
|
||||
>(function(x, undefined) { return x; })(42) : number
|
||||
>(function(x, undefined) { return x; }) : (x: number, undefined: any) => number
|
||||
>function(x, undefined) { return x; } : (x: number, undefined: any) => number
|
||||
>x : number
|
||||
>undefined : any
|
||||
>x : number
|
||||
>42 : 42
|
||||
|
||||
((x, y, z) => 42)();
|
||||
>((x, y, z) => 42)() : number
|
||||
>((x, y, z) => 42) : (x: any, y: any, z: any) => number
|
||||
>(x, y, z) => 42 : (x: any, y: any, z: any) => number
|
||||
>x : any
|
||||
>y : any
|
||||
>z : any
|
||||
>42 : 42
|
||||
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
//// [contextuallyTypedIifeStrict.ts]
|
||||
// arrow
|
||||
(jake => { })("build");
|
||||
// function expression
|
||||
(function (cats) { })("lol");
|
||||
// Lots of Irritating Superfluous Parentheses
|
||||
(function (x) { } ("!"));
|
||||
((((function (y) { }))))("-");
|
||||
// multiple arguments
|
||||
((a, b, c) => { })("foo", 101, false);
|
||||
// default parameters
|
||||
((m = 10) => m + 1)(12);
|
||||
((n = 10) => n + 1)();
|
||||
// optional parameters
|
||||
((j?) => j + 1)(12);
|
||||
((k?) => k + 1)();
|
||||
((l, o?) => l + o)(12); // o should be any
|
||||
// rest parameters
|
||||
((...numbers) => numbers.every(n => n > 0))(5,6,7);
|
||||
((...mixed) => mixed.every(n => !!n))(5,'oops','oh no');
|
||||
((...noNumbers) => noNumbers.some(n => n > 0))();
|
||||
((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10);
|
||||
// destructuring parameters (with defaults too!)
|
||||
(({ q }) => q)({ q : 13 });
|
||||
(({ p = 14 }) => p)({ p : 15 });
|
||||
(({ r = 17 } = { r: 18 }) => r)({r : 19});
|
||||
(({ u = 22 } = { u: 23 }) => u)();
|
||||
// contextually typed parameters.
|
||||
let twelve = (f => f(12))(i => i);
|
||||
let eleven = (o => o.a(11))({ a: function(n) { return n; } });
|
||||
// missing arguments
|
||||
(function(x, undefined) { return x; })(42);
|
||||
((x, y, z) => 42)();
|
||||
|
||||
|
||||
//// [contextuallyTypedIifeStrict.js]
|
||||
// arrow
|
||||
(function (jake) { })("build");
|
||||
// function expression
|
||||
(function (cats) { })("lol");
|
||||
// Lots of Irritating Superfluous Parentheses
|
||||
(function (x) { }("!"));
|
||||
((((function (y) { }))))("-");
|
||||
// multiple arguments
|
||||
(function (a, b, c) { })("foo", 101, false);
|
||||
// default parameters
|
||||
(function (m) {
|
||||
if (m === void 0) { m = 10; }
|
||||
return m + 1;
|
||||
})(12);
|
||||
(function (n) {
|
||||
if (n === void 0) { n = 10; }
|
||||
return n + 1;
|
||||
})();
|
||||
// optional parameters
|
||||
(function (j) { return j + 1; })(12);
|
||||
(function (k) { return k + 1; })();
|
||||
(function (l, o) { return l + o; })(12); // o should be any
|
||||
// rest parameters
|
||||
(function () {
|
||||
var numbers = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
numbers[_i] = arguments[_i];
|
||||
}
|
||||
return numbers.every(function (n) { return n > 0; });
|
||||
})(5, 6, 7);
|
||||
(function () {
|
||||
var mixed = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
mixed[_i] = arguments[_i];
|
||||
}
|
||||
return mixed.every(function (n) { return !!n; });
|
||||
})(5, 'oops', 'oh no');
|
||||
(function () {
|
||||
var noNumbers = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
noNumbers[_i] = arguments[_i];
|
||||
}
|
||||
return noNumbers.some(function (n) { return n > 0; });
|
||||
})();
|
||||
(function (first) {
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
return first ? [] : rest.map(function (n) { return n > 0; });
|
||||
})(8, 9, 10);
|
||||
// destructuring parameters (with defaults too!)
|
||||
(function (_a) {
|
||||
var q = _a.q;
|
||||
return q;
|
||||
})({ q: 13 });
|
||||
(function (_a) {
|
||||
var _b = _a.p, p = _b === void 0 ? 14 : _b;
|
||||
return p;
|
||||
})({ p: 15 });
|
||||
(function (_a) {
|
||||
var _b = (_a === void 0 ? { r: 18 } : _a).r, r = _b === void 0 ? 17 : _b;
|
||||
return r;
|
||||
})({ r: 19 });
|
||||
(function (_a) {
|
||||
var _b = (_a === void 0 ? { u: 23 } : _a).u, u = _b === void 0 ? 22 : _b;
|
||||
return u;
|
||||
})();
|
||||
// contextually typed parameters.
|
||||
var twelve = (function (f) { return f(12); })(function (i) { return i; });
|
||||
var eleven = (function (o) { return o.a(11); })({ a: function (n) { return n; } });
|
||||
// missing arguments
|
||||
(function (x, undefined) { return x; })(42);
|
||||
(function (x, y, z) { return 42; })();
|
||||
@@ -0,0 +1,132 @@
|
||||
=== tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts ===
|
||||
// arrow
|
||||
(jake => { })("build");
|
||||
>jake : Symbol(jake, Decl(contextuallyTypedIifeStrict.ts, 1, 1))
|
||||
|
||||
// function expression
|
||||
(function (cats) { })("lol");
|
||||
>cats : Symbol(cats, Decl(contextuallyTypedIifeStrict.ts, 3, 11))
|
||||
|
||||
// Lots of Irritating Superfluous Parentheses
|
||||
(function (x) { } ("!"));
|
||||
>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 5, 11))
|
||||
|
||||
((((function (y) { }))))("-");
|
||||
>y : Symbol(y, Decl(contextuallyTypedIifeStrict.ts, 6, 14))
|
||||
|
||||
// multiple arguments
|
||||
((a, b, c) => { })("foo", 101, false);
|
||||
>a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 8, 2))
|
||||
>b : Symbol(b, Decl(contextuallyTypedIifeStrict.ts, 8, 4))
|
||||
>c : Symbol(c, Decl(contextuallyTypedIifeStrict.ts, 8, 7))
|
||||
|
||||
// default parameters
|
||||
((m = 10) => m + 1)(12);
|
||||
>m : Symbol(m, Decl(contextuallyTypedIifeStrict.ts, 10, 2))
|
||||
>m : Symbol(m, Decl(contextuallyTypedIifeStrict.ts, 10, 2))
|
||||
|
||||
((n = 10) => n + 1)();
|
||||
>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 11, 2))
|
||||
>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 11, 2))
|
||||
|
||||
// optional parameters
|
||||
((j?) => j + 1)(12);
|
||||
>j : Symbol(j, Decl(contextuallyTypedIifeStrict.ts, 13, 2))
|
||||
>j : Symbol(j, Decl(contextuallyTypedIifeStrict.ts, 13, 2))
|
||||
|
||||
((k?) => k + 1)();
|
||||
>k : Symbol(k, Decl(contextuallyTypedIifeStrict.ts, 14, 2))
|
||||
>k : Symbol(k, Decl(contextuallyTypedIifeStrict.ts, 14, 2))
|
||||
|
||||
((l, o?) => l + o)(12); // o should be any
|
||||
>l : Symbol(l, Decl(contextuallyTypedIifeStrict.ts, 15, 2))
|
||||
>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 15, 4))
|
||||
>l : Symbol(l, Decl(contextuallyTypedIifeStrict.ts, 15, 2))
|
||||
>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 15, 4))
|
||||
|
||||
// rest parameters
|
||||
((...numbers) => numbers.every(n => n > 0))(5,6,7);
|
||||
>numbers : Symbol(numbers, Decl(contextuallyTypedIifeStrict.ts, 17, 2))
|
||||
>numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --))
|
||||
>numbers : Symbol(numbers, Decl(contextuallyTypedIifeStrict.ts, 17, 2))
|
||||
>every : Symbol(Array.every, Decl(lib.d.ts, --, --))
|
||||
>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 17, 31))
|
||||
>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 17, 31))
|
||||
|
||||
((...mixed) => mixed.every(n => !!n))(5,'oops','oh no');
|
||||
>mixed : Symbol(mixed, Decl(contextuallyTypedIifeStrict.ts, 18, 2))
|
||||
>mixed.every : Symbol(Array.every, Decl(lib.d.ts, --, --))
|
||||
>mixed : Symbol(mixed, Decl(contextuallyTypedIifeStrict.ts, 18, 2))
|
||||
>every : Symbol(Array.every, Decl(lib.d.ts, --, --))
|
||||
>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 18, 27))
|
||||
>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 18, 27))
|
||||
|
||||
((...noNumbers) => noNumbers.some(n => n > 0))();
|
||||
>noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIifeStrict.ts, 19, 2))
|
||||
>noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --))
|
||||
>noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIifeStrict.ts, 19, 2))
|
||||
>some : Symbol(Array.some, Decl(lib.d.ts, --, --))
|
||||
>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 19, 34))
|
||||
>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 19, 34))
|
||||
|
||||
((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10);
|
||||
>first : Symbol(first, Decl(contextuallyTypedIifeStrict.ts, 20, 2))
|
||||
>rest : Symbol(rest, Decl(contextuallyTypedIifeStrict.ts, 20, 8))
|
||||
>first : Symbol(first, Decl(contextuallyTypedIifeStrict.ts, 20, 2))
|
||||
>rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>rest : Symbol(rest, Decl(contextuallyTypedIifeStrict.ts, 20, 8))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 20, 43))
|
||||
>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 20, 43))
|
||||
|
||||
// destructuring parameters (with defaults too!)
|
||||
(({ q }) => q)({ q : 13 });
|
||||
>q : Symbol(q, Decl(contextuallyTypedIifeStrict.ts, 22, 3))
|
||||
>q : Symbol(q, Decl(contextuallyTypedIifeStrict.ts, 22, 3))
|
||||
>q : Symbol(q, Decl(contextuallyTypedIifeStrict.ts, 22, 16))
|
||||
|
||||
(({ p = 14 }) => p)({ p : 15 });
|
||||
>p : Symbol(p, Decl(contextuallyTypedIifeStrict.ts, 23, 3))
|
||||
>p : Symbol(p, Decl(contextuallyTypedIifeStrict.ts, 23, 3))
|
||||
>p : Symbol(p, Decl(contextuallyTypedIifeStrict.ts, 23, 21))
|
||||
|
||||
(({ r = 17 } = { r: 18 }) => r)({r : 19});
|
||||
>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 3))
|
||||
>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 16))
|
||||
>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 3))
|
||||
>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 33))
|
||||
|
||||
(({ u = 22 } = { u: 23 }) => u)();
|
||||
>u : Symbol(u, Decl(contextuallyTypedIifeStrict.ts, 25, 3))
|
||||
>u : Symbol(u, Decl(contextuallyTypedIifeStrict.ts, 25, 16))
|
||||
>u : Symbol(u, Decl(contextuallyTypedIifeStrict.ts, 25, 3))
|
||||
|
||||
// contextually typed parameters.
|
||||
let twelve = (f => f(12))(i => i);
|
||||
>twelve : Symbol(twelve, Decl(contextuallyTypedIifeStrict.ts, 27, 3))
|
||||
>f : Symbol(f, Decl(contextuallyTypedIifeStrict.ts, 27, 14))
|
||||
>f : Symbol(f, Decl(contextuallyTypedIifeStrict.ts, 27, 14))
|
||||
>i : Symbol(i, Decl(contextuallyTypedIifeStrict.ts, 27, 26))
|
||||
>i : Symbol(i, Decl(contextuallyTypedIifeStrict.ts, 27, 26))
|
||||
|
||||
let eleven = (o => o.a(11))({ a: function(n) { return n; } });
|
||||
>eleven : Symbol(eleven, Decl(contextuallyTypedIifeStrict.ts, 28, 3))
|
||||
>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 28, 14))
|
||||
>o.a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 28, 29))
|
||||
>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 28, 14))
|
||||
>a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 28, 29))
|
||||
>a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 28, 29))
|
||||
>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 28, 42))
|
||||
>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 28, 42))
|
||||
|
||||
// missing arguments
|
||||
(function(x, undefined) { return x; })(42);
|
||||
>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 30, 10))
|
||||
>undefined : Symbol(undefined, Decl(contextuallyTypedIifeStrict.ts, 30, 12))
|
||||
>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 30, 10))
|
||||
|
||||
((x, y, z) => 42)();
|
||||
>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 31, 2))
|
||||
>y : Symbol(y, Decl(contextuallyTypedIifeStrict.ts, 31, 4))
|
||||
>z : Symbol(z, Decl(contextuallyTypedIifeStrict.ts, 31, 7))
|
||||
|
||||
@@ -0,0 +1,271 @@
|
||||
=== tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts ===
|
||||
// arrow
|
||||
(jake => { })("build");
|
||||
>(jake => { })("build") : void
|
||||
>(jake => { }) : (jake: string) => void
|
||||
>jake => { } : (jake: string) => void
|
||||
>jake : string
|
||||
>"build" : "build"
|
||||
|
||||
// function expression
|
||||
(function (cats) { })("lol");
|
||||
>(function (cats) { })("lol") : void
|
||||
>(function (cats) { }) : (cats: string) => void
|
||||
>function (cats) { } : (cats: string) => void
|
||||
>cats : string
|
||||
>"lol" : "lol"
|
||||
|
||||
// Lots of Irritating Superfluous Parentheses
|
||||
(function (x) { } ("!"));
|
||||
>(function (x) { } ("!")) : void
|
||||
>function (x) { } ("!") : void
|
||||
>function (x) { } : (x: string) => void
|
||||
>x : string
|
||||
>"!" : "!"
|
||||
|
||||
((((function (y) { }))))("-");
|
||||
>((((function (y) { }))))("-") : void
|
||||
>((((function (y) { })))) : (y: string) => void
|
||||
>(((function (y) { }))) : (y: string) => void
|
||||
>((function (y) { })) : (y: string) => void
|
||||
>(function (y) { }) : (y: string) => void
|
||||
>function (y) { } : (y: string) => void
|
||||
>y : string
|
||||
>"-" : "-"
|
||||
|
||||
// multiple arguments
|
||||
((a, b, c) => { })("foo", 101, false);
|
||||
>((a, b, c) => { })("foo", 101, false) : void
|
||||
>((a, b, c) => { }) : (a: string, b: number, c: boolean) => void
|
||||
>(a, b, c) => { } : (a: string, b: number, c: boolean) => void
|
||||
>a : string
|
||||
>b : number
|
||||
>c : boolean
|
||||
>"foo" : "foo"
|
||||
>101 : 101
|
||||
>false : false
|
||||
|
||||
// default parameters
|
||||
((m = 10) => m + 1)(12);
|
||||
>((m = 10) => m + 1)(12) : number
|
||||
>((m = 10) => m + 1) : (m?: number) => number
|
||||
>(m = 10) => m + 1 : (m?: number) => number
|
||||
>m : number
|
||||
>10 : 10
|
||||
>m + 1 : number
|
||||
>m : number
|
||||
>1 : 1
|
||||
>12 : 12
|
||||
|
||||
((n = 10) => n + 1)();
|
||||
>((n = 10) => n + 1)() : number
|
||||
>((n = 10) => n + 1) : (n?: number) => number
|
||||
>(n = 10) => n + 1 : (n?: number) => number
|
||||
>n : number
|
||||
>10 : 10
|
||||
>n + 1 : number
|
||||
>n : number
|
||||
>1 : 1
|
||||
|
||||
// optional parameters
|
||||
((j?) => j + 1)(12);
|
||||
>((j?) => j + 1)(12) : number
|
||||
>((j?) => j + 1) : (j?: number | undefined) => number
|
||||
>(j?) => j + 1 : (j?: number | undefined) => number
|
||||
>j : number | undefined
|
||||
>j + 1 : number
|
||||
>j : number | undefined
|
||||
>1 : 1
|
||||
>12 : 12
|
||||
|
||||
((k?) => k + 1)();
|
||||
>((k?) => k + 1)() : number
|
||||
>((k?) => k + 1) : (k?: undefined) => number
|
||||
>(k?) => k + 1 : (k?: undefined) => number
|
||||
>k : undefined
|
||||
>k + 1 : number
|
||||
>k : undefined
|
||||
>1 : 1
|
||||
|
||||
((l, o?) => l + o)(12); // o should be any
|
||||
>((l, o?) => l + o)(12) : number
|
||||
>((l, o?) => l + o) : (l: number, o?: undefined) => number
|
||||
>(l, o?) => l + o : (l: number, o?: undefined) => number
|
||||
>l : number
|
||||
>o : undefined
|
||||
>l + o : number
|
||||
>l : number
|
||||
>o : undefined
|
||||
>12 : 12
|
||||
|
||||
// rest parameters
|
||||
((...numbers) => numbers.every(n => n > 0))(5,6,7);
|
||||
>((...numbers) => numbers.every(n => n > 0))(5,6,7) : boolean
|
||||
>((...numbers) => numbers.every(n => n > 0)) : (...numbers: number[]) => boolean
|
||||
>(...numbers) => numbers.every(n => n > 0) : (...numbers: number[]) => boolean
|
||||
>numbers : number[]
|
||||
>numbers.every(n => n > 0) : boolean
|
||||
>numbers.every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean
|
||||
>numbers : number[]
|
||||
>every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean
|
||||
>n => n > 0 : (n: number) => boolean
|
||||
>n : number
|
||||
>n > 0 : boolean
|
||||
>n : number
|
||||
>0 : 0
|
||||
>5 : 5
|
||||
>6 : 6
|
||||
>7 : 7
|
||||
|
||||
((...mixed) => mixed.every(n => !!n))(5,'oops','oh no');
|
||||
>((...mixed) => mixed.every(n => !!n))(5,'oops','oh no') : boolean
|
||||
>((...mixed) => mixed.every(n => !!n)) : (...mixed: (string | number)[]) => boolean
|
||||
>(...mixed) => mixed.every(n => !!n) : (...mixed: (string | number)[]) => boolean
|
||||
>mixed : (string | number)[]
|
||||
>mixed.every(n => !!n) : boolean
|
||||
>mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean
|
||||
>mixed : (string | number)[]
|
||||
>every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean
|
||||
>n => !!n : (n: string | number) => boolean
|
||||
>n : string | number
|
||||
>!!n : boolean
|
||||
>!n : boolean
|
||||
>n : string | number
|
||||
>5 : 5
|
||||
>'oops' : "oops"
|
||||
>'oh no' : "oh no"
|
||||
|
||||
((...noNumbers) => noNumbers.some(n => n > 0))();
|
||||
>((...noNumbers) => noNumbers.some(n => n > 0))() : boolean
|
||||
>((...noNumbers) => noNumbers.some(n => n > 0)) : (...noNumbers: any[]) => boolean
|
||||
>(...noNumbers) => noNumbers.some(n => n > 0) : (...noNumbers: any[]) => boolean
|
||||
>noNumbers : any[]
|
||||
>noNumbers.some(n => n > 0) : boolean
|
||||
>noNumbers.some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean
|
||||
>noNumbers : any[]
|
||||
>some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean
|
||||
>n => n > 0 : (n: any) => boolean
|
||||
>n : any
|
||||
>n > 0 : boolean
|
||||
>n : any
|
||||
>0 : 0
|
||||
|
||||
((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10);
|
||||
>((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10) : boolean[]
|
||||
>((first, ...rest) => first ? [] : rest.map(n => n > 0)) : (first: number, ...rest: number[]) => boolean[]
|
||||
>(first, ...rest) => first ? [] : rest.map(n => n > 0) : (first: number, ...rest: number[]) => boolean[]
|
||||
>first : number
|
||||
>rest : number[]
|
||||
>first ? [] : rest.map(n => n > 0) : boolean[]
|
||||
>first : number
|
||||
>[] : never[]
|
||||
>rest.map(n => n > 0) : boolean[]
|
||||
>rest.map : { <U>(this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; <U>(this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; }
|
||||
>rest : number[]
|
||||
>map : { <U>(this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; <U>(this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; }
|
||||
>n => n > 0 : (n: number) => boolean
|
||||
>n : number
|
||||
>n > 0 : boolean
|
||||
>n : number
|
||||
>0 : 0
|
||||
>8 : 8
|
||||
>9 : 9
|
||||
>10 : 10
|
||||
|
||||
// destructuring parameters (with defaults too!)
|
||||
(({ q }) => q)({ q : 13 });
|
||||
>(({ q }) => q)({ q : 13 }) : number
|
||||
>(({ q }) => q) : ({q}: { q: number; }) => number
|
||||
>({ q }) => q : ({q}: { q: number; }) => number
|
||||
>q : number
|
||||
>q : number
|
||||
>{ q : 13 } : { q: number; }
|
||||
>q : number
|
||||
>13 : 13
|
||||
|
||||
(({ p = 14 }) => p)({ p : 15 });
|
||||
>(({ p = 14 }) => p)({ p : 15 }) : number
|
||||
>(({ p = 14 }) => p) : ({p}: { p: number; }) => number
|
||||
>({ p = 14 }) => p : ({p}: { p: number; }) => number
|
||||
>p : number
|
||||
>14 : 14
|
||||
>p : number
|
||||
>{ p : 15 } : { p: number; }
|
||||
>p : number
|
||||
>15 : 15
|
||||
|
||||
(({ r = 17 } = { r: 18 }) => r)({r : 19});
|
||||
>(({ r = 17 } = { r: 18 }) => r)({r : 19}) : number
|
||||
>(({ r = 17 } = { r: 18 }) => r) : ({r}?: { r: number; }) => number
|
||||
>({ r = 17 } = { r: 18 }) => r : ({r}?: { r: number; }) => number
|
||||
>r : number
|
||||
>17 : 17
|
||||
>{ r: 18 } : { r: number; }
|
||||
>r : number
|
||||
>18 : 18
|
||||
>r : number
|
||||
>{r : 19} : { r: number; }
|
||||
>r : number
|
||||
>19 : 19
|
||||
|
||||
(({ u = 22 } = { u: 23 }) => u)();
|
||||
>(({ u = 22 } = { u: 23 }) => u)() : number
|
||||
>(({ u = 22 } = { u: 23 }) => u) : ({u}?: { u?: number; }) => number
|
||||
>({ u = 22 } = { u: 23 }) => u : ({u}?: { u?: number; }) => number
|
||||
>u : number
|
||||
>22 : 22
|
||||
>{ u: 23 } : { u?: number; }
|
||||
>u : number
|
||||
>23 : 23
|
||||
>u : number
|
||||
|
||||
// contextually typed parameters.
|
||||
let twelve = (f => f(12))(i => i);
|
||||
>twelve : any
|
||||
>(f => f(12))(i => i) : any
|
||||
>(f => f(12)) : (f: (i: any) => any) => any
|
||||
>f => f(12) : (f: (i: any) => any) => any
|
||||
>f : (i: any) => any
|
||||
>f(12) : any
|
||||
>f : (i: any) => any
|
||||
>12 : 12
|
||||
>i => i : (i: any) => any
|
||||
>i : any
|
||||
>i : any
|
||||
|
||||
let eleven = (o => o.a(11))({ a: function(n) { return n; } });
|
||||
>eleven : any
|
||||
>(o => o.a(11))({ a: function(n) { return n; } }) : any
|
||||
>(o => o.a(11)) : (o: { a: (n: any) => any; }) => any
|
||||
>o => o.a(11) : (o: { a: (n: any) => any; }) => any
|
||||
>o : { a: (n: any) => any; }
|
||||
>o.a(11) : any
|
||||
>o.a : (n: any) => any
|
||||
>o : { a: (n: any) => any; }
|
||||
>a : (n: any) => any
|
||||
>11 : 11
|
||||
>{ a: function(n) { return n; } } : { a: (n: any) => any; }
|
||||
>a : (n: any) => any
|
||||
>function(n) { return n; } : (n: any) => any
|
||||
>n : any
|
||||
>n : any
|
||||
|
||||
// missing arguments
|
||||
(function(x, undefined) { return x; })(42);
|
||||
>(function(x, undefined) { return x; })(42) : number
|
||||
>(function(x, undefined) { return x; }) : (x: number, undefined: undefined) => number
|
||||
>function(x, undefined) { return x; } : (x: number, undefined: undefined) => number
|
||||
>x : number
|
||||
>undefined : undefined
|
||||
>x : number
|
||||
>42 : 42
|
||||
|
||||
((x, y, z) => 42)();
|
||||
>((x, y, z) => 42)() : number
|
||||
>((x, y, z) => 42) : (x: undefined, y: undefined, z: undefined) => number
|
||||
>(x, y, z) => 42 : (x: undefined, y: undefined, z: undefined) => number
|
||||
>x : undefined
|
||||
>y : undefined
|
||||
>z : undefined
|
||||
>42 : 42
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -296,6 +296,30 @@ class C1 {
|
||||
}
|
||||
}
|
||||
|
||||
type S2 = {
|
||||
a: string;
|
||||
b: string;
|
||||
};
|
||||
|
||||
function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) {
|
||||
x1 = x2;
|
||||
x1 = x3;
|
||||
x1 = x4;
|
||||
x2 = x1;
|
||||
x2 = x3;
|
||||
x2 = x4;
|
||||
x3 = x1;
|
||||
x3 = x2;
|
||||
x3 = x4;
|
||||
x4 = x1;
|
||||
x4 = x2;
|
||||
x4 = x3;
|
||||
x1.length;
|
||||
x2.length;
|
||||
x3.length;
|
||||
x4.length;
|
||||
}
|
||||
|
||||
// Repros from #12011
|
||||
|
||||
class Base {
|
||||
@@ -429,7 +453,44 @@ type SomeMethodDescriptor = {
|
||||
returnValue: string[];
|
||||
}
|
||||
|
||||
let result = dispatchMethod<SomeMethodDescriptor>("someMethod", ["hello", 35]);
|
||||
let result = dispatchMethod<SomeMethodDescriptor>("someMethod", ["hello", 35]);
|
||||
|
||||
// Repro from #13073
|
||||
|
||||
type KeyTypes = "a" | "b"
|
||||
let MyThingy: { [key in KeyTypes]: string[] };
|
||||
|
||||
function addToMyThingy<S extends KeyTypes>(key: S) {
|
||||
MyThingy[key].push("a");
|
||||
}
|
||||
|
||||
// Repro from #13285
|
||||
|
||||
function updateIds<T extends Record<K, string>, K extends string>(
|
||||
obj: T,
|
||||
idFields: K[],
|
||||
idMapping: { [oldId: string]: string }
|
||||
): Record<K, string> {
|
||||
for (const idField of idFields) {
|
||||
const newId = idMapping[obj[idField]];
|
||||
if (newId) {
|
||||
obj[idField] = newId;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Repro from #13285
|
||||
|
||||
function updateIds2<T extends { [x: string]: string }, K extends keyof T>(
|
||||
obj: T,
|
||||
key: K,
|
||||
stringMap: { [oldId: string]: string }
|
||||
) {
|
||||
var x = obj[key];
|
||||
stringMap[x]; // Should be OK.
|
||||
}
|
||||
|
||||
|
||||
//// [keyofAndIndexedAccess.js]
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
@@ -649,6 +710,24 @@ var C1 = (function () {
|
||||
};
|
||||
return C1;
|
||||
}());
|
||||
function f90(x1, x2, x3, x4) {
|
||||
x1 = x2;
|
||||
x1 = x3;
|
||||
x1 = x4;
|
||||
x2 = x1;
|
||||
x2 = x3;
|
||||
x2 = x4;
|
||||
x3 = x1;
|
||||
x3 = x2;
|
||||
x3 = x4;
|
||||
x4 = x1;
|
||||
x4 = x2;
|
||||
x4 = x3;
|
||||
x1.length;
|
||||
x2.length;
|
||||
x3.length;
|
||||
x4.length;
|
||||
}
|
||||
// Repros from #12011
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
@@ -718,6 +797,26 @@ function f(p) {
|
||||
a[p].add; // any
|
||||
}
|
||||
var result = dispatchMethod("someMethod", ["hello", 35]);
|
||||
var MyThingy;
|
||||
function addToMyThingy(key) {
|
||||
MyThingy[key].push("a");
|
||||
}
|
||||
// Repro from #13285
|
||||
function updateIds(obj, idFields, idMapping) {
|
||||
for (var _i = 0, idFields_1 = idFields; _i < idFields_1.length; _i++) {
|
||||
var idField = idFields_1[_i];
|
||||
var newId = idMapping[obj[idField]];
|
||||
if (newId) {
|
||||
obj[idField] = newId;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
// Repro from #13285
|
||||
function updateIds2(obj, key, stringMap) {
|
||||
var x = obj[key];
|
||||
stringMap[x]; // Should be OK.
|
||||
}
|
||||
|
||||
|
||||
//// [keyofAndIndexedAccess.d.ts]
|
||||
@@ -853,6 +952,11 @@ declare class C1 {
|
||||
set<K extends keyof this>(key: K, value: this[K]): void;
|
||||
foo(): void;
|
||||
}
|
||||
declare type S2 = {
|
||||
a: string;
|
||||
b: string;
|
||||
};
|
||||
declare function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]): void;
|
||||
declare class Base {
|
||||
get<K extends keyof this>(prop: K): this[K];
|
||||
set<K extends keyof this>(prop: K, value: this[K]): void;
|
||||
@@ -925,3 +1029,16 @@ declare type SomeMethodDescriptor = {
|
||||
returnValue: string[];
|
||||
};
|
||||
declare let result: string[];
|
||||
declare type KeyTypes = "a" | "b";
|
||||
declare let MyThingy: {
|
||||
[key in KeyTypes]: string[];
|
||||
};
|
||||
declare function addToMyThingy<S extends KeyTypes>(key: S): void;
|
||||
declare function updateIds<T extends Record<K, string>, K extends string>(obj: T, idFields: K[], idMapping: {
|
||||
[oldId: string]: string;
|
||||
}): Record<K, string>;
|
||||
declare function updateIds2<T extends {
|
||||
[x: string]: string;
|
||||
}, K extends keyof T>(obj: T, key: K, stringMap: {
|
||||
[oldId: string]: string;
|
||||
}): void;
|
||||
|
||||
@@ -1139,440 +1139,643 @@ class C1 {
|
||||
}
|
||||
}
|
||||
|
||||
type S2 = {
|
||||
>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
|
||||
a: string;
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 297, 11))
|
||||
|
||||
b: string;
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 298, 14))
|
||||
|
||||
};
|
||||
|
||||
function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) {
|
||||
>f90 : Symbol(f90, Decl(keyofAndIndexedAccess.ts, 300, 2))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 302, 13))
|
||||
>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 302, 26))
|
||||
>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47))
|
||||
>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 302, 13))
|
||||
>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81))
|
||||
>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 302, 26))
|
||||
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 302, 13))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 302, 26))
|
||||
|
||||
x1 = x2;
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47))
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64))
|
||||
|
||||
x1 = x3;
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47))
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81))
|
||||
|
||||
x1 = x4;
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47))
|
||||
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92))
|
||||
|
||||
x2 = x1;
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64))
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47))
|
||||
|
||||
x2 = x3;
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64))
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81))
|
||||
|
||||
x2 = x4;
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64))
|
||||
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92))
|
||||
|
||||
x3 = x1;
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81))
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47))
|
||||
|
||||
x3 = x2;
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81))
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64))
|
||||
|
||||
x3 = x4;
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81))
|
||||
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92))
|
||||
|
||||
x4 = x1;
|
||||
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92))
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47))
|
||||
|
||||
x4 = x2;
|
||||
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92))
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64))
|
||||
|
||||
x4 = x3;
|
||||
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92))
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81))
|
||||
|
||||
x1.length;
|
||||
>x1.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
|
||||
x2.length;
|
||||
>x2.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
|
||||
x3.length;
|
||||
>x3.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
|
||||
x4.length;
|
||||
>x4.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
}
|
||||
|
||||
// Repros from #12011
|
||||
|
||||
class Base {
|
||||
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1))
|
||||
|
||||
get<K extends keyof this>(prop: K) {
|
||||
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 300, 8))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 300, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 300, 8))
|
||||
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 323, 12))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 324, 8))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 324, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 324, 8))
|
||||
|
||||
return this[prop];
|
||||
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 300, 30))
|
||||
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 324, 30))
|
||||
}
|
||||
set<K extends keyof this>(prop: K, value: this[K]) {
|
||||
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 303, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 303, 38))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8))
|
||||
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 326, 5))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 327, 8))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 327, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 327, 8))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 327, 38))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 327, 8))
|
||||
|
||||
this[prop] = value;
|
||||
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 303, 30))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 303, 38))
|
||||
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 327, 30))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 327, 38))
|
||||
}
|
||||
}
|
||||
|
||||
class Person extends Base {
|
||||
>Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1))
|
||||
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
>Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 330, 1))
|
||||
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1))
|
||||
|
||||
parts: number;
|
||||
>parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 308, 27))
|
||||
>parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 332, 27))
|
||||
|
||||
constructor(parts: number) {
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 310, 16))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 334, 16))
|
||||
|
||||
super();
|
||||
>super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
>super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1))
|
||||
|
||||
this.set("parts", parts);
|
||||
>this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5))
|
||||
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1))
|
||||
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 310, 16))
|
||||
>this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 326, 5))
|
||||
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 330, 1))
|
||||
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 326, 5))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 334, 16))
|
||||
}
|
||||
getParts() {
|
||||
>getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 313, 5))
|
||||
>getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 337, 5))
|
||||
|
||||
return this.get("parts")
|
||||
>this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12))
|
||||
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1))
|
||||
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12))
|
||||
>this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 323, 12))
|
||||
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 330, 1))
|
||||
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 323, 12))
|
||||
}
|
||||
}
|
||||
|
||||
class OtherPerson {
|
||||
>OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1))
|
||||
>OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 341, 1))
|
||||
|
||||
parts: number;
|
||||
>parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 319, 19))
|
||||
>parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 343, 19))
|
||||
|
||||
constructor(parts: number) {
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 321, 16))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 345, 16))
|
||||
|
||||
setProperty(this, "parts", parts);
|
||||
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 81, 1))
|
||||
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 321, 16))
|
||||
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 341, 1))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 345, 16))
|
||||
}
|
||||
getParts() {
|
||||
>getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 323, 5))
|
||||
>getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 347, 5))
|
||||
|
||||
return getProperty(this, "parts")
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 77, 26))
|
||||
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1))
|
||||
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 341, 1))
|
||||
}
|
||||
}
|
||||
|
||||
// Modified repro from #12544
|
||||
|
||||
function path<T, K1 extends keyof T>(obj: T, key1: K1): T[K1];
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 331, 37))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 331, 44))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 355, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 355, 37))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 355, 44))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 355, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 355, 16))
|
||||
|
||||
function path<T, K1 extends keyof T, K2 extends keyof T[K1]>(obj: T, key1: K1, key2: K2): T[K1][K2];
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 332, 61))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 332, 68))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 332, 78))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 356, 36))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 356, 61))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 356, 68))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 356, 78))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 356, 36))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 356, 36))
|
||||
|
||||
function path<T, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(obj: T, key1: K1, key2: K2, key3: K3): T[K1][K2][K3];
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16))
|
||||
>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 333, 89))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 333, 96))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 333, 106))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36))
|
||||
>key3 : Symbol(key3, Decl(keyofAndIndexedAccess.ts, 333, 116))
|
||||
>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36))
|
||||
>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16))
|
||||
>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 357, 60))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 357, 89))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 357, 96))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 357, 106))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36))
|
||||
>key3 : Symbol(key3, Decl(keyofAndIndexedAccess.ts, 357, 116))
|
||||
>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 357, 60))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36))
|
||||
>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 357, 60))
|
||||
|
||||
function path(obj: any, ...keys: (string | number)[]): any;
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 334, 14))
|
||||
>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 334, 23))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 358, 14))
|
||||
>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 358, 23))
|
||||
|
||||
function path(obj: any, ...keys: (string | number)[]): any {
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 335, 14))
|
||||
>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 335, 23))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 359, 14))
|
||||
>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 359, 23))
|
||||
|
||||
let result = obj;
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 335, 14))
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 359, 14))
|
||||
|
||||
for (let k of keys) {
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 337, 12))
|
||||
>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 335, 23))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 361, 12))
|
||||
>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 359, 23))
|
||||
|
||||
result = result[k];
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7))
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 337, 12))
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7))
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 361, 12))
|
||||
}
|
||||
return result;
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7))
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7))
|
||||
}
|
||||
|
||||
type Thing = {
|
||||
>Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 341, 1))
|
||||
>Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 365, 1))
|
||||
|
||||
a: { x: number, y: string },
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 343, 14))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 344, 8))
|
||||
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 344, 19))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 367, 14))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 368, 8))
|
||||
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 368, 19))
|
||||
|
||||
b: boolean
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 344, 32))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 368, 32))
|
||||
|
||||
};
|
||||
|
||||
|
||||
function f1(thing: Thing) {
|
||||
>f1 : Symbol(f1, Decl(keyofAndIndexedAccess.ts, 346, 2))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12))
|
||||
>Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 341, 1))
|
||||
>f1 : Symbol(f1, Decl(keyofAndIndexedAccess.ts, 370, 2))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12))
|
||||
>Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 365, 1))
|
||||
|
||||
let x1 = path(thing, 'a'); // { x: number, y: string }
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 350, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12))
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 374, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12))
|
||||
|
||||
let x2 = path(thing, 'a', 'y'); // string
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 351, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12))
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 375, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12))
|
||||
|
||||
let x3 = path(thing, 'b'); // boolean
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 352, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12))
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 376, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12))
|
||||
|
||||
let x4 = path(thing, ...['a', 'x']); // any
|
||||
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 353, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12))
|
||||
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 377, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12))
|
||||
}
|
||||
|
||||
// Repro from comment in #12114
|
||||
|
||||
const assignTo2 = <T, K1 extends keyof T, K2 extends keyof T[K1]>(object: T, key1: K1, key2: K2) =>
|
||||
>assignTo2 : Symbol(assignTo2, Decl(keyofAndIndexedAccess.ts, 358, 5))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21))
|
||||
>object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 358, 66))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 358, 76))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 358, 86))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41))
|
||||
>assignTo2 : Symbol(assignTo2, Decl(keyofAndIndexedAccess.ts, 382, 5))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 382, 41))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21))
|
||||
>object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 382, 66))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 382, 76))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 382, 86))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 382, 41))
|
||||
|
||||
(value: T[K1][K2]) => object[key1][key2] = value;
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 359, 5))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41))
|
||||
>object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 358, 66))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 358, 76))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 358, 86))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 359, 5))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 383, 5))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 382, 41))
|
||||
>object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 382, 66))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 382, 76))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 382, 86))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 383, 5))
|
||||
|
||||
// Modified repro from #12573
|
||||
|
||||
declare function one<T>(handler: (t: T) => void): T
|
||||
>one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 359, 53))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21))
|
||||
>handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 363, 24))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 363, 34))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21))
|
||||
>one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 383, 53))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 387, 21))
|
||||
>handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 387, 24))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 387, 34))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 387, 21))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 387, 21))
|
||||
|
||||
var empty = one(() => {}) // inferred as {}, expected
|
||||
>empty : Symbol(empty, Decl(keyofAndIndexedAccess.ts, 364, 3))
|
||||
>one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 359, 53))
|
||||
>empty : Symbol(empty, Decl(keyofAndIndexedAccess.ts, 388, 3))
|
||||
>one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 383, 53))
|
||||
|
||||
type Handlers<T> = { [K in keyof T]: (t: T[K]) => void }
|
||||
>Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 364, 25))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 366, 22))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 366, 38))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 366, 22))
|
||||
>Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 388, 25))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 390, 14))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 390, 22))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 390, 14))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 390, 38))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 390, 14))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 390, 22))
|
||||
|
||||
declare function on<T>(handlerHash: Handlers<T>): T
|
||||
>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20))
|
||||
>handlerHash : Symbol(handlerHash, Decl(keyofAndIndexedAccess.ts, 367, 23))
|
||||
>Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 364, 25))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20))
|
||||
>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 390, 56))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 391, 20))
|
||||
>handlerHash : Symbol(handlerHash, Decl(keyofAndIndexedAccess.ts, 391, 23))
|
||||
>Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 388, 25))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 391, 20))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 391, 20))
|
||||
|
||||
var hashOfEmpty1 = on({ test: () => {} }); // {}
|
||||
>hashOfEmpty1 : Symbol(hashOfEmpty1, Decl(keyofAndIndexedAccess.ts, 368, 3))
|
||||
>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56))
|
||||
>test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 368, 23))
|
||||
>hashOfEmpty1 : Symbol(hashOfEmpty1, Decl(keyofAndIndexedAccess.ts, 392, 3))
|
||||
>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 390, 56))
|
||||
>test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 392, 23))
|
||||
|
||||
var hashOfEmpty2 = on({ test: (x: boolean) => {} }); // { test: boolean }
|
||||
>hashOfEmpty2 : Symbol(hashOfEmpty2, Decl(keyofAndIndexedAccess.ts, 369, 3))
|
||||
>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56))
|
||||
>test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 369, 23))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 369, 31))
|
||||
>hashOfEmpty2 : Symbol(hashOfEmpty2, Decl(keyofAndIndexedAccess.ts, 393, 3))
|
||||
>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 390, 56))
|
||||
>test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 393, 23))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 393, 31))
|
||||
|
||||
// Repro from #12624
|
||||
|
||||
interface Options1<Data, Computed> {
|
||||
>Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 369, 52))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 373, 19))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 373, 24))
|
||||
>Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 393, 52))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 397, 19))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 397, 24))
|
||||
|
||||
data?: Data
|
||||
>data : Symbol(Options1.data, Decl(keyofAndIndexedAccess.ts, 373, 36))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 373, 19))
|
||||
>data : Symbol(Options1.data, Decl(keyofAndIndexedAccess.ts, 397, 36))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 397, 19))
|
||||
|
||||
computed?: Computed;
|
||||
>computed : Symbol(Options1.computed, Decl(keyofAndIndexedAccess.ts, 374, 15))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 373, 24))
|
||||
>computed : Symbol(Options1.computed, Decl(keyofAndIndexedAccess.ts, 398, 15))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 397, 24))
|
||||
}
|
||||
|
||||
declare class Component1<Data, Computed> {
|
||||
>Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 376, 1))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30))
|
||||
>Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 400, 1))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30))
|
||||
|
||||
constructor(options: Options1<Data, Computed>);
|
||||
>options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 379, 16))
|
||||
>Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 369, 52))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30))
|
||||
>options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 403, 16))
|
||||
>Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 393, 52))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30))
|
||||
|
||||
get<K extends keyof (Data & Computed)>(key: K): (Data & Computed)[K];
|
||||
>get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 380, 43))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8))
|
||||
>get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 403, 51))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 404, 8))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 404, 43))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 404, 8))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 404, 8))
|
||||
}
|
||||
|
||||
let c1 = new Component1({
|
||||
>c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 383, 3))
|
||||
>Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 376, 1))
|
||||
>c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 407, 3))
|
||||
>Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 400, 1))
|
||||
|
||||
data: {
|
||||
>data : Symbol(data, Decl(keyofAndIndexedAccess.ts, 383, 25))
|
||||
>data : Symbol(data, Decl(keyofAndIndexedAccess.ts, 407, 25))
|
||||
|
||||
hello: ""
|
||||
>hello : Symbol(hello, Decl(keyofAndIndexedAccess.ts, 384, 11))
|
||||
>hello : Symbol(hello, Decl(keyofAndIndexedAccess.ts, 408, 11))
|
||||
}
|
||||
});
|
||||
|
||||
c1.get("hello");
|
||||
>c1.get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51))
|
||||
>c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 383, 3))
|
||||
>get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51))
|
||||
>c1.get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 403, 51))
|
||||
>c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 407, 3))
|
||||
>get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 403, 51))
|
||||
|
||||
// Repro from #12625
|
||||
|
||||
interface Options2<Data, Computed> {
|
||||
>Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 389, 16))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 393, 19))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 393, 24))
|
||||
>Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 413, 16))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 417, 19))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 417, 24))
|
||||
|
||||
data?: Data
|
||||
>data : Symbol(Options2.data, Decl(keyofAndIndexedAccess.ts, 393, 36))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 393, 19))
|
||||
>data : Symbol(Options2.data, Decl(keyofAndIndexedAccess.ts, 417, 36))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 417, 19))
|
||||
|
||||
computed?: Computed;
|
||||
>computed : Symbol(Options2.computed, Decl(keyofAndIndexedAccess.ts, 394, 15))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 393, 24))
|
||||
>computed : Symbol(Options2.computed, Decl(keyofAndIndexedAccess.ts, 418, 15))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 417, 24))
|
||||
}
|
||||
|
||||
declare class Component2<Data, Computed> {
|
||||
>Component2 : Symbol(Component2, Decl(keyofAndIndexedAccess.ts, 396, 1))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30))
|
||||
>Component2 : Symbol(Component2, Decl(keyofAndIndexedAccess.ts, 420, 1))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30))
|
||||
|
||||
constructor(options: Options2<Data, Computed>);
|
||||
>options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 399, 16))
|
||||
>Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 389, 16))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30))
|
||||
>options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 423, 16))
|
||||
>Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 413, 16))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30))
|
||||
|
||||
get<K extends keyof Data | keyof Computed>(key: K): (Data & Computed)[K];
|
||||
>get : Symbol(Component2.get, Decl(keyofAndIndexedAccess.ts, 399, 51))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 400, 47))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8))
|
||||
>get : Symbol(Component2.get, Decl(keyofAndIndexedAccess.ts, 423, 51))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 424, 8))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 424, 47))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 424, 8))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 424, 8))
|
||||
}
|
||||
|
||||
// Repro from #12641
|
||||
|
||||
interface R {
|
||||
>R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 401, 1))
|
||||
>R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 425, 1))
|
||||
|
||||
p: number;
|
||||
>p : Symbol(R.p, Decl(keyofAndIndexedAccess.ts, 405, 13))
|
||||
>p : Symbol(R.p, Decl(keyofAndIndexedAccess.ts, 429, 13))
|
||||
}
|
||||
|
||||
function f<K extends keyof R>(p: K) {
|
||||
>f : Symbol(f, Decl(keyofAndIndexedAccess.ts, 407, 1))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 409, 11))
|
||||
>R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 401, 1))
|
||||
>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 409, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 409, 11))
|
||||
>f : Symbol(f, Decl(keyofAndIndexedAccess.ts, 431, 1))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 433, 11))
|
||||
>R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 425, 1))
|
||||
>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 433, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 433, 11))
|
||||
|
||||
let a: any;
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 410, 7))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 434, 7))
|
||||
|
||||
a[p].add; // any
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 410, 7))
|
||||
>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 409, 30))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 434, 7))
|
||||
>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 433, 30))
|
||||
}
|
||||
|
||||
// Repro from #12651
|
||||
|
||||
type MethodDescriptor = {
|
||||
>MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 412, 1))
|
||||
>MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 436, 1))
|
||||
|
||||
name: string;
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 416, 25))
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 440, 25))
|
||||
|
||||
args: any[];
|
||||
>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 417, 14))
|
||||
>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 441, 14))
|
||||
|
||||
returnValue: any;
|
||||
>returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 418, 13))
|
||||
>returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 442, 13))
|
||||
}
|
||||
|
||||
declare function dispatchMethod<M extends MethodDescriptor>(name: M['name'], args: M['args']): M['returnValue'];
|
||||
>dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 420, 1))
|
||||
>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32))
|
||||
>MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 412, 1))
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 422, 60))
|
||||
>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32))
|
||||
>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 422, 76))
|
||||
>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32))
|
||||
>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32))
|
||||
>dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 444, 1))
|
||||
>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32))
|
||||
>MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 436, 1))
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 446, 60))
|
||||
>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32))
|
||||
>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 446, 76))
|
||||
>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32))
|
||||
>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32))
|
||||
|
||||
type SomeMethodDescriptor = {
|
||||
>SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 422, 112))
|
||||
>SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 446, 112))
|
||||
|
||||
name: "someMethod";
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 424, 29))
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 448, 29))
|
||||
|
||||
args: [string, number];
|
||||
>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 425, 20))
|
||||
>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 449, 20))
|
||||
|
||||
returnValue: string[];
|
||||
>returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 426, 24))
|
||||
>returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 450, 24))
|
||||
}
|
||||
|
||||
let result = dispatchMethod<SomeMethodDescriptor>("someMethod", ["hello", 35]);
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 430, 3))
|
||||
>dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 420, 1))
|
||||
>SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 422, 112))
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 454, 3))
|
||||
>dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 444, 1))
|
||||
>SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 446, 112))
|
||||
|
||||
// Repro from #13073
|
||||
|
||||
type KeyTypes = "a" | "b"
|
||||
>KeyTypes : Symbol(KeyTypes, Decl(keyofAndIndexedAccess.ts, 454, 79))
|
||||
|
||||
let MyThingy: { [key in KeyTypes]: string[] };
|
||||
>MyThingy : Symbol(MyThingy, Decl(keyofAndIndexedAccess.ts, 459, 3))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 459, 17))
|
||||
>KeyTypes : Symbol(KeyTypes, Decl(keyofAndIndexedAccess.ts, 454, 79))
|
||||
|
||||
function addToMyThingy<S extends KeyTypes>(key: S) {
|
||||
>addToMyThingy : Symbol(addToMyThingy, Decl(keyofAndIndexedAccess.ts, 459, 46))
|
||||
>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 461, 23))
|
||||
>KeyTypes : Symbol(KeyTypes, Decl(keyofAndIndexedAccess.ts, 454, 79))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 461, 43))
|
||||
>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 461, 23))
|
||||
|
||||
MyThingy[key].push("a");
|
||||
>MyThingy[key].push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>MyThingy : Symbol(MyThingy, Decl(keyofAndIndexedAccess.ts, 459, 3))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 461, 43))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
}
|
||||
|
||||
// Repro from #13285
|
||||
|
||||
function updateIds<T extends Record<K, string>, K extends string>(
|
||||
>updateIds : Symbol(updateIds, Decl(keyofAndIndexedAccess.ts, 463, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 467, 19))
|
||||
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 467, 47))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 467, 47))
|
||||
|
||||
obj: T,
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 467, 66))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 467, 19))
|
||||
|
||||
idFields: K[],
|
||||
>idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 468, 11))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 467, 47))
|
||||
|
||||
idMapping: { [oldId: string]: string }
|
||||
>idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 469, 18))
|
||||
>oldId : Symbol(oldId, Decl(keyofAndIndexedAccess.ts, 470, 18))
|
||||
|
||||
): Record<K, string> {
|
||||
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 467, 47))
|
||||
|
||||
for (const idField of idFields) {
|
||||
>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 472, 14))
|
||||
>idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 468, 11))
|
||||
|
||||
const newId = idMapping[obj[idField]];
|
||||
>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 473, 13))
|
||||
>idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 469, 18))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 467, 66))
|
||||
>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 472, 14))
|
||||
|
||||
if (newId) {
|
||||
>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 473, 13))
|
||||
|
||||
obj[idField] = newId;
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 467, 66))
|
||||
>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 472, 14))
|
||||
>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 473, 13))
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 467, 66))
|
||||
}
|
||||
|
||||
// Repro from #13285
|
||||
|
||||
function updateIds2<T extends { [x: string]: string }, K extends keyof T>(
|
||||
>updateIds2 : Symbol(updateIds2, Decl(keyofAndIndexedAccess.ts, 479, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 483, 20))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 483, 33))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 483, 54))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 483, 20))
|
||||
|
||||
obj: T,
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 483, 74))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 483, 20))
|
||||
|
||||
key: K,
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 484, 11))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 483, 54))
|
||||
|
||||
stringMap: { [oldId: string]: string }
|
||||
>stringMap : Symbol(stringMap, Decl(keyofAndIndexedAccess.ts, 485, 11))
|
||||
>oldId : Symbol(oldId, Decl(keyofAndIndexedAccess.ts, 486, 18))
|
||||
|
||||
) {
|
||||
var x = obj[key];
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 488, 7))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 483, 74))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 484, 11))
|
||||
|
||||
stringMap[x]; // Should be OK.
|
||||
>stringMap : Symbol(stringMap, Decl(keyofAndIndexedAccess.ts, 485, 11))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 488, 7))
|
||||
}
|
||||
|
||||
|
||||
@@ -1385,6 +1385,117 @@ class C1 {
|
||||
}
|
||||
}
|
||||
|
||||
type S2 = {
|
||||
>S2 : S2
|
||||
|
||||
a: string;
|
||||
>a : string
|
||||
|
||||
b: string;
|
||||
>b : string
|
||||
|
||||
};
|
||||
|
||||
function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) {
|
||||
>f90 : <T extends S2, K extends "a" | "b">(x1: string, x2: T["a" | "b"], x3: S2[K], x4: T[K]) => void
|
||||
>T : T
|
||||
>S2 : S2
|
||||
>K : K
|
||||
>S2 : S2
|
||||
>x1 : string
|
||||
>S2 : S2
|
||||
>S2 : S2
|
||||
>x2 : T["a" | "b"]
|
||||
>T : T
|
||||
>S2 : S2
|
||||
>x3 : S2[K]
|
||||
>S2 : S2
|
||||
>K : K
|
||||
>x4 : T[K]
|
||||
>T : T
|
||||
>K : K
|
||||
|
||||
x1 = x2;
|
||||
>x1 = x2 : T["a" | "b"]
|
||||
>x1 : string
|
||||
>x2 : T["a" | "b"]
|
||||
|
||||
x1 = x3;
|
||||
>x1 = x3 : S2[K]
|
||||
>x1 : string
|
||||
>x3 : S2[K]
|
||||
|
||||
x1 = x4;
|
||||
>x1 = x4 : T[K]
|
||||
>x1 : string
|
||||
>x4 : T[K]
|
||||
|
||||
x2 = x1;
|
||||
>x2 = x1 : string
|
||||
>x2 : T["a" | "b"]
|
||||
>x1 : string
|
||||
|
||||
x2 = x3;
|
||||
>x2 = x3 : S2[K]
|
||||
>x2 : T["a" | "b"]
|
||||
>x3 : S2[K]
|
||||
|
||||
x2 = x4;
|
||||
>x2 = x4 : T[K]
|
||||
>x2 : T["a" | "b"]
|
||||
>x4 : T[K]
|
||||
|
||||
x3 = x1;
|
||||
>x3 = x1 : string
|
||||
>x3 : S2[K]
|
||||
>x1 : string
|
||||
|
||||
x3 = x2;
|
||||
>x3 = x2 : T["a" | "b"]
|
||||
>x3 : S2[K]
|
||||
>x2 : T["a" | "b"]
|
||||
|
||||
x3 = x4;
|
||||
>x3 = x4 : T[K]
|
||||
>x3 : S2[K]
|
||||
>x4 : T[K]
|
||||
|
||||
x4 = x1;
|
||||
>x4 = x1 : string
|
||||
>x4 : T[K]
|
||||
>x1 : string
|
||||
|
||||
x4 = x2;
|
||||
>x4 = x2 : T["a" | "b"]
|
||||
>x4 : T[K]
|
||||
>x2 : T["a" | "b"]
|
||||
|
||||
x4 = x3;
|
||||
>x4 = x3 : S2[K]
|
||||
>x4 : T[K]
|
||||
>x3 : S2[K]
|
||||
|
||||
x1.length;
|
||||
>x1.length : number
|
||||
>x1 : string
|
||||
>length : number
|
||||
|
||||
x2.length;
|
||||
>x2.length : number
|
||||
>x2 : T["a" | "b"]
|
||||
>length : number
|
||||
|
||||
x3.length;
|
||||
>x3.length : number
|
||||
>x3 : S2[K]
|
||||
>length : number
|
||||
|
||||
x4.length;
|
||||
>x4.length : number
|
||||
>x4 : T[K]
|
||||
>length : number
|
||||
}
|
||||
|
||||
// Repros from #12011
|
||||
|
||||
class Base {
|
||||
@@ -1875,3 +1986,116 @@ let result = dispatchMethod<SomeMethodDescriptor>("someMethod", ["hello", 35]);
|
||||
>"hello" : "hello"
|
||||
>35 : 35
|
||||
|
||||
// Repro from #13073
|
||||
|
||||
type KeyTypes = "a" | "b"
|
||||
>KeyTypes : "a" | "b"
|
||||
|
||||
let MyThingy: { [key in KeyTypes]: string[] };
|
||||
>MyThingy : { a: string[]; b: string[]; }
|
||||
>key : key
|
||||
>KeyTypes : "a" | "b"
|
||||
|
||||
function addToMyThingy<S extends KeyTypes>(key: S) {
|
||||
>addToMyThingy : <S extends "a" | "b">(key: S) => void
|
||||
>S : S
|
||||
>KeyTypes : "a" | "b"
|
||||
>key : S
|
||||
>S : S
|
||||
|
||||
MyThingy[key].push("a");
|
||||
>MyThingy[key].push("a") : number
|
||||
>MyThingy[key].push : (...items: string[]) => number
|
||||
>MyThingy[key] : { a: string[]; b: string[]; }[S]
|
||||
>MyThingy : { a: string[]; b: string[]; }
|
||||
>key : S
|
||||
>push : (...items: string[]) => number
|
||||
>"a" : "a"
|
||||
}
|
||||
|
||||
// Repro from #13285
|
||||
|
||||
function updateIds<T extends Record<K, string>, K extends string>(
|
||||
>updateIds : <T extends Record<K, string>, K extends string>(obj: T, idFields: K[], idMapping: { [oldId: string]: string; }) => Record<K, string>
|
||||
>T : T
|
||||
>Record : Record<K, T>
|
||||
>K : K
|
||||
>K : K
|
||||
|
||||
obj: T,
|
||||
>obj : T
|
||||
>T : T
|
||||
|
||||
idFields: K[],
|
||||
>idFields : K[]
|
||||
>K : K
|
||||
|
||||
idMapping: { [oldId: string]: string }
|
||||
>idMapping : { [oldId: string]: string; }
|
||||
>oldId : string
|
||||
|
||||
): Record<K, string> {
|
||||
>Record : Record<K, T>
|
||||
>K : K
|
||||
|
||||
for (const idField of idFields) {
|
||||
>idField : K
|
||||
>idFields : K[]
|
||||
|
||||
const newId = idMapping[obj[idField]];
|
||||
>newId : { [oldId: string]: string; }[T[K]]
|
||||
>idMapping[obj[idField]] : { [oldId: string]: string; }[T[K]]
|
||||
>idMapping : { [oldId: string]: string; }
|
||||
>obj[idField] : T[K]
|
||||
>obj : T
|
||||
>idField : K
|
||||
|
||||
if (newId) {
|
||||
>newId : { [oldId: string]: string; }[T[K]]
|
||||
|
||||
obj[idField] = newId;
|
||||
>obj[idField] = newId : { [oldId: string]: string; }[T[K]]
|
||||
>obj[idField] : T[K]
|
||||
>obj : T
|
||||
>idField : K
|
||||
>newId : { [oldId: string]: string; }[T[K]]
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
>obj : T
|
||||
}
|
||||
|
||||
// Repro from #13285
|
||||
|
||||
function updateIds2<T extends { [x: string]: string }, K extends keyof T>(
|
||||
>updateIds2 : <T extends { [x: string]: string; }, K extends keyof T>(obj: T, key: K, stringMap: { [oldId: string]: string; }) => void
|
||||
>T : T
|
||||
>x : string
|
||||
>K : K
|
||||
>T : T
|
||||
|
||||
obj: T,
|
||||
>obj : T
|
||||
>T : T
|
||||
|
||||
key: K,
|
||||
>key : K
|
||||
>K : K
|
||||
|
||||
stringMap: { [oldId: string]: string }
|
||||
>stringMap : { [oldId: string]: string; }
|
||||
>oldId : string
|
||||
|
||||
) {
|
||||
var x = obj[key];
|
||||
>x : T[K]
|
||||
>obj[key] : T[K]
|
||||
>obj : T
|
||||
>key : K
|
||||
|
||||
stringMap[x]; // Should be OK.
|
||||
>stringMap[x] : { [oldId: string]: string; }[T[K]]
|
||||
>stringMap : { [oldId: string]: string; }
|
||||
>x : T[K]
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(130,5): error TS2322: T
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(131,5): error TS2322: Type '{ a: string; }' is not assignable to type '{ [x: string]: any; a?: number | undefined; }'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'string' is not assignable to type 'number | undefined'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,16): error TS2322: Type '{}' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,16): error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,21): error TS2536: Type 'P' cannot be used to index type 'T'.
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,21): error TS2536:
|
||||
pf: {[P in F]?: T[P]},
|
||||
pt: {[P in T]?: T[P]}, // note: should be in keyof T
|
||||
~
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
~~~~
|
||||
!!! error TS2536: Type 'P' cannot be used to index type 'T'.
|
||||
};
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [mappedTypeNestedGenericInstantiation.ts]
|
||||
// Repro from #13346
|
||||
|
||||
interface Chainable<T> {
|
||||
value(): T;
|
||||
mapValues<U>(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>;
|
||||
}
|
||||
|
||||
declare function chain<T>(t: T): Chainable<T>;
|
||||
|
||||
const square = (x: number) => x * x;
|
||||
|
||||
const v = chain({a: 1, b: 2}).mapValues(square).value();
|
||||
|
||||
|
||||
//// [mappedTypeNestedGenericInstantiation.js]
|
||||
// Repro from #13346
|
||||
var square = function (x) { return x * x; };
|
||||
var v = chain({ a: 1, b: 2 }).mapValues(square).value();
|
||||
@@ -0,0 +1,50 @@
|
||||
=== tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts ===
|
||||
// Repro from #13346
|
||||
|
||||
interface Chainable<T> {
|
||||
>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
|
||||
|
||||
value(): T;
|
||||
>value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
|
||||
|
||||
mapValues<U>(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>;
|
||||
>mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13))
|
||||
>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12))
|
||||
>func : Symbol(func, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 15))
|
||||
>v : Symbol(v, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 22))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
|
||||
>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12))
|
||||
>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0))
|
||||
>k : Symbol(k, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 56))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
|
||||
>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12))
|
||||
}
|
||||
|
||||
declare function chain<T>(t: T): Chainable<T>;
|
||||
>chain : Symbol(chain, Decl(mappedTypeNestedGenericInstantiation.ts, 5, 1))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23))
|
||||
>t : Symbol(t, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 26))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23))
|
||||
>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23))
|
||||
|
||||
const square = (x: number) => x * x;
|
||||
>square : Symbol(square, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 5))
|
||||
>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16))
|
||||
>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16))
|
||||
>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16))
|
||||
|
||||
const v = chain({a: 1, b: 2}).mapValues(square).value();
|
||||
>v : Symbol(v, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 5))
|
||||
>chain({a: 1, b: 2}).mapValues(square).value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24))
|
||||
>chain({a: 1, b: 2}).mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13))
|
||||
>chain : Symbol(chain, Decl(mappedTypeNestedGenericInstantiation.ts, 5, 1))
|
||||
>a : Symbol(a, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 17))
|
||||
>b : Symbol(b, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 22))
|
||||
>mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13))
|
||||
>square : Symbol(square, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 5))
|
||||
>value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24))
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
=== tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts ===
|
||||
// Repro from #13346
|
||||
|
||||
interface Chainable<T> {
|
||||
>Chainable : Chainable<T>
|
||||
>T : T
|
||||
|
||||
value(): T;
|
||||
>value : () => T
|
||||
>T : T
|
||||
|
||||
mapValues<U>(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>;
|
||||
>mapValues : <U>(func: (v: T[keyof T]) => U) => Chainable<{ [k in keyof T]: U; }>
|
||||
>U : U
|
||||
>func : (v: T[keyof T]) => U
|
||||
>v : T[keyof T]
|
||||
>T : T
|
||||
>T : T
|
||||
>U : U
|
||||
>Chainable : Chainable<T>
|
||||
>k : k
|
||||
>T : T
|
||||
>U : U
|
||||
}
|
||||
|
||||
declare function chain<T>(t: T): Chainable<T>;
|
||||
>chain : <T>(t: T) => Chainable<T>
|
||||
>T : T
|
||||
>t : T
|
||||
>T : T
|
||||
>Chainable : Chainable<T>
|
||||
>T : T
|
||||
|
||||
const square = (x: number) => x * x;
|
||||
>square : (x: number) => number
|
||||
>(x: number) => x * x : (x: number) => number
|
||||
>x : number
|
||||
>x * x : number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
const v = chain({a: 1, b: 2}).mapValues(square).value();
|
||||
>v : { a: number; b: number; }
|
||||
>chain({a: 1, b: 2}).mapValues(square).value() : { a: number; b: number; }
|
||||
>chain({a: 1, b: 2}).mapValues(square).value : () => { a: number; b: number; }
|
||||
>chain({a: 1, b: 2}).mapValues(square) : Chainable<{ a: number; b: number; }>
|
||||
>chain({a: 1, b: 2}).mapValues : <U>(func: (v: number) => U) => Chainable<{ a: U; b: U; }>
|
||||
>chain({a: 1, b: 2}) : Chainable<{ a: number; b: number; }>
|
||||
>chain : <T>(t: T) => Chainable<T>
|
||||
>{a: 1, b: 2} : { a: number; b: number; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
>b : number
|
||||
>2 : 2
|
||||
>mapValues : <U>(func: (v: number) => U) => Chainable<{ a: U; b: U; }>
|
||||
>square : (x: number) => number
|
||||
>value : () => { a: number; b: number; }
|
||||
|
||||
@@ -3,8 +3,12 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(12,5): error TS2
|
||||
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(17,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'.
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(21,5): error TS2536: Type 'keyof U' cannot be used to index type 'T'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(22,5): error TS2322: Type 'T[keyof U]' is not assignable to type 'U[keyof U]'.
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(22,12): error TS2536: Type 'keyof U' cannot be used to index type 'T'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(26,5): error TS2536: Type 'K' cannot be used to index type 'T'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(27,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'.
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(27,12): error TS2536: Type 'K' cannot be used to index type 'T'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(31,5): error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'.
|
||||
Type 'undefined' is not assignable to type 'T[keyof T]'.
|
||||
@@ -28,7 +32,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(71,5): error TS2
|
||||
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2322: Type 'Partial<T>' is not assignable to type 'T'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (18 errors) ====
|
||||
==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (20 errors) ====
|
||||
|
||||
function f1<T>(x: T, k: keyof T) {
|
||||
return x[k];
|
||||
@@ -59,6 +63,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2
|
||||
~~~~
|
||||
!!! error TS2536: Type 'keyof U' cannot be used to index type 'T'.
|
||||
y[k] = x[k]; // Error
|
||||
~~~~
|
||||
!!! error TS2322: Type 'T[keyof U]' is not assignable to type 'U[keyof U]'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'U'.
|
||||
~~~~
|
||||
!!! error TS2536: Type 'keyof U' cannot be used to index type 'T'.
|
||||
}
|
||||
@@ -68,6 +75,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2
|
||||
~~~~
|
||||
!!! error TS2536: Type 'K' cannot be used to index type 'T'.
|
||||
y[k] = x[k]; // Error
|
||||
~~~~
|
||||
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'U'.
|
||||
~~~~
|
||||
!!! error TS2536: Type 'K' cannot be used to index type 'T'.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts(18,7): error TS2322: Type 'string' is not assignable to type '{ important: boolean; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts (1 errors) ====
|
||||
// Repro from #13351
|
||||
|
||||
type Meta<T, A> = {
|
||||
readonly[P in keyof T]: {
|
||||
value: T[P];
|
||||
also: A;
|
||||
readonly children: Meta<T[P], A>;
|
||||
};
|
||||
}
|
||||
|
||||
interface Input {
|
||||
x: string;
|
||||
y: number;
|
||||
}
|
||||
|
||||
declare const output: Meta<Input, boolean>;
|
||||
|
||||
const shouldFail: { important: boolean } = output.x.children;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type '{ important: boolean; }'.
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//// [mappedTypeWithCombinedTypeMappers.ts]
|
||||
// Repro from #13351
|
||||
|
||||
type Meta<T, A> = {
|
||||
readonly[P in keyof T]: {
|
||||
value: T[P];
|
||||
also: A;
|
||||
readonly children: Meta<T[P], A>;
|
||||
};
|
||||
}
|
||||
|
||||
interface Input {
|
||||
x: string;
|
||||
y: number;
|
||||
}
|
||||
|
||||
declare const output: Meta<Input, boolean>;
|
||||
|
||||
const shouldFail: { important: boolean } = output.x.children;
|
||||
|
||||
|
||||
//// [mappedTypeWithCombinedTypeMappers.js]
|
||||
// Repro from #13351
|
||||
var shouldFail = output.x.children;
|
||||
@@ -0,0 +1,33 @@
|
||||
tests/cases/conformance/types/spread/spreadMethods.ts(7,4): error TS2339: Property 'm' does not exist on type '{ p: number; }'.
|
||||
tests/cases/conformance/types/spread/spreadMethods.ts(9,5): error TS2339: Property 'm' does not exist on type '{ p: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/spread/spreadMethods.ts (2 errors) ====
|
||||
class K { p = 12; m() { } }
|
||||
interface I { p: number, m(): void }
|
||||
let k = new K()
|
||||
let sk = { ...k };
|
||||
let ssk = { ...k, ...k };
|
||||
sk.p;
|
||||
sk.m(); // error
|
||||
~
|
||||
!!! error TS2339: Property 'm' does not exist on type '{ p: number; }'.
|
||||
ssk.p;
|
||||
ssk.m(); // error
|
||||
~
|
||||
!!! error TS2339: Property 'm' does not exist on type '{ p: number; }'.
|
||||
let i: I = { p: 12, m() { } };
|
||||
let si = { ...i };
|
||||
let ssi = { ...i, ...i };
|
||||
si.p;
|
||||
si.m(); // ok
|
||||
ssi.p;
|
||||
ssi.m(); // ok
|
||||
let o = { p: 12, m() { } };
|
||||
let so = { ...o };
|
||||
let sso = { ...o, ...o };
|
||||
so.p;
|
||||
so.m(); // ok
|
||||
sso.p;
|
||||
sso.m(); // ok
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
//// [spreadMethods.ts]
|
||||
class K { p = 12; m() { } }
|
||||
interface I { p: number, m(): void }
|
||||
let k = new K()
|
||||
let sk = { ...k };
|
||||
let ssk = { ...k, ...k };
|
||||
sk.p;
|
||||
sk.m(); // error
|
||||
ssk.p;
|
||||
ssk.m(); // error
|
||||
let i: I = { p: 12, m() { } };
|
||||
let si = { ...i };
|
||||
let ssi = { ...i, ...i };
|
||||
si.p;
|
||||
si.m(); // ok
|
||||
ssi.p;
|
||||
ssi.m(); // ok
|
||||
let o = { p: 12, m() { } };
|
||||
let so = { ...o };
|
||||
let sso = { ...o, ...o };
|
||||
so.p;
|
||||
so.m(); // ok
|
||||
sso.p;
|
||||
sso.m(); // ok
|
||||
|
||||
|
||||
//// [spreadMethods.js]
|
||||
var __assign = (this && this.__assign) || Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
var K = (function () {
|
||||
function K() {
|
||||
this.p = 12;
|
||||
}
|
||||
K.prototype.m = function () { };
|
||||
return K;
|
||||
}());
|
||||
var k = new K();
|
||||
var sk = __assign({}, k);
|
||||
var ssk = __assign({}, k, k);
|
||||
sk.p;
|
||||
sk.m(); // error
|
||||
ssk.p;
|
||||
ssk.m(); // error
|
||||
var i = { p: 12, m: function () { } };
|
||||
var si = __assign({}, i);
|
||||
var ssi = __assign({}, i, i);
|
||||
si.p;
|
||||
si.m(); // ok
|
||||
ssi.p;
|
||||
ssi.m(); // ok
|
||||
var o = { p: 12, m: function () { } };
|
||||
var so = __assign({}, o);
|
||||
var sso = __assign({}, o, o);
|
||||
so.p;
|
||||
so.m(); // ok
|
||||
sso.p;
|
||||
sso.m(); // ok
|
||||
@@ -23,11 +23,12 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterInd
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(16,21): error TS2313: Type parameter 'T' has a circular constraint.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(16,34): error TS2313: Type parameter 'U' has a circular constraint.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(16,47): error TS2313: Type parameter 'V' has a circular constraint.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(18,19): error TS2313: Type parameter 'U' has a circular constraint.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(18,32): error TS2313: Type parameter 'T' has a circular constraint.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(18,45): error TS2313: Type parameter 'V' has a circular constraint.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts (27 errors) ====
|
||||
==== tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts (28 errors) ====
|
||||
class C<U extends T, T extends U> { }
|
||||
~
|
||||
!!! error TS2313: Type parameter 'U' has a circular constraint.
|
||||
@@ -96,6 +97,8 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterInd
|
||||
!!! error TS2313: Type parameter 'V' has a circular constraint.
|
||||
|
||||
class D<U extends T, T extends V, V extends T> { }
|
||||
~
|
||||
!!! error TS2313: Type parameter 'U' has a circular constraint.
|
||||
~
|
||||
!!! error TS2313: Type parameter 'T' has a circular constraint.
|
||||
~
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
tests/cases/compiler/typeParameterWithInvalidConstraintType.ts(1,19): error TS2313: Type parameter 'T' has a circular constraint.
|
||||
tests/cases/compiler/typeParameterWithInvalidConstraintType.ts(4,19): error TS2339: Property 'foo' does not exist on type 'T'.
|
||||
tests/cases/compiler/typeParameterWithInvalidConstraintType.ts(5,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/typeParameterWithInvalidConstraintType.ts(7,17): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures.
|
||||
|
||||
|
||||
==== tests/cases/compiler/typeParameterWithInvalidConstraintType.ts (1 errors) ====
|
||||
==== tests/cases/compiler/typeParameterWithInvalidConstraintType.ts (4 errors) ====
|
||||
class A<T extends T> {
|
||||
~
|
||||
!!! error TS2313: Type parameter 'T' has a circular constraint.
|
||||
foo() {
|
||||
var x: T;
|
||||
// no error expected below this line
|
||||
var a = x.foo();
|
||||
~~~
|
||||
!!! error TS2339: Property 'foo' does not exist on type 'T'.
|
||||
var b = new x(123);
|
||||
~~~~~~~~~~
|
||||
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
var c = x[1];
|
||||
var d = x();
|
||||
~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures.
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
class A<T extends T> {
|
||||
foo() {
|
||||
var x: T;
|
||||
// no error expected below this line
|
||||
var a = x.foo();
|
||||
var b = new x(123);
|
||||
var c = x[1];
|
||||
@@ -16,7 +15,6 @@ var A = (function () {
|
||||
}
|
||||
A.prototype.foo = function () {
|
||||
var x;
|
||||
// no error expected below this line
|
||||
var a = x.foo();
|
||||
var b = new x(123);
|
||||
var c = x[1];
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// Repro from #13346
|
||||
|
||||
interface Chainable<T> {
|
||||
value(): T;
|
||||
mapValues<U>(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>;
|
||||
}
|
||||
|
||||
declare function chain<T>(t: T): Chainable<T>;
|
||||
|
||||
const square = (x: number) => x * x;
|
||||
|
||||
const v = chain({a: 1, b: 2}).mapValues(square).value();
|
||||
@@ -0,0 +1,18 @@
|
||||
// Repro from #13351
|
||||
|
||||
type Meta<T, A> = {
|
||||
readonly[P in keyof T]: {
|
||||
value: T[P];
|
||||
also: A;
|
||||
readonly children: Meta<T[P], A>;
|
||||
};
|
||||
}
|
||||
|
||||
interface Input {
|
||||
x: string;
|
||||
y: number;
|
||||
}
|
||||
|
||||
declare const output: Meta<Input, boolean>;
|
||||
|
||||
const shouldFail: { important: boolean } = output.x.children;
|
||||
@@ -1,7 +1,6 @@
|
||||
class A<T extends T> {
|
||||
foo() {
|
||||
var x: T;
|
||||
// no error expected below this line
|
||||
var a = x.foo();
|
||||
var b = new x(123);
|
||||
var c = x[1];
|
||||
|
||||
@@ -27,3 +27,6 @@
|
||||
// contextually typed parameters.
|
||||
let twelve = (f => f(12))(i => i);
|
||||
let eleven = (o => o.a(11))({ a: function(n) { return n; } });
|
||||
// missing arguments
|
||||
(function(x, undefined) { return x; })(42);
|
||||
((x, y, z) => 42)();
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// @strictNullChecks: true
|
||||
// arrow
|
||||
(jake => { })("build");
|
||||
// function expression
|
||||
(function (cats) { })("lol");
|
||||
// Lots of Irritating Superfluous Parentheses
|
||||
(function (x) { } ("!"));
|
||||
((((function (y) { }))))("-");
|
||||
// multiple arguments
|
||||
((a, b, c) => { })("foo", 101, false);
|
||||
// default parameters
|
||||
((m = 10) => m + 1)(12);
|
||||
((n = 10) => n + 1)();
|
||||
// optional parameters
|
||||
((j?) => j + 1)(12);
|
||||
((k?) => k + 1)();
|
||||
((l, o?) => l + o)(12); // o should be any
|
||||
// rest parameters
|
||||
((...numbers) => numbers.every(n => n > 0))(5,6,7);
|
||||
((...mixed) => mixed.every(n => !!n))(5,'oops','oh no');
|
||||
((...noNumbers) => noNumbers.some(n => n > 0))();
|
||||
((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10);
|
||||
// destructuring parameters (with defaults too!)
|
||||
(({ q }) => q)({ q : 13 });
|
||||
(({ p = 14 }) => p)({ p : 15 });
|
||||
(({ r = 17 } = { r: 18 }) => r)({r : 19});
|
||||
(({ u = 22 } = { u: 23 }) => u)();
|
||||
// contextually typed parameters.
|
||||
let twelve = (f => f(12))(i => i);
|
||||
let eleven = (o => o.a(11))({ a: function(n) { return n; } });
|
||||
// missing arguments
|
||||
(function(x, undefined) { return x; })(42);
|
||||
((x, y, z) => 42)();
|
||||
@@ -13,7 +13,7 @@ declare let x2: T2<"x">;
|
||||
let x2x = x2.x;
|
||||
|
||||
interface T3<T extends T3<T>> {
|
||||
x: T["x"]; // Error
|
||||
x: T["x"];
|
||||
}
|
||||
|
||||
interface T4<T extends T4<T>> {
|
||||
@@ -25,7 +25,16 @@ class C1 {
|
||||
}
|
||||
|
||||
class C2 {
|
||||
x: this["y"]; // Error
|
||||
y: this["z"]; // Error
|
||||
z: this["x"]; // Error
|
||||
}
|
||||
x: this["y"];
|
||||
y: this["z"];
|
||||
z: this["x"];
|
||||
}
|
||||
|
||||
// Repro from #12627
|
||||
|
||||
interface Foo {
|
||||
hello: boolean;
|
||||
}
|
||||
|
||||
function foo<T extends Foo | T["hello"]>() {
|
||||
}
|
||||
|
||||
@@ -297,6 +297,30 @@ class C1 {
|
||||
}
|
||||
}
|
||||
|
||||
type S2 = {
|
||||
a: string;
|
||||
b: string;
|
||||
};
|
||||
|
||||
function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) {
|
||||
x1 = x2;
|
||||
x1 = x3;
|
||||
x1 = x4;
|
||||
x2 = x1;
|
||||
x2 = x3;
|
||||
x2 = x4;
|
||||
x3 = x1;
|
||||
x3 = x2;
|
||||
x3 = x4;
|
||||
x4 = x1;
|
||||
x4 = x2;
|
||||
x4 = x3;
|
||||
x1.length;
|
||||
x2.length;
|
||||
x3.length;
|
||||
x4.length;
|
||||
}
|
||||
|
||||
// Repros from #12011
|
||||
|
||||
class Base {
|
||||
@@ -430,4 +454,40 @@ type SomeMethodDescriptor = {
|
||||
returnValue: string[];
|
||||
}
|
||||
|
||||
let result = dispatchMethod<SomeMethodDescriptor>("someMethod", ["hello", 35]);
|
||||
let result = dispatchMethod<SomeMethodDescriptor>("someMethod", ["hello", 35]);
|
||||
|
||||
// Repro from #13073
|
||||
|
||||
type KeyTypes = "a" | "b"
|
||||
let MyThingy: { [key in KeyTypes]: string[] };
|
||||
|
||||
function addToMyThingy<S extends KeyTypes>(key: S) {
|
||||
MyThingy[key].push("a");
|
||||
}
|
||||
|
||||
// Repro from #13285
|
||||
|
||||
function updateIds<T extends Record<K, string>, K extends string>(
|
||||
obj: T,
|
||||
idFields: K[],
|
||||
idMapping: { [oldId: string]: string }
|
||||
): Record<K, string> {
|
||||
for (const idField of idFields) {
|
||||
const newId = idMapping[obj[idField]];
|
||||
if (newId) {
|
||||
obj[idField] = newId;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Repro from #13285
|
||||
|
||||
function updateIds2<T extends { [x: string]: string }, K extends keyof T>(
|
||||
obj: T,
|
||||
key: K,
|
||||
stringMap: { [oldId: string]: string }
|
||||
) {
|
||||
var x = obj[key];
|
||||
stringMap[x]; // Should be OK.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
class K { p = 12; m() { } }
|
||||
interface I { p: number, m(): void }
|
||||
let k = new K()
|
||||
let sk = { ...k };
|
||||
let ssk = { ...k, ...k };
|
||||
sk.p;
|
||||
sk.m(); // error
|
||||
ssk.p;
|
||||
ssk.m(); // error
|
||||
let i: I = { p: 12, m() { } };
|
||||
let si = { ...i };
|
||||
let ssi = { ...i, ...i };
|
||||
si.p;
|
||||
si.m(); // ok
|
||||
ssi.p;
|
||||
ssi.m(); // ok
|
||||
let o = { p: 12, m() { } };
|
||||
let so = { ...o };
|
||||
let sso = { ...o, ...o };
|
||||
so.p;
|
||||
so.m(); // ok
|
||||
sso.p;
|
||||
sso.m(); // ok
|
||||
@@ -1,13 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: declarations.d.ts
|
||||
/////*module*/declare module "jquery"
|
||||
////declare module /*module*/"jquery"
|
||||
|
||||
// @Filename: user.ts
|
||||
///////<reference path="declarations.d.ts"/>
|
||||
////import /*importFoo*/foo, {bar} from "jquery";
|
||||
////import /*importBaz*/* as /*idBaz*/baz from "jquery";
|
||||
/////*importBang*/import /*idBang*/bang = require("jquery");
|
||||
////import * as /*importBaz*/baz from "jquery";
|
||||
////import /*importBang*/bang = require("jquery");
|
||||
////foo/*useFoo*/(bar/*useBar*/, baz/*useBaz*/, bang/*useBang*/);
|
||||
|
||||
verify.quickInfoAt("useFoo", "import foo");
|
||||
@@ -22,11 +22,11 @@ verify.goToDefinition("useBar", "module");
|
||||
verify.quickInfoAt("useBaz", "import baz");
|
||||
verify.goToDefinition({
|
||||
useBaz: "importBaz",
|
||||
idBaz: "module"
|
||||
importBaz: "module"
|
||||
});
|
||||
|
||||
verify.quickInfoAt("useBang", "import bang = require(\"jquery\")");
|
||||
verify.goToDefinition({
|
||||
useBang: "importBang",
|
||||
idBang: "module"
|
||||
importBang: "module"
|
||||
});
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface Foo {
|
||||
//// x: "abc" | "def";
|
||||
////}
|
||||
////function bar(f: Foo) { };
|
||||
////bar({x: "/**/"});
|
||||
|
||||
goTo.marker();
|
||||
verify.completionListContains("abc");
|
||||
verify.completionListContains("def");
|
||||
verify.completionListCount(2);
|
||||
@@ -120,7 +120,6 @@ declare namespace FourSlashInterface {
|
||||
marker(name?: string): void;
|
||||
bof(): void;
|
||||
eof(): void;
|
||||
type(definitionIndex?: number): void;
|
||||
implementation(): void;
|
||||
position(position: number, fileIndex?: number): any;
|
||||
position(position: number, fileName?: string): any;
|
||||
@@ -175,6 +174,8 @@ declare namespace FourSlashInterface {
|
||||
goToDefinition(startsAndEnds: { [startMarkerName: string]: string | string[] }): void;
|
||||
/** Verifies goToDefinition for each `${markerName}Reference` -> `${markerName}Definition` */
|
||||
goToDefinitionForMarkers(...markerNames: string[]): void;
|
||||
goToType(startsAndEnds: { [startMarkerName: string]: string | string[] }): void;
|
||||
goToType(startMarkerNames: string | string[], endMarkerNames: string | string[]): void;
|
||||
verifyGetEmitOutputForCurrentFile(expected: string): void;
|
||||
verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void;
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: b.ts
|
||||
/////*alias1Definition*/import alias1 = require("fileb");
|
||||
////import /*alias1Definition*/alias1 = require("fileb");
|
||||
////module Module {
|
||||
//// /*alias2Definition*/export import alias2 = alias1;
|
||||
//// export import /*alias2Definition*/alias2 = alias1;
|
||||
////}
|
||||
////
|
||||
////// Type position
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////declare var /*ambientVariableDefinition*/ambientVar;
|
||||
/////*ambientFunctionDefinition*/declare function ambientFunction();
|
||||
////declare function /*ambientFunctionDefinition*/ambientFunction();
|
||||
////declare class ambientClass {
|
||||
//// /*constructorDefinition*/constructor();
|
||||
//// /*staticMethodDefinition*/static method();
|
||||
//// /*instanceMethodDefinition*/public method();
|
||||
//// static /*staticMethodDefinition*/method();
|
||||
//// public /*instanceMethodDefinition*/method();
|
||||
////}
|
||||
////
|
||||
/////*ambientVariableReference*/ambientVar = 1;
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
|
||||
// @Filename: a.ts
|
||||
/////*decoratorDefinition*/function decorator(target) {
|
||||
////function /*decoratorDefinition*/decorator(target) {
|
||||
//// return target;
|
||||
////}
|
||||
/////*decoratorFactoryDefinition*/function decoratorFactory(...args) {
|
||||
////function /*decoratorFactoryDefinition*/decoratorFactory(...args) {
|
||||
//// return target => target;
|
||||
////}
|
||||
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
|
||||
////async function f() {}
|
||||
////
|
||||
/////*defDecString*/function dec(target: any, propertyKey: string): void;
|
||||
/////*defDecSymbol*/function dec(target: any, propertyKey: symbol): void;
|
||||
////function /*defDecString*/dec(target: any, propertyKey: string): void;
|
||||
////function /*defDecSymbol*/dec(target: any, propertyKey: symbol): void;
|
||||
////function dec(target: any, propertyKey: string | symbol) {}
|
||||
////
|
||||
////declare const s: symbol;
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
// @Filename: goToDefinitionDifferentFile_Definition.ts
|
||||
////var /*remoteVariableDefinition*/remoteVariable;
|
||||
/////*remoteFunctionDefinition*/function remoteFunction() { }
|
||||
/////*remoteClassDefinition*/class remoteClass { }
|
||||
/////*remoteInterfaceDefinition*/interface remoteInterface{ }
|
||||
/////*remoteModuleDefinition*/module remoteModule{ export var foo = 1;}
|
||||
////function /*remoteFunctionDefinition*/remoteFunction() { }
|
||||
////class /*remoteClassDefinition*/remoteClass { }
|
||||
////interface /*remoteInterfaceDefinition*/remoteInterface{ }
|
||||
////module /*remoteModuleDefinition*/remoteModule{ export var foo = 1;}
|
||||
|
||||
// @Filename: goToDefinitionDifferentFile_Consumption.ts
|
||||
/////*remoteVariableReference*/remoteVariable = 1;
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
// @Filename: Remote2.ts
|
||||
////var /*remoteVariableDefinition*/rem2Var;
|
||||
/////*remoteFunctionDefinition*/function rem2Fn() { }
|
||||
/////*remoteClassDefinition*/class rem2Cls { }
|
||||
/////*remoteInterfaceDefinition*/interface rem2Int{}
|
||||
/////*remoteModuleDefinition*/module rem2Mod { export var foo; }
|
||||
////function /*remoteFunctionDefinition*/rem2Fn() { }
|
||||
////class /*remoteClassDefinition*/rem2Cls { }
|
||||
////interface /*remoteInterfaceDefinition*/rem2Int{}
|
||||
////module /*remoteModuleDefinition*/rem2Mod { export var foo; }
|
||||
|
||||
// @Filename: Remote1.ts
|
||||
////var remVar;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
////var x = new n.Foo();
|
||||
|
||||
// @Filename: a.ts
|
||||
/////*2*/declare module "e" {
|
||||
////declare module /*2*/"e" {
|
||||
//// class Foo { }
|
||||
////}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: a.ts
|
||||
/////*2*/declare module "external/*1*/" {
|
||||
////declare module /*2*/"external/*1*/" {
|
||||
//// class Foo { }
|
||||
////}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
////import * from 'e/*1*/';
|
||||
|
||||
// @Filename: a.ts
|
||||
/////*2*/declare module "e" {
|
||||
////declare module /*2*/"e" {
|
||||
//// class Foo { }
|
||||
////}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
////import {Foo, Bar} from 'e/*1*/';
|
||||
|
||||
// @Filename: a.ts
|
||||
/////*2*/declare module "e" {
|
||||
////declare module /*2*/"e" {
|
||||
//// class Foo { }
|
||||
////}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
////export {Foo, Bar} from 'e/*1*/';
|
||||
|
||||
// @Filename: a.ts
|
||||
/////*2*/declare module "e" {
|
||||
////declare module /*2*/"e" {
|
||||
//// class Foo { }
|
||||
////}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
////export * from 'e/*1*/';
|
||||
|
||||
// @Filename: a.ts
|
||||
/////*2*/declare module "e" {
|
||||
////declare module /*2*/"e" {
|
||||
//// class Foo { }
|
||||
////}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////function /*def*/f() {}
|
||||
/////*use*/f(123);
|
||||
|
||||
verify.goToDefinition("use", "def");
|
||||
@@ -1,8 +1,8 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
/////*functionOverload1*/function /*functionOverload*/functionOverload(value: number);
|
||||
/////*functionOverload2*/function functionOverload(value: string);
|
||||
/////*functionOverloadDefinition*/function functionOverload() {}
|
||||
////function /*functionOverload1*/functionOverload(value: number);
|
||||
////function /*functionOverload2*/functionOverload(value: string);
|
||||
////function /*functionOverloadDefinition*/functionOverload() {}
|
||||
////
|
||||
/////*functionOverloadReference1*/functionOverload(123);
|
||||
/////*functionOverloadReference2*/functionOverload("123");
|
||||
@@ -12,5 +12,5 @@ verify.goToDefinition({
|
||||
functionOverloadReference1: "functionOverload1",
|
||||
functionOverloadReference2: "functionOverload2",
|
||||
brokenOverload: "functionOverload1",
|
||||
functionOverload: "functionOverloadDefinition"
|
||||
functionOverload1: "functionOverloadDefinition"
|
||||
});
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
////class clsInOverload {
|
||||
//// static fnOverload();
|
||||
//// static /*staticFunctionOverload*/fnOverload(foo: string);
|
||||
//// /*staticFunctionOverloadDefinition*/static fnOverload(foo: any) { }
|
||||
//// static /*staticFunctionOverloadDefinition*/fnOverload(foo: any) { }
|
||||
//// public /*functionOverload*/fnOverload(): any;
|
||||
//// public fnOverload(foo: string);
|
||||
//// /*functionOverloadDefinition*/public fnOverload(foo: any) { return "foo" }
|
||||
//// public /*functionOverloadDefinition*/fnOverload(foo: any) { return "foo" }
|
||||
////
|
||||
//// constructor() { }
|
||||
////}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
/////*constructorDefinition*/class ImplicitConstructor {
|
||||
////class /*constructorDefinition*/ImplicitConstructor {
|
||||
////}
|
||||
////var implicitConstructor = new /*constructorReference*/ImplicitConstructor();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// @Filename: a.ts
|
||||
////export module Module {
|
||||
////}
|
||||
/////*classDefinition*/export class Class {
|
||||
////export class /*classDefinition*/Class {
|
||||
//// private f;
|
||||
////}
|
||||
////export interface Interface {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// @Filename: a.ts
|
||||
////export module Module {
|
||||
////}
|
||||
/////*classDefinition*/export class Class {
|
||||
////export class /*classDefinition*/Class {
|
||||
//// private f;
|
||||
////}
|
||||
////export interface Interface {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
// @Filename: a.ts
|
||||
////export module Module {
|
||||
////}
|
||||
/////*classDefinition*/export class Class {
|
||||
////export class /*classDefinition*/Class {
|
||||
//// private f;
|
||||
////}
|
||||
////export interface Interface {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// @Filename: a.ts
|
||||
////export module Module {
|
||||
////}
|
||||
/////*classDefinition*/export class Class {
|
||||
////export class /*classDefinition*/Class {
|
||||
//// private f;
|
||||
////}
|
||||
////export interface Interface {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// @Filename: a.ts
|
||||
////export module Module {
|
||||
////}
|
||||
/////*classDefinition*/export class Class {
|
||||
////export class /*classDefinition*/Class {
|
||||
//// private f;
|
||||
////}
|
||||
////export interface Interface {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
|
||||
// @Filename: a.ts
|
||||
/////*classDefinition*/class Class {
|
||||
////class /*classDefinition*/Class {
|
||||
//// private f;
|
||||
////}
|
||||
////export default Class;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
/////*interfaceDefinition*/interface IFoo { method1(): number; }
|
||||
////interface /*interfaceDefinition*/IFoo { method1(): number; }
|
||||
////
|
||||
/////*classDefinition*/class Foo implements IFoo {
|
||||
////class /*classDefinition*/Foo implements IFoo {
|
||||
//// public method1(): number { return 0; }
|
||||
////}
|
||||
////
|
||||
/////*enumDefinition*/enum Enum { value1, value2 };
|
||||
////enum /*enumDefinition*/Enum { value1, value2 };
|
||||
////
|
||||
/////*selfDefinition*/class Bar {
|
||||
////class /*selfDefinition*/Bar {
|
||||
//// public _interface: IFo/*interfaceReference*/o = new Fo/*classReferenceInInitializer*/o();
|
||||
//// public _class: Fo/*classReference*/o = new Foo();
|
||||
//// public _list: IF/*interfaceReferenceInList*/oo[]=[];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
/////*fooDefinition*/class Foo<T> { }
|
||||
////class /*fooDefinition*/Foo<T> { }
|
||||
////
|
||||
/////*barDefinition*/class Bar { }
|
||||
////class /*barDefinition*/Bar { }
|
||||
////
|
||||
////var x = new Fo/*fooReference*/o<Ba/*barReference*/r>();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
/////*interfaceDefinition*/interface sInt {
|
||||
////interface /*interfaceDefinition*/sInt {
|
||||
//// sVar: number;
|
||||
//// sFn: () => void;
|
||||
////}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////class MethodOverload {
|
||||
//// /*staticMethodOverload1*/static /*staticMethodOverload1Name*/method();
|
||||
//// /*staticMethodOverload2*/static method(foo: string);
|
||||
//// /*staticMethodDefinition*/static method(foo?: any) { }
|
||||
//// /*instanceMethodOverload1*/public /*instanceMethodOverload1Name*/method(): any;
|
||||
//// /*instanceMethodOverload2*/public method(foo: string);
|
||||
/////*instanceMethodDefinition*/public method(foo?: any) { return "foo" }
|
||||
//// static /*staticMethodOverload1*/method();
|
||||
//// static /*staticMethodOverload2*/method(foo: string);
|
||||
//// static /*staticMethodDefinition*/method(foo?: any) { }
|
||||
//// public /*instanceMethodOverload1*/method(): any;
|
||||
//// public /*instanceMethodOverload2*/method(foo: string);
|
||||
//// public /*instanceMethodDefinition*/method(foo?: any) { return "foo" }
|
||||
////}
|
||||
|
||||
////// static method
|
||||
@@ -23,6 +23,6 @@ verify.goToDefinition({
|
||||
staticMethodReference2: "staticMethodOverload2",
|
||||
instanceMethodReference1: "instanceMethodOverload1",
|
||||
instanceMethodReference2: "instanceMethodOverload2",
|
||||
staticMethodOverload1Name: "staticMethodDefinition",
|
||||
instanceMethodOverload1Name: "instanceMethodDefinition"
|
||||
staticMethodOverload1: "staticMethodDefinition",
|
||||
instanceMethodOverload1: "instanceMethodDefinition"
|
||||
});
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: a.ts
|
||||
/////*interfaceDefinition1*/interface IFoo {
|
||||
////interface /*interfaceDefinition1*/IFoo {
|
||||
//// instance1: number;
|
||||
////}
|
||||
|
||||
// @Filename: b.ts
|
||||
/////*interfaceDefinition2*/interface IFoo {
|
||||
////interface /*interfaceDefinition2*/IFoo {
|
||||
//// instance2: number;
|
||||
////}
|
||||
////
|
||||
/////*interfaceDefinition3*/interface IFoo {
|
||||
////interface /*interfaceDefinition3*/IFoo {
|
||||
//// instance3: number;
|
||||
////}
|
||||
////
|
||||
@@ -19,12 +19,12 @@
|
||||
verify.goToDefinition("interfaceReference", ["interfaceDefinition1", "interfaceDefinition2", "interfaceDefinition3"]);
|
||||
|
||||
// @Filename: c.ts
|
||||
/////*moduleDefinition1*/module Module {
|
||||
////module /*moduleDefinition1*/Module {
|
||||
//// export class c1 { }
|
||||
////}
|
||||
|
||||
// @Filename: d.ts
|
||||
/////*moduleDefinition2*/module Module {
|
||||
////module /*moduleDefinition2*/Module {
|
||||
//// export class c2 { }
|
||||
////}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
////var o = {
|
||||
//// /*valueDefinition*/value: 0,
|
||||
//// /*getterDefinition*/get getter() {return 0 },
|
||||
//// /*setterDefinition*/set setter(v: number) { },
|
||||
//// get /*getterDefinition*/getter() {return 0 },
|
||||
//// set /*setterDefinition*/setter(v: number) { },
|
||||
//// /*methodDefinition*/method: () => { },
|
||||
//// /*es6StyleMethodDefinition*/es6StyleMethod() { }
|
||||
////};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
////namespace A {
|
||||
//// export namespace B {
|
||||
//// export function f(value: number): void;
|
||||
//// /*1*/export function f(value: string): void;
|
||||
//// export function /*1*/f(value: string): void;
|
||||
//// export function f(value: number | string) {}
|
||||
//// }
|
||||
////}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
// @Filename: goToDefinitionPartialImplementation_1.ts
|
||||
////module A {
|
||||
//// /*Part1Definition*/export interface IA {
|
||||
//// export interface /*Part1Definition*/IA {
|
||||
//// y: string;
|
||||
//// }
|
||||
////}
|
||||
|
||||
// @Filename: goToDefinitionPartialImplementation_2.ts
|
||||
////module A {
|
||||
//// /*Part2Definition*/export interface IA {
|
||||
//// export interface /*Part2Definition*/IA {
|
||||
//// x: number;
|
||||
//// }
|
||||
////
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////var /*localVariableDefinition*/localVariable;
|
||||
/////*localFunctionDefinition*/function localFunction() { }
|
||||
/////*localClassDefinition*/class localClass { }
|
||||
/////*localInterfaceDefinition*/interface localInterface{ }
|
||||
/////*localModuleDefinition*/module localModule{ export var foo = 1;}
|
||||
////function /*localFunctionDefinition*/localFunction() { }
|
||||
////class /*localClassDefinition*/localClass { }
|
||||
////interface /*localInterfaceDefinition*/localInterface{ }
|
||||
////module /*localModuleDefinition*/localModule{ export var foo = 1;}
|
||||
////
|
||||
////
|
||||
/////*localVariableReference*/localVariable = 1;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: Definition.ts
|
||||
//// /*2*/class c { }
|
||||
////class /*2*/c { }
|
||||
|
||||
// @Filename: Consumption.ts
|
||||
//// var n = new /*1*/c();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
/////*defFNumber*/function f(strs: TemplateStringsArray, x: number): void;
|
||||
/////*defFBool*/function f(strs: TemplateStringsArray, x: boolean): void;
|
||||
////function /*defFNumber*/f(strs: TemplateStringsArray, x: number): void;
|
||||
////function /*defFBool*/f(strs: TemplateStringsArray, x: boolean): void;
|
||||
////function f(strs: TemplateStringsArray, x: number | boolean) {}
|
||||
////
|
||||
/////*useFNumber*/f`${0}`;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
////function f(/*fnDecl*/this: number) {
|
||||
//// return /*fnUse*/this;
|
||||
////}
|
||||
/////*cls*/class C {
|
||||
////class /*cls*/C {
|
||||
//// constructor() { return /*clsUse*/this; }
|
||||
//// get self(/*getterDecl*/this: number) { return /*getterUse*/this; }
|
||||
////}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// /*classDeclaration*/class A {}
|
||||
//// class /*classDeclaration*/A {}
|
||||
//// function f(/*parameterDeclaration*/parameter: any): /*parameterName*/parameter is /*typeReference*/A {
|
||||
//// return typeof parameter === "string";
|
||||
//// }
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//// /*ctr*/constructor() {}
|
||||
//// x() {}
|
||||
////}
|
||||
/////*B*/class B extends A {}
|
||||
////class /*B*/B extends A {}
|
||||
////class C extends B {
|
||||
//// constructor() {
|
||||
//// /*super*/super();
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: a.ts
|
||||
//// /*2*/export class Foo {}
|
||||
////export class /*2*/Foo {}
|
||||
|
||||
// @Filename: b.ts
|
||||
//// /*3*/import n = require('a');
|
||||
//// import /*3*/n = require('a');
|
||||
//// var x = new /*1*/n.Foo();
|
||||
|
||||
// Won't-fixed: Should go to '2' instead
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: goToTypeDefinition_Definition.ts
|
||||
/////*definition*/class C {
|
||||
////class /*definition*/C {
|
||||
//// p;
|
||||
////}
|
||||
////var c: C;
|
||||
@@ -9,6 +9,4 @@
|
||||
// @Filename: goToTypeDefinition_Consumption.ts
|
||||
/////*reference*/c = undefined;
|
||||
|
||||
goTo.marker('reference');
|
||||
goTo.type();
|
||||
verify.caretAtMarker('definition');
|
||||
verify.goToType("reference", "definition");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: goToTypeDefinition2_Definition.ts
|
||||
/////*definition*/interface I1 {
|
||||
////interface /*definition*/I1 {
|
||||
//// p;
|
||||
////}
|
||||
////type propertyType = I1;
|
||||
@@ -13,6 +13,4 @@
|
||||
////var i2: I2;
|
||||
////i2.prop/*reference*/erty;
|
||||
|
||||
goTo.marker('reference');
|
||||
goTo.type();
|
||||
verify.caretAtMarker('definition');
|
||||
verify.goToType("reference", "definition");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: goToTypeDefinitioAliases_module1.ts
|
||||
/////*definition*/interface I {
|
||||
////interface /*definition*/I {
|
||||
//// p;
|
||||
////}
|
||||
////export {I as I2};
|
||||
@@ -15,10 +15,7 @@
|
||||
////import {/*reference1*/v2 as v3} from "./goToTypeDefinitioAliases_module2";
|
||||
/////*reference2*/v3;
|
||||
|
||||
goTo.marker('reference1');
|
||||
goTo.type();
|
||||
verify.caretAtMarker('definition');
|
||||
|
||||
goTo.marker('reference2');
|
||||
goTo.type();
|
||||
verify.caretAtMarker('definition');
|
||||
verify.goToType({
|
||||
reference1: "definition",
|
||||
reference2: "definition"
|
||||
});
|
||||
|
||||
@@ -8,6 +8,4 @@
|
||||
////
|
||||
/////*reference*/x;
|
||||
|
||||
goTo.marker('reference');
|
||||
goTo.type();
|
||||
verify.caretAtMarker('definition');
|
||||
verify.goToType("reference", "definition");
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: goToTypeDefinitioAliases_module1.ts
|
||||
/////*definition*/module M {
|
||||
// @Filename: module1.ts
|
||||
////module /*definition*/M {
|
||||
//// export var p;
|
||||
////}
|
||||
////var m: typeof M;
|
||||
|
||||
// @Filename: goToTypeDefinitioAliases_module3.ts
|
||||
// @Filename: module3.ts
|
||||
/////*reference1*/M;
|
||||
/////*reference2*/m;
|
||||
|
||||
goTo.marker('reference1');
|
||||
goTo.type();
|
||||
verify.caretAtMarker('definition');
|
||||
|
||||
goTo.marker('reference2');
|
||||
goTo.type();
|
||||
verify.caretAtMarker('definition');
|
||||
verify.goToType({
|
||||
reference1: "definition",
|
||||
reference2: "definition"
|
||||
});
|
||||
|
||||
@@ -12,14 +12,9 @@
|
||||
/////*reference3*/y;
|
||||
/////*reference4*/y;
|
||||
|
||||
goTo.marker('reference1');
|
||||
verify.typeDefinitionCountIs(0);
|
||||
|
||||
goTo.marker('reference1');
|
||||
verify.typeDefinitionCountIs(0);
|
||||
|
||||
goTo.marker('reference2');
|
||||
verify.typeDefinitionCountIs(0);
|
||||
|
||||
goTo.marker('reference4');
|
||||
verify.typeDefinitionCountIs(0);
|
||||
verify.goToType({
|
||||
reference1: [],
|
||||
reference2: [],
|
||||
reference3: [],
|
||||
reference4: []
|
||||
});
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
/////*definition0*/class C {
|
||||
////class /*definition0*/C {
|
||||
//// p;
|
||||
////}
|
||||
////
|
||||
/////*definition1*/interface I {
|
||||
////interface /*definition1*/I {
|
||||
//// x;
|
||||
////}
|
||||
////
|
||||
////module M {
|
||||
//// /*definition2*/export interface I {
|
||||
//// export interface /*definition2*/I {
|
||||
//// y;
|
||||
//// }
|
||||
////}
|
||||
@@ -18,14 +18,4 @@
|
||||
////
|
||||
/////*reference*/x;
|
||||
|
||||
goTo.marker('reference');
|
||||
goTo.type(0);
|
||||
verify.caretAtMarker('definition0');
|
||||
|
||||
goTo.marker('reference');
|
||||
goTo.type(1);
|
||||
verify.caretAtMarker('definition1');
|
||||
|
||||
goTo.marker('reference');
|
||||
goTo.type(2);
|
||||
verify.caretAtMarker('definition2');
|
||||
verify.goToType("reference", ["definition0", "definition1", "definition2"]);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
// @Filename: foo_user.ts
|
||||
///////<reference path="foo.d.ts" />
|
||||
/////*foo_type_declaration*/import foo = require("foo_module");
|
||||
////import /*foo_type_declaration*/foo = require("foo_module");
|
||||
////const x = foo/*foo_value*/;
|
||||
////const i: foo/*foo_type*/ = { x: 1, y: 2 };
|
||||
|
||||
@@ -37,7 +37,7 @@ verify.goToDefinitionIs("foo_type_declaration");
|
||||
|
||||
|
||||
// @Filename: bar.d.ts
|
||||
/////*bar_type_declaration*/declare interface bar { x: number; y: number }
|
||||
////declare interface /*bar_type_declaration*/bar { x: number; y: number }
|
||||
////declare module "bar_module" {
|
||||
//// const x: number;
|
||||
//// export = x;
|
||||
@@ -45,7 +45,7 @@ verify.goToDefinitionIs("foo_type_declaration");
|
||||
|
||||
// @Filename: bar_user.ts
|
||||
///////<reference path="bar.d.ts" />
|
||||
/////*bar_value_declaration*/import bar = require("bar_module");
|
||||
////import /*bar_value_declaration*/bar = require("bar_module");
|
||||
////const x = bar/*bar_value*/;
|
||||
////const i: bar/*bar_type*/ = { x: 1, y: 2 };
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
//// /**
|
||||
//// * @typedef {Object} Person
|
||||
//// * /*1*/@property {string} personName
|
||||
//// * @property {string} /*1*/personName
|
||||
//// * @property {number} personAge
|
||||
//// */
|
||||
////
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
////var x/*1*/ = new n.Foo();
|
||||
|
||||
// @Filename: a.ts
|
||||
//// /*2*/export class Foo {}
|
||||
////export class /*2*/Foo {}
|
||||
|
||||
goTo.marker('1');
|
||||
goTo.type();
|
||||
verify.caretAtMarker('2');
|
||||
verify.goToType("1", "2");
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
// @Filename: goToDefinitionDifferentFile_Definition.ts
|
||||
////var /*remoteVariableDefinition*/remoteVariable;
|
||||
/////*remoteFunctionDefinition*/function remoteFunction() { }
|
||||
/////*remoteClassDefinition*/class remoteClass { }
|
||||
/////*remoteInterfaceDefinition*/interface remoteInterface{ }
|
||||
/////*remoteModuleDefinition*/module remoteModule{ export var foo = 1;}
|
||||
////function /*remoteFunctionDefinition*/remoteFunction() { }
|
||||
////class /*remoteClassDefinition*/remoteClass { }
|
||||
////interface /*remoteInterfaceDefinition*/remoteInterface{ }
|
||||
////module /*remoteModuleDefinition*/remoteModule{ export var foo = 1;}
|
||||
|
||||
// @Filename: goToDefinitionDifferentFile_Consumption.ts
|
||||
/////*remoteVariableReference*/remoteVariable = 1;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: goToTypeDefinition_Definition.ts
|
||||
/////*definition*/class C {
|
||||
////class /*definition*/C {
|
||||
//// p;
|
||||
////}
|
||||
////var c: C;
|
||||
@@ -9,6 +9,4 @@
|
||||
// @Filename: goToTypeDefinition_Consumption.ts
|
||||
/////*reference*/c = undefined;
|
||||
|
||||
goTo.marker('reference');
|
||||
goTo.type();
|
||||
verify.caretAtMarker('definition');
|
||||
verify.goToType("reference", "definition");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user