Merge branch 'master' of https://github.com/Microsoft/TypeScript
This commit is contained in:
commit
1eb7b9183b
126 changed files with 4169 additions and 496 deletions
|
@ -50,7 +50,8 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
|
|||
r: "reporter",
|
||||
color: "colors",
|
||||
f: "files",
|
||||
file: "files"
|
||||
file: "files",
|
||||
w: "workers",
|
||||
},
|
||||
default: {
|
||||
soft: false,
|
||||
|
@ -63,6 +64,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
|
|||
reporter: process.env.reporter || process.env.r,
|
||||
lint: process.env.lint || true,
|
||||
files: process.env.f || process.env.file || process.env.files || "",
|
||||
workers: process.env.workerCount || os.cpus().length,
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -604,7 +606,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
|
|||
} while (fs.existsSync(taskConfigsFolder));
|
||||
fs.mkdirSync(taskConfigsFolder);
|
||||
|
||||
workerCount = process.env.workerCount || os.cpus().length;
|
||||
workerCount = cmdLineOptions["workers"];
|
||||
}
|
||||
|
||||
if (tests || light || taskConfigsFolder) {
|
||||
|
@ -1017,7 +1019,7 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are:
|
|||
cb();
|
||||
}, (cb) => {
|
||||
files = files.filter(file => fileMatcher.test(file.path)).sort((filea, fileb) => filea.stat.size - fileb.stat.size);
|
||||
const workerCount = (process.env.workerCount && +process.env.workerCount) || os.cpus().length;
|
||||
const workerCount = cmdLineOptions["workers"];
|
||||
for (let i = 0; i < workerCount; i++) {
|
||||
spawnLintWorker(files, finished);
|
||||
}
|
||||
|
|
|
@ -1513,7 +1513,7 @@ namespace ts {
|
|||
errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
|
||||
}
|
||||
if (isExternalModuleAugmentation(node)) {
|
||||
declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes);
|
||||
declareModuleSymbol(node);
|
||||
}
|
||||
else {
|
||||
let pattern: Pattern | undefined;
|
||||
|
@ -1535,12 +1535,8 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
else {
|
||||
const state = getModuleInstanceState(node);
|
||||
if (state === ModuleInstanceState.NonInstantiated) {
|
||||
declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes);
|
||||
}
|
||||
else {
|
||||
declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes);
|
||||
const state = declareModuleSymbol(node);
|
||||
if (state !== ModuleInstanceState.NonInstantiated) {
|
||||
if (node.symbol.flags & (SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.RegularEnum)) {
|
||||
// if module was already merged with some function, class or non-const enum
|
||||
// treat is a non-const-enum-only
|
||||
|
@ -1561,6 +1557,15 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
function declareModuleSymbol(node: ModuleDeclaration): ModuleInstanceState {
|
||||
const state = getModuleInstanceState(node);
|
||||
const instantiated = state !== ModuleInstanceState.NonInstantiated;
|
||||
declareSymbolAndAddToSymbolTable(node,
|
||||
instantiated ? SymbolFlags.ValueModule : SymbolFlags.NamespaceModule,
|
||||
instantiated ? SymbolFlags.ValueModuleExcludes : SymbolFlags.NamespaceModuleExcludes);
|
||||
return state;
|
||||
}
|
||||
|
||||
function bindFunctionOrConstructorType(node: SignatureDeclaration): void {
|
||||
// For a given function symbol "<...>(...) => T" we want to generate a symbol identical
|
||||
// to the one we would get for: { <...>(...): T }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/// <reference path="moduleNameResolver.ts"/>
|
||||
/// <reference path="moduleNameResolver.ts"/>
|
||||
/// <reference path="binder.ts"/>
|
||||
|
||||
/* @internal */
|
||||
|
@ -486,6 +486,9 @@ namespace ts {
|
|||
}
|
||||
recordMergedSymbol(target, source);
|
||||
}
|
||||
else if (target.flags & SymbolFlags.NamespaceModule) {
|
||||
error(source.valueDeclaration.name, Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target));
|
||||
}
|
||||
else {
|
||||
const message = target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable
|
||||
? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0;
|
||||
|
@ -2464,7 +2467,8 @@ namespace ts {
|
|||
const symbol = type.symbol;
|
||||
if (symbol) {
|
||||
// Always use 'typeof T' for type of class, enum, and module objects
|
||||
if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) {
|
||||
if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) ||
|
||||
symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule)) {
|
||||
writeTypeOfSymbol(type, flags);
|
||||
}
|
||||
else if (shouldWriteTypeOfFunctionSymbol()) {
|
||||
|
@ -3638,6 +3642,11 @@ namespace ts {
|
|||
return links.type;
|
||||
}
|
||||
|
||||
function getBaseTypeVariableOfClass(symbol: Symbol) {
|
||||
const baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
|
||||
return baseConstructorType.flags & TypeFlags.TypeVariable ? baseConstructorType : undefined;
|
||||
}
|
||||
|
||||
function getTypeOfFuncClassEnumModule(symbol: Symbol): Type {
|
||||
const links = getSymbolLinks(symbol);
|
||||
if (!links.type) {
|
||||
|
@ -3646,8 +3655,13 @@ namespace ts {
|
|||
}
|
||||
else {
|
||||
const type = createObjectType(ObjectFlags.Anonymous, symbol);
|
||||
links.type = strictNullChecks && symbol.flags & SymbolFlags.Optional ?
|
||||
includeFalsyTypes(type, TypeFlags.Undefined) : type;
|
||||
if (symbol.flags & SymbolFlags.Class) {
|
||||
const baseTypeVariable = getBaseTypeVariableOfClass(symbol);
|
||||
links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
|
||||
}
|
||||
else {
|
||||
links.type = strictNullChecks && symbol.flags & SymbolFlags.Optional ? includeFalsyTypes(type, TypeFlags.Undefined) : type;
|
||||
}
|
||||
}
|
||||
}
|
||||
return links.type;
|
||||
|
@ -3811,8 +3825,26 @@ namespace ts {
|
|||
return concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol));
|
||||
}
|
||||
|
||||
// A type is a mixin constructor if it has a single construct signature taking no type parameters and a single
|
||||
// rest parameter of type any[].
|
||||
function isMixinConstructorType(type: Type) {
|
||||
const signatures = getSignaturesOfType(type, SignatureKind.Construct);
|
||||
if (signatures.length === 1) {
|
||||
const s = signatures[0];
|
||||
return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isConstructorType(type: Type): boolean {
|
||||
return isValidBaseType(type) && getSignaturesOfType(type, SignatureKind.Construct).length > 0;
|
||||
if (isValidBaseType(type) && getSignaturesOfType(type, SignatureKind.Construct).length > 0) {
|
||||
return true;
|
||||
}
|
||||
if (type.flags & TypeFlags.TypeVariable) {
|
||||
const constraint = getBaseConstraintOfType(<TypeVariable>type);
|
||||
return isValidBaseType(constraint) && isMixinConstructorType(constraint);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getBaseTypeNodeOfClass(type: InterfaceType): ExpressionWithTypeArguments {
|
||||
|
@ -3891,7 +3923,7 @@ namespace ts {
|
|||
|
||||
function resolveBaseTypesOfClass(type: InterfaceType): void {
|
||||
type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray;
|
||||
const baseConstructorType = <ObjectType>getBaseConstructorTypeOfClass(type);
|
||||
const baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type));
|
||||
if (!(baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection))) {
|
||||
return;
|
||||
}
|
||||
|
@ -4541,16 +4573,47 @@ namespace ts {
|
|||
getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly);
|
||||
}
|
||||
|
||||
function includeMixinType(type: Type, types: Type[], index: number): Type {
|
||||
const mixedTypes: Type[] = [];
|
||||
for (let i = 0; i < types.length; i++) {
|
||||
if (i === index) {
|
||||
mixedTypes.push(type);
|
||||
}
|
||||
else if (isMixinConstructorType(types[i])) {
|
||||
mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], SignatureKind.Construct)[0]));
|
||||
}
|
||||
}
|
||||
return getIntersectionType(mixedTypes);
|
||||
}
|
||||
|
||||
function resolveIntersectionTypeMembers(type: IntersectionType) {
|
||||
// The members and properties collections are empty for intersection types. To get all properties of an
|
||||
// intersection type use getPropertiesOfType (only the language service uses this).
|
||||
let callSignatures: Signature[] = emptyArray;
|
||||
let constructSignatures: Signature[] = emptyArray;
|
||||
let stringIndexInfo: IndexInfo = undefined;
|
||||
let numberIndexInfo: IndexInfo = undefined;
|
||||
for (const t of type.types) {
|
||||
let stringIndexInfo: IndexInfo;
|
||||
let numberIndexInfo: IndexInfo;
|
||||
const types = type.types;
|
||||
const mixinCount = countWhere(types, isMixinConstructorType);
|
||||
for (let i = 0; i < types.length; i++) {
|
||||
const t = type.types[i];
|
||||
// When an intersection type contains mixin constructor types, the construct signatures from
|
||||
// those types are discarded and their return types are mixed into the return types of all
|
||||
// other construct signatures in the intersection type. For example, the intersection type
|
||||
// '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature
|
||||
// 'new(s: string) => A & B'.
|
||||
if (mixinCount === 0 || mixinCount === types.length && i === 0 || !isMixinConstructorType(t)) {
|
||||
let signatures = getSignaturesOfType(t, SignatureKind.Construct);
|
||||
if (signatures.length && mixinCount > 0) {
|
||||
signatures = map(signatures, s => {
|
||||
const clone = cloneSignature(s);
|
||||
clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, i);
|
||||
return clone;
|
||||
});
|
||||
}
|
||||
constructSignatures = concatenate(constructSignatures, signatures);
|
||||
}
|
||||
callSignatures = concatenate(callSignatures, getSignaturesOfType(t, SignatureKind.Call));
|
||||
constructSignatures = concatenate(constructSignatures, getSignaturesOfType(t, SignatureKind.Construct));
|
||||
stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, IndexKind.String));
|
||||
numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, IndexKind.Number));
|
||||
}
|
||||
|
@ -4592,7 +4655,7 @@ namespace ts {
|
|||
constructSignatures = getDefaultConstructSignatures(classType);
|
||||
}
|
||||
const baseConstructorType = getBaseConstructorTypeOfClass(classType);
|
||||
if (baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection)) {
|
||||
if (baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection | TypeFlags.TypeVariable)) {
|
||||
members = createSymbolTable(getNamedMembers(members));
|
||||
addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
|
||||
}
|
||||
|
@ -4620,12 +4683,14 @@ namespace ts {
|
|||
const typeParameter = getTypeParameterFromMappedType(type);
|
||||
const constraintType = getConstraintTypeFromMappedType(type);
|
||||
const templateType = getTemplateTypeFromMappedType(type);
|
||||
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
||||
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T'
|
||||
const templateReadonly = !!type.declaration.readonlyToken;
|
||||
const templateOptional = !!type.declaration.questionToken;
|
||||
if (type.declaration.typeParameter.constraint.kind === SyntaxKind.TypeOperator) {
|
||||
// We have a { [P in keyof T]: X }
|
||||
forEachType(getLiteralTypeFromPropertyNames(modifiersType), addMemberForKeyType);
|
||||
for (const propertySymbol of getPropertiesOfType(modifiersType)) {
|
||||
addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol);
|
||||
}
|
||||
if (getIndexInfoOfType(modifiersType, IndexKind.String)) {
|
||||
addMemberForKeyType(stringType);
|
||||
}
|
||||
|
@ -4640,7 +4705,7 @@ namespace ts {
|
|||
}
|
||||
setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined);
|
||||
|
||||
function addMemberForKeyType(t: Type) {
|
||||
function addMemberForKeyType(t: Type, propertySymbol?: Symbol) {
|
||||
// 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.
|
||||
|
@ -4656,6 +4721,9 @@ namespace ts {
|
|||
const prop = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient | (isOptional ? SymbolFlags.Optional : 0), propName);
|
||||
prop.type = propType;
|
||||
prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp);
|
||||
if (propertySymbol) {
|
||||
prop.mappedTypeOrigin = propertySymbol;
|
||||
}
|
||||
members.set(propName, prop);
|
||||
}
|
||||
else if (t.flags & TypeFlags.String) {
|
||||
|
@ -4884,6 +4952,7 @@ namespace ts {
|
|||
|
||||
function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: string): Symbol {
|
||||
const types = containingType.types;
|
||||
const excludeModifiers = containingType.flags & TypeFlags.Union ? ModifierFlags.Private | ModifierFlags.Protected : 0;
|
||||
let props: Symbol[];
|
||||
// Flags we want to propagate to the result if they exist in all source symbols
|
||||
let commonFlags = (containingType.flags & TypeFlags.Intersection) ? SymbolFlags.Optional : SymbolFlags.None;
|
||||
|
@ -4893,7 +4962,7 @@ namespace ts {
|
|||
const type = getApparentType(current);
|
||||
if (type !== unknownType) {
|
||||
const prop = getPropertyOfType(type, name);
|
||||
if (prop && !(getDeclarationModifierFlagsFromSymbol(prop) & (ModifierFlags.Private | ModifierFlags.Protected))) {
|
||||
if (prop && !(getDeclarationModifierFlagsFromSymbol(prop) & excludeModifiers)) {
|
||||
commonFlags &= prop.flags;
|
||||
if (!props) {
|
||||
props = [prop];
|
||||
|
@ -6313,6 +6382,9 @@ namespace ts {
|
|||
if (right.flags & TypeFlags.Union) {
|
||||
return mapType(right, t => getSpreadType(left, t));
|
||||
}
|
||||
if (right.flags & TypeFlags.NonPrimitive) {
|
||||
return emptyObjectType;
|
||||
}
|
||||
|
||||
const members = createMap<Symbol>();
|
||||
const skippedPrivateMembers = createMap<boolean>();
|
||||
|
@ -6794,6 +6866,11 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.MappedType:
|
||||
if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode((<MappedTypeNode>node).typeParameter)))) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.JSDocFunctionType:
|
||||
const func = node as JSDocFunctionType;
|
||||
for (const p of func.parameters) {
|
||||
|
@ -6956,9 +7033,12 @@ namespace ts {
|
|||
result.properties = resolved.properties;
|
||||
result.callSignatures = emptyArray;
|
||||
result.constructSignatures = emptyArray;
|
||||
type = result;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else if (type.flags & TypeFlags.Intersection) {
|
||||
return getIntersectionType(map((<IntersectionType>type).types, getTypeWithoutSignatures));
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -11712,7 +11792,7 @@ namespace ts {
|
|||
member = prop;
|
||||
}
|
||||
else if (memberDecl.kind === SyntaxKind.SpreadAssignment) {
|
||||
if (languageVersion < ScriptTarget.ESNext) {
|
||||
if (languageVersion < ScriptTarget.ES2015) {
|
||||
checkExternalEmitHelpers(memberDecl, ExternalEmitHelpers.Assign);
|
||||
}
|
||||
if (propertiesArray.length > 0) {
|
||||
|
@ -11806,7 +11886,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function isValidSpreadType(type: Type): boolean {
|
||||
return !!(type.flags & (TypeFlags.Any | TypeFlags.Null | TypeFlags.Undefined) ||
|
||||
return !!(type.flags & (TypeFlags.Any | TypeFlags.Null | TypeFlags.Undefined | TypeFlags.NonPrimitive) ||
|
||||
type.flags & TypeFlags.Object && !isGenericMappedType(type) ||
|
||||
type.flags & TypeFlags.UnionOrIntersection && !forEach((<UnionOrIntersectionType>type).types, t => !isValidSpreadType(t)));
|
||||
}
|
||||
|
@ -11870,6 +11950,16 @@ namespace ts {
|
|||
function checkJsxAttribute(node: JsxAttribute, elementAttributesType: Type, nameTable: Map<boolean>) {
|
||||
let correspondingPropType: Type = undefined;
|
||||
|
||||
// We need to unconditionally get the expression type
|
||||
let exprType: Type;
|
||||
if (node.initializer) {
|
||||
exprType = checkExpression(node.initializer);
|
||||
}
|
||||
else {
|
||||
// <Elem attr /> is sugar for <Elem attr={true} />
|
||||
exprType = booleanType;
|
||||
}
|
||||
|
||||
// Look up the corresponding property for this attribute
|
||||
if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) {
|
||||
// If there is no 'props' property, you may not have non-"data-" attributes
|
||||
|
@ -11893,15 +11983,6 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
let exprType: Type;
|
||||
if (node.initializer) {
|
||||
exprType = checkExpression(node.initializer);
|
||||
}
|
||||
else {
|
||||
// <Elem attr /> is sugar for <Elem attr={true} />
|
||||
exprType = booleanType;
|
||||
}
|
||||
|
||||
if (correspondingPropType) {
|
||||
checkTypeAssignableTo(exprType, correspondingPropType, node);
|
||||
}
|
||||
|
@ -12327,12 +12408,15 @@ namespace ts {
|
|||
// - In a static member function or static member accessor
|
||||
// where this references the constructor function object of a derived class,
|
||||
// a super property access is permitted and must specify a public static member function of the base class.
|
||||
if (languageVersion < ScriptTarget.ES2015 && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) {
|
||||
// `prop` refers to a *property* declared in the super class
|
||||
// rather than a *method*, so it does not satisfy the above criteria.
|
||||
if (languageVersion < ScriptTarget.ES2015) {
|
||||
const propKind = getDeclarationKindFromSymbol(prop);
|
||||
if (propKind !== SyntaxKind.MethodDeclaration && propKind !== SyntaxKind.MethodSignature) {
|
||||
// `prop` refers to a *property* declared in the super class
|
||||
// rather than a *method*, so it does not satisfy the above criteria.
|
||||
|
||||
error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
|
||||
return false;
|
||||
error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & ModifierFlags.Abstract) {
|
||||
|
@ -18380,7 +18464,8 @@ namespace ts {
|
|||
const baseTypes = getBaseTypes(type);
|
||||
if (baseTypes.length && produceDiagnostics) {
|
||||
const baseType = baseTypes[0];
|
||||
const staticBaseType = getBaseConstructorTypeOfClass(type);
|
||||
const baseConstructorType = getBaseConstructorTypeOfClass(type);
|
||||
const staticBaseType = getApparentType(baseConstructorType);
|
||||
checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
|
||||
checkSourceElement(baseTypeNode.expression);
|
||||
if (baseTypeNode.typeArguments) {
|
||||
|
@ -18394,6 +18479,9 @@ namespace ts {
|
|||
checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1);
|
||||
checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node,
|
||||
Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
|
||||
if (baseConstructorType.flags & TypeFlags.TypeVariable && !isMixinConstructorType(staticType)) {
|
||||
error(node.name || node, Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
|
||||
}
|
||||
|
||||
if (baseType.symbol && baseType.symbol.valueDeclaration &&
|
||||
!isInAmbientContext(baseType.symbol.valueDeclaration) &&
|
||||
|
@ -18403,7 +18491,7 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class)) {
|
||||
if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class) && !(baseConstructorType.flags & TypeFlags.TypeVariable)) {
|
||||
// When the static base type is a "class-like" constructor function (but not actually a class), we verify
|
||||
// that all instantiated base constructor signatures return the same type. We can simply compare the type
|
||||
// references (as opposed to checking the structure of the types) because elsewhere we have already checked
|
||||
|
@ -20242,6 +20330,10 @@ namespace ts {
|
|||
const links = symbol as SymbolLinks;
|
||||
return [links.leftSpread, links.rightSpread];
|
||||
}
|
||||
if ((symbol as SymbolLinks).mappedTypeOrigin) {
|
||||
return getRootSymbols((symbol as SymbolLinks).mappedTypeOrigin);
|
||||
}
|
||||
|
||||
let target: Symbol;
|
||||
let next = symbol;
|
||||
while (next = getSymbolLinks(next).target) {
|
||||
|
|
|
@ -67,10 +67,11 @@ namespace ts {
|
|||
name: "jsx",
|
||||
type: createMapFromTemplate({
|
||||
"preserve": JsxEmit.Preserve,
|
||||
"react-native": JsxEmit.ReactNative,
|
||||
"react": JsxEmit.React
|
||||
}),
|
||||
paramType: Diagnostics.KIND,
|
||||
description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react,
|
||||
description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react,
|
||||
},
|
||||
{
|
||||
name: "reactNamespace",
|
||||
|
@ -1257,7 +1258,6 @@ namespace ts {
|
|||
|
||||
const literalFiles = arrayFrom(literalFileMap.values());
|
||||
const wildcardFiles = arrayFrom(wildcardFileMap.values());
|
||||
wildcardFiles.sort(host.useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive);
|
||||
return {
|
||||
fileNames: literalFiles.concat(wildcardFiles),
|
||||
wildcardDirectories
|
||||
|
|
|
@ -260,6 +260,16 @@ namespace ts {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
/** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */
|
||||
export function findIndex<T>(array: T[], predicate: (element: T, index: number) => boolean): number {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (predicate(array[i], i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first truthy result of `callback`, or else fails.
|
||||
* This is like `forEach`, but never returns undefined.
|
||||
|
@ -1724,7 +1734,19 @@ namespace ts {
|
|||
const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*";
|
||||
const singleAsteriskRegexFragmentOther = "[^/]*";
|
||||
|
||||
export function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude") {
|
||||
export function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude"): string | undefined {
|
||||
const patterns = getRegularExpressionsForWildcards(specs, basePath, usage);
|
||||
if (!patterns || !patterns.length) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const pattern = patterns.map(pattern => `(${pattern})`).join("|");
|
||||
// If excluding, match "foo/bar/baz...", but if including, only allow "foo".
|
||||
const terminator = usage === "exclude" ? "($|/)" : "$";
|
||||
return `^(${pattern})${terminator}`;
|
||||
}
|
||||
|
||||
function getRegularExpressionsForWildcards(specs: string[], basePath: string, usage: "files" | "directories" | "exclude"): string[] | undefined {
|
||||
if (specs === undefined || specs.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -1738,33 +1760,8 @@ namespace ts {
|
|||
*/
|
||||
const doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?";
|
||||
|
||||
let pattern = "";
|
||||
let hasWrittenSubpattern = false;
|
||||
for (const spec of specs) {
|
||||
if (!spec) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter);
|
||||
if (subPattern === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasWrittenSubpattern) {
|
||||
pattern += "|";
|
||||
}
|
||||
|
||||
pattern += "(" + subPattern + ")";
|
||||
hasWrittenSubpattern = true;
|
||||
}
|
||||
|
||||
if (!pattern) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// If excluding, match "foo/bar/baz...", but if including, only allow "foo".
|
||||
const terminator = usage === "exclude" ? "($|/)" : "$";
|
||||
return `^(${pattern})${terminator}`;
|
||||
return flatMap(specs, spec =>
|
||||
spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1859,6 +1856,9 @@ namespace ts {
|
|||
}
|
||||
|
||||
export interface FileMatcherPatterns {
|
||||
/** One pattern for each "include" spec. */
|
||||
includeFilePatterns: string[];
|
||||
/** One pattern matching one of any of the "include" specs. */
|
||||
includeFilePattern: string;
|
||||
includeDirectoryPattern: string;
|
||||
excludePattern: string;
|
||||
|
@ -1871,6 +1871,7 @@ namespace ts {
|
|||
const absolutePath = combinePaths(currentDirectory, path);
|
||||
|
||||
return {
|
||||
includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), pattern => `^${pattern}$`),
|
||||
includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
|
||||
includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
|
||||
excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
|
||||
|
@ -1885,26 +1886,39 @@ namespace ts {
|
|||
const patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
|
||||
|
||||
const regexFlag = useCaseSensitiveFileNames ? "" : "i";
|
||||
const includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag);
|
||||
const includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(pattern => new RegExp(pattern, regexFlag));
|
||||
const includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag);
|
||||
const excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag);
|
||||
|
||||
const result: string[] = [];
|
||||
// Associate an array of results with each include regex. This keeps results in order of the "include" order.
|
||||
// If there are no "includes", then just put everything in results[0].
|
||||
const results: string[][] = includeFileRegexes ? includeFileRegexes.map(() => []) : [[]];
|
||||
|
||||
const comparer = useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive;
|
||||
for (const basePath of patterns.basePaths) {
|
||||
visitDirectory(basePath, combinePaths(currentDirectory, basePath));
|
||||
}
|
||||
return result;
|
||||
|
||||
return flatten(results);
|
||||
|
||||
function visitDirectory(path: string, absolutePath: string) {
|
||||
const { files, directories } = getFileSystemEntries(path);
|
||||
let { files, directories } = getFileSystemEntries(path);
|
||||
files = files.slice().sort(comparer);
|
||||
directories = directories.slice().sort(comparer);
|
||||
|
||||
for (const current of files) {
|
||||
const name = combinePaths(path, current);
|
||||
const absoluteName = combinePaths(absolutePath, current);
|
||||
if ((!extensions || fileExtensionIsAny(name, extensions)) &&
|
||||
(!includeFileRegex || includeFileRegex.test(absoluteName)) &&
|
||||
(!excludeRegex || !excludeRegex.test(absoluteName))) {
|
||||
result.push(name);
|
||||
if (extensions && !fileExtensionIsAny(name, extensions)) continue;
|
||||
if (excludeRegex && excludeRegex.test(absoluteName)) continue;
|
||||
if (!includeFileRegexes) {
|
||||
results[0].push(name);
|
||||
}
|
||||
else {
|
||||
const includeIndex = findIndex(includeFileRegexes, re => re.test(absoluteName));
|
||||
if (includeIndex !== -1) {
|
||||
results[includeIndex].push(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1783,6 +1783,10 @@
|
|||
"category": "Error",
|
||||
"code": 2544
|
||||
},
|
||||
"A mixin class must have a constructor with a single rest parameter of type 'any[]'.": {
|
||||
"category": "Error",
|
||||
"code": 2545
|
||||
},
|
||||
"JSX element attributes type '{0}' may not be a union type.": {
|
||||
"category": "Error",
|
||||
"code": 2600
|
||||
|
@ -1823,6 +1827,10 @@
|
|||
"category": "Error",
|
||||
"code": 2609
|
||||
},
|
||||
"Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": {
|
||||
"category": "Error",
|
||||
"code": 2649
|
||||
},
|
||||
"Cannot emit namespaced JSX elements in React": {
|
||||
"category": "Error",
|
||||
"code": 2650
|
||||
|
@ -2713,7 +2721,7 @@
|
|||
"category": "Message",
|
||||
"code": 6079
|
||||
},
|
||||
"Specify JSX code generation: 'preserve' or 'react'": {
|
||||
"Specify JSX code generation: 'preserve', 'react-native', or 'react'": {
|
||||
"category": "Message",
|
||||
"code": 6080
|
||||
},
|
||||
|
@ -3263,6 +3271,10 @@
|
|||
"category": "Message",
|
||||
"code": 90007
|
||||
},
|
||||
"Add 'this.' to unresolved variable.": {
|
||||
"category": "Message",
|
||||
"code": 90008
|
||||
},
|
||||
"Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig": {
|
||||
"category": "Error",
|
||||
"code": 90009
|
||||
|
|
|
@ -1054,9 +1054,11 @@ namespace ts {
|
|||
// Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal
|
||||
function needsDotDotForPropertyAccess(expression: Expression) {
|
||||
if (expression.kind === SyntaxKind.NumericLiteral) {
|
||||
// check if numeric literal was originally written with a dot
|
||||
// check if numeric literal is a decimal literal that was originally written with a dot
|
||||
const text = getLiteralTextOfNode(<LiteralExpression>expression);
|
||||
return text.indexOf(tokenToString(SyntaxKind.DotToken)) < 0;
|
||||
return getNumericLiteralFlags(text, /*hint*/ NumericLiteralFlags.All) === NumericLiteralFlags.None
|
||||
&& !(<LiteralExpression>expression).isOctalLiteral
|
||||
&& text.indexOf(tokenToString(SyntaxKind.DotToken)) < 0;
|
||||
}
|
||||
else if (isPropertyAccessExpression(expression) || isElementAccessExpression(expression)) {
|
||||
// check if constant enum value is integer
|
||||
|
|
|
@ -6693,10 +6693,15 @@ namespace ts {
|
|||
typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0);
|
||||
if (typedefTag.fullName) {
|
||||
let rightNode = typedefTag.fullName;
|
||||
while (rightNode.kind !== SyntaxKind.Identifier) {
|
||||
while (true) {
|
||||
if (rightNode.kind === SyntaxKind.Identifier || !rightNode.body) {
|
||||
// if node is identifier - use it as name
|
||||
// otherwise use name of the rightmost part that we were able to parse
|
||||
typedefTag.name = rightNode.kind === SyntaxKind.Identifier ? rightNode : rightNode.name;
|
||||
break;
|
||||
}
|
||||
rightNode = rightNode.body;
|
||||
}
|
||||
typedefTag.name = rightNode;
|
||||
}
|
||||
typedefTag.typeExpression = typeExpression;
|
||||
skipWhitespace();
|
||||
|
|
|
@ -2316,7 +2316,7 @@ namespace ts {
|
|||
addRange(statements, convertedLoopBodyStatements);
|
||||
}
|
||||
else {
|
||||
const statement = visitNode(node.statement, visitor, isStatement);
|
||||
const statement = visitNode(node.statement, visitor, isStatement, /*optional*/ false, liftToBlock);
|
||||
if (isBlock(statement)) {
|
||||
addRange(statements, statement.statements);
|
||||
bodyLocation = statement;
|
||||
|
|
|
@ -11,10 +11,10 @@ namespace ts {
|
|||
export function transformES5(context: TransformationContext) {
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
|
||||
// enable emit notification only if using --jsx preserve
|
||||
// enable emit notification only if using --jsx preserve or react-native
|
||||
let previousOnEmitNode: (emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) => void;
|
||||
let noSubstitution: boolean[];
|
||||
if (compilerOptions.jsx === JsxEmit.Preserve) {
|
||||
if (compilerOptions.jsx === JsxEmit.Preserve || compilerOptions.jsx === JsxEmit.ReactNative) {
|
||||
previousOnEmitNode = context.onEmitNode;
|
||||
context.onEmitNode = onEmitNode;
|
||||
context.enableEmitNotification(SyntaxKind.JsxOpeningElement);
|
||||
|
@ -116,4 +116,4 @@ namespace ts {
|
|||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -402,6 +402,11 @@ namespace ts {
|
|||
};
|
||||
|
||||
export function createAssignHelper(context: TransformationContext, attributesSegments: Expression[]) {
|
||||
if (context.getCompilerOptions().target >= ScriptTarget.ES2015) {
|
||||
return createCall(createPropertyAccess(createIdentifier("Object"), "assign"),
|
||||
/*typeArguments*/ undefined,
|
||||
attributesSegments);
|
||||
}
|
||||
context.requestEmitHelper(assignHelper);
|
||||
return createCall(
|
||||
getHelperName("__assign"),
|
||||
|
|
|
@ -2712,6 +2712,7 @@
|
|||
containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property
|
||||
leftSpread?: Symbol; // Left source for synthetic spread property
|
||||
rightSpread?: Symbol; // Right source for synthetic spread property
|
||||
mappedTypeOrigin?: Symbol; // For a property on a mapped type, points back to the orignal 'T' from 'keyof T'.
|
||||
hasNonUniformType?: boolean; // True if constituents have non-uniform types
|
||||
isPartial?: boolean; // True if syntheric property of union type occurs in some but not all constituents
|
||||
isDiscriminantProperty?: boolean; // True if discriminant synthetic property
|
||||
|
@ -3300,7 +3301,8 @@
|
|||
export const enum JsxEmit {
|
||||
None = 0,
|
||||
Preserve = 1,
|
||||
React = 2
|
||||
React = 2,
|
||||
ReactNative = 3
|
||||
}
|
||||
|
||||
export const enum NewLineKind {
|
||||
|
|
|
@ -341,16 +341,52 @@ namespace ts {
|
|||
}
|
||||
|
||||
export function isBinaryOrOctalIntegerLiteral(node: LiteralLikeNode, text: string) {
|
||||
if (node.kind === SyntaxKind.NumericLiteral && text.length > 1) {
|
||||
return node.kind === SyntaxKind.NumericLiteral
|
||||
&& (getNumericLiteralFlags(text, /*hint*/ NumericLiteralFlags.BinaryOrOctal) & NumericLiteralFlags.BinaryOrOctal) !== 0;
|
||||
}
|
||||
|
||||
export const enum NumericLiteralFlags {
|
||||
None = 0,
|
||||
Hexadecimal = 1 << 0,
|
||||
Binary = 1 << 1,
|
||||
Octal = 1 << 2,
|
||||
Scientific = 1 << 3,
|
||||
|
||||
BinaryOrOctal = Binary | Octal,
|
||||
BinaryOrOctalOrHexadecimal = BinaryOrOctal | Hexadecimal,
|
||||
All = Hexadecimal | Binary | Octal | Scientific,
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans a numeric literal string to determine the form of the number.
|
||||
* @param text Numeric literal text
|
||||
* @param hint If `Scientific` or `All` is specified, performs a more expensive check to scan for scientific notation.
|
||||
*/
|
||||
export function getNumericLiteralFlags(text: string, hint?: NumericLiteralFlags) {
|
||||
if (text.length > 1) {
|
||||
switch (text.charCodeAt(1)) {
|
||||
case CharacterCodes.b:
|
||||
case CharacterCodes.B:
|
||||
return NumericLiteralFlags.Binary;
|
||||
case CharacterCodes.o:
|
||||
case CharacterCodes.O:
|
||||
return true;
|
||||
return NumericLiteralFlags.Octal;
|
||||
case CharacterCodes.x:
|
||||
case CharacterCodes.X:
|
||||
return NumericLiteralFlags.Hexadecimal;
|
||||
}
|
||||
|
||||
if (hint & NumericLiteralFlags.Scientific) {
|
||||
for (let i = text.length - 1; i >= 0; i--) {
|
||||
switch (text.charCodeAt(i)) {
|
||||
case CharacterCodes.e:
|
||||
case CharacterCodes.E:
|
||||
return NumericLiteralFlags.Scientific;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return NumericLiteralFlags.None;
|
||||
}
|
||||
|
||||
function getQuotedEscapedLiteralText(leftQuote: string, text: string, rightQuote: string) {
|
||||
|
@ -395,7 +431,7 @@ namespace ts {
|
|||
|
||||
function isShorthandAmbientModule(node: Node): boolean {
|
||||
// The only kind of module that can be missing a body is a shorthand ambient module.
|
||||
return node.kind === SyntaxKind.ModuleDeclaration && (!(<ModuleDeclaration>node).body);
|
||||
return node && node.kind === SyntaxKind.ModuleDeclaration && (!(<ModuleDeclaration>node).body);
|
||||
}
|
||||
|
||||
export function isBlockScopedContainerTopLevel(node: Node): boolean {
|
||||
|
@ -1667,11 +1703,15 @@ namespace ts {
|
|||
node = parent;
|
||||
break;
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
if ((<ShorthandPropertyAssignment>parent).name !== node) {
|
||||
if ((parent as ShorthandPropertyAssignment).name !== node) {
|
||||
return AssignmentKind.None;
|
||||
}
|
||||
// Fall through
|
||||
node = parent.parent;
|
||||
break;
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
if ((parent as ShorthandPropertyAssignment).name === node) {
|
||||
return AssignmentKind.None;
|
||||
}
|
||||
node = parent.parent;
|
||||
break;
|
||||
default:
|
||||
|
@ -1683,7 +1723,8 @@ namespace ts {
|
|||
|
||||
// A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property
|
||||
// assignment in an object literal that is an assignment target, or if it is parented by an array literal that is
|
||||
// an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'.
|
||||
// an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'.
|
||||
// (Note that `p` is not a target in the above examples, only `a`.)
|
||||
export function isAssignmentTarget(node: Node): boolean {
|
||||
return getAssignmentTargetKind(node) !== AssignmentKind.None;
|
||||
}
|
||||
|
@ -3109,7 +3150,11 @@ namespace ts {
|
|||
}
|
||||
|
||||
export function getLocalSymbolForExportDefault(symbol: Symbol) {
|
||||
return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, ModifierFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
|
||||
return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined;
|
||||
}
|
||||
|
||||
export function isExportDefaultSymbol(symbol: Symbol): boolean {
|
||||
return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, ModifierFlags.Default);
|
||||
}
|
||||
|
||||
/** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace ts {
|
|||
start: undefined,
|
||||
length: undefined,
|
||||
}, {
|
||||
messageText: "Argument for '--jsx' option must be: 'preserve', 'react'",
|
||||
messageText: "Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace ts {
|
|||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--jsx' option must be: 'preserve', 'react'",
|
||||
messageText: "Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
|
|
|
@ -290,16 +290,21 @@ namespace ts {
|
|||
});
|
||||
describe("getFirstToken", () => {
|
||||
it("gets jsdoc", () => {
|
||||
const first = ts.createSourceFile("foo.ts", "/** comment */var a = true;", ts.ScriptTarget.ES5, /*setParentNodes*/ true);
|
||||
const root = ts.createSourceFile("foo.ts", "/** comment */var a = true;", ts.ScriptTarget.ES5, /*setParentNodes*/ true);
|
||||
assert.isDefined(root);
|
||||
assert.equal(root.kind, ts.SyntaxKind.SourceFile);
|
||||
const first = root.getFirstToken();
|
||||
assert.isDefined(first);
|
||||
assert.equal(first.kind, 263);
|
||||
assert.equal(first.kind, ts.SyntaxKind.VarKeyword);
|
||||
});
|
||||
});
|
||||
describe("getLastToken", () => {
|
||||
it("gets jsdoc", () => {
|
||||
const last = ts.createSourceFile("foo.ts", "var a = true;/** comment */", ts.ScriptTarget.ES5, /*setParentNodes*/ true);
|
||||
const root = ts.createSourceFile("foo.ts", "var a = true;/** comment */", ts.ScriptTarget.ES5, /*setParentNodes*/ true);
|
||||
assert.isDefined(root);
|
||||
const last = root.getLastToken();
|
||||
assert.isDefined(last);
|
||||
assert.equal(last.kind, 263);
|
||||
assert.equal(last.kind, ts.SyntaxKind.EndOfFileToken);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -346,9 +346,9 @@ namespace ts {
|
|||
fileNames: [
|
||||
"c:/dev/a.ts",
|
||||
"c:/dev/b.ts",
|
||||
"c:/dev/node_modules/a.ts",
|
||||
"c:/dev/bower_components/a.ts",
|
||||
"c:/dev/jspm_packages/a.ts",
|
||||
"c:/dev/node_modules/a.ts"
|
||||
"c:/dev/jspm_packages/a.ts"
|
||||
],
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
|
@ -373,9 +373,9 @@ namespace ts {
|
|||
options: {},
|
||||
errors: [],
|
||||
fileNames: [
|
||||
"c:/dev/node_modules/a.ts",
|
||||
"c:/dev/bower_components/a.ts",
|
||||
"c:/dev/jspm_packages/a.ts",
|
||||
"c:/dev/node_modules/a.ts"
|
||||
"c:/dev/jspm_packages/a.ts"
|
||||
],
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
|
@ -398,9 +398,9 @@ namespace ts {
|
|||
fileNames: [
|
||||
"c:/dev/a.ts",
|
||||
"c:/dev/b.ts",
|
||||
"c:/dev/node_modules/a.ts",
|
||||
"c:/dev/bower_components/a.ts",
|
||||
"c:/dev/jspm_packages/a.ts",
|
||||
"c:/dev/node_modules/a.ts"
|
||||
"c:/dev/jspm_packages/a.ts"
|
||||
],
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
|
@ -410,6 +410,36 @@ namespace ts {
|
|||
});
|
||||
|
||||
describe("with wildcard include list", () => {
|
||||
it("is sorted in include order, then in alphabetical order", () => {
|
||||
const json = {
|
||||
include: [
|
||||
"z/*.ts",
|
||||
"x/*.ts"
|
||||
]
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
fileNames: [
|
||||
"c:/dev/z/a.ts",
|
||||
"c:/dev/z/aba.ts",
|
||||
"c:/dev/z/abz.ts",
|
||||
"c:/dev/z/b.ts",
|
||||
"c:/dev/z/bba.ts",
|
||||
"c:/dev/z/bbz.ts",
|
||||
"c:/dev/x/a.ts",
|
||||
"c:/dev/x/aa.ts",
|
||||
"c:/dev/x/b.ts"
|
||||
],
|
||||
wildcardDirectories: {
|
||||
"c:/dev/z": ts.WatchDirectoryFlags.None,
|
||||
"c:/dev/x": ts.WatchDirectoryFlags.None
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
|
||||
it("same named declarations are excluded", () => {
|
||||
const json = {
|
||||
include: [
|
||||
|
@ -506,8 +536,8 @@ namespace ts {
|
|||
options: {},
|
||||
errors: [],
|
||||
fileNames: [
|
||||
"c:/dev/x/a.ts",
|
||||
"c:/dev/x/y/a.ts",
|
||||
"c:/dev/x/a.ts",
|
||||
"c:/dev/z/a.ts"
|
||||
],
|
||||
wildcardDirectories: {
|
||||
|
@ -909,6 +939,31 @@ namespace ts {
|
|||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with jsx=react-native, allowJs=false", () => {
|
||||
const json = {
|
||||
compilerOptions: {
|
||||
jsx: "react-native",
|
||||
allowJs: false
|
||||
}
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {
|
||||
jsx: ts.JsxEmit.ReactNative,
|
||||
allowJs: false
|
||||
},
|
||||
errors: [],
|
||||
fileNames: [
|
||||
"c:/dev/a.ts",
|
||||
"c:/dev/b.tsx",
|
||||
"c:/dev/c.tsx",
|
||||
],
|
||||
wildcardDirectories: {
|
||||
"c:/dev": ts.WatchDirectoryFlags.Recursive
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with jsx=none, allowJs=true", () => {
|
||||
const json = {
|
||||
compilerOptions: {
|
||||
|
@ -961,6 +1016,33 @@ namespace ts {
|
|||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with jsx=react-native, allowJs=true", () => {
|
||||
const json = {
|
||||
compilerOptions: {
|
||||
jsx: "react-native",
|
||||
allowJs: true
|
||||
}
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {
|
||||
jsx: ts.JsxEmit.ReactNative,
|
||||
allowJs: true
|
||||
},
|
||||
errors: [],
|
||||
fileNames: [
|
||||
"c:/dev/a.ts",
|
||||
"c:/dev/b.tsx",
|
||||
"c:/dev/c.tsx",
|
||||
"c:/dev/d.js",
|
||||
"c:/dev/e.jsx",
|
||||
],
|
||||
wildcardDirectories: {
|
||||
"c:/dev": ts.WatchDirectoryFlags.Recursive
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("exclude .min.js files using wildcards", () => {
|
||||
const json = {
|
||||
compilerOptions: {
|
||||
|
@ -1230,8 +1312,8 @@ namespace ts {
|
|||
options: {},
|
||||
errors: [],
|
||||
fileNames: [
|
||||
"c:/dev/.z/.b.ts",
|
||||
"c:/dev/x/.y/a.ts"
|
||||
"c:/dev/x/.y/a.ts",
|
||||
"c:/dev/.z/.b.ts"
|
||||
],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
|
@ -1271,8 +1353,8 @@ namespace ts {
|
|||
options: {},
|
||||
errors: [],
|
||||
fileNames: [
|
||||
"c:/dev/.z/.b.ts",
|
||||
"c:/dev/x/.y/a.ts"
|
||||
"c:/dev/x/.y/a.ts",
|
||||
"c:/dev/.z/.b.ts"
|
||||
],
|
||||
wildcardDirectories: {
|
||||
"c:/dev/.z": ts.WatchDirectoryFlags.Recursive,
|
||||
|
@ -1306,4 +1388,4 @@ namespace ts {
|
|||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
4
src/lib/es2015.collection.d.ts
vendored
4
src/lib/es2015.collection.d.ts
vendored
|
@ -22,7 +22,7 @@ interface ReadonlyMap<K, V> {
|
|||
readonly size: number;
|
||||
}
|
||||
|
||||
interface WeakMap<K, V> {
|
||||
interface WeakMap<K extends object, V> {
|
||||
delete(key: K): boolean;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
|
@ -31,7 +31,7 @@ interface WeakMap<K, V> {
|
|||
|
||||
interface WeakMapConstructor {
|
||||
new (): WeakMap<any, any>;
|
||||
new <K, V>(entries?: [K, V][]): WeakMap<K, V>;
|
||||
new <K extends object, V>(entries?: [K, V][]): WeakMap<K, V>;
|
||||
readonly prototype: WeakMap<any, any>;
|
||||
}
|
||||
declare var WeakMap: WeakMapConstructor;
|
||||
|
|
2
src/lib/es2015.core.d.ts
vendored
2
src/lib/es2015.core.d.ts
vendored
|
@ -325,7 +325,7 @@ interface ObjectConstructor {
|
|||
* @param o The object to change its prototype.
|
||||
* @param proto The value of the new prototype or null.
|
||||
*/
|
||||
setPrototypeOf(o: any, proto: any): any;
|
||||
setPrototypeOf(o: any, proto: object | null): any;
|
||||
|
||||
/**
|
||||
* Gets the own property descriptor of the specified object.
|
||||
|
|
6
src/lib/es2015.iterable.d.ts
vendored
6
src/lib/es2015.iterable.d.ts
vendored
|
@ -99,10 +99,10 @@ interface MapConstructor {
|
|||
new <K, V>(iterable: Iterable<[K, V]>): Map<K, V>;
|
||||
}
|
||||
|
||||
interface WeakMap<K, V> { }
|
||||
interface WeakMap<K extends object, V> { }
|
||||
|
||||
interface WeakMapConstructor {
|
||||
new <K, V>(iterable: Iterable<[K, V]>): WeakMap<K, V>;
|
||||
new <K extends object, V>(iterable: Iterable<[K, V]>): WeakMap<K, V>;
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
|
@ -442,4 +442,4 @@ interface Float64ArrayConstructor {
|
|||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array;
|
||||
}
|
||||
}
|
||||
|
|
4
src/lib/es2015.proxy.d.ts
vendored
4
src/lib/es2015.proxy.d.ts
vendored
|
@ -1,5 +1,5 @@
|
|||
interface ProxyHandler<T> {
|
||||
getPrototypeOf? (target: T): {} | null;
|
||||
getPrototypeOf? (target: T): object | null;
|
||||
setPrototypeOf? (target: T, v: any): boolean;
|
||||
isExtensible? (target: T): boolean;
|
||||
preventExtensions? (target: T): boolean;
|
||||
|
@ -12,7 +12,7 @@ interface ProxyHandler<T> {
|
|||
enumerate? (target: T): PropertyKey[];
|
||||
ownKeys? (target: T): PropertyKey[];
|
||||
apply? (target: T, thisArg: any, argArray?: any): any;
|
||||
construct? (target: T, argArray: any, newTarget?: any): {};
|
||||
construct? (target: T, argArray: any, newTarget?: any): object
|
||||
}
|
||||
|
||||
interface ProxyConstructor {
|
||||
|
|
4
src/lib/es2015.symbol.wellknown.d.ts
vendored
4
src/lib/es2015.symbol.wellknown.d.ts
vendored
|
@ -110,7 +110,7 @@ interface Map<K, V> {
|
|||
readonly [Symbol.toStringTag]: "Map";
|
||||
}
|
||||
|
||||
interface WeakMap<K, V>{
|
||||
interface WeakMap<K extends object, V>{
|
||||
readonly [Symbol.toStringTag]: "WeakMap";
|
||||
}
|
||||
|
||||
|
@ -324,4 +324,4 @@ interface Float32Array {
|
|||
*/
|
||||
interface Float64Array {
|
||||
readonly [Symbol.toStringTag]: "Float64Array";
|
||||
}
|
||||
}
|
||||
|
|
4
src/lib/es5.d.ts
vendored
4
src/lib/es5.d.ts
vendored
|
@ -146,14 +146,14 @@ interface ObjectConstructor {
|
|||
* Creates an object that has the specified prototype, and that optionally contains specified properties.
|
||||
* @param o Object to use as a prototype. May be null
|
||||
*/
|
||||
create<T>(o: T): T;
|
||||
create<T extends object>(o: T): T;
|
||||
|
||||
/**
|
||||
* Creates an object that has the specified prototype, and that optionally contains specified properties.
|
||||
* @param o Object to use as a prototype. May be null
|
||||
* @param properties JavaScript object that contains one or more property descriptors.
|
||||
*/
|
||||
create(o: any, properties: PropertyDescriptorMap): any;
|
||||
create(o: object | null, properties: PropertyDescriptorMap): any;
|
||||
|
||||
/**
|
||||
* Adds a property to an object, or modifies attributes of an existing property.
|
||||
|
|
|
@ -417,7 +417,7 @@ namespace ts.server.protocol {
|
|||
startOffset: number;
|
||||
|
||||
/**
|
||||
* Position (can be specified instead of line/offset pair)
|
||||
* Position (can be specified instead of line/offset pair)
|
||||
*/
|
||||
/* @internal */
|
||||
startPosition?: number;
|
||||
|
@ -433,7 +433,7 @@ namespace ts.server.protocol {
|
|||
endOffset: number;
|
||||
|
||||
/**
|
||||
* Position (can be specified instead of line/offset pair)
|
||||
* Position (can be specified instead of line/offset pair)
|
||||
*/
|
||||
/* @internal */
|
||||
endPosition?: number;
|
||||
|
@ -445,7 +445,7 @@ namespace ts.server.protocol {
|
|||
}
|
||||
|
||||
/**
|
||||
* Response for GetCodeFixes request.
|
||||
* Response for GetCodeFixes request.
|
||||
*/
|
||||
export interface GetCodeFixesResponse extends Response {
|
||||
body?: CodeAction[];
|
||||
|
@ -2272,10 +2272,11 @@ namespace ts.server.protocol {
|
|||
export namespace JsxEmit {
|
||||
export type None = "None";
|
||||
export type Preserve = "Preserve";
|
||||
export type ReactNative = "ReactNative";
|
||||
export type React = "React";
|
||||
}
|
||||
|
||||
export type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React;
|
||||
export type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.ReactNative;
|
||||
|
||||
export namespace ModuleKind {
|
||||
export type None = "None";
|
||||
|
|
|
@ -484,18 +484,20 @@ namespace ts.server {
|
|||
|
||||
private getImplementation(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.FileSpan[] | ImplementationLocation[] {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const scriptInfo = project.getScriptInfoForNormalizedPath(file);
|
||||
const position = this.getPosition(args, scriptInfo);
|
||||
const position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file));
|
||||
const implementations = project.getLanguageService().getImplementationAtPosition(file, position);
|
||||
if (!implementations) {
|
||||
return [];
|
||||
}
|
||||
if (simplifiedResult) {
|
||||
return implementations.map(impl => ({
|
||||
file: impl.fileName,
|
||||
start: scriptInfo.positionToLineOffset(impl.textSpan.start),
|
||||
end: scriptInfo.positionToLineOffset(ts.textSpanEnd(impl.textSpan))
|
||||
}));
|
||||
return implementations.map(({ fileName, textSpan }) => {
|
||||
const scriptInfo = project.getScriptInfo(fileName);
|
||||
return {
|
||||
file: fileName,
|
||||
start: scriptInfo.positionToLineOffset(textSpan.start),
|
||||
end: scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan))
|
||||
};
|
||||
});
|
||||
}
|
||||
else {
|
||||
return implementations;
|
||||
|
|
16
src/services/codefixes/fixForgottenThisPropertyAccess.ts
Normal file
16
src/services/codefixes/fixForgottenThisPropertyAccess.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* @internal */
|
||||
namespace ts.codefix {
|
||||
registerCodeFix({
|
||||
errorCodes: [Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code],
|
||||
getCodeActions: (context: CodeFixContext) => {
|
||||
const sourceFile = context.sourceFile;
|
||||
const token = getTokenAtPosition(sourceFile, context.span.start);
|
||||
const start = token.getStart(sourceFile);
|
||||
|
||||
return [{
|
||||
description: getLocaleSpecificMessage(Diagnostics.Add_this_to_unresolved_variable),
|
||||
changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start, length: 0 } }] }]
|
||||
}];
|
||||
}
|
||||
});
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
/// <reference path="fixClassSuperMustPrecedeThisAccess.ts" />
|
||||
/// <reference path="fixConstructorForDerivedNeedSuperCall.ts" />
|
||||
/// <reference path="fixExtendsInterfaceBecomesImplements.ts" />
|
||||
/// <reference path="fixForgottenThisPropertyAccess.ts" />
|
||||
/// <reference path='unusedIdentifierFixes.ts' />
|
||||
/// <reference path='importFixes.ts' />
|
||||
/// <reference path='helpers.ts' />
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace ts.DocumentHighlights {
|
|||
}
|
||||
|
||||
function getSemanticDocumentHighlights(node: Node, typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] {
|
||||
const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/false, /*findInComments*/false, /*implementations*/false);
|
||||
const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch);
|
||||
return referencedSymbols && convertReferencedSymbols(referencedSymbols);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,49 +1,27 @@
|
|||
/* @internal */
|
||||
namespace ts.FindAllReferences {
|
||||
export function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] | undefined {
|
||||
export function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean, isForRename: boolean): ReferencedSymbol[] | undefined {
|
||||
const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true);
|
||||
return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, /*implementations*/false);
|
||||
return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename);
|
||||
}
|
||||
|
||||
export function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean, implementations: boolean): ReferencedSymbol[] | undefined {
|
||||
export function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings?: boolean, findInComments?: boolean, isForRename?: boolean, implementations?: boolean): ReferencedSymbol[] | undefined {
|
||||
if (!implementations) {
|
||||
if (isTypeKeyword(node.kind)) {
|
||||
return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken);
|
||||
}
|
||||
|
||||
// Labels
|
||||
if (isLabelName(node)) {
|
||||
if (isJumpStatementTarget(node)) {
|
||||
const labelDefinition = getTargetLabel((<BreakOrContinueStatement>node.parent), (<Identifier>node).text);
|
||||
// if we have a label definition, look within its statement for references, if not, then
|
||||
// the label is undefined and we have no results..
|
||||
return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken);
|
||||
}
|
||||
else {
|
||||
// it is a label definition and not a target, search within the parent labeledStatement
|
||||
return getLabelReferencesInNode(node.parent, <Identifier>node, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
if (isThis(node)) {
|
||||
return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken);
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.SuperKeyword) {
|
||||
return getReferencesForSuperKeyword(node, typeChecker, cancellationToken);
|
||||
const special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken);
|
||||
if (special) {
|
||||
return special;
|
||||
}
|
||||
}
|
||||
|
||||
// `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword,
|
||||
// so we have to specify that we want the constructor symbol.
|
||||
const symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
if (!implementations && !symbol && node.kind === SyntaxKind.StringLiteral) {
|
||||
return getReferencesForStringLiteral(<StringLiteral>node, sourceFiles, typeChecker, cancellationToken);
|
||||
}
|
||||
let symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
// Could not find a symbol e.g. unknown identifier
|
||||
if (!symbol) {
|
||||
if (!implementations && node.kind === SyntaxKind.StringLiteral) {
|
||||
return getReferencesForStringLiteral(<StringLiteral>node, sourceFiles, typeChecker, cancellationToken);
|
||||
}
|
||||
// Can't have references to something that we have no symbol for.
|
||||
return undefined;
|
||||
}
|
||||
|
@ -55,9 +33,23 @@ namespace ts.FindAllReferences {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const { symbol: aliasedSymbol, shorthandModuleSymbol } = followAliases(symbol, node, typeChecker, isForRename);
|
||||
symbol = aliasedSymbol;
|
||||
|
||||
// Build the set of symbols to search for, initially it has only the current symbol
|
||||
const searchSymbols = populateSearchSymbolSet(symbol, node, typeChecker, implementations);
|
||||
if (shorthandModuleSymbol) {
|
||||
searchSymbols.push(shorthandModuleSymbol);
|
||||
}
|
||||
|
||||
// Compute the meaning from the location and the symbol it references
|
||||
const searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations);
|
||||
|
||||
const result: ReferencedSymbol[] = [];
|
||||
// Maps from a symbol ID to the ReferencedSymbol entry in 'result'.
|
||||
const symbolToIndex: number[] = [];
|
||||
const inheritsFromCache: Map<boolean> = createMap<boolean>();
|
||||
|
||||
// Get the text to search for.
|
||||
// Note: if this is an external module symbol, the name doesn't include quotes.
|
||||
const declaredName = stripQuotes(getDeclaredName(typeChecker, symbol, node));
|
||||
|
@ -65,33 +57,107 @@ namespace ts.FindAllReferences {
|
|||
// Try to get the smallest valid scope that we can limit our search to;
|
||||
// otherwise we'll need to search globally (i.e. include each file).
|
||||
const scope = getSymbolScope(symbol);
|
||||
|
||||
// Maps from a symbol ID to the ReferencedSymbol entry in 'result'.
|
||||
const symbolToIndex: number[] = [];
|
||||
|
||||
let result: ReferencedSymbol[];
|
||||
if (scope) {
|
||||
result = [];
|
||||
getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken);
|
||||
getRefs(scope, declaredName);
|
||||
}
|
||||
else {
|
||||
const internedName = getInternedName(symbol, node);
|
||||
const isDefault = isExportDefaultSymbol(symbol);
|
||||
const internedName = isDefault ? symbol.valueDeclaration.localSymbol.name : getInternedName(symbol, node);
|
||||
for (const sourceFile of sourceFiles) {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
if (sourceFileHasName(sourceFile, internedName)) {
|
||||
result = result || [];
|
||||
getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken);
|
||||
const searchName = (isDefault ? getDefaultImportName(symbol, sourceFile, typeChecker) : undefined) ||
|
||||
(sourceFileHasName(sourceFile, internedName) ? declaredName : undefined);
|
||||
if (searchName !== undefined) {
|
||||
getRefs(sourceFile, searchName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
function getRefs(scope: ts.Node, searchName: string): void {
|
||||
getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result,
|
||||
symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache);
|
||||
}
|
||||
}
|
||||
|
||||
/** getReferencedSymbols for special node kinds. */
|
||||
function getReferencedSymbolsSpecial(node: Node, sourceFiles: SourceFile[], typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] | undefined {
|
||||
if (isTypeKeyword(node.kind)) {
|
||||
return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken);
|
||||
}
|
||||
|
||||
// Labels
|
||||
if (isLabelName(node)) {
|
||||
if (isJumpStatementTarget(node)) {
|
||||
const labelDefinition = getTargetLabel((<BreakOrContinueStatement>node.parent), (<Identifier>node).text);
|
||||
// if we have a label definition, look within its statement for references, if not, then
|
||||
// the label is undefined and we have no results..
|
||||
return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken);
|
||||
}
|
||||
else {
|
||||
// it is a label definition and not a target, search within the parent labeledStatement
|
||||
return getLabelReferencesInNode(node.parent, <Identifier>node, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
if (isThis(node)) {
|
||||
return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken);
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.SuperKeyword) {
|
||||
return getReferencesForSuperKeyword(node, typeChecker, cancellationToken);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Follows aliases to get to the original declaration of a symbol.
|
||||
* For a shorthand ambient module, we don't follow the alias to it, but we will need to add it to the set of search symbols.
|
||||
*/
|
||||
function followAliases(symbol: Symbol, node: Node, typeChecker: TypeChecker, isForRename: boolean): { symbol: Symbol, shorthandModuleSymbol?: Symbol } {
|
||||
while (true) {
|
||||
// When renaming a default import, only rename in the current file
|
||||
if (isForRename && isImportDefaultSymbol(symbol)) {
|
||||
return { symbol };
|
||||
}
|
||||
|
||||
const aliasedSymbol = getAliasSymbolForPropertyNameSymbol(symbol, node, typeChecker);
|
||||
// Don't follow alias if it goes to unknown symbol. This can happen if it points to an untyped module.
|
||||
if (!aliasedSymbol || !aliasedSymbol.declarations) {
|
||||
return { symbol };
|
||||
}
|
||||
|
||||
if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) {
|
||||
return { symbol, shorthandModuleSymbol: aliasedSymbol };
|
||||
}
|
||||
|
||||
symbol = aliasedSymbol;
|
||||
}
|
||||
}
|
||||
|
||||
function sourceFileHasName(sourceFile: SourceFile, name: string): boolean {
|
||||
return getNameTable(sourceFile).get(name) !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a symbol, see if any of the imports in a source file reference it.
|
||||
* Only call this if `symbol` is a default export.
|
||||
*/
|
||||
function getDefaultImportName(symbol: Symbol, sourceFile: SourceFile, checker: ts.TypeChecker): string | undefined {
|
||||
for (const importSpecifier of sourceFile.imports) {
|
||||
const importDecl = importSpecifier.parent as ts.ImportDeclaration;
|
||||
Debug.assert(importDecl.moduleSpecifier === importSpecifier);
|
||||
const defaultName = importDecl.importClause.name;
|
||||
const defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName));
|
||||
if (symbol === defaultReferencedSymbol) {
|
||||
return defaultName.text;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getDefinition(symbol: Symbol, node: Node, typeChecker: TypeChecker): ReferencedSymbolDefinitionInfo {
|
||||
const { displayParts, symbolKind } = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), getContainerNode(node), node);
|
||||
const name = displayParts.map(p => p.text).join("");
|
||||
|
@ -112,29 +178,30 @@ namespace ts.FindAllReferences {
|
|||
}
|
||||
|
||||
function getAliasSymbolForPropertyNameSymbol(symbol: Symbol, location: Node, typeChecker: TypeChecker): Symbol | undefined {
|
||||
if (symbol.flags & SymbolFlags.Alias) {
|
||||
// Default import get alias
|
||||
const defaultImport = getDeclarationOfKind(symbol, SyntaxKind.ImportClause);
|
||||
if (defaultImport) {
|
||||
return typeChecker.getAliasedSymbol(symbol);
|
||||
}
|
||||
|
||||
const importOrExportSpecifier = <ImportOrExportSpecifier>forEach(symbol.declarations,
|
||||
declaration => (declaration.kind === SyntaxKind.ImportSpecifier ||
|
||||
declaration.kind === SyntaxKind.ExportSpecifier) ? declaration : undefined);
|
||||
if (importOrExportSpecifier &&
|
||||
// export { a }
|
||||
(!importOrExportSpecifier.propertyName ||
|
||||
// export {a as class } where a is location
|
||||
importOrExportSpecifier.propertyName === location)) {
|
||||
// If Import specifier -> get alias
|
||||
// else Export specifier -> get local target
|
||||
return importOrExportSpecifier.kind === SyntaxKind.ImportSpecifier ?
|
||||
typeChecker.getAliasedSymbol(symbol) :
|
||||
typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier);
|
||||
}
|
||||
if (!(symbol.flags & SymbolFlags.Alias)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Default import get alias
|
||||
const defaultImport = getDeclarationOfKind(symbol, SyntaxKind.ImportClause);
|
||||
if (defaultImport) {
|
||||
return typeChecker.getAliasedSymbol(symbol);
|
||||
}
|
||||
|
||||
const importOrExportSpecifier = <ImportOrExportSpecifier>forEach(symbol.declarations,
|
||||
declaration => (declaration.kind === SyntaxKind.ImportSpecifier ||
|
||||
declaration.kind === SyntaxKind.ExportSpecifier) ? declaration : undefined);
|
||||
if (importOrExportSpecifier &&
|
||||
// export { a }
|
||||
(!importOrExportSpecifier.propertyName ||
|
||||
// export {a as class } where a is location
|
||||
importOrExportSpecifier.propertyName === location)) {
|
||||
// If Import specifier -> get alias
|
||||
// else Export specifier -> get local target
|
||||
return importOrExportSpecifier.kind === SyntaxKind.ImportSpecifier ?
|
||||
typeChecker.getAliasedSymbol(symbol) :
|
||||
typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function followAliasIfNecessary(symbol: Symbol, location: Node, typeChecker: TypeChecker): Symbol {
|
||||
|
@ -166,14 +233,9 @@ namespace ts.FindAllReferences {
|
|||
// If this is an export or import specifier it could have been renamed using the 'as' syntax.
|
||||
// If so we want to search for whatever under the cursor.
|
||||
if (isImportOrExportSpecifierName(location)) {
|
||||
return location.getText();
|
||||
return location.text;
|
||||
}
|
||||
|
||||
// Try to get the local symbol if we're dealing with an 'export default'
|
||||
// since that symbol has the "true" name.
|
||||
const localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol);
|
||||
symbol = localExportDefaultSymbol || symbol;
|
||||
|
||||
return stripQuotes(symbol.name);
|
||||
}
|
||||
|
||||
|
@ -390,7 +452,9 @@ namespace ts.FindAllReferences {
|
|||
symbolToIndex: number[],
|
||||
implementations: boolean,
|
||||
typeChecker: TypeChecker,
|
||||
cancellationToken: CancellationToken): void {
|
||||
cancellationToken: CancellationToken,
|
||||
searchSymbols: Symbol[],
|
||||
inheritsFromCache: Map<boolean>): void {
|
||||
|
||||
const sourceFile = container.getSourceFile();
|
||||
|
||||
|
@ -398,9 +462,6 @@ namespace ts.FindAllReferences {
|
|||
const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken);
|
||||
|
||||
const parents = getParentSymbolsOfPropertyAccess();
|
||||
const inheritsFromCache: Map<boolean> = createMap<boolean>();
|
||||
// Build the set of symbols to search for, initially it has only the current symbol
|
||||
const searchSymbols = populateSearchSymbolSet(searchSymbol, searchLocation, typeChecker, implementations);
|
||||
|
||||
for (const position of possiblePositions) {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
@ -445,12 +506,12 @@ namespace ts.FindAllReferences {
|
|||
addReferenceToRelatedSymbol(referenceLocation, relatedSymbol);
|
||||
}
|
||||
/* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment
|
||||
* has two meaning : property name and property value. Therefore when we do findAllReference at the position where
|
||||
* an identifier is declared, the language service should return the position of the variable declaration as well as
|
||||
* the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the
|
||||
* position of property accessing, the referenceEntry of such position will be handled in the first case.
|
||||
*/
|
||||
else if (!(referenceSymbol.flags & SymbolFlags.Transient) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) {
|
||||
* has two meanings: property name and property value. Therefore when we do findAllReference at the position where
|
||||
* an identifier is declared, the language service should return the position of the variable declaration as well as
|
||||
* the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the
|
||||
* position of property accessing, the referenceEntry of such position will be handled in the first case.
|
||||
*/
|
||||
else if (!(referenceSymbol.flags & SymbolFlags.Transient) && contains(searchSymbols, shorthandValueSymbol)) {
|
||||
addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol);
|
||||
}
|
||||
else if (searchLocation.kind === SyntaxKind.ConstructorKeyword) {
|
||||
|
@ -461,10 +522,10 @@ namespace ts.FindAllReferences {
|
|||
return;
|
||||
|
||||
/* If we are just looking for implementations and this is a property access expression, we need to get the
|
||||
* symbol of the local type of the symbol the property is being accessed on. This is because our search
|
||||
* symbol may have a different parent symbol if the local type's symbol does not declare the property
|
||||
* being accessed (i.e. it is declared in some parent class or interface)
|
||||
*/
|
||||
* symbol of the local type of the symbol the property is being accessed on. This is because our search
|
||||
* symbol may have a different parent symbol if the local type's symbol does not declare the property
|
||||
* being accessed (i.e. it is declared in some parent class or interface)
|
||||
*/
|
||||
function getParentSymbolsOfPropertyAccess(): Symbol[] | undefined {
|
||||
if (implementations) {
|
||||
const propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation);
|
||||
|
@ -482,10 +543,6 @@ namespace ts.FindAllReferences {
|
|||
}
|
||||
}
|
||||
|
||||
function getPropertyAccessExpressionFromRightHandSide(node: Node): PropertyAccessExpression {
|
||||
return isRightSideOfPropertyAccess(node) && <PropertyAccessExpression>node.parent;
|
||||
}
|
||||
|
||||
/** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */
|
||||
function findAdditionalConstructorReferences(referenceSymbol: Symbol, referenceLocation: Node): void {
|
||||
Debug.assert(isClassLike(searchSymbol.valueDeclaration));
|
||||
|
@ -494,7 +551,7 @@ namespace ts.FindAllReferences {
|
|||
if (referenceSymbol === searchSymbol && isClassLike(referenceClass)) {
|
||||
Debug.assert(referenceClass.name === referenceLocation);
|
||||
// This is the class declaration containing the constructor.
|
||||
addReferences(findOwnConstructorCalls(searchSymbol));
|
||||
addReferences(findOwnConstructorCalls(searchSymbol, sourceFile));
|
||||
}
|
||||
else {
|
||||
// If this class appears in `extends C`, then the extending class' "super" calls are references.
|
||||
|
@ -512,58 +569,6 @@ namespace ts.FindAllReferences {
|
|||
}
|
||||
}
|
||||
|
||||
/** `classSymbol` is the class where the constructor was defined.
|
||||
* Reference the constructor and all calls to `new this()`.
|
||||
*/
|
||||
function findOwnConstructorCalls(classSymbol: Symbol): Node[] {
|
||||
const result: Node[] = [];
|
||||
|
||||
for (const decl of classSymbol.members.get("__constructor").declarations) {
|
||||
const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)!
|
||||
Debug.assert(decl.kind === SyntaxKind.Constructor && !!ctrKeyword);
|
||||
result.push(ctrKeyword);
|
||||
}
|
||||
|
||||
classSymbol.exports.forEach(member => {
|
||||
const decl = member.valueDeclaration;
|
||||
if (decl && decl.kind === SyntaxKind.MethodDeclaration) {
|
||||
const body = (<MethodDeclaration>decl).body;
|
||||
if (body) {
|
||||
forEachDescendantOfKind(body, SyntaxKind.ThisKeyword, thisKeyword => {
|
||||
if (isNewExpressionTarget(thisKeyword)) {
|
||||
result.push(thisKeyword);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Find references to `super` in the constructor of an extending class. */
|
||||
function superConstructorAccesses(cls: ClassLikeDeclaration): Node[] {
|
||||
const symbol = cls.symbol;
|
||||
const ctr = symbol.members.get("__constructor");
|
||||
if (!ctr) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const result: Node[] = [];
|
||||
for (const decl of ctr.declarations) {
|
||||
Debug.assert(decl.kind === SyntaxKind.Constructor);
|
||||
const body = (<ConstructorDeclaration>decl).body;
|
||||
if (body) {
|
||||
forEachDescendantOfKind(body, SyntaxKind.SuperKeyword, node => {
|
||||
if (isCallExpressionTarget(node)) {
|
||||
result.push(node);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
function getReferencedSymbol(symbol: Symbol): ReferencedSymbol {
|
||||
const symbolId = getSymbolId(symbol);
|
||||
let index = symbolToIndex[symbolId];
|
||||
|
@ -591,6 +596,62 @@ namespace ts.FindAllReferences {
|
|||
}
|
||||
}
|
||||
|
||||
function getPropertyAccessExpressionFromRightHandSide(node: Node): PropertyAccessExpression {
|
||||
return isRightSideOfPropertyAccess(node) && <PropertyAccessExpression>node.parent;
|
||||
}
|
||||
|
||||
/** `classSymbol` is the class where the constructor was defined.
|
||||
* Reference the constructor and all calls to `new this()`.
|
||||
*/
|
||||
function findOwnConstructorCalls(classSymbol: Symbol, sourceFile: SourceFile): Node[] {
|
||||
const result: Node[] = [];
|
||||
|
||||
for (const decl of classSymbol.members.get("__constructor").declarations) {
|
||||
const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)!
|
||||
Debug.assert(decl.kind === SyntaxKind.Constructor && !!ctrKeyword);
|
||||
result.push(ctrKeyword);
|
||||
}
|
||||
|
||||
classSymbol.exports.forEach(member => {
|
||||
const decl = member.valueDeclaration;
|
||||
if (decl && decl.kind === SyntaxKind.MethodDeclaration) {
|
||||
const body = (<MethodDeclaration>decl).body;
|
||||
if (body) {
|
||||
forEachDescendantOfKind(body, SyntaxKind.ThisKeyword, thisKeyword => {
|
||||
if (isNewExpressionTarget(thisKeyword)) {
|
||||
result.push(thisKeyword);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Find references to `super` in the constructor of an extending class. */
|
||||
function superConstructorAccesses(cls: ClassLikeDeclaration): Node[] {
|
||||
const symbol = cls.symbol;
|
||||
const ctr = symbol.members.get("__constructor");
|
||||
if (!ctr) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const result: Node[] = [];
|
||||
for (const decl of ctr.declarations) {
|
||||
Debug.assert(decl.kind === SyntaxKind.Constructor);
|
||||
const body = (<ConstructorDeclaration>decl).body;
|
||||
if (body) {
|
||||
forEachDescendantOfKind(body, SyntaxKind.SuperKeyword, node => {
|
||||
if (isCallExpressionTarget(node)) {
|
||||
result.push(node);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
function getImplementationReferenceEntryForNode(refNode: Node, result: ReferenceEntry[], typeChecker: TypeChecker): void {
|
||||
// Check if we found a function/propertyAssignment/method with an implementation or initializer
|
||||
if (isDeclarationName(refNode) && isImplementation(refNode.parent)) {
|
||||
|
@ -805,13 +866,13 @@ namespace ts.FindAllReferences {
|
|||
|
||||
const sourceFile = searchSpaceNode.getSourceFile();
|
||||
const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken);
|
||||
forEach(possiblePositions, position => {
|
||||
for (const position of possiblePositions) {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
const node = getTouchingWord(sourceFile, position);
|
||||
|
||||
if (!node || node.kind !== SyntaxKind.SuperKeyword) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
const container = getSuperContainer(node, /*stopOnFunctions*/ false);
|
||||
|
@ -822,7 +883,7 @@ namespace ts.FindAllReferences {
|
|||
if (container && (ModifierFlags.Static & getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) {
|
||||
references.push(getReferenceEntryFromNode(node));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker);
|
||||
return [{ definition, references }];
|
||||
|
@ -985,7 +1046,7 @@ namespace ts.FindAllReferences {
|
|||
|
||||
function populateSearchSymbolSet(symbol: Symbol, location: Node, typeChecker: TypeChecker, implementations: boolean): Symbol[] {
|
||||
// The search set contains at least the current symbol
|
||||
let result = [symbol];
|
||||
const result = [symbol];
|
||||
|
||||
// If the location is name of property symbol from object literal destructuring pattern
|
||||
// Search the property symbol
|
||||
|
@ -998,22 +1059,6 @@ namespace ts.FindAllReferences {
|
|||
}
|
||||
}
|
||||
|
||||
// If the symbol is an alias, add what it aliases to the list
|
||||
// import {a} from "mod";
|
||||
// export {a}
|
||||
// If the symbol is an alias to default declaration, add what it aliases to the list
|
||||
// declare "mod" { export default class B { } }
|
||||
// import B from "mod";
|
||||
//// For export specifiers, the exported name can be referring to a local symbol, e.g.:
|
||||
//// import {a} from "mod";
|
||||
//// export {a as somethingElse}
|
||||
//// We want the *local* declaration of 'a' as declared in the import,
|
||||
//// *not* as declared within "mod" (or farther)
|
||||
const aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker);
|
||||
if (aliasSymbol) {
|
||||
result = result.concat(populateSearchSymbolSet(aliasSymbol, location, typeChecker, implementations));
|
||||
}
|
||||
|
||||
// If the location is in a context sensitive location (i.e. in an object literal) try
|
||||
// to get a contextual type for it, and add the property symbol from the contextual
|
||||
// type to the search set
|
||||
|
@ -1045,7 +1090,7 @@ namespace ts.FindAllReferences {
|
|||
// Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members
|
||||
if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.Parameter &&
|
||||
isParameterPropertyDeclaration(<ParameterDeclaration>symbol.valueDeclaration)) {
|
||||
result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(<ParameterDeclaration>symbol.valueDeclaration, symbol.name));
|
||||
addRange(result, typeChecker.getSymbolsOfParameterPropertyDeclaration(<ParameterDeclaration>symbol.valueDeclaration, symbol.name));
|
||||
}
|
||||
|
||||
// If this is symbol of binding element without propertyName declaration in Object binding pattern
|
||||
|
@ -1057,7 +1102,7 @@ namespace ts.FindAllReferences {
|
|||
|
||||
// If this is a union property, add all the symbols from all its source symbols in all unioned types.
|
||||
// If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list
|
||||
forEach(typeChecker.getRootSymbols(symbol), rootSymbol => {
|
||||
for (const rootSymbol of typeChecker.getRootSymbols(symbol)) {
|
||||
if (rootSymbol !== symbol) {
|
||||
result.push(rootSymbol);
|
||||
}
|
||||
|
@ -1066,7 +1111,7 @@ namespace ts.FindAllReferences {
|
|||
if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
|
||||
getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap<Symbol>(), typeChecker);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1130,10 +1175,10 @@ namespace ts.FindAllReferences {
|
|||
}
|
||||
}
|
||||
|
||||
function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, searchLocationIsConstructor: boolean, parents: Symbol[] | undefined, cache: Map<boolean>, typeChecker: TypeChecker): Symbol {
|
||||
function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, searchLocationIsConstructor: boolean, parents: Symbol[] | undefined, cache: Map<boolean>, typeChecker: TypeChecker): Symbol | undefined {
|
||||
if (contains(searchSymbols, referenceSymbol)) {
|
||||
// If we are searching for constructor uses, they must be 'new' expressions.
|
||||
return (!searchLocationIsConstructor || isNewExpressionTarget(referenceLocation)) && referenceSymbol;
|
||||
return (!searchLocationIsConstructor || isNewExpressionTarget(referenceLocation)) ? referenceSymbol : undefined;
|
||||
}
|
||||
|
||||
// If the reference symbol is an alias, check if what it is aliasing is one of the search
|
||||
|
@ -1148,9 +1193,8 @@ namespace ts.FindAllReferences {
|
|||
// compare to our searchSymbol
|
||||
const containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation);
|
||||
if (containingObjectLiteralElement) {
|
||||
const contextualSymbol = forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), contextualSymbol => {
|
||||
return forEach(typeChecker.getRootSymbols(contextualSymbol), s => searchSymbols.indexOf(s) >= 0 ? s : undefined);
|
||||
});
|
||||
const contextualSymbol = forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), contextualSymbol =>
|
||||
find(typeChecker.getRootSymbols(contextualSymbol), symbol => contains(searchSymbols, symbol)));
|
||||
|
||||
if (contextualSymbol) {
|
||||
return contextualSymbol;
|
||||
|
@ -1161,7 +1205,7 @@ namespace ts.FindAllReferences {
|
|||
// In below eg. get 'property' from type of elems iterating type
|
||||
// for ( { property: p2 } of elems) { }
|
||||
const propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker);
|
||||
if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) {
|
||||
if (propertySymbol && contains(searchSymbols, propertySymbol)) {
|
||||
return propertySymbol;
|
||||
}
|
||||
}
|
||||
|
@ -1170,7 +1214,7 @@ namespace ts.FindAllReferences {
|
|||
// then include the binding element in the related symbols
|
||||
// let { a } : { a };
|
||||
const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker);
|
||||
if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) {
|
||||
if (bindingElementPropertySymbol && contains(searchSymbols, bindingElementPropertySymbol)) {
|
||||
return bindingElementPropertySymbol;
|
||||
}
|
||||
|
||||
|
@ -1178,7 +1222,7 @@ namespace ts.FindAllReferences {
|
|||
// Or a union property, use its underlying unioned symbols
|
||||
return forEach(typeChecker.getRootSymbols(referenceSymbol), rootSymbol => {
|
||||
// if it is in the list, then we are done
|
||||
if (searchSymbols.indexOf(rootSymbol) >= 0) {
|
||||
if (contains(searchSymbols, rootSymbol)) {
|
||||
return rootSymbol;
|
||||
}
|
||||
|
||||
|
@ -1195,7 +1239,7 @@ namespace ts.FindAllReferences {
|
|||
|
||||
const result: Symbol[] = [];
|
||||
getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap<Symbol>(), typeChecker);
|
||||
return forEach(result, s => searchSymbols.indexOf(s) >= 0 ? s : undefined);
|
||||
return find(result, symbol => contains(searchSymbols, symbol));
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
@ -1214,7 +1258,8 @@ namespace ts.FindAllReferences {
|
|||
return (<Identifier | LiteralExpression>node.name).text;
|
||||
}
|
||||
|
||||
function getPropertySymbolsFromContextualType(node: ObjectLiteralElement, typeChecker: TypeChecker): Symbol[] {
|
||||
/** Gets all symbols for one property. Does not get symbols for every property. */
|
||||
function getPropertySymbolsFromContextualType(node: ObjectLiteralElement, typeChecker: TypeChecker): Symbol[] | undefined {
|
||||
const objectLiteral = <ObjectLiteralExpression>node.parent;
|
||||
const contextualType = typeChecker.getContextualType(objectLiteral);
|
||||
const name = getNameFromObjectLiteralElement(node);
|
||||
|
@ -1420,4 +1465,8 @@ namespace ts.FindAllReferences {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isImportDefaultSymbol(symbol: Symbol): boolean {
|
||||
return symbol.declarations[0].kind === SyntaxKind.ImportClause;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,7 +187,15 @@ namespace ts.GoToDefinition {
|
|||
}
|
||||
|
||||
function isSignatureDeclaration(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature
|
||||
switch (node.kind) {
|
||||
case ts.SyntaxKind.Constructor:
|
||||
case ts.SyntaxKind.FunctionDeclaration:
|
||||
case ts.SyntaxKind.MethodDeclaration:
|
||||
case ts.SyntaxKind.MethodSignature:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
|
||||
|
@ -254,6 +262,11 @@ namespace ts.GoToDefinition {
|
|||
|
||||
function tryGetSignatureDeclaration(typeChecker: TypeChecker, node: Node): SignatureDeclaration | undefined {
|
||||
const callLike = getAncestorCallLikeExpression(node);
|
||||
return callLike && typeChecker.getResolvedSignature(callLike).declaration;
|
||||
const decl = callLike && typeChecker.getResolvedSignature(callLike).declaration;
|
||||
if (decl && isSignatureDeclaration(decl)) {
|
||||
return decl;
|
||||
}
|
||||
// Don't go to a function type, go to the value having that type.
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace ts.GoToImplementation {
|
|||
else {
|
||||
// Perform "Find all References" and retrieve only those that are implementations
|
||||
const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken,
|
||||
node, sourceFiles, /*findInStrings*/false, /*findInComments*/false, /*implementations*/true);
|
||||
node, sourceFiles, /*findInStrings*/false, /*findInComments*/false, /*isForRename*/false, /*implementations*/true);
|
||||
const result = flatMap(referencedSymbols, symbol =>
|
||||
map(symbol.references, ({ textSpan, fileName }) => ({ textSpan, fileName })));
|
||||
|
||||
|
|
|
@ -1,98 +1,92 @@
|
|||
/* @internal */
|
||||
namespace ts.Rename {
|
||||
export function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string, sourceFile: SourceFile, position: number): RenameInfo {
|
||||
const canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName));
|
||||
|
||||
const getCanonicalDefaultLibName = memoize(() => getCanonicalFileName(ts.normalizePath(defaultLibFileName)));
|
||||
const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true);
|
||||
|
||||
if (node) {
|
||||
if (node.kind === SyntaxKind.Identifier ||
|
||||
node.kind === SyntaxKind.StringLiteral ||
|
||||
isLiteralNameOfPropertyDeclarationOrIndexAccess(node) ||
|
||||
isThis(node)) {
|
||||
const symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
// Only allow a symbol to be renamed if it actually has at least one declaration.
|
||||
if (symbol) {
|
||||
const declarations = symbol.getDeclarations();
|
||||
if (declarations && declarations.length > 0) {
|
||||
// Disallow rename for elements that are defined in the standard TypeScript library.
|
||||
if (forEach(declarations, isDefinedInLibraryFile)) {
|
||||
return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library));
|
||||
}
|
||||
|
||||
const displayName = stripQuotes(getDeclaredName(typeChecker, symbol, node));
|
||||
const kind = SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
|
||||
if (kind) {
|
||||
return {
|
||||
canRename: true,
|
||||
kind,
|
||||
displayName,
|
||||
localizedErrorMessage: undefined,
|
||||
fullDisplayName: typeChecker.getFullyQualifiedName(symbol),
|
||||
kindModifiers: SymbolDisplay.getSymbolModifiers(symbol),
|
||||
triggerSpan: createTriggerSpanForNode(node, sourceFile)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (node.kind === SyntaxKind.StringLiteral) {
|
||||
const type = getStringLiteralTypeForNode(<StringLiteral>node, typeChecker);
|
||||
if (type) {
|
||||
if (isDefinedInLibraryFile(node)) {
|
||||
return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library));
|
||||
}
|
||||
else {
|
||||
const displayName = stripQuotes(type.text);
|
||||
return {
|
||||
canRename: true,
|
||||
kind: ScriptElementKind.variableElement,
|
||||
displayName,
|
||||
localizedErrorMessage: undefined,
|
||||
fullDisplayName: displayName,
|
||||
kindModifiers: ScriptElementKindModifier.none,
|
||||
triggerSpan: createTriggerSpanForNode(node, sourceFile)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_this_element));
|
||||
|
||||
function getRenameInfoError(localizedErrorMessage: string): RenameInfo {
|
||||
return {
|
||||
canRename: false,
|
||||
localizedErrorMessage: localizedErrorMessage,
|
||||
displayName: undefined,
|
||||
fullDisplayName: undefined,
|
||||
kind: undefined,
|
||||
kindModifiers: undefined,
|
||||
triggerSpan: undefined
|
||||
};
|
||||
}
|
||||
const renameInfo = node && nodeIsEligibleForRename(node)
|
||||
? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile)
|
||||
: undefined;
|
||||
return renameInfo || getRenameInfoError(Diagnostics.You_cannot_rename_this_element);
|
||||
|
||||
function isDefinedInLibraryFile(declaration: Node) {
|
||||
if (defaultLibFileName) {
|
||||
const sourceFile = declaration.getSourceFile();
|
||||
const canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName));
|
||||
if (canonicalName === canonicalDefaultLibName) {
|
||||
return true;
|
||||
}
|
||||
if (!defaultLibFileName) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function createTriggerSpanForNode(node: Node, sourceFile: SourceFile) {
|
||||
let start = node.getStart(sourceFile);
|
||||
let width = node.getWidth(sourceFile);
|
||||
if (node.kind === SyntaxKind.StringLiteral) {
|
||||
// Exclude the quotes
|
||||
start += 1;
|
||||
width -= 2;
|
||||
}
|
||||
return createTextSpan(start, width);
|
||||
const sourceFile = declaration.getSourceFile();
|
||||
const canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName));
|
||||
return canonicalName === getCanonicalDefaultLibName();
|
||||
}
|
||||
}
|
||||
|
||||
function getRenameInfoForNode(node: Node, typeChecker: TypeChecker, sourceFile: SourceFile, isDefinedInLibraryFile: (declaration: Node) => boolean): RenameInfo | undefined {
|
||||
const symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
// Only allow a symbol to be renamed if it actually has at least one declaration.
|
||||
if (symbol) {
|
||||
const declarations = symbol.getDeclarations();
|
||||
if (declarations && declarations.length > 0) {
|
||||
// Disallow rename for elements that are defined in the standard TypeScript library.
|
||||
if (some(declarations, isDefinedInLibraryFile)) {
|
||||
return getRenameInfoError(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library);
|
||||
}
|
||||
|
||||
const displayName = stripQuotes(getDeclaredName(typeChecker, symbol, node));
|
||||
const kind = SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
|
||||
return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined;
|
||||
}
|
||||
}
|
||||
else if (node.kind === SyntaxKind.StringLiteral) {
|
||||
const type = getStringLiteralTypeForNode(<StringLiteral>node, typeChecker);
|
||||
if (type) {
|
||||
if (isDefinedInLibraryFile(node)) {
|
||||
return getRenameInfoError(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library);
|
||||
}
|
||||
|
||||
const displayName = stripQuotes(type.text);
|
||||
return getRenameInfoSuccess(displayName, displayName, ScriptElementKind.variableElement, ScriptElementKindModifier.none, node, sourceFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getRenameInfoSuccess(displayName: string, fullDisplayName: string, kind: string, kindModifiers: string, node: Node, sourceFile: SourceFile): RenameInfo {
|
||||
return {
|
||||
canRename: true,
|
||||
kind,
|
||||
displayName,
|
||||
localizedErrorMessage: undefined,
|
||||
fullDisplayName,
|
||||
kindModifiers,
|
||||
triggerSpan: createTriggerSpanForNode(node, sourceFile)
|
||||
};
|
||||
}
|
||||
|
||||
function getRenameInfoError(diagnostic: DiagnosticMessage): RenameInfo {
|
||||
return {
|
||||
canRename: false,
|
||||
localizedErrorMessage: getLocaleSpecificMessage(diagnostic),
|
||||
displayName: undefined,
|
||||
fullDisplayName: undefined,
|
||||
kind: undefined,
|
||||
kindModifiers: undefined,
|
||||
triggerSpan: undefined
|
||||
};
|
||||
}
|
||||
|
||||
function createTriggerSpanForNode(node: Node, sourceFile: SourceFile) {
|
||||
let start = node.getStart(sourceFile);
|
||||
let width = node.getWidth(sourceFile);
|
||||
if (node.kind === SyntaxKind.StringLiteral) {
|
||||
// Exclude the quotes
|
||||
start += 1;
|
||||
width -= 2;
|
||||
}
|
||||
return createTextSpan(start, width);
|
||||
}
|
||||
|
||||
function nodeIsEligibleForRename(node: Node) {
|
||||
return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.StringLiteral ||
|
||||
isLiteralNameOfPropertyDeclarationOrIndexAccess(node) ||
|
||||
isThis(node);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,8 +193,8 @@ namespace ts {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const child = children[0];
|
||||
return child.kind < SyntaxKind.FirstNode || SyntaxKind.FirstJSDocNode <= child.kind && child.kind <= SyntaxKind.LastJSDocNode ?
|
||||
const child = ts.find(children, kid => kid.kind < SyntaxKind.FirstJSDocNode || kid.kind > SyntaxKind.LastJSDocNode);
|
||||
return child.kind < SyntaxKind.FirstNode ?
|
||||
child :
|
||||
child.getFirstToken(sourceFile);
|
||||
}
|
||||
|
@ -207,9 +207,7 @@ namespace ts {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
return child.kind < SyntaxKind.FirstNode || SyntaxKind.FirstJSDocNode <= child.kind && child.kind <= SyntaxKind.LastJSDocNode ?
|
||||
child :
|
||||
child.getLastToken(sourceFile);
|
||||
return child.kind < SyntaxKind.FirstNode ? child : child.getLastToken(sourceFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1406,25 +1404,25 @@ namespace ts {
|
|||
}
|
||||
|
||||
function findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] {
|
||||
const referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments);
|
||||
const referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments, /*isForRename*/true);
|
||||
return FindAllReferences.convertReferences(referencedSymbols);
|
||||
}
|
||||
|
||||
function getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
|
||||
const referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false);
|
||||
const referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/false);
|
||||
return FindAllReferences.convertReferences(referencedSymbols);
|
||||
}
|
||||
|
||||
function findReferences(fileName: string, position: number): ReferencedSymbol[] {
|
||||
const referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false);
|
||||
const referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/false);
|
||||
|
||||
// Only include referenced symbols that have a valid definition.
|
||||
return filter(referencedSymbols, rs => !!rs.definition);
|
||||
}
|
||||
|
||||
function findReferencedSymbols(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] {
|
||||
function findReferencedSymbols(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, isForRename: boolean): ReferencedSymbol[] {
|
||||
synchronizeHostData();
|
||||
return FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments);
|
||||
return FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments, isForRename);
|
||||
}
|
||||
|
||||
/// NavigateTo
|
||||
|
|
|
@ -385,7 +385,10 @@ namespace ts {
|
|||
if (settingsJson == null || settingsJson == "") {
|
||||
throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings");
|
||||
}
|
||||
return <CompilerOptions>JSON.parse(settingsJson);
|
||||
const compilerOptions = <CompilerOptions>JSON.parse(settingsJson);
|
||||
// permit language service to handle all files (filtering should be performed on the host side)
|
||||
compilerOptions.allowNonTsExtensions = true;
|
||||
return compilerOptions;
|
||||
}
|
||||
|
||||
public getScriptFileNames(): string[] {
|
||||
|
@ -1061,12 +1064,6 @@ namespace ts {
|
|||
const compilerOptions = <CompilerOptions>JSON.parse(compilerOptionsJson);
|
||||
const result = resolveModuleName(moduleName, normalizeSlashes(fileName), compilerOptions, this.host);
|
||||
const resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined;
|
||||
if (resolvedFileName && !compilerOptions.allowJs && fileExtensionIs(resolvedFileName, ".js")) {
|
||||
return {
|
||||
resolvedFileName: undefined,
|
||||
failedLookupLocations: []
|
||||
};
|
||||
}
|
||||
return {
|
||||
resolvedFileName,
|
||||
failedLookupLocations: result.failedLookupLocations
|
||||
|
|
|
@ -83,6 +83,7 @@
|
|||
"codefixes/fixClassDoesntImplementInheritedAbstractMember.ts",
|
||||
"codefixes/fixClassSuperMustPrecedeThisAccess.ts",
|
||||
"codefixes/fixConstructorForDerivedNeedSuperCall.ts",
|
||||
"codefixes/fixForgottenThisPropertyAccess.ts",
|
||||
"codefixes/fixes.ts",
|
||||
"codefixes/helpers.ts",
|
||||
"codefixes/importFixes.ts",
|
||||
|
|
|
@ -1319,7 +1319,7 @@ namespace ts {
|
|||
return name;
|
||||
}
|
||||
|
||||
export function isImportOrExportSpecifierName(location: Node): boolean {
|
||||
export function isImportOrExportSpecifierName(location: Node): location is Identifier {
|
||||
return location.parent &&
|
||||
(location.parent.kind === SyntaxKind.ImportSpecifier || location.parent.kind === SyntaxKind.ExportSpecifier) &&
|
||||
(<ImportOrExportSpecifier>location.parent).propertyName === location;
|
||||
|
|
16
tests/baselines/reference/augmentExportEquals7.errors.txt
Normal file
16
tests/baselines/reference/augmentExportEquals7.errors.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
/node_modules/@types/lib-extender/index.d.ts(2,16): error TS2649: Cannot augment module 'lib' with value exports because it resolves to a non-module entity.
|
||||
|
||||
|
||||
==== /node_modules/lib/index.d.ts (0 errors) ====
|
||||
declare var lib: () => void;
|
||||
declare namespace lib {}
|
||||
export = lib;
|
||||
|
||||
==== /node_modules/@types/lib-extender/index.d.ts (1 errors) ====
|
||||
import * as lib from "lib";
|
||||
declare module "lib" {
|
||||
~~~~~
|
||||
!!! error TS2649: Cannot augment module 'lib' with value exports because it resolves to a non-module entity.
|
||||
export function fn(): void;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
//// [destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts]
|
||||
// test for #10668
|
||||
function qux(bar: { value: number }) {
|
||||
let foo: number;
|
||||
({ value: foo } = bar);
|
||||
let x = () => bar;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// [destructuringPropertyAssignmentNameIsNotAssignmentTarget.js]
|
||||
// test for #10668
|
||||
function qux(bar) {
|
||||
var foo;
|
||||
(foo = bar.value);
|
||||
var x = function () { return bar; };
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
=== tests/cases/compiler/destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts ===
|
||||
// test for #10668
|
||||
function qux(bar: { value: number }) {
|
||||
>qux : Symbol(qux, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 0, 0))
|
||||
>bar : Symbol(bar, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 1, 13))
|
||||
>value : Symbol(value, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 1, 19))
|
||||
|
||||
let foo: number;
|
||||
>foo : Symbol(foo, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 2, 7))
|
||||
|
||||
({ value: foo } = bar);
|
||||
>value : Symbol(value, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 3, 6))
|
||||
>foo : Symbol(foo, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 2, 7))
|
||||
>bar : Symbol(bar, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 1, 13))
|
||||
|
||||
let x = () => bar;
|
||||
>x : Symbol(x, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 4, 7))
|
||||
>bar : Symbol(bar, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 1, 13))
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
=== tests/cases/compiler/destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts ===
|
||||
// test for #10668
|
||||
function qux(bar: { value: number }) {
|
||||
>qux : (bar: { value: number; }) => void
|
||||
>bar : { value: number; }
|
||||
>value : number
|
||||
|
||||
let foo: number;
|
||||
>foo : number
|
||||
|
||||
({ value: foo } = bar);
|
||||
>({ value: foo } = bar) : { value: number; }
|
||||
>{ value: foo } = bar : { value: number; }
|
||||
>{ value: foo } : { value: number; }
|
||||
>value : number
|
||||
>foo : number
|
||||
>bar : { value: number; }
|
||||
|
||||
let x = () => bar;
|
||||
>x : () => { value: number; }
|
||||
>() => bar : () => { value: number; }
|
||||
>bar : { value: number; }
|
||||
}
|
||||
|
||||
|
11
tests/baselines/reference/es3-jsx-preserve.js
Normal file
11
tests/baselines/reference/es3-jsx-preserve.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
//// [es3-jsx-preserve.tsx]
|
||||
|
||||
const React: any = null;
|
||||
|
||||
const elem = <div></div>;
|
||||
|
||||
|
||||
|
||||
//// [es3-jsx-preserve.jsx]
|
||||
var React = null;
|
||||
var elem = <div></div>;
|
11
tests/baselines/reference/es3-jsx-preserve.symbols
Normal file
11
tests/baselines/reference/es3-jsx-preserve.symbols
Normal file
|
@ -0,0 +1,11 @@
|
|||
=== tests/cases/compiler/es3-jsx-preserve.tsx ===
|
||||
|
||||
const React: any = null;
|
||||
>React : Symbol(React, Decl(es3-jsx-preserve.tsx, 1, 5))
|
||||
|
||||
const elem = <div></div>;
|
||||
>elem : Symbol(elem, Decl(es3-jsx-preserve.tsx, 3, 5))
|
||||
>div : Symbol(unknown)
|
||||
>div : Symbol(unknown)
|
||||
|
||||
|
13
tests/baselines/reference/es3-jsx-preserve.types
Normal file
13
tests/baselines/reference/es3-jsx-preserve.types
Normal file
|
@ -0,0 +1,13 @@
|
|||
=== tests/cases/compiler/es3-jsx-preserve.tsx ===
|
||||
|
||||
const React: any = null;
|
||||
>React : any
|
||||
>null : null
|
||||
|
||||
const elem = <div></div>;
|
||||
>elem : any
|
||||
><div></div> : any
|
||||
>div : any
|
||||
>div : any
|
||||
|
||||
|
11
tests/baselines/reference/es3-jsx-react-native.js
Normal file
11
tests/baselines/reference/es3-jsx-react-native.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
//// [es3-jsx-react-native.tsx]
|
||||
|
||||
const React: any = null;
|
||||
|
||||
const elem = <div></div>;
|
||||
|
||||
|
||||
|
||||
//// [es3-jsx-react-native.js]
|
||||
var React = null;
|
||||
var elem = <div></div>;
|
11
tests/baselines/reference/es3-jsx-react-native.symbols
Normal file
11
tests/baselines/reference/es3-jsx-react-native.symbols
Normal file
|
@ -0,0 +1,11 @@
|
|||
=== tests/cases/compiler/es3-jsx-react-native.tsx ===
|
||||
|
||||
const React: any = null;
|
||||
>React : Symbol(React, Decl(es3-jsx-react-native.tsx, 1, 5))
|
||||
|
||||
const elem = <div></div>;
|
||||
>elem : Symbol(elem, Decl(es3-jsx-react-native.tsx, 3, 5))
|
||||
>div : Symbol(unknown)
|
||||
>div : Symbol(unknown)
|
||||
|
||||
|
13
tests/baselines/reference/es3-jsx-react-native.types
Normal file
13
tests/baselines/reference/es3-jsx-react-native.types
Normal file
|
@ -0,0 +1,13 @@
|
|||
=== tests/cases/compiler/es3-jsx-react-native.tsx ===
|
||||
|
||||
const React: any = null;
|
||||
>React : any
|
||||
>null : null
|
||||
|
||||
const elem = <div></div>;
|
||||
>elem : any
|
||||
><div></div> : any
|
||||
>div : any
|
||||
>div : any
|
||||
|
||||
|
11
tests/baselines/reference/es3-jsx-react.js
Normal file
11
tests/baselines/reference/es3-jsx-react.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
//// [es3-jsx-react.tsx]
|
||||
|
||||
const React: any = null;
|
||||
|
||||
const elem = <div></div>;
|
||||
|
||||
|
||||
|
||||
//// [es3-jsx-react.js]
|
||||
var React = null;
|
||||
var elem = React.createElement("div", null);
|
11
tests/baselines/reference/es3-jsx-react.symbols
Normal file
11
tests/baselines/reference/es3-jsx-react.symbols
Normal file
|
@ -0,0 +1,11 @@
|
|||
=== tests/cases/compiler/es3-jsx-react.tsx ===
|
||||
|
||||
const React: any = null;
|
||||
>React : Symbol(React, Decl(es3-jsx-react.tsx, 1, 5))
|
||||
|
||||
const elem = <div></div>;
|
||||
>elem : Symbol(elem, Decl(es3-jsx-react.tsx, 3, 5))
|
||||
>div : Symbol(unknown)
|
||||
>div : Symbol(unknown)
|
||||
|
||||
|
13
tests/baselines/reference/es3-jsx-react.types
Normal file
13
tests/baselines/reference/es3-jsx-react.types
Normal file
|
@ -0,0 +1,13 @@
|
|||
=== tests/cases/compiler/es3-jsx-react.tsx ===
|
||||
|
||||
const React: any = null;
|
||||
>React : any
|
||||
>null : null
|
||||
|
||||
const elem = <div></div>;
|
||||
>elem : any
|
||||
><div></div> : any
|
||||
>div : any
|
||||
>div : any
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
export { };
|
||||
|
||||
declare global {
|
||||
>global : any
|
||||
>global : typeof global
|
||||
|
||||
var x: number;
|
||||
>x : number
|
||||
|
|
|
@ -5,10 +5,12 @@ declare var dec: any;
|
|||
@dec export class A {
|
||||
|
||||
}
|
||||
|
||||
const o = { a: 1 };
|
||||
const y = { ...o };
|
||||
|
||||
//// [tslib.d.ts]
|
||||
export declare function __extends(d: Function, b: Function): void;
|
||||
export declare function __assign(t: any, ...sources: any[]): any;
|
||||
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
|
||||
export declare function __param(paramIndex: number, decorator: Function): Function;
|
||||
export declare function __metadata(metadataKey: any, metadataValue: any): Function;
|
||||
|
@ -23,3 +25,5 @@ A = tslib_1.__decorate([
|
|||
dec
|
||||
], A);
|
||||
export { A };
|
||||
const o = { a: 1 };
|
||||
const y = Object.assign({}, o);
|
||||
|
|
|
@ -8,6 +8,14 @@ declare var dec: any;
|
|||
|
||||
}
|
||||
|
||||
const o = { a: 1 };
|
||||
>o : Symbol(o, Decl(a.ts, 5, 5))
|
||||
>a : Symbol(a, Decl(a.ts, 5, 11))
|
||||
|
||||
const y = { ...o };
|
||||
>y : Symbol(y, Decl(a.ts, 6, 5))
|
||||
>o : Symbol(o, Decl(a.ts, 5, 5))
|
||||
|
||||
=== tests/cases/compiler/tslib.d.ts ===
|
||||
export declare function __extends(d: Function, b: Function): void;
|
||||
>__extends : Symbol(__extends, Decl(tslib.d.ts, --, --))
|
||||
|
@ -16,11 +24,6 @@ export declare function __extends(d: Function, b: Function): void;
|
|||
>b : Symbol(b, Decl(tslib.d.ts, --, --))
|
||||
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
|
||||
export declare function __assign(t: any, ...sources: any[]): any;
|
||||
>__assign : Symbol(__assign, Decl(tslib.d.ts, --, --))
|
||||
>t : Symbol(t, Decl(tslib.d.ts, --, --))
|
||||
>sources : Symbol(sources, Decl(tslib.d.ts, --, --))
|
||||
|
||||
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
|
||||
>__decorate : Symbol(__decorate, Decl(tslib.d.ts, --, --))
|
||||
>decorators : Symbol(decorators, Decl(tslib.d.ts, --, --))
|
||||
|
|
|
@ -8,6 +8,17 @@ declare var dec: any;
|
|||
|
||||
}
|
||||
|
||||
const o = { a: 1 };
|
||||
>o : { a: number; }
|
||||
>{ a: 1 } : { a: number; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
|
||||
const y = { ...o };
|
||||
>y : { a: number; }
|
||||
>{ ...o } : { a: number; }
|
||||
>o : { a: number; }
|
||||
|
||||
=== tests/cases/compiler/tslib.d.ts ===
|
||||
export declare function __extends(d: Function, b: Function): void;
|
||||
>__extends : (d: Function, b: Function) => void
|
||||
|
@ -16,11 +27,6 @@ export declare function __extends(d: Function, b: Function): void;
|
|||
>b : Function
|
||||
>Function : Function
|
||||
|
||||
export declare function __assign(t: any, ...sources: any[]): any;
|
||||
>__assign : (t: any, ...sources: any[]) => any
|
||||
>t : any
|
||||
>sources : any[]
|
||||
|
||||
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
|
||||
>__decorate : (decorators: Function[], target: any, key?: string | symbol, desc?: any) => any
|
||||
>decorators : Function[]
|
||||
|
|
|
@ -516,6 +516,16 @@ class B extends A<{ x: number}> {
|
|||
p.x;
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #13749
|
||||
|
||||
class Form<T> {
|
||||
private childFormFactories: {[K in keyof T]: (v: T[K]) => Form<T[K]>}
|
||||
|
||||
public set<K extends keyof T>(prop: K, value: T[K]) {
|
||||
this.childFormFactories[prop](value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [keyofAndIndexedAccess.js]
|
||||
|
@ -862,6 +872,15 @@ var B = (function (_super) {
|
|||
};
|
||||
return B;
|
||||
}(A));
|
||||
// Repro from #13749
|
||||
var Form = (function () {
|
||||
function Form() {
|
||||
}
|
||||
Form.prototype.set = function (prop, value) {
|
||||
this.childFormFactories[prop](value);
|
||||
};
|
||||
return Form;
|
||||
}());
|
||||
|
||||
|
||||
//// [keyofAndIndexedAccess.d.ts]
|
||||
|
@ -1104,3 +1123,7 @@ declare class B extends A<{
|
|||
}> {
|
||||
f(p: this["props"]): void;
|
||||
}
|
||||
declare class Form<T> {
|
||||
private childFormFactories;
|
||||
set<K extends keyof T>(prop: K, value: T[K]): void;
|
||||
}
|
||||
|
|
|
@ -1844,3 +1844,39 @@ class B extends A<{ x: number}> {
|
|||
}
|
||||
}
|
||||
|
||||
// Repro from #13749
|
||||
|
||||
class Form<T> {
|
||||
>Form : Symbol(Form, Decl(keyofAndIndexedAccess.ts, 516, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 520, 11))
|
||||
|
||||
private childFormFactories: {[K in keyof T]: (v: T[K]) => Form<T[K]>}
|
||||
>childFormFactories : Symbol(Form.childFormFactories, Decl(keyofAndIndexedAccess.ts, 520, 15))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 521, 34))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 520, 11))
|
||||
>v : Symbol(v, Decl(keyofAndIndexedAccess.ts, 521, 50))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 520, 11))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 521, 34))
|
||||
>Form : Symbol(Form, Decl(keyofAndIndexedAccess.ts, 516, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 520, 11))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 521, 34))
|
||||
|
||||
public set<K extends keyof T>(prop: K, value: T[K]) {
|
||||
>set : Symbol(Form.set, Decl(keyofAndIndexedAccess.ts, 521, 73))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 523, 15))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 520, 11))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 523, 34))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 523, 15))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 523, 42))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 520, 11))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 523, 15))
|
||||
|
||||
this.childFormFactories[prop](value)
|
||||
>this.childFormFactories : Symbol(Form.childFormFactories, Decl(keyofAndIndexedAccess.ts, 520, 15))
|
||||
>this : Symbol(Form, Decl(keyofAndIndexedAccess.ts, 516, 1))
|
||||
>childFormFactories : Symbol(Form.childFormFactories, Decl(keyofAndIndexedAccess.ts, 520, 15))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 523, 34))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 523, 42))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2166,3 +2166,41 @@ class B extends A<{ x: number}> {
|
|||
}
|
||||
}
|
||||
|
||||
// Repro from #13749
|
||||
|
||||
class Form<T> {
|
||||
>Form : Form<T>
|
||||
>T : T
|
||||
|
||||
private childFormFactories: {[K in keyof T]: (v: T[K]) => Form<T[K]>}
|
||||
>childFormFactories : { [K in keyof T]: (v: T[K]) => Form<T[K]>; }
|
||||
>K : K
|
||||
>T : T
|
||||
>v : T[K]
|
||||
>T : T
|
||||
>K : K
|
||||
>Form : Form<T>
|
||||
>T : T
|
||||
>K : K
|
||||
|
||||
public set<K extends keyof T>(prop: K, value: T[K]) {
|
||||
>set : <K extends keyof T>(prop: K, value: T[K]) => void
|
||||
>K : K
|
||||
>T : T
|
||||
>prop : K
|
||||
>K : K
|
||||
>value : T[K]
|
||||
>T : T
|
||||
>K : K
|
||||
|
||||
this.childFormFactories[prop](value)
|
||||
>this.childFormFactories[prop](value) : Form<T[K]>
|
||||
>this.childFormFactories[prop] : (v: T[K]) => Form<T[K]>
|
||||
>this.childFormFactories : { [K in keyof T]: (v: T[K]) => Form<T[K]>; }
|
||||
>this : this
|
||||
>childFormFactories : { [K in keyof T]: (v: T[K]) => Form<T[K]>; }
|
||||
>prop : K
|
||||
>value : T[K]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,9 +139,9 @@ declare let x2: string;
|
|||
declare let x3: number;
|
||||
declare let x4: {
|
||||
toString: void;
|
||||
valueOf: void;
|
||||
toFixed: void;
|
||||
toExponential: void;
|
||||
toPrecision: void;
|
||||
valueOf: void;
|
||||
toLocaleString: void;
|
||||
};
|
||||
|
|
|
@ -165,7 +165,7 @@ let x3 = f3();
|
|||
>f3 : <T1 extends number>() => { [P in keyof T1]: void; }
|
||||
|
||||
let x4 = f4();
|
||||
>x4 : { toString: void; valueOf: void; toFixed: void; toExponential: void; toPrecision: void; toLocaleString: void; }
|
||||
>f4() : { toString: void; valueOf: void; toFixed: void; toExponential: void; toPrecision: void; toLocaleString: void; }
|
||||
>x4 : { toString: void; toFixed: void; toExponential: void; toPrecision: void; valueOf: void; toLocaleString: void; }
|
||||
>f4() : { toString: void; toFixed: void; toExponential: void; toPrecision: void; valueOf: void; toLocaleString: void; }
|
||||
>f4 : <T1 extends Number>() => { [P in keyof T1]: void; }
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
=== tests/cases/compiler/a.js ===
|
||||
|
||||
No type information for this code./** @typedef {{ endTime: number, screenshots: number}} A.<b>*/
|
||||
No type information for this code.Animation.AnimationModel.ScreenshotCapture.Request;
|
||||
No type information for this code.
|
||||
No type information for this code./** @typedef {{ endTime: number, screenshots: !B.<string>}} */
|
||||
No type information for this code.Animation.AnimationModel.ScreenshotCapture.Request;
|
||||
No type information for this code.
|
22
tests/baselines/reference/misspelledJsDocTypedefTags.types
Normal file
22
tests/baselines/reference/misspelledJsDocTypedefTags.types
Normal file
|
@ -0,0 +1,22 @@
|
|||
=== tests/cases/compiler/a.js ===
|
||||
|
||||
/** @typedef {{ endTime: number, screenshots: number}} A.<b>*/
|
||||
Animation.AnimationModel.ScreenshotCapture.Request;
|
||||
>Animation.AnimationModel.ScreenshotCapture.Request : any
|
||||
>Animation.AnimationModel.ScreenshotCapture : any
|
||||
>Animation.AnimationModel : any
|
||||
>Animation : any
|
||||
>AnimationModel : any
|
||||
>ScreenshotCapture : any
|
||||
>Request : any
|
||||
|
||||
/** @typedef {{ endTime: number, screenshots: !B.<string>}} */
|
||||
Animation.AnimationModel.ScreenshotCapture.Request;
|
||||
>Animation.AnimationModel.ScreenshotCapture.Request : any
|
||||
>Animation.AnimationModel.ScreenshotCapture : any
|
||||
>Animation.AnimationModel : any
|
||||
>Animation : any
|
||||
>AnimationModel : any
|
||||
>ScreenshotCapture : any
|
||||
>Request : any
|
||||
|
183
tests/baselines/reference/mixinClassesAnnotated.js
Normal file
183
tests/baselines/reference/mixinClassesAnnotated.js
Normal file
|
@ -0,0 +1,183 @@
|
|||
//// [mixinClassesAnnotated.ts]
|
||||
|
||||
type Constructor<T> = new(...args: any[]) => T;
|
||||
|
||||
class Base {
|
||||
constructor(public x: number, public y: number) {}
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
constructor(x: number, y: number, public z: number) {
|
||||
super(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
interface Printable {
|
||||
print(): void;
|
||||
}
|
||||
|
||||
const Printable = <T extends Constructor<Base>>(superClass: T): Constructor<Printable> & { message: string } & T =>
|
||||
class extends superClass {
|
||||
static message = "hello";
|
||||
print() {
|
||||
const output = this.x + "," + this.y;
|
||||
}
|
||||
}
|
||||
|
||||
interface Tagged {
|
||||
_tag: string;
|
||||
}
|
||||
|
||||
function Tagged<T extends Constructor<{}>>(superClass: T): Constructor<Tagged> & T {
|
||||
class C extends superClass {
|
||||
_tag: string;
|
||||
constructor(...args: any[]) {
|
||||
super(...args);
|
||||
this._tag = "hello";
|
||||
}
|
||||
}
|
||||
return C;
|
||||
}
|
||||
|
||||
const Thing1 = Tagged(Derived);
|
||||
const Thing2 = Tagged(Printable(Derived));
|
||||
Thing2.message;
|
||||
|
||||
function f1() {
|
||||
const thing = new Thing1(1, 2, 3);
|
||||
thing.x;
|
||||
thing._tag;
|
||||
}
|
||||
|
||||
function f2() {
|
||||
const thing = new Thing2(1, 2, 3);
|
||||
thing.x;
|
||||
thing._tag;
|
||||
thing.print();
|
||||
}
|
||||
|
||||
class Thing3 extends Thing2 {
|
||||
constructor(tag: string) {
|
||||
super(10, 20, 30);
|
||||
this._tag = tag;
|
||||
}
|
||||
test() {
|
||||
this.print();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [mixinClassesAnnotated.js]
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var Base = (function () {
|
||||
function Base(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
return Base;
|
||||
}());
|
||||
var Derived = (function (_super) {
|
||||
__extends(Derived, _super);
|
||||
function Derived(x, y, z) {
|
||||
var _this = _super.call(this, x, y) || this;
|
||||
_this.z = z;
|
||||
return _this;
|
||||
}
|
||||
return Derived;
|
||||
}(Base));
|
||||
var Printable = function (superClass) { return _a = (function (_super) {
|
||||
__extends(class_1, _super);
|
||||
function class_1() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
class_1.prototype.print = function () {
|
||||
var output = this.x + "," + this.y;
|
||||
};
|
||||
return class_1;
|
||||
}(superClass)),
|
||||
_a.message = "hello",
|
||||
_a; var _a; };
|
||||
function Tagged(superClass) {
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
var _this = _super.apply(this, args) || this;
|
||||
_this._tag = "hello";
|
||||
return _this;
|
||||
}
|
||||
return C;
|
||||
}(superClass));
|
||||
return C;
|
||||
}
|
||||
var Thing1 = Tagged(Derived);
|
||||
var Thing2 = Tagged(Printable(Derived));
|
||||
Thing2.message;
|
||||
function f1() {
|
||||
var thing = new Thing1(1, 2, 3);
|
||||
thing.x;
|
||||
thing._tag;
|
||||
}
|
||||
function f2() {
|
||||
var thing = new Thing2(1, 2, 3);
|
||||
thing.x;
|
||||
thing._tag;
|
||||
thing.print();
|
||||
}
|
||||
var Thing3 = (function (_super) {
|
||||
__extends(Thing3, _super);
|
||||
function Thing3(tag) {
|
||||
var _this = _super.call(this, 10, 20, 30) || this;
|
||||
_this._tag = tag;
|
||||
return _this;
|
||||
}
|
||||
Thing3.prototype.test = function () {
|
||||
this.print();
|
||||
};
|
||||
return Thing3;
|
||||
}(Thing2));
|
||||
|
||||
|
||||
//// [mixinClassesAnnotated.d.ts]
|
||||
declare type Constructor<T> = new (...args: any[]) => T;
|
||||
declare class Base {
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x: number, y: number);
|
||||
}
|
||||
declare class Derived extends Base {
|
||||
z: number;
|
||||
constructor(x: number, y: number, z: number);
|
||||
}
|
||||
interface Printable {
|
||||
print(): void;
|
||||
}
|
||||
declare const Printable: <T extends Constructor<Base>>(superClass: T) => Constructor<Printable> & {
|
||||
message: string;
|
||||
} & T;
|
||||
interface Tagged {
|
||||
_tag: string;
|
||||
}
|
||||
declare function Tagged<T extends Constructor<{}>>(superClass: T): Constructor<Tagged> & T;
|
||||
declare const Thing1: Constructor<Tagged> & typeof Derived;
|
||||
declare const Thing2: Constructor<Tagged> & Constructor<Printable> & {
|
||||
message: string;
|
||||
} & typeof Derived;
|
||||
declare function f1(): void;
|
||||
declare function f2(): void;
|
||||
declare class Thing3 extends Thing2 {
|
||||
constructor(tag: string);
|
||||
test(): void;
|
||||
}
|
193
tests/baselines/reference/mixinClassesAnnotated.symbols
Normal file
193
tests/baselines/reference/mixinClassesAnnotated.symbols
Normal file
|
@ -0,0 +1,193 @@
|
|||
=== tests/cases/conformance/classes/mixinClassesAnnotated.ts ===
|
||||
|
||||
type Constructor<T> = new(...args: any[]) => T;
|
||||
>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 1, 17))
|
||||
>args : Symbol(args, Decl(mixinClassesAnnotated.ts, 1, 26))
|
||||
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 1, 17))
|
||||
|
||||
class Base {
|
||||
>Base : Symbol(Base, Decl(mixinClassesAnnotated.ts, 1, 47))
|
||||
|
||||
constructor(public x: number, public y: number) {}
|
||||
>x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16))
|
||||
>y : Symbol(Base.y, Decl(mixinClassesAnnotated.ts, 4, 33))
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
>Derived : Symbol(Derived, Decl(mixinClassesAnnotated.ts, 5, 1))
|
||||
>Base : Symbol(Base, Decl(mixinClassesAnnotated.ts, 1, 47))
|
||||
|
||||
constructor(x: number, y: number, public z: number) {
|
||||
>x : Symbol(x, Decl(mixinClassesAnnotated.ts, 8, 16))
|
||||
>y : Symbol(y, Decl(mixinClassesAnnotated.ts, 8, 26))
|
||||
>z : Symbol(Derived.z, Decl(mixinClassesAnnotated.ts, 8, 37))
|
||||
|
||||
super(x, y);
|
||||
>super : Symbol(Base, Decl(mixinClassesAnnotated.ts, 1, 47))
|
||||
>x : Symbol(x, Decl(mixinClassesAnnotated.ts, 8, 16))
|
||||
>y : Symbol(y, Decl(mixinClassesAnnotated.ts, 8, 26))
|
||||
}
|
||||
}
|
||||
|
||||
interface Printable {
|
||||
>Printable : Symbol(Printable, Decl(mixinClassesAnnotated.ts, 11, 1), Decl(mixinClassesAnnotated.ts, 17, 5))
|
||||
|
||||
print(): void;
|
||||
>print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21))
|
||||
}
|
||||
|
||||
const Printable = <T extends Constructor<Base>>(superClass: T): Constructor<Printable> & { message: string } & T =>
|
||||
>Printable : Symbol(Printable, Decl(mixinClassesAnnotated.ts, 11, 1), Decl(mixinClassesAnnotated.ts, 17, 5))
|
||||
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 17, 19))
|
||||
>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0))
|
||||
>Base : Symbol(Base, Decl(mixinClassesAnnotated.ts, 1, 47))
|
||||
>superClass : Symbol(superClass, Decl(mixinClassesAnnotated.ts, 17, 48))
|
||||
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 17, 19))
|
||||
>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0))
|
||||
>Printable : Symbol(Printable, Decl(mixinClassesAnnotated.ts, 11, 1), Decl(mixinClassesAnnotated.ts, 17, 5))
|
||||
>message : Symbol(message, Decl(mixinClassesAnnotated.ts, 17, 90))
|
||||
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 17, 19))
|
||||
|
||||
class extends superClass {
|
||||
>superClass : Symbol(superClass, Decl(mixinClassesAnnotated.ts, 17, 48))
|
||||
|
||||
static message = "hello";
|
||||
>message : Symbol((Anonymous class).message, Decl(mixinClassesAnnotated.ts, 18, 30))
|
||||
|
||||
print() {
|
||||
>print : Symbol((Anonymous class).print, Decl(mixinClassesAnnotated.ts, 19, 33))
|
||||
|
||||
const output = this.x + "," + this.y;
|
||||
>output : Symbol(output, Decl(mixinClassesAnnotated.ts, 21, 17))
|
||||
>this.x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16))
|
||||
>this : Symbol((Anonymous class), Decl(mixinClassesAnnotated.ts, 17, 115))
|
||||
>x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16))
|
||||
>this.y : Symbol(Base.y, Decl(mixinClassesAnnotated.ts, 4, 33))
|
||||
>this : Symbol((Anonymous class), Decl(mixinClassesAnnotated.ts, 17, 115))
|
||||
>y : Symbol(Base.y, Decl(mixinClassesAnnotated.ts, 4, 33))
|
||||
}
|
||||
}
|
||||
|
||||
interface Tagged {
|
||||
>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1))
|
||||
|
||||
_tag: string;
|
||||
>_tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18))
|
||||
}
|
||||
|
||||
function Tagged<T extends Constructor<{}>>(superClass: T): Constructor<Tagged> & T {
|
||||
>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1))
|
||||
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 29, 16))
|
||||
>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0))
|
||||
>superClass : Symbol(superClass, Decl(mixinClassesAnnotated.ts, 29, 43))
|
||||
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 29, 16))
|
||||
>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0))
|
||||
>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1))
|
||||
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 29, 16))
|
||||
|
||||
class C extends superClass {
|
||||
>C : Symbol(C, Decl(mixinClassesAnnotated.ts, 29, 84))
|
||||
>superClass : Symbol(superClass, Decl(mixinClassesAnnotated.ts, 29, 43))
|
||||
|
||||
_tag: string;
|
||||
>_tag : Symbol(C._tag, Decl(mixinClassesAnnotated.ts, 30, 32))
|
||||
|
||||
constructor(...args: any[]) {
|
||||
>args : Symbol(args, Decl(mixinClassesAnnotated.ts, 32, 20))
|
||||
|
||||
super(...args);
|
||||
>super : Symbol(T, Decl(mixinClassesAnnotated.ts, 29, 16))
|
||||
>args : Symbol(args, Decl(mixinClassesAnnotated.ts, 32, 20))
|
||||
|
||||
this._tag = "hello";
|
||||
>this._tag : Symbol(C._tag, Decl(mixinClassesAnnotated.ts, 30, 32))
|
||||
>this : Symbol(C, Decl(mixinClassesAnnotated.ts, 29, 84))
|
||||
>_tag : Symbol(C._tag, Decl(mixinClassesAnnotated.ts, 30, 32))
|
||||
}
|
||||
}
|
||||
return C;
|
||||
>C : Symbol(C, Decl(mixinClassesAnnotated.ts, 29, 84))
|
||||
}
|
||||
|
||||
const Thing1 = Tagged(Derived);
|
||||
>Thing1 : Symbol(Thing1, Decl(mixinClassesAnnotated.ts, 40, 5))
|
||||
>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1))
|
||||
>Derived : Symbol(Derived, Decl(mixinClassesAnnotated.ts, 5, 1))
|
||||
|
||||
const Thing2 = Tagged(Printable(Derived));
|
||||
>Thing2 : Symbol(Thing2, Decl(mixinClassesAnnotated.ts, 41, 5))
|
||||
>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1))
|
||||
>Printable : Symbol(Printable, Decl(mixinClassesAnnotated.ts, 11, 1), Decl(mixinClassesAnnotated.ts, 17, 5))
|
||||
>Derived : Symbol(Derived, Decl(mixinClassesAnnotated.ts, 5, 1))
|
||||
|
||||
Thing2.message;
|
||||
>Thing2.message : Symbol(message, Decl(mixinClassesAnnotated.ts, 17, 90))
|
||||
>Thing2 : Symbol(Thing2, Decl(mixinClassesAnnotated.ts, 41, 5))
|
||||
>message : Symbol(message, Decl(mixinClassesAnnotated.ts, 17, 90))
|
||||
|
||||
function f1() {
|
||||
>f1 : Symbol(f1, Decl(mixinClassesAnnotated.ts, 42, 15))
|
||||
|
||||
const thing = new Thing1(1, 2, 3);
|
||||
>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 45, 9))
|
||||
>Thing1 : Symbol(Thing1, Decl(mixinClassesAnnotated.ts, 40, 5))
|
||||
|
||||
thing.x;
|
||||
>thing.x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16))
|
||||
>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 45, 9))
|
||||
>x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16))
|
||||
|
||||
thing._tag;
|
||||
>thing._tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18))
|
||||
>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 45, 9))
|
||||
>_tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18))
|
||||
}
|
||||
|
||||
function f2() {
|
||||
>f2 : Symbol(f2, Decl(mixinClassesAnnotated.ts, 48, 1))
|
||||
|
||||
const thing = new Thing2(1, 2, 3);
|
||||
>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 51, 9))
|
||||
>Thing2 : Symbol(Thing2, Decl(mixinClassesAnnotated.ts, 41, 5))
|
||||
|
||||
thing.x;
|
||||
>thing.x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16))
|
||||
>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 51, 9))
|
||||
>x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16))
|
||||
|
||||
thing._tag;
|
||||
>thing._tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18))
|
||||
>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 51, 9))
|
||||
>_tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18))
|
||||
|
||||
thing.print();
|
||||
>thing.print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21))
|
||||
>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 51, 9))
|
||||
>print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21))
|
||||
}
|
||||
|
||||
class Thing3 extends Thing2 {
|
||||
>Thing3 : Symbol(Thing3, Decl(mixinClassesAnnotated.ts, 55, 1))
|
||||
>Thing2 : Symbol(Thing2, Decl(mixinClassesAnnotated.ts, 41, 5))
|
||||
|
||||
constructor(tag: string) {
|
||||
>tag : Symbol(tag, Decl(mixinClassesAnnotated.ts, 58, 16))
|
||||
|
||||
super(10, 20, 30);
|
||||
this._tag = tag;
|
||||
>this._tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18))
|
||||
>this : Symbol(Thing3, Decl(mixinClassesAnnotated.ts, 55, 1))
|
||||
>_tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18))
|
||||
>tag : Symbol(tag, Decl(mixinClassesAnnotated.ts, 58, 16))
|
||||
}
|
||||
test() {
|
||||
>test : Symbol(Thing3.test, Decl(mixinClassesAnnotated.ts, 61, 5))
|
||||
|
||||
this.print();
|
||||
>this.print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21))
|
||||
>this : Symbol(Thing3, Decl(mixinClassesAnnotated.ts, 55, 1))
|
||||
>print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21))
|
||||
}
|
||||
}
|
||||
|
224
tests/baselines/reference/mixinClassesAnnotated.types
Normal file
224
tests/baselines/reference/mixinClassesAnnotated.types
Normal file
|
@ -0,0 +1,224 @@
|
|||
=== tests/cases/conformance/classes/mixinClassesAnnotated.ts ===
|
||||
|
||||
type Constructor<T> = new(...args: any[]) => T;
|
||||
>Constructor : Constructor<T>
|
||||
>T : T
|
||||
>args : any[]
|
||||
>T : T
|
||||
|
||||
class Base {
|
||||
>Base : Base
|
||||
|
||||
constructor(public x: number, public y: number) {}
|
||||
>x : number
|
||||
>y : number
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
>Derived : Derived
|
||||
>Base : Base
|
||||
|
||||
constructor(x: number, y: number, public z: number) {
|
||||
>x : number
|
||||
>y : number
|
||||
>z : number
|
||||
|
||||
super(x, y);
|
||||
>super(x, y) : void
|
||||
>super : typeof Base
|
||||
>x : number
|
||||
>y : number
|
||||
}
|
||||
}
|
||||
|
||||
interface Printable {
|
||||
>Printable : Printable
|
||||
|
||||
print(): void;
|
||||
>print : () => void
|
||||
}
|
||||
|
||||
const Printable = <T extends Constructor<Base>>(superClass: T): Constructor<Printable> & { message: string } & T =>
|
||||
>Printable : <T extends Constructor<Base>>(superClass: T) => Constructor<Printable> & { message: string; } & T
|
||||
><T extends Constructor<Base>>(superClass: T): Constructor<Printable> & { message: string } & T => class extends superClass { static message = "hello"; print() { const output = this.x + "," + this.y; } } : <T extends Constructor<Base>>(superClass: T) => Constructor<Printable> & { message: string; } & T
|
||||
>T : T
|
||||
>Constructor : Constructor<T>
|
||||
>Base : Base
|
||||
>superClass : T
|
||||
>T : T
|
||||
>Constructor : Constructor<T>
|
||||
>Printable : Printable
|
||||
>message : string
|
||||
>T : T
|
||||
|
||||
class extends superClass {
|
||||
>class extends superClass { static message = "hello"; print() { const output = this.x + "," + this.y; } } : { new (...args: any[]): (Anonymous class); prototype: <any>.(Anonymous class); message: string; } & T
|
||||
>superClass : Base
|
||||
|
||||
static message = "hello";
|
||||
>message : string
|
||||
>"hello" : "hello"
|
||||
|
||||
print() {
|
||||
>print : () => void
|
||||
|
||||
const output = this.x + "," + this.y;
|
||||
>output : string
|
||||
>this.x + "," + this.y : string
|
||||
>this.x + "," : string
|
||||
>this.x : number
|
||||
>this : this
|
||||
>x : number
|
||||
>"," : ","
|
||||
>this.y : number
|
||||
>this : this
|
||||
>y : number
|
||||
}
|
||||
}
|
||||
|
||||
interface Tagged {
|
||||
>Tagged : Tagged
|
||||
|
||||
_tag: string;
|
||||
>_tag : string
|
||||
}
|
||||
|
||||
function Tagged<T extends Constructor<{}>>(superClass: T): Constructor<Tagged> & T {
|
||||
>Tagged : <T extends Constructor<{}>>(superClass: T) => Constructor<Tagged> & T
|
||||
>T : T
|
||||
>Constructor : Constructor<T>
|
||||
>superClass : T
|
||||
>T : T
|
||||
>Constructor : Constructor<T>
|
||||
>Tagged : Tagged
|
||||
>T : T
|
||||
|
||||
class C extends superClass {
|
||||
>C : C
|
||||
>superClass : {}
|
||||
|
||||
_tag: string;
|
||||
>_tag : string
|
||||
|
||||
constructor(...args: any[]) {
|
||||
>args : any[]
|
||||
|
||||
super(...args);
|
||||
>super(...args) : void
|
||||
>super : T
|
||||
>...args : any
|
||||
>args : any[]
|
||||
|
||||
this._tag = "hello";
|
||||
>this._tag = "hello" : "hello"
|
||||
>this._tag : string
|
||||
>this : this
|
||||
>_tag : string
|
||||
>"hello" : "hello"
|
||||
}
|
||||
}
|
||||
return C;
|
||||
>C : { new (...args: any[]): C; prototype: Tagged<any>.C; } & T
|
||||
}
|
||||
|
||||
const Thing1 = Tagged(Derived);
|
||||
>Thing1 : Constructor<Tagged> & typeof Derived
|
||||
>Tagged(Derived) : Constructor<Tagged> & typeof Derived
|
||||
>Tagged : <T extends Constructor<{}>>(superClass: T) => Constructor<Tagged> & T
|
||||
>Derived : typeof Derived
|
||||
|
||||
const Thing2 = Tagged(Printable(Derived));
|
||||
>Thing2 : Constructor<Tagged> & Constructor<Printable> & { message: string; } & typeof Derived
|
||||
>Tagged(Printable(Derived)) : Constructor<Tagged> & Constructor<Printable> & { message: string; } & typeof Derived
|
||||
>Tagged : <T extends Constructor<{}>>(superClass: T) => Constructor<Tagged> & T
|
||||
>Printable(Derived) : Constructor<Printable> & { message: string; } & typeof Derived
|
||||
>Printable : <T extends Constructor<Base>>(superClass: T) => Constructor<Printable> & { message: string; } & T
|
||||
>Derived : typeof Derived
|
||||
|
||||
Thing2.message;
|
||||
>Thing2.message : string
|
||||
>Thing2 : Constructor<Tagged> & Constructor<Printable> & { message: string; } & typeof Derived
|
||||
>message : string
|
||||
|
||||
function f1() {
|
||||
>f1 : () => void
|
||||
|
||||
const thing = new Thing1(1, 2, 3);
|
||||
>thing : Tagged & Derived
|
||||
>new Thing1(1, 2, 3) : Tagged & Derived
|
||||
>Thing1 : Constructor<Tagged> & typeof Derived
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
thing.x;
|
||||
>thing.x : number
|
||||
>thing : Tagged & Derived
|
||||
>x : number
|
||||
|
||||
thing._tag;
|
||||
>thing._tag : string
|
||||
>thing : Tagged & Derived
|
||||
>_tag : string
|
||||
}
|
||||
|
||||
function f2() {
|
||||
>f2 : () => void
|
||||
|
||||
const thing = new Thing2(1, 2, 3);
|
||||
>thing : Tagged & Printable & Derived
|
||||
>new Thing2(1, 2, 3) : Tagged & Printable & Derived
|
||||
>Thing2 : Constructor<Tagged> & Constructor<Printable> & { message: string; } & typeof Derived
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
thing.x;
|
||||
>thing.x : number
|
||||
>thing : Tagged & Printable & Derived
|
||||
>x : number
|
||||
|
||||
thing._tag;
|
||||
>thing._tag : string
|
||||
>thing : Tagged & Printable & Derived
|
||||
>_tag : string
|
||||
|
||||
thing.print();
|
||||
>thing.print() : void
|
||||
>thing.print : () => void
|
||||
>thing : Tagged & Printable & Derived
|
||||
>print : () => void
|
||||
}
|
||||
|
||||
class Thing3 extends Thing2 {
|
||||
>Thing3 : Thing3
|
||||
>Thing2 : Tagged & Printable & Derived
|
||||
|
||||
constructor(tag: string) {
|
||||
>tag : string
|
||||
|
||||
super(10, 20, 30);
|
||||
>super(10, 20, 30) : void
|
||||
>super : Constructor<Tagged> & Constructor<Printable> & { message: string; } & typeof Derived
|
||||
>10 : 10
|
||||
>20 : 20
|
||||
>30 : 30
|
||||
|
||||
this._tag = tag;
|
||||
>this._tag = tag : string
|
||||
>this._tag : string
|
||||
>this : this
|
||||
>_tag : string
|
||||
>tag : string
|
||||
}
|
||||
test() {
|
||||
>test : () => void
|
||||
|
||||
this.print();
|
||||
>this.print() : void
|
||||
>this.print : () => void
|
||||
>this : this
|
||||
>print : () => void
|
||||
}
|
||||
}
|
||||
|
140
tests/baselines/reference/mixinClassesAnonymous.js
Normal file
140
tests/baselines/reference/mixinClassesAnonymous.js
Normal file
|
@ -0,0 +1,140 @@
|
|||
//// [mixinClassesAnonymous.ts]
|
||||
type Constructor<T> = new(...args: any[]) => T;
|
||||
|
||||
class Base {
|
||||
constructor(public x: number, public y: number) {}
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
constructor(x: number, y: number, public z: number) {
|
||||
super(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
const Printable = <T extends Constructor<Base>>(superClass: T) => class extends superClass {
|
||||
static message = "hello";
|
||||
print() {
|
||||
const output = this.x + "," + this.y;
|
||||
}
|
||||
}
|
||||
|
||||
function Tagged<T extends Constructor<{}>>(superClass: T) {
|
||||
class C extends superClass {
|
||||
_tag: string;
|
||||
constructor(...args: any[]) {
|
||||
super(...args);
|
||||
this._tag = "hello";
|
||||
}
|
||||
}
|
||||
return C;
|
||||
}
|
||||
|
||||
const Thing1 = Tagged(Derived);
|
||||
const Thing2 = Tagged(Printable(Derived));
|
||||
Thing2.message;
|
||||
|
||||
function f1() {
|
||||
const thing = new Thing1(1, 2, 3);
|
||||
thing.x;
|
||||
thing._tag;
|
||||
}
|
||||
|
||||
function f2() {
|
||||
const thing = new Thing2(1, 2, 3);
|
||||
thing.x;
|
||||
thing._tag;
|
||||
thing.print();
|
||||
}
|
||||
|
||||
class Thing3 extends Thing2 {
|
||||
constructor(tag: string) {
|
||||
super(10, 20, 30);
|
||||
this._tag = tag;
|
||||
}
|
||||
test() {
|
||||
this.print();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [mixinClassesAnonymous.js]
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var Base = (function () {
|
||||
function Base(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
return Base;
|
||||
}());
|
||||
var Derived = (function (_super) {
|
||||
__extends(Derived, _super);
|
||||
function Derived(x, y, z) {
|
||||
var _this = _super.call(this, x, y) || this;
|
||||
_this.z = z;
|
||||
return _this;
|
||||
}
|
||||
return Derived;
|
||||
}(Base));
|
||||
var Printable = function (superClass) { return _a = (function (_super) {
|
||||
__extends(class_1, _super);
|
||||
function class_1() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
class_1.prototype.print = function () {
|
||||
var output = this.x + "," + this.y;
|
||||
};
|
||||
return class_1;
|
||||
}(superClass)),
|
||||
_a.message = "hello",
|
||||
_a; var _a; };
|
||||
function Tagged(superClass) {
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
var _this = _super.apply(this, args) || this;
|
||||
_this._tag = "hello";
|
||||
return _this;
|
||||
}
|
||||
return C;
|
||||
}(superClass));
|
||||
return C;
|
||||
}
|
||||
var Thing1 = Tagged(Derived);
|
||||
var Thing2 = Tagged(Printable(Derived));
|
||||
Thing2.message;
|
||||
function f1() {
|
||||
var thing = new Thing1(1, 2, 3);
|
||||
thing.x;
|
||||
thing._tag;
|
||||
}
|
||||
function f2() {
|
||||
var thing = new Thing2(1, 2, 3);
|
||||
thing.x;
|
||||
thing._tag;
|
||||
thing.print();
|
||||
}
|
||||
var Thing3 = (function (_super) {
|
||||
__extends(Thing3, _super);
|
||||
function Thing3(tag) {
|
||||
var _this = _super.call(this, 10, 20, 30) || this;
|
||||
_this._tag = tag;
|
||||
return _this;
|
||||
}
|
||||
Thing3.prototype.test = function () {
|
||||
this.print();
|
||||
};
|
||||
return Thing3;
|
||||
}(Thing2));
|
169
tests/baselines/reference/mixinClassesAnonymous.symbols
Normal file
169
tests/baselines/reference/mixinClassesAnonymous.symbols
Normal file
|
@ -0,0 +1,169 @@
|
|||
=== tests/cases/conformance/classes/mixinClassesAnonymous.ts ===
|
||||
type Constructor<T> = new(...args: any[]) => T;
|
||||
>Constructor : Symbol(Constructor, Decl(mixinClassesAnonymous.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mixinClassesAnonymous.ts, 0, 17))
|
||||
>args : Symbol(args, Decl(mixinClassesAnonymous.ts, 0, 26))
|
||||
>T : Symbol(T, Decl(mixinClassesAnonymous.ts, 0, 17))
|
||||
|
||||
class Base {
|
||||
>Base : Symbol(Base, Decl(mixinClassesAnonymous.ts, 0, 47))
|
||||
|
||||
constructor(public x: number, public y: number) {}
|
||||
>x : Symbol(Base.x, Decl(mixinClassesAnonymous.ts, 3, 16))
|
||||
>y : Symbol(Base.y, Decl(mixinClassesAnonymous.ts, 3, 33))
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
>Derived : Symbol(Derived, Decl(mixinClassesAnonymous.ts, 4, 1))
|
||||
>Base : Symbol(Base, Decl(mixinClassesAnonymous.ts, 0, 47))
|
||||
|
||||
constructor(x: number, y: number, public z: number) {
|
||||
>x : Symbol(x, Decl(mixinClassesAnonymous.ts, 7, 16))
|
||||
>y : Symbol(y, Decl(mixinClassesAnonymous.ts, 7, 26))
|
||||
>z : Symbol(Derived.z, Decl(mixinClassesAnonymous.ts, 7, 37))
|
||||
|
||||
super(x, y);
|
||||
>super : Symbol(Base, Decl(mixinClassesAnonymous.ts, 0, 47))
|
||||
>x : Symbol(x, Decl(mixinClassesAnonymous.ts, 7, 16))
|
||||
>y : Symbol(y, Decl(mixinClassesAnonymous.ts, 7, 26))
|
||||
}
|
||||
}
|
||||
|
||||
const Printable = <T extends Constructor<Base>>(superClass: T) => class extends superClass {
|
||||
>Printable : Symbol(Printable, Decl(mixinClassesAnonymous.ts, 12, 5))
|
||||
>T : Symbol(T, Decl(mixinClassesAnonymous.ts, 12, 19))
|
||||
>Constructor : Symbol(Constructor, Decl(mixinClassesAnonymous.ts, 0, 0))
|
||||
>Base : Symbol(Base, Decl(mixinClassesAnonymous.ts, 0, 47))
|
||||
>superClass : Symbol(superClass, Decl(mixinClassesAnonymous.ts, 12, 48))
|
||||
>T : Symbol(T, Decl(mixinClassesAnonymous.ts, 12, 19))
|
||||
>superClass : Symbol(superClass, Decl(mixinClassesAnonymous.ts, 12, 48))
|
||||
|
||||
static message = "hello";
|
||||
>message : Symbol((Anonymous class).message, Decl(mixinClassesAnonymous.ts, 12, 92))
|
||||
|
||||
print() {
|
||||
>print : Symbol((Anonymous class).print, Decl(mixinClassesAnonymous.ts, 13, 29))
|
||||
|
||||
const output = this.x + "," + this.y;
|
||||
>output : Symbol(output, Decl(mixinClassesAnonymous.ts, 15, 13))
|
||||
>this.x : Symbol(Base.x, Decl(mixinClassesAnonymous.ts, 3, 16))
|
||||
>this : Symbol((Anonymous class), Decl(mixinClassesAnonymous.ts, 12, 65))
|
||||
>x : Symbol(Base.x, Decl(mixinClassesAnonymous.ts, 3, 16))
|
||||
>this.y : Symbol(Base.y, Decl(mixinClassesAnonymous.ts, 3, 33))
|
||||
>this : Symbol((Anonymous class), Decl(mixinClassesAnonymous.ts, 12, 65))
|
||||
>y : Symbol(Base.y, Decl(mixinClassesAnonymous.ts, 3, 33))
|
||||
}
|
||||
}
|
||||
|
||||
function Tagged<T extends Constructor<{}>>(superClass: T) {
|
||||
>Tagged : Symbol(Tagged, Decl(mixinClassesAnonymous.ts, 17, 1))
|
||||
>T : Symbol(T, Decl(mixinClassesAnonymous.ts, 19, 16))
|
||||
>Constructor : Symbol(Constructor, Decl(mixinClassesAnonymous.ts, 0, 0))
|
||||
>superClass : Symbol(superClass, Decl(mixinClassesAnonymous.ts, 19, 43))
|
||||
>T : Symbol(T, Decl(mixinClassesAnonymous.ts, 19, 16))
|
||||
|
||||
class C extends superClass {
|
||||
>C : Symbol(C, Decl(mixinClassesAnonymous.ts, 19, 59))
|
||||
>superClass : Symbol(superClass, Decl(mixinClassesAnonymous.ts, 19, 43))
|
||||
|
||||
_tag: string;
|
||||
>_tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32))
|
||||
|
||||
constructor(...args: any[]) {
|
||||
>args : Symbol(args, Decl(mixinClassesAnonymous.ts, 22, 20))
|
||||
|
||||
super(...args);
|
||||
>super : Symbol(T, Decl(mixinClassesAnonymous.ts, 19, 16))
|
||||
>args : Symbol(args, Decl(mixinClassesAnonymous.ts, 22, 20))
|
||||
|
||||
this._tag = "hello";
|
||||
>this._tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32))
|
||||
>this : Symbol(C, Decl(mixinClassesAnonymous.ts, 19, 59))
|
||||
>_tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32))
|
||||
}
|
||||
}
|
||||
return C;
|
||||
>C : Symbol(C, Decl(mixinClassesAnonymous.ts, 19, 59))
|
||||
}
|
||||
|
||||
const Thing1 = Tagged(Derived);
|
||||
>Thing1 : Symbol(Thing1, Decl(mixinClassesAnonymous.ts, 30, 5))
|
||||
>Tagged : Symbol(Tagged, Decl(mixinClassesAnonymous.ts, 17, 1))
|
||||
>Derived : Symbol(Derived, Decl(mixinClassesAnonymous.ts, 4, 1))
|
||||
|
||||
const Thing2 = Tagged(Printable(Derived));
|
||||
>Thing2 : Symbol(Thing2, Decl(mixinClassesAnonymous.ts, 31, 5))
|
||||
>Tagged : Symbol(Tagged, Decl(mixinClassesAnonymous.ts, 17, 1))
|
||||
>Printable : Symbol(Printable, Decl(mixinClassesAnonymous.ts, 12, 5))
|
||||
>Derived : Symbol(Derived, Decl(mixinClassesAnonymous.ts, 4, 1))
|
||||
|
||||
Thing2.message;
|
||||
>Thing2.message : Symbol((Anonymous class).message, Decl(mixinClassesAnonymous.ts, 12, 92))
|
||||
>Thing2 : Symbol(Thing2, Decl(mixinClassesAnonymous.ts, 31, 5))
|
||||
>message : Symbol((Anonymous class).message, Decl(mixinClassesAnonymous.ts, 12, 92))
|
||||
|
||||
function f1() {
|
||||
>f1 : Symbol(f1, Decl(mixinClassesAnonymous.ts, 32, 15))
|
||||
|
||||
const thing = new Thing1(1, 2, 3);
|
||||
>thing : Symbol(thing, Decl(mixinClassesAnonymous.ts, 35, 9))
|
||||
>Thing1 : Symbol(Thing1, Decl(mixinClassesAnonymous.ts, 30, 5))
|
||||
|
||||
thing.x;
|
||||
>thing.x : Symbol(Base.x, Decl(mixinClassesAnonymous.ts, 3, 16))
|
||||
>thing : Symbol(thing, Decl(mixinClassesAnonymous.ts, 35, 9))
|
||||
>x : Symbol(Base.x, Decl(mixinClassesAnonymous.ts, 3, 16))
|
||||
|
||||
thing._tag;
|
||||
>thing._tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32))
|
||||
>thing : Symbol(thing, Decl(mixinClassesAnonymous.ts, 35, 9))
|
||||
>_tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32))
|
||||
}
|
||||
|
||||
function f2() {
|
||||
>f2 : Symbol(f2, Decl(mixinClassesAnonymous.ts, 38, 1))
|
||||
|
||||
const thing = new Thing2(1, 2, 3);
|
||||
>thing : Symbol(thing, Decl(mixinClassesAnonymous.ts, 41, 9))
|
||||
>Thing2 : Symbol(Thing2, Decl(mixinClassesAnonymous.ts, 31, 5))
|
||||
|
||||
thing.x;
|
||||
>thing.x : Symbol(Base.x, Decl(mixinClassesAnonymous.ts, 3, 16))
|
||||
>thing : Symbol(thing, Decl(mixinClassesAnonymous.ts, 41, 9))
|
||||
>x : Symbol(Base.x, Decl(mixinClassesAnonymous.ts, 3, 16))
|
||||
|
||||
thing._tag;
|
||||
>thing._tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32))
|
||||
>thing : Symbol(thing, Decl(mixinClassesAnonymous.ts, 41, 9))
|
||||
>_tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32))
|
||||
|
||||
thing.print();
|
||||
>thing.print : Symbol((Anonymous class).print, Decl(mixinClassesAnonymous.ts, 13, 29))
|
||||
>thing : Symbol(thing, Decl(mixinClassesAnonymous.ts, 41, 9))
|
||||
>print : Symbol((Anonymous class).print, Decl(mixinClassesAnonymous.ts, 13, 29))
|
||||
}
|
||||
|
||||
class Thing3 extends Thing2 {
|
||||
>Thing3 : Symbol(Thing3, Decl(mixinClassesAnonymous.ts, 45, 1))
|
||||
>Thing2 : Symbol(Thing2, Decl(mixinClassesAnonymous.ts, 31, 5))
|
||||
|
||||
constructor(tag: string) {
|
||||
>tag : Symbol(tag, Decl(mixinClassesAnonymous.ts, 48, 16))
|
||||
|
||||
super(10, 20, 30);
|
||||
this._tag = tag;
|
||||
>this._tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32))
|
||||
>this : Symbol(Thing3, Decl(mixinClassesAnonymous.ts, 45, 1))
|
||||
>_tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32))
|
||||
>tag : Symbol(tag, Decl(mixinClassesAnonymous.ts, 48, 16))
|
||||
}
|
||||
test() {
|
||||
>test : Symbol(Thing3.test, Decl(mixinClassesAnonymous.ts, 51, 5))
|
||||
|
||||
this.print();
|
||||
>this.print : Symbol((Anonymous class).print, Decl(mixinClassesAnonymous.ts, 13, 29))
|
||||
>this : Symbol(Thing3, Decl(mixinClassesAnonymous.ts, 45, 1))
|
||||
>print : Symbol((Anonymous class).print, Decl(mixinClassesAnonymous.ts, 13, 29))
|
||||
}
|
||||
}
|
||||
|
200
tests/baselines/reference/mixinClassesAnonymous.types
Normal file
200
tests/baselines/reference/mixinClassesAnonymous.types
Normal file
|
@ -0,0 +1,200 @@
|
|||
=== tests/cases/conformance/classes/mixinClassesAnonymous.ts ===
|
||||
type Constructor<T> = new(...args: any[]) => T;
|
||||
>Constructor : Constructor<T>
|
||||
>T : T
|
||||
>args : any[]
|
||||
>T : T
|
||||
|
||||
class Base {
|
||||
>Base : Base
|
||||
|
||||
constructor(public x: number, public y: number) {}
|
||||
>x : number
|
||||
>y : number
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
>Derived : Derived
|
||||
>Base : Base
|
||||
|
||||
constructor(x: number, y: number, public z: number) {
|
||||
>x : number
|
||||
>y : number
|
||||
>z : number
|
||||
|
||||
super(x, y);
|
||||
>super(x, y) : void
|
||||
>super : typeof Base
|
||||
>x : number
|
||||
>y : number
|
||||
}
|
||||
}
|
||||
|
||||
const Printable = <T extends Constructor<Base>>(superClass: T) => class extends superClass {
|
||||
>Printable : <T extends Constructor<Base>>(superClass: T) => { new (...args: any[]): (Anonymous class); prototype: <any>.(Anonymous class); message: string; } & T
|
||||
><T extends Constructor<Base>>(superClass: T) => class extends superClass { static message = "hello"; print() { const output = this.x + "," + this.y; }} : <T extends Constructor<Base>>(superClass: T) => { new (...args: any[]): (Anonymous class); prototype: <any>.(Anonymous class); message: string; } & T
|
||||
>T : T
|
||||
>Constructor : Constructor<T>
|
||||
>Base : Base
|
||||
>superClass : T
|
||||
>T : T
|
||||
>class extends superClass { static message = "hello"; print() { const output = this.x + "," + this.y; }} : { new (...args: any[]): (Anonymous class); prototype: <any>.(Anonymous class); message: string; } & T
|
||||
>superClass : Base
|
||||
|
||||
static message = "hello";
|
||||
>message : string
|
||||
>"hello" : "hello"
|
||||
|
||||
print() {
|
||||
>print : () => void
|
||||
|
||||
const output = this.x + "," + this.y;
|
||||
>output : string
|
||||
>this.x + "," + this.y : string
|
||||
>this.x + "," : string
|
||||
>this.x : number
|
||||
>this : this
|
||||
>x : number
|
||||
>"," : ","
|
||||
>this.y : number
|
||||
>this : this
|
||||
>y : number
|
||||
}
|
||||
}
|
||||
|
||||
function Tagged<T extends Constructor<{}>>(superClass: T) {
|
||||
>Tagged : <T extends Constructor<{}>>(superClass: T) => { new (...args: any[]): C; prototype: Tagged<any>.C; } & T
|
||||
>T : T
|
||||
>Constructor : Constructor<T>
|
||||
>superClass : T
|
||||
>T : T
|
||||
|
||||
class C extends superClass {
|
||||
>C : C
|
||||
>superClass : {}
|
||||
|
||||
_tag: string;
|
||||
>_tag : string
|
||||
|
||||
constructor(...args: any[]) {
|
||||
>args : any[]
|
||||
|
||||
super(...args);
|
||||
>super(...args) : void
|
||||
>super : T
|
||||
>...args : any
|
||||
>args : any[]
|
||||
|
||||
this._tag = "hello";
|
||||
>this._tag = "hello" : "hello"
|
||||
>this._tag : string
|
||||
>this : this
|
||||
>_tag : string
|
||||
>"hello" : "hello"
|
||||
}
|
||||
}
|
||||
return C;
|
||||
>C : { new (...args: any[]): C; prototype: Tagged<any>.C; } & T
|
||||
}
|
||||
|
||||
const Thing1 = Tagged(Derived);
|
||||
>Thing1 : { new (...args: any[]): Tagged<typeof Derived>.C; prototype: Tagged<any>.C; } & typeof Derived
|
||||
>Tagged(Derived) : { new (...args: any[]): Tagged<typeof Derived>.C; prototype: Tagged<any>.C; } & typeof Derived
|
||||
>Tagged : <T extends Constructor<{}>>(superClass: T) => { new (...args: any[]): C; prototype: Tagged<any>.C; } & T
|
||||
>Derived : typeof Derived
|
||||
|
||||
const Thing2 = Tagged(Printable(Derived));
|
||||
>Thing2 : { new (...args: any[]): Tagged<{ new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived>.C; prototype: Tagged<any>.C; } & { new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived
|
||||
>Tagged(Printable(Derived)) : { new (...args: any[]): Tagged<{ new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived>.C; prototype: Tagged<any>.C; } & { new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived
|
||||
>Tagged : <T extends Constructor<{}>>(superClass: T) => { new (...args: any[]): C; prototype: Tagged<any>.C; } & T
|
||||
>Printable(Derived) : { new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived
|
||||
>Printable : <T extends Constructor<Base>>(superClass: T) => { new (...args: any[]): (Anonymous class); prototype: <any>.(Anonymous class); message: string; } & T
|
||||
>Derived : typeof Derived
|
||||
|
||||
Thing2.message;
|
||||
>Thing2.message : string
|
||||
>Thing2 : { new (...args: any[]): Tagged<{ new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived>.C; prototype: Tagged<any>.C; } & { new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived
|
||||
>message : string
|
||||
|
||||
function f1() {
|
||||
>f1 : () => void
|
||||
|
||||
const thing = new Thing1(1, 2, 3);
|
||||
>thing : Tagged<typeof Derived>.C & Derived
|
||||
>new Thing1(1, 2, 3) : Tagged<typeof Derived>.C & Derived
|
||||
>Thing1 : { new (...args: any[]): Tagged<typeof Derived>.C; prototype: Tagged<any>.C; } & typeof Derived
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
thing.x;
|
||||
>thing.x : number
|
||||
>thing : Tagged<typeof Derived>.C & Derived
|
||||
>x : number
|
||||
|
||||
thing._tag;
|
||||
>thing._tag : string
|
||||
>thing : Tagged<typeof Derived>.C & Derived
|
||||
>_tag : string
|
||||
}
|
||||
|
||||
function f2() {
|
||||
>f2 : () => void
|
||||
|
||||
const thing = new Thing2(1, 2, 3);
|
||||
>thing : Tagged<{ new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived>.C & <typeof Derived>.(Anonymous class) & Derived
|
||||
>new Thing2(1, 2, 3) : Tagged<{ new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived>.C & <typeof Derived>.(Anonymous class) & Derived
|
||||
>Thing2 : { new (...args: any[]): Tagged<{ new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived>.C; prototype: Tagged<any>.C; } & { new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
thing.x;
|
||||
>thing.x : number
|
||||
>thing : Tagged<{ new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived>.C & <typeof Derived>.(Anonymous class) & Derived
|
||||
>x : number
|
||||
|
||||
thing._tag;
|
||||
>thing._tag : string
|
||||
>thing : Tagged<{ new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived>.C & <typeof Derived>.(Anonymous class) & Derived
|
||||
>_tag : string
|
||||
|
||||
thing.print();
|
||||
>thing.print() : void
|
||||
>thing.print : () => void
|
||||
>thing : Tagged<{ new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived>.C & <typeof Derived>.(Anonymous class) & Derived
|
||||
>print : () => void
|
||||
}
|
||||
|
||||
class Thing3 extends Thing2 {
|
||||
>Thing3 : Thing3
|
||||
>Thing2 : Tagged<{ new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived>.C & <typeof Derived>.(Anonymous class) & Derived
|
||||
|
||||
constructor(tag: string) {
|
||||
>tag : string
|
||||
|
||||
super(10, 20, 30);
|
||||
>super(10, 20, 30) : void
|
||||
>super : { new (...args: any[]): Tagged<{ new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived>.C; prototype: Tagged<any>.C; } & { new (...args: any[]): <typeof Derived>.(Anonymous class); prototype: <any>.(Anonymous class); message: string; } & typeof Derived
|
||||
>10 : 10
|
||||
>20 : 20
|
||||
>30 : 30
|
||||
|
||||
this._tag = tag;
|
||||
>this._tag = tag : string
|
||||
>this._tag : string
|
||||
>this : this
|
||||
>_tag : string
|
||||
>tag : string
|
||||
}
|
||||
test() {
|
||||
>test : () => void
|
||||
|
||||
this.print();
|
||||
>this.print() : void
|
||||
>this.print : () => void
|
||||
>this : this
|
||||
>print : () => void
|
||||
}
|
||||
}
|
||||
|
220
tests/baselines/reference/mixinClassesMembers.js
Normal file
220
tests/baselines/reference/mixinClassesMembers.js
Normal file
|
@ -0,0 +1,220 @@
|
|||
//// [mixinClassesMembers.ts]
|
||||
|
||||
declare class C1 {
|
||||
public a: number;
|
||||
protected b: number;
|
||||
private c: number;
|
||||
constructor(s: string);
|
||||
constructor(n: number);
|
||||
}
|
||||
|
||||
declare class M1 {
|
||||
constructor(...args: any[]);
|
||||
p: number;
|
||||
static p: number;
|
||||
}
|
||||
|
||||
declare class M2 {
|
||||
constructor(...args: any[]);
|
||||
f(): number;
|
||||
static f(): number;
|
||||
}
|
||||
|
||||
declare const Mixed1: typeof M1 & typeof C1;
|
||||
declare const Mixed2: typeof C1 & typeof M1;
|
||||
declare const Mixed3: typeof M2 & typeof M1 & typeof C1;
|
||||
declare const Mixed4: typeof C1 & typeof M1 & typeof M2;
|
||||
declare const Mixed5: typeof M1 & typeof M2;
|
||||
|
||||
function f1() {
|
||||
let x1 = new Mixed1("hello");
|
||||
let x2 = new Mixed1(42);
|
||||
let x3 = new Mixed2("hello");
|
||||
let x4 = new Mixed2(42);
|
||||
let x5 = new Mixed3("hello");
|
||||
let x6 = new Mixed3(42);
|
||||
let x7 = new Mixed4("hello");
|
||||
let x8 = new Mixed4(42);
|
||||
let x9 = new Mixed5();
|
||||
}
|
||||
|
||||
function f2() {
|
||||
let x = new Mixed1("hello");
|
||||
x.a;
|
||||
x.p;
|
||||
Mixed1.p;
|
||||
}
|
||||
|
||||
function f3() {
|
||||
let x = new Mixed2("hello");
|
||||
x.a;
|
||||
x.p;
|
||||
Mixed2.p;
|
||||
}
|
||||
|
||||
function f4() {
|
||||
let x = new Mixed3("hello");
|
||||
x.a;
|
||||
x.p;
|
||||
x.f();
|
||||
Mixed3.p;
|
||||
Mixed3.f();
|
||||
}
|
||||
|
||||
function f5() {
|
||||
let x = new Mixed4("hello");
|
||||
x.a;
|
||||
x.p;
|
||||
x.f();
|
||||
Mixed4.p;
|
||||
Mixed4.f();
|
||||
}
|
||||
|
||||
function f6() {
|
||||
let x = new Mixed5();
|
||||
x.p;
|
||||
x.f();
|
||||
Mixed5.p;
|
||||
Mixed5.f();
|
||||
}
|
||||
|
||||
class C2 extends Mixed1 {
|
||||
constructor() {
|
||||
super("hello");
|
||||
this.a;
|
||||
this.b;
|
||||
this.p;
|
||||
}
|
||||
}
|
||||
|
||||
class C3 extends Mixed3 {
|
||||
constructor() {
|
||||
super(42);
|
||||
this.a;
|
||||
this.b;
|
||||
this.p;
|
||||
this.f();
|
||||
}
|
||||
f() { return super.f(); }
|
||||
}
|
||||
|
||||
|
||||
//// [mixinClassesMembers.js]
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
function f1() {
|
||||
var x1 = new Mixed1("hello");
|
||||
var x2 = new Mixed1(42);
|
||||
var x3 = new Mixed2("hello");
|
||||
var x4 = new Mixed2(42);
|
||||
var x5 = new Mixed3("hello");
|
||||
var x6 = new Mixed3(42);
|
||||
var x7 = new Mixed4("hello");
|
||||
var x8 = new Mixed4(42);
|
||||
var x9 = new Mixed5();
|
||||
}
|
||||
function f2() {
|
||||
var x = new Mixed1("hello");
|
||||
x.a;
|
||||
x.p;
|
||||
Mixed1.p;
|
||||
}
|
||||
function f3() {
|
||||
var x = new Mixed2("hello");
|
||||
x.a;
|
||||
x.p;
|
||||
Mixed2.p;
|
||||
}
|
||||
function f4() {
|
||||
var x = new Mixed3("hello");
|
||||
x.a;
|
||||
x.p;
|
||||
x.f();
|
||||
Mixed3.p;
|
||||
Mixed3.f();
|
||||
}
|
||||
function f5() {
|
||||
var x = new Mixed4("hello");
|
||||
x.a;
|
||||
x.p;
|
||||
x.f();
|
||||
Mixed4.p;
|
||||
Mixed4.f();
|
||||
}
|
||||
function f6() {
|
||||
var x = new Mixed5();
|
||||
x.p;
|
||||
x.f();
|
||||
Mixed5.p;
|
||||
Mixed5.f();
|
||||
}
|
||||
var C2 = (function (_super) {
|
||||
__extends(C2, _super);
|
||||
function C2() {
|
||||
var _this = _super.call(this, "hello") || this;
|
||||
_this.a;
|
||||
_this.b;
|
||||
_this.p;
|
||||
return _this;
|
||||
}
|
||||
return C2;
|
||||
}(Mixed1));
|
||||
var C3 = (function (_super) {
|
||||
__extends(C3, _super);
|
||||
function C3() {
|
||||
var _this = _super.call(this, 42) || this;
|
||||
_this.a;
|
||||
_this.b;
|
||||
_this.p;
|
||||
_this.f();
|
||||
return _this;
|
||||
}
|
||||
C3.prototype.f = function () { return _super.prototype.f.call(this); };
|
||||
return C3;
|
||||
}(Mixed3));
|
||||
|
||||
|
||||
//// [mixinClassesMembers.d.ts]
|
||||
declare class C1 {
|
||||
a: number;
|
||||
protected b: number;
|
||||
private c;
|
||||
constructor(s: string);
|
||||
constructor(n: number);
|
||||
}
|
||||
declare class M1 {
|
||||
constructor(...args: any[]);
|
||||
p: number;
|
||||
static p: number;
|
||||
}
|
||||
declare class M2 {
|
||||
constructor(...args: any[]);
|
||||
f(): number;
|
||||
static f(): number;
|
||||
}
|
||||
declare const Mixed1: typeof M1 & typeof C1;
|
||||
declare const Mixed2: typeof C1 & typeof M1;
|
||||
declare const Mixed3: typeof M2 & typeof M1 & typeof C1;
|
||||
declare const Mixed4: typeof C1 & typeof M1 & typeof M2;
|
||||
declare const Mixed5: typeof M1 & typeof M2;
|
||||
declare function f1(): void;
|
||||
declare function f2(): void;
|
||||
declare function f3(): void;
|
||||
declare function f4(): void;
|
||||
declare function f5(): void;
|
||||
declare function f6(): void;
|
||||
declare class C2 extends Mixed1 {
|
||||
constructor();
|
||||
}
|
||||
declare class C3 extends Mixed3 {
|
||||
constructor();
|
||||
f(): number;
|
||||
}
|
309
tests/baselines/reference/mixinClassesMembers.symbols
Normal file
309
tests/baselines/reference/mixinClassesMembers.symbols
Normal file
|
@ -0,0 +1,309 @@
|
|||
=== tests/cases/conformance/classes/mixinClassesMembers.ts ===
|
||||
|
||||
declare class C1 {
|
||||
>C1 : Symbol(C1, Decl(mixinClassesMembers.ts, 0, 0))
|
||||
|
||||
public a: number;
|
||||
>a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18))
|
||||
|
||||
protected b: number;
|
||||
>b : Symbol(C1.b, Decl(mixinClassesMembers.ts, 2, 21))
|
||||
|
||||
private c: number;
|
||||
>c : Symbol(C1.c, Decl(mixinClassesMembers.ts, 3, 24))
|
||||
|
||||
constructor(s: string);
|
||||
>s : Symbol(s, Decl(mixinClassesMembers.ts, 5, 16))
|
||||
|
||||
constructor(n: number);
|
||||
>n : Symbol(n, Decl(mixinClassesMembers.ts, 6, 16))
|
||||
}
|
||||
|
||||
declare class M1 {
|
||||
>M1 : Symbol(M1, Decl(mixinClassesMembers.ts, 7, 1))
|
||||
|
||||
constructor(...args: any[]);
|
||||
>args : Symbol(args, Decl(mixinClassesMembers.ts, 10, 16))
|
||||
|
||||
p: number;
|
||||
>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
|
||||
static p: number;
|
||||
>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14))
|
||||
}
|
||||
|
||||
declare class M2 {
|
||||
>M2 : Symbol(M2, Decl(mixinClassesMembers.ts, 13, 1))
|
||||
|
||||
constructor(...args: any[]);
|
||||
>args : Symbol(args, Decl(mixinClassesMembers.ts, 16, 16))
|
||||
|
||||
f(): number;
|
||||
>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32))
|
||||
|
||||
static f(): number;
|
||||
>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 17, 16))
|
||||
}
|
||||
|
||||
declare const Mixed1: typeof M1 & typeof C1;
|
||||
>Mixed1 : Symbol(Mixed1, Decl(mixinClassesMembers.ts, 21, 13))
|
||||
>M1 : Symbol(M1, Decl(mixinClassesMembers.ts, 7, 1))
|
||||
>C1 : Symbol(C1, Decl(mixinClassesMembers.ts, 0, 0))
|
||||
|
||||
declare const Mixed2: typeof C1 & typeof M1;
|
||||
>Mixed2 : Symbol(Mixed2, Decl(mixinClassesMembers.ts, 22, 13))
|
||||
>C1 : Symbol(C1, Decl(mixinClassesMembers.ts, 0, 0))
|
||||
>M1 : Symbol(M1, Decl(mixinClassesMembers.ts, 7, 1))
|
||||
|
||||
declare const Mixed3: typeof M2 & typeof M1 & typeof C1;
|
||||
>Mixed3 : Symbol(Mixed3, Decl(mixinClassesMembers.ts, 23, 13))
|
||||
>M2 : Symbol(M2, Decl(mixinClassesMembers.ts, 13, 1))
|
||||
>M1 : Symbol(M1, Decl(mixinClassesMembers.ts, 7, 1))
|
||||
>C1 : Symbol(C1, Decl(mixinClassesMembers.ts, 0, 0))
|
||||
|
||||
declare const Mixed4: typeof C1 & typeof M1 & typeof M2;
|
||||
>Mixed4 : Symbol(Mixed4, Decl(mixinClassesMembers.ts, 24, 13))
|
||||
>C1 : Symbol(C1, Decl(mixinClassesMembers.ts, 0, 0))
|
||||
>M1 : Symbol(M1, Decl(mixinClassesMembers.ts, 7, 1))
|
||||
>M2 : Symbol(M2, Decl(mixinClassesMembers.ts, 13, 1))
|
||||
|
||||
declare const Mixed5: typeof M1 & typeof M2;
|
||||
>Mixed5 : Symbol(Mixed5, Decl(mixinClassesMembers.ts, 25, 13))
|
||||
>M1 : Symbol(M1, Decl(mixinClassesMembers.ts, 7, 1))
|
||||
>M2 : Symbol(M2, Decl(mixinClassesMembers.ts, 13, 1))
|
||||
|
||||
function f1() {
|
||||
>f1 : Symbol(f1, Decl(mixinClassesMembers.ts, 25, 44))
|
||||
|
||||
let x1 = new Mixed1("hello");
|
||||
>x1 : Symbol(x1, Decl(mixinClassesMembers.ts, 28, 7))
|
||||
>Mixed1 : Symbol(Mixed1, Decl(mixinClassesMembers.ts, 21, 13))
|
||||
|
||||
let x2 = new Mixed1(42);
|
||||
>x2 : Symbol(x2, Decl(mixinClassesMembers.ts, 29, 7))
|
||||
>Mixed1 : Symbol(Mixed1, Decl(mixinClassesMembers.ts, 21, 13))
|
||||
|
||||
let x3 = new Mixed2("hello");
|
||||
>x3 : Symbol(x3, Decl(mixinClassesMembers.ts, 30, 7))
|
||||
>Mixed2 : Symbol(Mixed2, Decl(mixinClassesMembers.ts, 22, 13))
|
||||
|
||||
let x4 = new Mixed2(42);
|
||||
>x4 : Symbol(x4, Decl(mixinClassesMembers.ts, 31, 7))
|
||||
>Mixed2 : Symbol(Mixed2, Decl(mixinClassesMembers.ts, 22, 13))
|
||||
|
||||
let x5 = new Mixed3("hello");
|
||||
>x5 : Symbol(x5, Decl(mixinClassesMembers.ts, 32, 7))
|
||||
>Mixed3 : Symbol(Mixed3, Decl(mixinClassesMembers.ts, 23, 13))
|
||||
|
||||
let x6 = new Mixed3(42);
|
||||
>x6 : Symbol(x6, Decl(mixinClassesMembers.ts, 33, 7))
|
||||
>Mixed3 : Symbol(Mixed3, Decl(mixinClassesMembers.ts, 23, 13))
|
||||
|
||||
let x7 = new Mixed4("hello");
|
||||
>x7 : Symbol(x7, Decl(mixinClassesMembers.ts, 34, 7))
|
||||
>Mixed4 : Symbol(Mixed4, Decl(mixinClassesMembers.ts, 24, 13))
|
||||
|
||||
let x8 = new Mixed4(42);
|
||||
>x8 : Symbol(x8, Decl(mixinClassesMembers.ts, 35, 7))
|
||||
>Mixed4 : Symbol(Mixed4, Decl(mixinClassesMembers.ts, 24, 13))
|
||||
|
||||
let x9 = new Mixed5();
|
||||
>x9 : Symbol(x9, Decl(mixinClassesMembers.ts, 36, 7))
|
||||
>Mixed5 : Symbol(Mixed5, Decl(mixinClassesMembers.ts, 25, 13))
|
||||
}
|
||||
|
||||
function f2() {
|
||||
>f2 : Symbol(f2, Decl(mixinClassesMembers.ts, 37, 1))
|
||||
|
||||
let x = new Mixed1("hello");
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 40, 7))
|
||||
>Mixed1 : Symbol(Mixed1, Decl(mixinClassesMembers.ts, 21, 13))
|
||||
|
||||
x.a;
|
||||
>x.a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18))
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 40, 7))
|
||||
>a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18))
|
||||
|
||||
x.p;
|
||||
>x.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 40, 7))
|
||||
>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
|
||||
Mixed1.p;
|
||||
>Mixed1.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14))
|
||||
>Mixed1 : Symbol(Mixed1, Decl(mixinClassesMembers.ts, 21, 13))
|
||||
>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14))
|
||||
}
|
||||
|
||||
function f3() {
|
||||
>f3 : Symbol(f3, Decl(mixinClassesMembers.ts, 44, 1))
|
||||
|
||||
let x = new Mixed2("hello");
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 47, 7))
|
||||
>Mixed2 : Symbol(Mixed2, Decl(mixinClassesMembers.ts, 22, 13))
|
||||
|
||||
x.a;
|
||||
>x.a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18))
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 47, 7))
|
||||
>a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18))
|
||||
|
||||
x.p;
|
||||
>x.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 47, 7))
|
||||
>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
|
||||
Mixed2.p;
|
||||
>Mixed2.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14))
|
||||
>Mixed2 : Symbol(Mixed2, Decl(mixinClassesMembers.ts, 22, 13))
|
||||
>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14))
|
||||
}
|
||||
|
||||
function f4() {
|
||||
>f4 : Symbol(f4, Decl(mixinClassesMembers.ts, 51, 1))
|
||||
|
||||
let x = new Mixed3("hello");
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 54, 7))
|
||||
>Mixed3 : Symbol(Mixed3, Decl(mixinClassesMembers.ts, 23, 13))
|
||||
|
||||
x.a;
|
||||
>x.a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18))
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 54, 7))
|
||||
>a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18))
|
||||
|
||||
x.p;
|
||||
>x.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 54, 7))
|
||||
>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
|
||||
x.f();
|
||||
>x.f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32))
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 54, 7))
|
||||
>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32))
|
||||
|
||||
Mixed3.p;
|
||||
>Mixed3.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14))
|
||||
>Mixed3 : Symbol(Mixed3, Decl(mixinClassesMembers.ts, 23, 13))
|
||||
>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14))
|
||||
|
||||
Mixed3.f();
|
||||
>Mixed3.f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 17, 16))
|
||||
>Mixed3 : Symbol(Mixed3, Decl(mixinClassesMembers.ts, 23, 13))
|
||||
>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 17, 16))
|
||||
}
|
||||
|
||||
function f5() {
|
||||
>f5 : Symbol(f5, Decl(mixinClassesMembers.ts, 60, 1))
|
||||
|
||||
let x = new Mixed4("hello");
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 63, 7))
|
||||
>Mixed4 : Symbol(Mixed4, Decl(mixinClassesMembers.ts, 24, 13))
|
||||
|
||||
x.a;
|
||||
>x.a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18))
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 63, 7))
|
||||
>a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18))
|
||||
|
||||
x.p;
|
||||
>x.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 63, 7))
|
||||
>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
|
||||
x.f();
|
||||
>x.f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32))
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 63, 7))
|
||||
>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32))
|
||||
|
||||
Mixed4.p;
|
||||
>Mixed4.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14))
|
||||
>Mixed4 : Symbol(Mixed4, Decl(mixinClassesMembers.ts, 24, 13))
|
||||
>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14))
|
||||
|
||||
Mixed4.f();
|
||||
>Mixed4.f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 17, 16))
|
||||
>Mixed4 : Symbol(Mixed4, Decl(mixinClassesMembers.ts, 24, 13))
|
||||
>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 17, 16))
|
||||
}
|
||||
|
||||
function f6() {
|
||||
>f6 : Symbol(f6, Decl(mixinClassesMembers.ts, 69, 1))
|
||||
|
||||
let x = new Mixed5();
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 72, 7))
|
||||
>Mixed5 : Symbol(Mixed5, Decl(mixinClassesMembers.ts, 25, 13))
|
||||
|
||||
x.p;
|
||||
>x.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 72, 7))
|
||||
>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
|
||||
x.f();
|
||||
>x.f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32))
|
||||
>x : Symbol(x, Decl(mixinClassesMembers.ts, 72, 7))
|
||||
>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32))
|
||||
|
||||
Mixed5.p;
|
||||
>Mixed5.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14))
|
||||
>Mixed5 : Symbol(Mixed5, Decl(mixinClassesMembers.ts, 25, 13))
|
||||
>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14))
|
||||
|
||||
Mixed5.f();
|
||||
>Mixed5.f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 17, 16))
|
||||
>Mixed5 : Symbol(Mixed5, Decl(mixinClassesMembers.ts, 25, 13))
|
||||
>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 17, 16))
|
||||
}
|
||||
|
||||
class C2 extends Mixed1 {
|
||||
>C2 : Symbol(C2, Decl(mixinClassesMembers.ts, 77, 1))
|
||||
>Mixed1 : Symbol(Mixed1, Decl(mixinClassesMembers.ts, 21, 13))
|
||||
|
||||
constructor() {
|
||||
super("hello");
|
||||
this.a;
|
||||
>this.a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18))
|
||||
>this : Symbol(C2, Decl(mixinClassesMembers.ts, 77, 1))
|
||||
>a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18))
|
||||
|
||||
this.b;
|
||||
>this.b : Symbol(C1.b, Decl(mixinClassesMembers.ts, 2, 21))
|
||||
>this : Symbol(C2, Decl(mixinClassesMembers.ts, 77, 1))
|
||||
>b : Symbol(C1.b, Decl(mixinClassesMembers.ts, 2, 21))
|
||||
|
||||
this.p;
|
||||
>this.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
>this : Symbol(C2, Decl(mixinClassesMembers.ts, 77, 1))
|
||||
>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
}
|
||||
}
|
||||
|
||||
class C3 extends Mixed3 {
|
||||
>C3 : Symbol(C3, Decl(mixinClassesMembers.ts, 86, 1))
|
||||
>Mixed3 : Symbol(Mixed3, Decl(mixinClassesMembers.ts, 23, 13))
|
||||
|
||||
constructor() {
|
||||
super(42);
|
||||
this.a;
|
||||
>this.a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18))
|
||||
>this : Symbol(C3, Decl(mixinClassesMembers.ts, 86, 1))
|
||||
>a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18))
|
||||
|
||||
this.b;
|
||||
>this.b : Symbol(C1.b, Decl(mixinClassesMembers.ts, 2, 21))
|
||||
>this : Symbol(C3, Decl(mixinClassesMembers.ts, 86, 1))
|
||||
>b : Symbol(C1.b, Decl(mixinClassesMembers.ts, 2, 21))
|
||||
|
||||
this.p;
|
||||
>this.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
>this : Symbol(C3, Decl(mixinClassesMembers.ts, 86, 1))
|
||||
>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32))
|
||||
|
||||
this.f();
|
||||
>this.f : Symbol(C3.f, Decl(mixinClassesMembers.ts, 95, 5))
|
||||
>this : Symbol(C3, Decl(mixinClassesMembers.ts, 86, 1))
|
||||
>f : Symbol(C3.f, Decl(mixinClassesMembers.ts, 95, 5))
|
||||
}
|
||||
f() { return super.f(); }
|
||||
>f : Symbol(C3.f, Decl(mixinClassesMembers.ts, 95, 5))
|
||||
>super.f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32))
|
||||
>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32))
|
||||
}
|
||||
|
352
tests/baselines/reference/mixinClassesMembers.types
Normal file
352
tests/baselines/reference/mixinClassesMembers.types
Normal file
|
@ -0,0 +1,352 @@
|
|||
=== tests/cases/conformance/classes/mixinClassesMembers.ts ===
|
||||
|
||||
declare class C1 {
|
||||
>C1 : C1
|
||||
|
||||
public a: number;
|
||||
>a : number
|
||||
|
||||
protected b: number;
|
||||
>b : number
|
||||
|
||||
private c: number;
|
||||
>c : number
|
||||
|
||||
constructor(s: string);
|
||||
>s : string
|
||||
|
||||
constructor(n: number);
|
||||
>n : number
|
||||
}
|
||||
|
||||
declare class M1 {
|
||||
>M1 : M1
|
||||
|
||||
constructor(...args: any[]);
|
||||
>args : any[]
|
||||
|
||||
p: number;
|
||||
>p : number
|
||||
|
||||
static p: number;
|
||||
>p : number
|
||||
}
|
||||
|
||||
declare class M2 {
|
||||
>M2 : M2
|
||||
|
||||
constructor(...args: any[]);
|
||||
>args : any[]
|
||||
|
||||
f(): number;
|
||||
>f : () => number
|
||||
|
||||
static f(): number;
|
||||
>f : () => number
|
||||
}
|
||||
|
||||
declare const Mixed1: typeof M1 & typeof C1;
|
||||
>Mixed1 : typeof M1 & typeof C1
|
||||
>M1 : typeof M1
|
||||
>C1 : typeof C1
|
||||
|
||||
declare const Mixed2: typeof C1 & typeof M1;
|
||||
>Mixed2 : typeof C1 & typeof M1
|
||||
>C1 : typeof C1
|
||||
>M1 : typeof M1
|
||||
|
||||
declare const Mixed3: typeof M2 & typeof M1 & typeof C1;
|
||||
>Mixed3 : typeof M2 & typeof M1 & typeof C1
|
||||
>M2 : typeof M2
|
||||
>M1 : typeof M1
|
||||
>C1 : typeof C1
|
||||
|
||||
declare const Mixed4: typeof C1 & typeof M1 & typeof M2;
|
||||
>Mixed4 : typeof C1 & typeof M1 & typeof M2
|
||||
>C1 : typeof C1
|
||||
>M1 : typeof M1
|
||||
>M2 : typeof M2
|
||||
|
||||
declare const Mixed5: typeof M1 & typeof M2;
|
||||
>Mixed5 : typeof M1 & typeof M2
|
||||
>M1 : typeof M1
|
||||
>M2 : typeof M2
|
||||
|
||||
function f1() {
|
||||
>f1 : () => void
|
||||
|
||||
let x1 = new Mixed1("hello");
|
||||
>x1 : M1 & C1
|
||||
>new Mixed1("hello") : M1 & C1
|
||||
>Mixed1 : typeof M1 & typeof C1
|
||||
>"hello" : "hello"
|
||||
|
||||
let x2 = new Mixed1(42);
|
||||
>x2 : M1 & C1
|
||||
>new Mixed1(42) : M1 & C1
|
||||
>Mixed1 : typeof M1 & typeof C1
|
||||
>42 : 42
|
||||
|
||||
let x3 = new Mixed2("hello");
|
||||
>x3 : C1 & M1
|
||||
>new Mixed2("hello") : C1 & M1
|
||||
>Mixed2 : typeof C1 & typeof M1
|
||||
>"hello" : "hello"
|
||||
|
||||
let x4 = new Mixed2(42);
|
||||
>x4 : C1 & M1
|
||||
>new Mixed2(42) : C1 & M1
|
||||
>Mixed2 : typeof C1 & typeof M1
|
||||
>42 : 42
|
||||
|
||||
let x5 = new Mixed3("hello");
|
||||
>x5 : M2 & M1 & C1
|
||||
>new Mixed3("hello") : M2 & M1 & C1
|
||||
>Mixed3 : typeof M2 & typeof M1 & typeof C1
|
||||
>"hello" : "hello"
|
||||
|
||||
let x6 = new Mixed3(42);
|
||||
>x6 : M2 & M1 & C1
|
||||
>new Mixed3(42) : M2 & M1 & C1
|
||||
>Mixed3 : typeof M2 & typeof M1 & typeof C1
|
||||
>42 : 42
|
||||
|
||||
let x7 = new Mixed4("hello");
|
||||
>x7 : C1 & M1 & M2
|
||||
>new Mixed4("hello") : C1 & M1 & M2
|
||||
>Mixed4 : typeof C1 & typeof M1 & typeof M2
|
||||
>"hello" : "hello"
|
||||
|
||||
let x8 = new Mixed4(42);
|
||||
>x8 : C1 & M1 & M2
|
||||
>new Mixed4(42) : C1 & M1 & M2
|
||||
>Mixed4 : typeof C1 & typeof M1 & typeof M2
|
||||
>42 : 42
|
||||
|
||||
let x9 = new Mixed5();
|
||||
>x9 : M1 & M2
|
||||
>new Mixed5() : M1 & M2
|
||||
>Mixed5 : typeof M1 & typeof M2
|
||||
}
|
||||
|
||||
function f2() {
|
||||
>f2 : () => void
|
||||
|
||||
let x = new Mixed1("hello");
|
||||
>x : M1 & C1
|
||||
>new Mixed1("hello") : M1 & C1
|
||||
>Mixed1 : typeof M1 & typeof C1
|
||||
>"hello" : "hello"
|
||||
|
||||
x.a;
|
||||
>x.a : number
|
||||
>x : M1 & C1
|
||||
>a : number
|
||||
|
||||
x.p;
|
||||
>x.p : number
|
||||
>x : M1 & C1
|
||||
>p : number
|
||||
|
||||
Mixed1.p;
|
||||
>Mixed1.p : number
|
||||
>Mixed1 : typeof M1 & typeof C1
|
||||
>p : number
|
||||
}
|
||||
|
||||
function f3() {
|
||||
>f3 : () => void
|
||||
|
||||
let x = new Mixed2("hello");
|
||||
>x : C1 & M1
|
||||
>new Mixed2("hello") : C1 & M1
|
||||
>Mixed2 : typeof C1 & typeof M1
|
||||
>"hello" : "hello"
|
||||
|
||||
x.a;
|
||||
>x.a : number
|
||||
>x : C1 & M1
|
||||
>a : number
|
||||
|
||||
x.p;
|
||||
>x.p : number
|
||||
>x : C1 & M1
|
||||
>p : number
|
||||
|
||||
Mixed2.p;
|
||||
>Mixed2.p : number
|
||||
>Mixed2 : typeof C1 & typeof M1
|
||||
>p : number
|
||||
}
|
||||
|
||||
function f4() {
|
||||
>f4 : () => void
|
||||
|
||||
let x = new Mixed3("hello");
|
||||
>x : M2 & M1 & C1
|
||||
>new Mixed3("hello") : M2 & M1 & C1
|
||||
>Mixed3 : typeof M2 & typeof M1 & typeof C1
|
||||
>"hello" : "hello"
|
||||
|
||||
x.a;
|
||||
>x.a : number
|
||||
>x : M2 & M1 & C1
|
||||
>a : number
|
||||
|
||||
x.p;
|
||||
>x.p : number
|
||||
>x : M2 & M1 & C1
|
||||
>p : number
|
||||
|
||||
x.f();
|
||||
>x.f() : number
|
||||
>x.f : () => number
|
||||
>x : M2 & M1 & C1
|
||||
>f : () => number
|
||||
|
||||
Mixed3.p;
|
||||
>Mixed3.p : number
|
||||
>Mixed3 : typeof M2 & typeof M1 & typeof C1
|
||||
>p : number
|
||||
|
||||
Mixed3.f();
|
||||
>Mixed3.f() : number
|
||||
>Mixed3.f : () => number
|
||||
>Mixed3 : typeof M2 & typeof M1 & typeof C1
|
||||
>f : () => number
|
||||
}
|
||||
|
||||
function f5() {
|
||||
>f5 : () => void
|
||||
|
||||
let x = new Mixed4("hello");
|
||||
>x : C1 & M1 & M2
|
||||
>new Mixed4("hello") : C1 & M1 & M2
|
||||
>Mixed4 : typeof C1 & typeof M1 & typeof M2
|
||||
>"hello" : "hello"
|
||||
|
||||
x.a;
|
||||
>x.a : number
|
||||
>x : C1 & M1 & M2
|
||||
>a : number
|
||||
|
||||
x.p;
|
||||
>x.p : number
|
||||
>x : C1 & M1 & M2
|
||||
>p : number
|
||||
|
||||
x.f();
|
||||
>x.f() : number
|
||||
>x.f : () => number
|
||||
>x : C1 & M1 & M2
|
||||
>f : () => number
|
||||
|
||||
Mixed4.p;
|
||||
>Mixed4.p : number
|
||||
>Mixed4 : typeof C1 & typeof M1 & typeof M2
|
||||
>p : number
|
||||
|
||||
Mixed4.f();
|
||||
>Mixed4.f() : number
|
||||
>Mixed4.f : () => number
|
||||
>Mixed4 : typeof C1 & typeof M1 & typeof M2
|
||||
>f : () => number
|
||||
}
|
||||
|
||||
function f6() {
|
||||
>f6 : () => void
|
||||
|
||||
let x = new Mixed5();
|
||||
>x : M1 & M2
|
||||
>new Mixed5() : M1 & M2
|
||||
>Mixed5 : typeof M1 & typeof M2
|
||||
|
||||
x.p;
|
||||
>x.p : number
|
||||
>x : M1 & M2
|
||||
>p : number
|
||||
|
||||
x.f();
|
||||
>x.f() : number
|
||||
>x.f : () => number
|
||||
>x : M1 & M2
|
||||
>f : () => number
|
||||
|
||||
Mixed5.p;
|
||||
>Mixed5.p : number
|
||||
>Mixed5 : typeof M1 & typeof M2
|
||||
>p : number
|
||||
|
||||
Mixed5.f();
|
||||
>Mixed5.f() : number
|
||||
>Mixed5.f : () => number
|
||||
>Mixed5 : typeof M1 & typeof M2
|
||||
>f : () => number
|
||||
}
|
||||
|
||||
class C2 extends Mixed1 {
|
||||
>C2 : C2
|
||||
>Mixed1 : M1 & C1
|
||||
|
||||
constructor() {
|
||||
super("hello");
|
||||
>super("hello") : void
|
||||
>super : typeof M1 & typeof C1
|
||||
>"hello" : "hello"
|
||||
|
||||
this.a;
|
||||
>this.a : number
|
||||
>this : this
|
||||
>a : number
|
||||
|
||||
this.b;
|
||||
>this.b : number
|
||||
>this : this
|
||||
>b : number
|
||||
|
||||
this.p;
|
||||
>this.p : number
|
||||
>this : this
|
||||
>p : number
|
||||
}
|
||||
}
|
||||
|
||||
class C3 extends Mixed3 {
|
||||
>C3 : C3
|
||||
>Mixed3 : M2 & M1 & C1
|
||||
|
||||
constructor() {
|
||||
super(42);
|
||||
>super(42) : void
|
||||
>super : typeof M2 & typeof M1 & typeof C1
|
||||
>42 : 42
|
||||
|
||||
this.a;
|
||||
>this.a : number
|
||||
>this : this
|
||||
>a : number
|
||||
|
||||
this.b;
|
||||
>this.b : number
|
||||
>this : this
|
||||
>b : number
|
||||
|
||||
this.p;
|
||||
>this.p : number
|
||||
>this : this
|
||||
>p : number
|
||||
|
||||
this.f();
|
||||
>this.f() : number
|
||||
>this.f : () => number
|
||||
>this : this
|
||||
>f : () => number
|
||||
}
|
||||
f() { return super.f(); }
|
||||
>f : () => number
|
||||
>super.f() : number
|
||||
>super.f : () => number
|
||||
>super : M2 & M1 & C1
|
||||
>f : () => number
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
//// [nestedLoopWithOnlyInnerLetCaptured.ts]
|
||||
declare let doSomething;
|
||||
|
||||
for (let a1 of [])
|
||||
for (let a2 of a1.someArray)
|
||||
doSomething(() => a2);
|
||||
|
||||
//// [nestedLoopWithOnlyInnerLetCaptured.js]
|
||||
for (var _i = 0, _a = []; _i < _a.length; _i++) {
|
||||
var a1 = _a[_i];
|
||||
var _loop_1 = function (a2) {
|
||||
doSomething(function () { return a2; });
|
||||
};
|
||||
for (var _b = 0, _c = a1.someArray; _b < _c.length; _b++) {
|
||||
var a2 = _c[_b];
|
||||
_loop_1(a2);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
=== tests/cases/compiler/nestedLoopWithOnlyInnerLetCaptured.ts ===
|
||||
declare let doSomething;
|
||||
>doSomething : Symbol(doSomething, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 0, 11))
|
||||
|
||||
for (let a1 of [])
|
||||
>a1 : Symbol(a1, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 2, 8))
|
||||
|
||||
for (let a2 of a1.someArray)
|
||||
>a2 : Symbol(a2, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 3, 12))
|
||||
>a1 : Symbol(a1, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 2, 8))
|
||||
|
||||
doSomething(() => a2);
|
||||
>doSomething : Symbol(doSomething, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 0, 11))
|
||||
>a2 : Symbol(a2, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 3, 12))
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
=== tests/cases/compiler/nestedLoopWithOnlyInnerLetCaptured.ts ===
|
||||
declare let doSomething;
|
||||
>doSomething : any
|
||||
|
||||
for (let a1 of [])
|
||||
>a1 : any
|
||||
>[] : undefined[]
|
||||
|
||||
for (let a2 of a1.someArray)
|
||||
>a2 : any
|
||||
>a1.someArray : any
|
||||
>a1 : any
|
||||
>someArray : any
|
||||
|
||||
doSomething(() => a2);
|
||||
>doSomething(() => a2) : any
|
||||
>doSomething : any
|
||||
>() => a2 : () => any
|
||||
>a2 : any
|
||||
|
|
@ -1,10 +1,16 @@
|
|||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts(3,3): error TS2339: Property 'nonExist' does not exist on type 'object'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts(5,7): error TS2459: Type 'object' has no property 'destructuring' and no string index signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts (1 errors) ====
|
||||
==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts (2 errors) ====
|
||||
var a: object;
|
||||
a.toString();
|
||||
a.nonExist(); // error
|
||||
~~~~~~~~
|
||||
!!! error TS2339: Property 'nonExist' does not exist on type 'object'.
|
||||
|
||||
var { destructuring } = a; // error
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2459: Type 'object' has no property 'destructuring' and no string index signature.
|
||||
var { ...rest } = a; // ok
|
||||
|
|
@ -2,9 +2,23 @@
|
|||
var a: object;
|
||||
a.toString();
|
||||
a.nonExist(); // error
|
||||
|
||||
var { destructuring } = a; // error
|
||||
var { ...rest } = a; // ok
|
||||
|
||||
|
||||
//// [nonPrimitiveAccessProperty.js]
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
|
||||
t[p[i]] = s[p[i]];
|
||||
return t;
|
||||
};
|
||||
var a;
|
||||
a.toString();
|
||||
a.nonExist(); // error
|
||||
var destructuring = a.destructuring; // error
|
||||
var rest = __rest(a, []); // ok
|
||||
|
|
|
@ -15,14 +15,6 @@ rootConnection('test');
|
|||
|
||||
|
||||
//// [objectRest2.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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
|
@ -35,7 +27,7 @@ function rootConnection(name) {
|
|||
return {
|
||||
resolve: (context, args) => __awaiter(this, void 0, void 0, function* () {
|
||||
const { objects } = yield { objects: 12 };
|
||||
return __assign({}, connectionFromArray(objects, args));
|
||||
return Object.assign({}, connectionFromArray(objects, args));
|
||||
})
|
||||
};
|
||||
}
|
||||
|
|
|
@ -15,14 +15,6 @@ for (const norest of array.map(a => ({ ...a, x: 'a string' }))) {
|
|||
|
||||
|
||||
//// [objectRestForOf.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 __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
|
@ -43,6 +35,6 @@ for (let _b of array) {
|
|||
({ x: xx } = _b, rrestOff = __rest(_b, ["x"]));
|
||||
[xx, rrestOff];
|
||||
}
|
||||
for (const norest of array.map(a => (__assign({}, a, { x: 'a string' })))) {
|
||||
for (const norest of array.map(a => (Object.assign({}, a, { x: 'a string' })))) {
|
||||
[norest.x, norest.y];
|
||||
}
|
||||
|
|
|
@ -78,7 +78,8 @@ let computedAfter: { a: number, b: string, "at the end": number } =
|
|||
// shortcut syntax
|
||||
let a = 12;
|
||||
let shortCutted: { a: number, b: string } = { ...o, a }
|
||||
|
||||
// non primitive
|
||||
let spreadNonPrimitive = { ...<object>{}};
|
||||
|
||||
|
||||
//// [objectSpread.js]
|
||||
|
@ -148,4 +149,6 @@ var computedAfter = __assign({}, o, (_c = { b: 'yeah' }, _c['at the end'] = 14,
|
|||
// shortcut syntax
|
||||
var a = 12;
|
||||
var shortCutted = __assign({}, o, { a: a });
|
||||
// non primitive
|
||||
var spreadNonPrimitive = __assign({}, {});
|
||||
var _a, _b, _c;
|
||||
|
|
|
@ -316,4 +316,7 @@ let shortCutted: { a: number, b: string } = { ...o, a }
|
|||
>o : Symbol(o, Decl(objectSpread.ts, 0, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 78, 51))
|
||||
|
||||
// non primitive
|
||||
let spreadNonPrimitive = { ...<object>{}};
|
||||
>spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 80, 3))
|
||||
|
||||
|
|
|
@ -407,4 +407,10 @@ let shortCutted: { a: number, b: string } = { ...o, a }
|
|||
>o : { a: number; b: string; }
|
||||
>a : number
|
||||
|
||||
// non primitive
|
||||
let spreadNonPrimitive = { ...<object>{}};
|
||||
>spreadNonPrimitive : {}
|
||||
>{ ...<object>{}} : {}
|
||||
><object>{} : object
|
||||
>{} : {}
|
||||
|
||||
|
|
|
@ -14,11 +14,12 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(37,19): error TS269
|
|||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(42,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(46,12): error TS2339: Property 'b' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(52,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(56,14): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(59,14): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(57,11): error TS2339: Property 'a' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(61,14): error TS2698: Spread types may only be created from object types.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(64,14): error TS2698: Spread types may only be created from object types.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (15 errors) ====
|
||||
==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (16 errors) ====
|
||||
let o = { a: 1, b: 'no' }
|
||||
|
||||
/// private propagates
|
||||
|
@ -101,6 +102,13 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(59,14): error TS269
|
|||
~
|
||||
!!! error TS2339: Property 'm' does not exist on type '{ p: number; }'.
|
||||
|
||||
// non primitive
|
||||
let obj: object = { a: 123 };
|
||||
let spreadObj = { ...obj };
|
||||
spreadObj.a; // error 'a' is not in {}
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type '{}'.
|
||||
|
||||
// generics
|
||||
function f<T, U>(t: T, u: U) {
|
||||
return { ...t, ...u, id: 'id' };
|
||||
|
|
|
@ -52,6 +52,11 @@ let c: C = new C()
|
|||
let spreadC = { ...c }
|
||||
spreadC.m(); // error 'm' is not in '{ ... c }'
|
||||
|
||||
// non primitive
|
||||
let obj: object = { a: 123 };
|
||||
let spreadObj = { ...obj };
|
||||
spreadObj.a; // error 'a' is not in {}
|
||||
|
||||
// generics
|
||||
function f<T, U>(t: T, u: U) {
|
||||
return { ...t, ...u, id: 'id' };
|
||||
|
@ -132,6 +137,10 @@ var C = (function () {
|
|||
var c = new C();
|
||||
var spreadC = __assign({}, c);
|
||||
spreadC.m(); // error 'm' is not in '{ ... c }'
|
||||
// non primitive
|
||||
var obj = { a: 123 };
|
||||
var spreadObj = __assign({}, obj);
|
||||
spreadObj.a; // error 'a' is not in {}
|
||||
// generics
|
||||
function f(t, u) {
|
||||
return __assign({}, t, u, { id: 'id' });
|
||||
|
|
|
@ -2,19 +2,10 @@ maxDepthExceeded/root.ts(3,1): error TS2322: Type '"10"' is not assignable to ty
|
|||
maxDepthExceeded/root.ts(4,4): error TS2540: Cannot assign to 'rel' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
==== entry.js (0 errors) ====
|
||||
var m3 = require("m3");
|
||||
|
||||
module.exports = {
|
||||
"a": 42,
|
||||
"b": "hello, world",
|
||||
"person": m3.person
|
||||
};
|
||||
|
||||
==== relative.js (0 errors) ====
|
||||
exports.relativeProp = true;
|
||||
|
||||
==== maxDepthExceeded/node_modules/m1/index.js (0 errors) ====
|
||||
==== index.js (0 errors) ====
|
||||
var m2 = require('m2');
|
||||
var rel = require('./relative');
|
||||
|
||||
|
@ -40,4 +31,13 @@ maxDepthExceeded/root.ts(4,4): error TS2540: Cannot assign to 'rel' because it i
|
|||
!!! error TS2540: Cannot assign to 'rel' because it is a constant or a read-only property.
|
||||
|
||||
m1.f2.person.age = "10"; // OK if stopped at 2 modules: person will be "any".
|
||||
|
||||
==== entry.js (0 errors) ====
|
||||
var m3 = require("m3");
|
||||
|
||||
module.exports = {
|
||||
"a": 42,
|
||||
"b": "hello, world",
|
||||
"person": m3.person
|
||||
};
|
||||
|
|
@ -7,10 +7,10 @@
|
|||
"project": "maxDepthExceeded",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"maxDepthExceeded/node_modules/m2/entry.js",
|
||||
"maxDepthExceeded/node_modules/m1/relative.js",
|
||||
"maxDepthExceeded/node_modules/m1/index.js",
|
||||
"maxDepthExceeded/root.ts"
|
||||
"maxDepthExceeded/root.ts",
|
||||
"maxDepthExceeded/node_modules/m2/entry.js"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"maxDepthExceeded/built/node_modules/m1/relative.js",
|
||||
|
|
|
@ -2,19 +2,10 @@ maxDepthExceeded/root.ts(3,1): error TS2322: Type '"10"' is not assignable to ty
|
|||
maxDepthExceeded/root.ts(4,4): error TS2540: Cannot assign to 'rel' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
==== entry.js (0 errors) ====
|
||||
var m3 = require("m3");
|
||||
|
||||
module.exports = {
|
||||
"a": 42,
|
||||
"b": "hello, world",
|
||||
"person": m3.person
|
||||
};
|
||||
|
||||
==== relative.js (0 errors) ====
|
||||
exports.relativeProp = true;
|
||||
|
||||
==== maxDepthExceeded/node_modules/m1/index.js (0 errors) ====
|
||||
==== index.js (0 errors) ====
|
||||
var m2 = require('m2');
|
||||
var rel = require('./relative');
|
||||
|
||||
|
@ -40,4 +31,13 @@ maxDepthExceeded/root.ts(4,4): error TS2540: Cannot assign to 'rel' because it i
|
|||
!!! error TS2540: Cannot assign to 'rel' because it is a constant or a read-only property.
|
||||
|
||||
m1.f2.person.age = "10"; // OK if stopped at 2 modules: person will be "any".
|
||||
|
||||
==== entry.js (0 errors) ====
|
||||
var m3 = require("m3");
|
||||
|
||||
module.exports = {
|
||||
"a": 42,
|
||||
"b": "hello, world",
|
||||
"person": m3.person
|
||||
};
|
||||
|
|
@ -7,10 +7,10 @@
|
|||
"project": "maxDepthExceeded",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"maxDepthExceeded/node_modules/m2/entry.js",
|
||||
"maxDepthExceeded/node_modules/m1/relative.js",
|
||||
"maxDepthExceeded/node_modules/m1/index.js",
|
||||
"maxDepthExceeded/root.ts"
|
||||
"maxDepthExceeded/root.ts",
|
||||
"maxDepthExceeded/node_modules/m2/entry.js"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"maxDepthExceeded/built/node_modules/m1/relative.js",
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
//// [propertyAccessNumericLiterals.es6.ts]
|
||||
0xffffffff.toString();
|
||||
0o01234.toString();
|
||||
0b01101101.toString();
|
||||
1234..toString();
|
||||
1e0.toString();
|
||||
|
||||
|
||||
//// [propertyAccessNumericLiterals.es6.js]
|
||||
0xffffffff.toString();
|
||||
0o01234.toString();
|
||||
0b01101101.toString();
|
||||
1234..toString();
|
||||
1e0.toString();
|
|
@ -0,0 +1,21 @@
|
|||
=== tests/cases/conformance/es6/propertyAccess/propertyAccessNumericLiterals.es6.ts ===
|
||||
0xffffffff.toString();
|
||||
>0xffffffff.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
0o01234.toString();
|
||||
>0o01234.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
0b01101101.toString();
|
||||
>0b01101101.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
1234..toString();
|
||||
>1234..toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
1e0.toString();
|
||||
>1e0.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
=== tests/cases/conformance/es6/propertyAccess/propertyAccessNumericLiterals.es6.ts ===
|
||||
0xffffffff.toString();
|
||||
>0xffffffff.toString() : string
|
||||
>0xffffffff.toString : (radix?: number) => string
|
||||
>0xffffffff : 4294967295
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
0o01234.toString();
|
||||
>0o01234.toString() : string
|
||||
>0o01234.toString : (radix?: number) => string
|
||||
>0o01234 : 668
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
0b01101101.toString();
|
||||
>0b01101101.toString() : string
|
||||
>0b01101101.toString : (radix?: number) => string
|
||||
>0b01101101 : 109
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
1234..toString();
|
||||
>1234..toString() : string
|
||||
>1234..toString : (radix?: number) => string
|
||||
>1234. : 1234
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
1e0.toString();
|
||||
>1e0.toString() : string
|
||||
>1e0.toString : (radix?: number) => string
|
||||
>1e0 : 1
|
||||
>toString : (radix?: number) => string
|
||||
|
15
tests/baselines/reference/propertyAccessNumericLiterals.js
Normal file
15
tests/baselines/reference/propertyAccessNumericLiterals.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
//// [propertyAccessNumericLiterals.ts]
|
||||
0xffffffff.toString();
|
||||
0o01234.toString();
|
||||
0b01101101.toString();
|
||||
1234..toString();
|
||||
1e0.toString();
|
||||
000.toString();
|
||||
|
||||
//// [propertyAccessNumericLiterals.js]
|
||||
0xffffffff.toString();
|
||||
668..toString();
|
||||
109..toString();
|
||||
1234..toString();
|
||||
1e0.toString();
|
||||
000.toString();
|
|
@ -0,0 +1,25 @@
|
|||
=== tests/cases/conformance/expressions/propertyAccess/propertyAccessNumericLiterals.ts ===
|
||||
0xffffffff.toString();
|
||||
>0xffffffff.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
|
||||
0o01234.toString();
|
||||
>0o01234.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
|
||||
0b01101101.toString();
|
||||
>0b01101101.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
|
||||
1234..toString();
|
||||
>1234..toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
|
||||
1e0.toString();
|
||||
>1e0.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
|
||||
000.toString();
|
||||
>000.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
=== tests/cases/conformance/expressions/propertyAccess/propertyAccessNumericLiterals.ts ===
|
||||
0xffffffff.toString();
|
||||
>0xffffffff.toString() : string
|
||||
>0xffffffff.toString : (radix?: number) => string
|
||||
>0xffffffff : 4294967295
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
0o01234.toString();
|
||||
>0o01234.toString() : string
|
||||
>0o01234.toString : (radix?: number) => string
|
||||
>0o01234 : 668
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
0b01101101.toString();
|
||||
>0b01101101.toString() : string
|
||||
>0b01101101.toString : (radix?: number) => string
|
||||
>0b01101101 : 109
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
1234..toString();
|
||||
>1234..toString() : string
|
||||
>1234..toString : (radix?: number) => string
|
||||
>1234. : 1234
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
1e0.toString();
|
||||
>1e0.toString() : string
|
||||
>1e0.toString : (radix?: number) => string
|
||||
>1e0 : 1
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
000.toString();
|
||||
>000.toString() : string
|
||||
>000.toString : (radix?: number) => string
|
||||
>000 : 0
|
||||
>toString : (radix?: number) => string
|
||||
|
48
tests/baselines/reference/reactImportDropped.js
Normal file
48
tests/baselines/reference/reactImportDropped.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
//// [tests/cases/compiler/reactImportDropped.ts] ////
|
||||
|
||||
//// [react.d.ts]
|
||||
|
||||
export = React;
|
||||
export as namespace React;
|
||||
|
||||
declare namespace React {
|
||||
|
||||
function createClass(spec: any): ClassicComponentClass;
|
||||
|
||||
interface ClassicComponentClass {
|
||||
new (props?: any): ClassicComponentClass;
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
namespace JSX {
|
||||
interface ElementAttributesProperty { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [TabBar.js]
|
||||
export default React.createClass({
|
||||
render() {
|
||||
return (
|
||||
null
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
//// [NavigationView.js]
|
||||
import TabBar from '../../components/TabBar';
|
||||
import {layout} from '../../utils/theme'; // <- DO NOT DROP this import
|
||||
const x = <TabBar height={layout.footerHeight} />;
|
||||
|
||||
|
||||
//// [TabBar.js]
|
||||
export default React.createClass({
|
||||
render() {
|
||||
return (null);
|
||||
}
|
||||
});
|
||||
//// [NavigationView.js]
|
||||
import TabBar from '../../components/TabBar';
|
||||
import { layout } from '../../utils/theme'; // <- DO NOT DROP this import
|
||||
const x = React.createElement(TabBar, { height: layout.footerHeight });
|
65
tests/baselines/reference/reactImportDropped.symbols
Normal file
65
tests/baselines/reference/reactImportDropped.symbols
Normal file
|
@ -0,0 +1,65 @@
|
|||
=== tests/cases/compiler/react.d.ts ===
|
||||
|
||||
export = React;
|
||||
>React : Symbol(React, Decl(react.d.ts, 2, 26))
|
||||
|
||||
export as namespace React;
|
||||
>React : Symbol(React, Decl(react.d.ts, 1, 15))
|
||||
|
||||
declare namespace React {
|
||||
>React : Symbol(React, Decl(react.d.ts, 2, 26))
|
||||
|
||||
function createClass(spec: any): ClassicComponentClass;
|
||||
>createClass : Symbol(createClass, Decl(react.d.ts, 4, 25))
|
||||
>spec : Symbol(spec, Decl(react.d.ts, 6, 25))
|
||||
>ClassicComponentClass : Symbol(ClassicComponentClass, Decl(react.d.ts, 6, 59))
|
||||
|
||||
interface ClassicComponentClass {
|
||||
>ClassicComponentClass : Symbol(ClassicComponentClass, Decl(react.d.ts, 6, 59))
|
||||
|
||||
new (props?: any): ClassicComponentClass;
|
||||
>props : Symbol(props, Decl(react.d.ts, 9, 13))
|
||||
>ClassicComponentClass : Symbol(ClassicComponentClass, Decl(react.d.ts, 6, 59))
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
>global : Symbol(global, Decl(react.d.ts, 11, 1))
|
||||
|
||||
namespace JSX {
|
||||
>JSX : Symbol(JSX, Decl(react.d.ts, 13, 16))
|
||||
|
||||
interface ElementAttributesProperty { }
|
||||
>ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(react.d.ts, 14, 19))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
=== tests/cases/compiler/src/components/TabBar.js ===
|
||||
export default React.createClass({
|
||||
>React.createClass : Symbol(React.createClass, Decl(react.d.ts, 4, 25))
|
||||
>React : Symbol(React, Decl(react.d.ts, 1, 15))
|
||||
>createClass : Symbol(React.createClass, Decl(react.d.ts, 4, 25))
|
||||
|
||||
render() {
|
||||
>render : Symbol(render, Decl(TabBar.js, 0, 34))
|
||||
|
||||
return (
|
||||
null
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
=== tests/cases/compiler/src/modules/navigation/NavigationView.js ===
|
||||
import TabBar from '../../components/TabBar';
|
||||
>TabBar : Symbol(TabBar, Decl(NavigationView.js, 0, 6))
|
||||
|
||||
import {layout} from '../../utils/theme'; // <- DO NOT DROP this import
|
||||
>layout : Symbol(layout, Decl(NavigationView.js, 1, 8))
|
||||
|
||||
const x = <TabBar height={layout.footerHeight} />;
|
||||
>x : Symbol(x, Decl(NavigationView.js, 2, 5))
|
||||
>TabBar : Symbol(TabBar, Decl(NavigationView.js, 0, 6))
|
||||
>height : Symbol(layout)
|
||||
>layout : Symbol(layout, Decl(NavigationView.js, 1, 8))
|
||||
|
74
tests/baselines/reference/reactImportDropped.types
Normal file
74
tests/baselines/reference/reactImportDropped.types
Normal file
|
@ -0,0 +1,74 @@
|
|||
=== tests/cases/compiler/react.d.ts ===
|
||||
|
||||
export = React;
|
||||
>React : typeof React
|
||||
|
||||
export as namespace React;
|
||||
>React : typeof React
|
||||
|
||||
declare namespace React {
|
||||
>React : typeof React
|
||||
|
||||
function createClass(spec: any): ClassicComponentClass;
|
||||
>createClass : (spec: any) => ClassicComponentClass
|
||||
>spec : any
|
||||
>ClassicComponentClass : ClassicComponentClass
|
||||
|
||||
interface ClassicComponentClass {
|
||||
>ClassicComponentClass : ClassicComponentClass
|
||||
|
||||
new (props?: any): ClassicComponentClass;
|
||||
>props : any
|
||||
>ClassicComponentClass : ClassicComponentClass
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
>global : any
|
||||
|
||||
namespace JSX {
|
||||
>JSX : any
|
||||
|
||||
interface ElementAttributesProperty { }
|
||||
>ElementAttributesProperty : ElementAttributesProperty
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
=== tests/cases/compiler/src/components/TabBar.js ===
|
||||
export default React.createClass({
|
||||
>React.createClass({ render() { return ( null ); }}) : React.ClassicComponentClass
|
||||
>React.createClass : (spec: any) => React.ClassicComponentClass
|
||||
>React : typeof React
|
||||
>createClass : (spec: any) => React.ClassicComponentClass
|
||||
>{ render() { return ( null ); }} : { render(): any; }
|
||||
|
||||
render() {
|
||||
>render : () => any
|
||||
|
||||
return (
|
||||
>( null ) : null
|
||||
|
||||
null
|
||||
>null : null
|
||||
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
=== tests/cases/compiler/src/modules/navigation/NavigationView.js ===
|
||||
import TabBar from '../../components/TabBar';
|
||||
>TabBar : React.ClassicComponentClass
|
||||
|
||||
import {layout} from '../../utils/theme'; // <- DO NOT DROP this import
|
||||
>layout : any
|
||||
|
||||
const x = <TabBar height={layout.footerHeight} />;
|
||||
>x : any
|
||||
><TabBar height={layout.footerHeight} /> : any
|
||||
>TabBar : React.ClassicComponentClass
|
||||
>height : any
|
||||
>layout.footerHeight : any
|
||||
>layout : any
|
||||
>footerHeight : any
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
//// [superHasMethodsFromMergedInterface.ts]
|
||||
class C { m1() { } }
|
||||
interface C { m2(): void }
|
||||
class Sub extends C {
|
||||
m3() {
|
||||
super.m2();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [superHasMethodsFromMergedInterface.js]
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.m1 = function () { };
|
||||
return C;
|
||||
}());
|
||||
var Sub = (function (_super) {
|
||||
__extends(Sub, _super);
|
||||
function Sub() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
Sub.prototype.m3 = function () {
|
||||
_super.prototype.m2.call(this);
|
||||
};
|
||||
return Sub;
|
||||
}(C));
|
|
@ -0,0 +1,23 @@
|
|||
=== tests/cases/compiler/superHasMethodsFromMergedInterface.ts ===
|
||||
class C { m1() { } }
|
||||
>C : Symbol(C, Decl(superHasMethodsFromMergedInterface.ts, 0, 0), Decl(superHasMethodsFromMergedInterface.ts, 0, 20))
|
||||
>m1 : Symbol(C.m1, Decl(superHasMethodsFromMergedInterface.ts, 0, 9))
|
||||
|
||||
interface C { m2(): void }
|
||||
>C : Symbol(C, Decl(superHasMethodsFromMergedInterface.ts, 0, 0), Decl(superHasMethodsFromMergedInterface.ts, 0, 20))
|
||||
>m2 : Symbol(C.m2, Decl(superHasMethodsFromMergedInterface.ts, 1, 13))
|
||||
|
||||
class Sub extends C {
|
||||
>Sub : Symbol(Sub, Decl(superHasMethodsFromMergedInterface.ts, 1, 26))
|
||||
>C : Symbol(C, Decl(superHasMethodsFromMergedInterface.ts, 0, 0), Decl(superHasMethodsFromMergedInterface.ts, 0, 20))
|
||||
|
||||
m3() {
|
||||
>m3 : Symbol(Sub.m3, Decl(superHasMethodsFromMergedInterface.ts, 2, 21))
|
||||
|
||||
super.m2();
|
||||
>super.m2 : Symbol(C.m2, Decl(superHasMethodsFromMergedInterface.ts, 1, 13))
|
||||
>super : Symbol(C, Decl(superHasMethodsFromMergedInterface.ts, 0, 0), Decl(superHasMethodsFromMergedInterface.ts, 0, 20))
|
||||
>m2 : Symbol(C.m2, Decl(superHasMethodsFromMergedInterface.ts, 1, 13))
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
=== tests/cases/compiler/superHasMethodsFromMergedInterface.ts ===
|
||||
class C { m1() { } }
|
||||
>C : C
|
||||
>m1 : () => void
|
||||
|
||||
interface C { m2(): void }
|
||||
>C : C
|
||||
>m2 : () => void
|
||||
|
||||
class Sub extends C {
|
||||
>Sub : Sub
|
||||
>C : C
|
||||
|
||||
m3() {
|
||||
>m3 : () => void
|
||||
|
||||
super.m2();
|
||||
>super.m2() : void
|
||||
>super.m2 : () => void
|
||||
>super : C
|
||||
>m2 : () => void
|
||||
}
|
||||
}
|
||||
|
10
tests/cases/compiler/augmentExportEquals7.ts
Normal file
10
tests/cases/compiler/augmentExportEquals7.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
// @Filename: /node_modules/lib/index.d.ts
|
||||
declare var lib: () => void;
|
||||
declare namespace lib {}
|
||||
export = lib;
|
||||
|
||||
// @Filename: /node_modules/@types/lib-extender/index.d.ts
|
||||
import * as lib from "lib";
|
||||
declare module "lib" {
|
||||
export function fn(): void;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
// test for #10668
|
||||
function qux(bar: { value: number }) {
|
||||
let foo: number;
|
||||
({ value: foo } = bar);
|
||||
let x = () => bar;
|
||||
}
|
||||
|
9
tests/cases/compiler/es3-jsx-preserve.tsx
Normal file
9
tests/cases/compiler/es3-jsx-preserve.tsx
Normal file
|
@ -0,0 +1,9 @@
|
|||
// @target: ES3
|
||||
// @sourcemap: false
|
||||
// @declaration: false
|
||||
// @jsx: preserve
|
||||
|
||||
const React: any = null;
|
||||
|
||||
const elem = <div></div>;
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue