Merge branch 'master' into wip-master-statelessOverload
This commit is contained in:
commit
42c0816164
79 changed files with 3464 additions and 392 deletions
|
@ -2465,7 +2465,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()) {
|
||||
|
@ -3644,6 +3645,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) {
|
||||
|
@ -3652,8 +3658,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;
|
||||
|
@ -3817,8 +3828,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 {
|
||||
|
@ -3897,7 +3926,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;
|
||||
}
|
||||
|
@ -4547,16 +4576,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));
|
||||
}
|
||||
|
@ -4598,7 +4658,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));
|
||||
}
|
||||
|
@ -4895,6 +4955,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;
|
||||
|
@ -4904,7 +4965,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];
|
||||
|
@ -6808,6 +6869,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) {
|
||||
|
@ -6977,9 +7043,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;
|
||||
}
|
||||
|
||||
|
@ -7652,7 +7721,7 @@ namespace ts {
|
|||
return false;
|
||||
}
|
||||
|
||||
function isEmptyObjectType(t: ResolvedType) {
|
||||
function isEmptyResolvedType(t: ResolvedType) {
|
||||
return t.properties.length === 0 &&
|
||||
t.callSignatures.length === 0 &&
|
||||
t.constructSignatures.length === 0 &&
|
||||
|
@ -7660,6 +7729,10 @@ namespace ts {
|
|||
!t.numberIndexInfo;
|
||||
}
|
||||
|
||||
function isEmptyObjectType(type: Type) {
|
||||
return type.flags & TypeFlags.Object && isEmptyResolvedType(resolveStructuredTypeMembers(<ObjectType>type));
|
||||
}
|
||||
|
||||
function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
|
||||
if (maybeTypeOfKind(target, TypeFlags.Object) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) {
|
||||
const isComparingJsxAttributes = !!(source.flags & TypeFlags.JsxAttributes);
|
||||
|
@ -7881,10 +7954,14 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ((<MappedType>target).declaration.questionToken && isEmptyObjectType(source)) {
|
||||
return Ternary.True;
|
||||
|
||||
}
|
||||
}
|
||||
else if (relation !== identityRelation) {
|
||||
const resolved = resolveStructuredTypeMembers(<ObjectType>target);
|
||||
if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & TypeFlags.Any) {
|
||||
if (isEmptyResolvedType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & TypeFlags.Any) {
|
||||
return Ternary.True;
|
||||
}
|
||||
}
|
||||
|
@ -11748,7 +11825,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) {
|
||||
|
@ -12533,12 +12610,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) {
|
||||
|
@ -18712,7 +18792,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) {
|
||||
|
@ -18726,6 +18807,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) &&
|
||||
|
@ -18735,7 +18819,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
|
||||
|
|
|
@ -1258,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
|
||||
|
@ -3267,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
|
||||
|
|
|
@ -1056,9 +1056,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
|
||||
|
|
|
@ -6701,10 +6701,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();
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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: {
|
||||
|
@ -1282,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: {}
|
||||
};
|
||||
|
@ -1323,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,
|
||||
|
|
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.
|
||||
|
|
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);
|
||||
|
@ -1391,4 +1436,8 @@ namespace ts.FindAllReferences {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isImportDefaultSymbol(symbol: Symbol): boolean {
|
||||
return symbol.declarations[0].kind === SyntaxKind.ImportClause;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 })));
|
||||
|
||||
|
|
|
@ -1404,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",
|
||||
|
|
|
@ -1320,7 +1320,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;
|
||||
|
|
|
@ -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; }
|
||||
}
|
||||
|
||||
|
|
@ -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]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,26 +12,37 @@ function f2<T>(x: Partial<T>, y: Readonly<T>) {
|
|||
obj = y;
|
||||
}
|
||||
|
||||
function f3<T>(x: Partial<T>) {
|
||||
x = {};
|
||||
}
|
||||
|
||||
// Repro from #12900
|
||||
|
||||
interface Base {
|
||||
foo: { [key: string]: any };
|
||||
bar: any;
|
||||
baz: any;
|
||||
foo: { [key: string]: any };
|
||||
bar: any;
|
||||
baz: any;
|
||||
}
|
||||
|
||||
interface E1<T> extends Base {
|
||||
foo: T;
|
||||
foo: T;
|
||||
}
|
||||
|
||||
interface Something { name: string, value: string };
|
||||
interface E2 extends Base {
|
||||
foo: Partial<Something>; // or other mapped type
|
||||
foo: Partial<Something>; // or other mapped type
|
||||
}
|
||||
|
||||
interface E3<T> extends Base {
|
||||
foo: Partial<T>; // or other mapped type
|
||||
}
|
||||
foo: Partial<T>; // or other mapped type
|
||||
}
|
||||
|
||||
// Repro from #13747
|
||||
|
||||
class Form<T> {
|
||||
private values: {[P in keyof T]?: T[P]} = {}
|
||||
}
|
||||
|
||||
|
||||
//// [mappedTypesAndObjects.js]
|
||||
function f1(x, y) {
|
||||
|
@ -44,12 +55,23 @@ function f2(x, y) {
|
|||
obj = x;
|
||||
obj = y;
|
||||
}
|
||||
function f3(x) {
|
||||
x = {};
|
||||
}
|
||||
;
|
||||
// Repro from #13747
|
||||
var Form = (function () {
|
||||
function Form() {
|
||||
this.values = {};
|
||||
}
|
||||
return Form;
|
||||
}());
|
||||
|
||||
|
||||
//// [mappedTypesAndObjects.d.ts]
|
||||
declare function f1<T>(x: Partial<T>, y: Readonly<T>): void;
|
||||
declare function f2<T>(x: Partial<T>, y: Readonly<T>): void;
|
||||
declare function f3<T>(x: Partial<T>): void;
|
||||
interface Base {
|
||||
foo: {
|
||||
[key: string]: any;
|
||||
|
@ -70,3 +92,6 @@ interface E2 extends Base {
|
|||
interface E3<T> extends Base {
|
||||
foo: Partial<T>;
|
||||
}
|
||||
declare class Form<T> {
|
||||
private values;
|
||||
}
|
||||
|
|
|
@ -45,54 +45,80 @@ function f2<T>(x: Partial<T>, y: Readonly<T>) {
|
|||
>y : Symbol(y, Decl(mappedTypesAndObjects.ts, 7, 29))
|
||||
}
|
||||
|
||||
function f3<T>(x: Partial<T>) {
|
||||
>f3 : Symbol(f3, Decl(mappedTypesAndObjects.ts, 11, 1))
|
||||
>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 13, 12))
|
||||
>x : Symbol(x, Decl(mappedTypesAndObjects.ts, 13, 15))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 13, 12))
|
||||
|
||||
x = {};
|
||||
>x : Symbol(x, Decl(mappedTypesAndObjects.ts, 13, 15))
|
||||
}
|
||||
|
||||
// Repro from #12900
|
||||
|
||||
interface Base {
|
||||
>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 11, 1))
|
||||
>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 15, 1))
|
||||
|
||||
foo: { [key: string]: any };
|
||||
>foo : Symbol(Base.foo, Decl(mappedTypesAndObjects.ts, 15, 16))
|
||||
>key : Symbol(key, Decl(mappedTypesAndObjects.ts, 16, 11))
|
||||
foo: { [key: string]: any };
|
||||
>foo : Symbol(Base.foo, Decl(mappedTypesAndObjects.ts, 19, 16))
|
||||
>key : Symbol(key, Decl(mappedTypesAndObjects.ts, 20, 12))
|
||||
|
||||
bar: any;
|
||||
>bar : Symbol(Base.bar, Decl(mappedTypesAndObjects.ts, 16, 31))
|
||||
bar: any;
|
||||
>bar : Symbol(Base.bar, Decl(mappedTypesAndObjects.ts, 20, 32))
|
||||
|
||||
baz: any;
|
||||
>baz : Symbol(Base.baz, Decl(mappedTypesAndObjects.ts, 17, 12))
|
||||
baz: any;
|
||||
>baz : Symbol(Base.baz, Decl(mappedTypesAndObjects.ts, 21, 13))
|
||||
}
|
||||
|
||||
interface E1<T> extends Base {
|
||||
>E1 : Symbol(E1, Decl(mappedTypesAndObjects.ts, 19, 1))
|
||||
>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 21, 13))
|
||||
>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 11, 1))
|
||||
>E1 : Symbol(E1, Decl(mappedTypesAndObjects.ts, 23, 1))
|
||||
>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 25, 13))
|
||||
>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 15, 1))
|
||||
|
||||
foo: T;
|
||||
>foo : Symbol(E1.foo, Decl(mappedTypesAndObjects.ts, 21, 30))
|
||||
>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 21, 13))
|
||||
foo: T;
|
||||
>foo : Symbol(E1.foo, Decl(mappedTypesAndObjects.ts, 25, 30))
|
||||
>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 25, 13))
|
||||
}
|
||||
|
||||
interface Something { name: string, value: string };
|
||||
>Something : Symbol(Something, Decl(mappedTypesAndObjects.ts, 23, 1))
|
||||
>name : Symbol(Something.name, Decl(mappedTypesAndObjects.ts, 25, 21))
|
||||
>value : Symbol(Something.value, Decl(mappedTypesAndObjects.ts, 25, 35))
|
||||
>Something : Symbol(Something, Decl(mappedTypesAndObjects.ts, 27, 1))
|
||||
>name : Symbol(Something.name, Decl(mappedTypesAndObjects.ts, 29, 21))
|
||||
>value : Symbol(Something.value, Decl(mappedTypesAndObjects.ts, 29, 35))
|
||||
|
||||
interface E2 extends Base {
|
||||
>E2 : Symbol(E2, Decl(mappedTypesAndObjects.ts, 25, 52))
|
||||
>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 11, 1))
|
||||
>E2 : Symbol(E2, Decl(mappedTypesAndObjects.ts, 29, 52))
|
||||
>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 15, 1))
|
||||
|
||||
foo: Partial<Something>; // or other mapped type
|
||||
>foo : Symbol(E2.foo, Decl(mappedTypesAndObjects.ts, 26, 27))
|
||||
foo: Partial<Something>; // or other mapped type
|
||||
>foo : Symbol(E2.foo, Decl(mappedTypesAndObjects.ts, 30, 27))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>Something : Symbol(Something, Decl(mappedTypesAndObjects.ts, 23, 1))
|
||||
>Something : Symbol(Something, Decl(mappedTypesAndObjects.ts, 27, 1))
|
||||
}
|
||||
|
||||
interface E3<T> extends Base {
|
||||
>E3 : Symbol(E3, Decl(mappedTypesAndObjects.ts, 28, 1))
|
||||
>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 30, 13))
|
||||
>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 11, 1))
|
||||
>E3 : Symbol(E3, Decl(mappedTypesAndObjects.ts, 32, 1))
|
||||
>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 34, 13))
|
||||
>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 15, 1))
|
||||
|
||||
foo: Partial<T>; // or other mapped type
|
||||
>foo : Symbol(E3.foo, Decl(mappedTypesAndObjects.ts, 30, 30))
|
||||
foo: Partial<T>; // or other mapped type
|
||||
>foo : Symbol(E3.foo, Decl(mappedTypesAndObjects.ts, 34, 30))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 30, 13))
|
||||
>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 34, 13))
|
||||
}
|
||||
|
||||
// Repro from #13747
|
||||
|
||||
class Form<T> {
|
||||
>Form : Symbol(Form, Decl(mappedTypesAndObjects.ts, 36, 1))
|
||||
>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 40, 11))
|
||||
|
||||
private values: {[P in keyof T]?: T[P]} = {}
|
||||
>values : Symbol(Form.values, Decl(mappedTypesAndObjects.ts, 40, 15))
|
||||
>P : Symbol(P, Decl(mappedTypesAndObjects.ts, 41, 22))
|
||||
>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 40, 11))
|
||||
>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 40, 11))
|
||||
>P : Symbol(P, Decl(mappedTypesAndObjects.ts, 41, 22))
|
||||
}
|
||||
|
||||
|
|
|
@ -49,19 +49,32 @@ function f2<T>(x: Partial<T>, y: Readonly<T>) {
|
|||
>y : Readonly<T>
|
||||
}
|
||||
|
||||
function f3<T>(x: Partial<T>) {
|
||||
>f3 : <T>(x: Partial<T>) => void
|
||||
>T : T
|
||||
>x : Partial<T>
|
||||
>Partial : Partial<T>
|
||||
>T : T
|
||||
|
||||
x = {};
|
||||
>x = {} : {}
|
||||
>x : Partial<T>
|
||||
>{} : {}
|
||||
}
|
||||
|
||||
// Repro from #12900
|
||||
|
||||
interface Base {
|
||||
>Base : Base
|
||||
|
||||
foo: { [key: string]: any };
|
||||
foo: { [key: string]: any };
|
||||
>foo : { [key: string]: any; }
|
||||
>key : string
|
||||
|
||||
bar: any;
|
||||
bar: any;
|
||||
>bar : any
|
||||
|
||||
baz: any;
|
||||
baz: any;
|
||||
>baz : any
|
||||
}
|
||||
|
||||
|
@ -70,7 +83,7 @@ interface E1<T> extends Base {
|
|||
>T : T
|
||||
>Base : Base
|
||||
|
||||
foo: T;
|
||||
foo: T;
|
||||
>foo : T
|
||||
>T : T
|
||||
}
|
||||
|
@ -84,7 +97,7 @@ interface E2 extends Base {
|
|||
>E2 : E2
|
||||
>Base : Base
|
||||
|
||||
foo: Partial<Something>; // or other mapped type
|
||||
foo: Partial<Something>; // or other mapped type
|
||||
>foo : Partial<Something>
|
||||
>Partial : Partial<T>
|
||||
>Something : Something
|
||||
|
@ -95,8 +108,24 @@ interface E3<T> extends Base {
|
|||
>T : T
|
||||
>Base : Base
|
||||
|
||||
foo: Partial<T>; // or other mapped type
|
||||
foo: Partial<T>; // or other mapped type
|
||||
>foo : Partial<T>
|
||||
>Partial : Partial<T>
|
||||
>T : T
|
||||
}
|
||||
|
||||
// Repro from #13747
|
||||
|
||||
class Form<T> {
|
||||
>Form : Form<T>
|
||||
>T : T
|
||||
|
||||
private values: {[P in keyof T]?: T[P]} = {}
|
||||
>values : { [P in keyof T]?: T[P] | undefined; }
|
||||
>P : P
|
||||
>T : T
|
||||
>T : T
|
||||
>P : P
|
||||
>{} : {}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
// test for #10668
|
||||
function qux(bar: { value: number }) {
|
||||
let foo: number;
|
||||
({ value: foo } = bar);
|
||||
let x = () => bar;
|
||||
}
|
||||
|
|
@ -7,9 +7,11 @@ declare var dec: any;
|
|||
|
||||
}
|
||||
|
||||
const o = { a: 1 };
|
||||
const y = { ...o };
|
||||
|
||||
// @filename: 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;
|
||||
|
|
9
tests/cases/compiler/misspelledJsDocTypedefTags.ts
Normal file
9
tests/cases/compiler/misspelledJsDocTypedefTags.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
// @allowJs: true
|
||||
// @noEmit: true
|
||||
|
||||
// @filename: a.js
|
||||
/** @typedef {{ endTime: number, screenshots: number}} A.<b>*/
|
||||
Animation.AnimationModel.ScreenshotCapture.Request;
|
||||
|
||||
/** @typedef {{ endTime: number, screenshots: !B.<string>}} */
|
||||
Animation.AnimationModel.ScreenshotCapture.Request;
|
|
@ -0,0 +1,7 @@
|
|||
class C { m1() { } }
|
||||
interface C { m2(): void }
|
||||
class Sub extends C {
|
||||
m3() {
|
||||
super.m2();
|
||||
}
|
||||
}
|
67
tests/cases/conformance/classes/mixinClassesAnnotated.ts
Normal file
67
tests/cases/conformance/classes/mixinClassesAnnotated.ts
Normal file
|
@ -0,0 +1,67 @@
|
|||
// @declaration: true
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
56
tests/cases/conformance/classes/mixinClassesAnonymous.ts
Normal file
56
tests/cases/conformance/classes/mixinClassesAnonymous.ts
Normal file
|
@ -0,0 +1,56 @@
|
|||
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();
|
||||
}
|
||||
}
|
99
tests/cases/conformance/classes/mixinClassesMembers.ts
Normal file
99
tests/cases/conformance/classes/mixinClassesMembers.ts
Normal file
|
@ -0,0 +1,99 @@
|
|||
// @declaration: true
|
||||
|
||||
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(); }
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
// @target: es6
|
||||
0xffffffff.toString();
|
||||
0o01234.toString();
|
||||
0b01101101.toString();
|
||||
1234..toString();
|
||||
1e0.toString();
|
|
@ -0,0 +1,7 @@
|
|||
// @target: es3
|
||||
0xffffffff.toString();
|
||||
0o01234.toString();
|
||||
0b01101101.toString();
|
||||
1234..toString();
|
||||
1e0.toString();
|
||||
000.toString();
|
|
@ -517,3 +517,13 @@ 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,23 +13,33 @@ function f2<T>(x: Partial<T>, y: Readonly<T>) {
|
|||
obj = y;
|
||||
}
|
||||
|
||||
function f3<T>(x: Partial<T>) {
|
||||
x = {};
|
||||
}
|
||||
|
||||
// Repro from #12900
|
||||
|
||||
interface Base {
|
||||
foo: { [key: string]: any };
|
||||
bar: any;
|
||||
baz: any;
|
||||
foo: { [key: string]: any };
|
||||
bar: any;
|
||||
baz: any;
|
||||
}
|
||||
|
||||
interface E1<T> extends Base {
|
||||
foo: T;
|
||||
foo: T;
|
||||
}
|
||||
|
||||
interface Something { name: string, value: string };
|
||||
interface E2 extends Base {
|
||||
foo: Partial<Something>; // or other mapped type
|
||||
foo: Partial<Something>; // or other mapped type
|
||||
}
|
||||
|
||||
interface E3<T> extends Base {
|
||||
foo: Partial<T>; // or other mapped type
|
||||
}
|
||||
foo: Partial<T>; // or other mapped type
|
||||
}
|
||||
|
||||
// Repro from #13747
|
||||
|
||||
class Form<T> {
|
||||
private values: {[P in keyof T]?: T[P]} = {}
|
||||
}
|
||||
|
|
10
tests/cases/fourslash/codeFixAddForgottenThis01.ts
Normal file
10
tests/cases/fourslash/codeFixAddForgottenThis01.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////class C {
|
||||
//// foo: number;
|
||||
//// constructor() {
|
||||
//// [|foo = 10|];
|
||||
//// }
|
||||
////}
|
||||
|
||||
verify.rangeAfterCodeFix("this.foo = 10");
|
9
tests/cases/fourslash/codeFixAddForgottenThis02.ts
Normal file
9
tests/cases/fourslash/codeFixAddForgottenThis02.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////class C {
|
||||
//// constructor(public foo) {
|
||||
//// }
|
||||
//// bar() { [|foo = 10|] };
|
||||
////}
|
||||
|
||||
verify.rangeAfterCodeFix("this.foo = 10");
|
11
tests/cases/fourslash/findAllRefsForDefaultExport.ts
Normal file
11
tests/cases/fourslash/findAllRefsForDefaultExport.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: a.ts
|
||||
////export default function /*def*/[|f|]() {}
|
||||
|
||||
// @Filename: b.ts
|
||||
////import [|g|] from "./a";
|
||||
/////*ref*/[|g|]();
|
||||
|
||||
verify.rangesReferenceEachOther();
|
||||
verify.goToDefinition("ref", "def");
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface T { [|a|]: number };
|
||||
////type U { [K in keyof T]: string };
|
||||
////type U = { [K in keyof T]: string };
|
||||
////type V = { [K in keyof U]: boolean };
|
||||
////const u: U = { [|a|]: "" }
|
||||
////const v: V = { [|a|]: true }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: B.ts
|
||||
////export default class [|B|] {
|
||||
////export default class /*1*/[|B|] {
|
||||
//// test() {
|
||||
//// }
|
||||
////}
|
||||
|
@ -11,4 +11,17 @@
|
|||
////let b = new [|B|]();
|
||||
////b.test();
|
||||
|
||||
verify.rangesAreRenameLocations();
|
||||
goTo.marker("1");
|
||||
verify.occurrencesAtPositionCount(1);
|
||||
|
||||
const [C, B0, B1] = test.ranges();
|
||||
verify.rangesReferenceEachOther();
|
||||
|
||||
goTo.rangeStart(C);
|
||||
verify.renameLocations(false, false, [C, B0, B1]);
|
||||
|
||||
const rangesInB = [B0, B1];
|
||||
for (const r of rangesInB) {
|
||||
goTo.rangeStart(r);
|
||||
verify.renameLocations(false, false, rangesInB);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: B.ts
|
||||
////export default class /*1*/C {
|
||||
////export default class /*1*/[|C|] {
|
||||
//// test() {
|
||||
//// }
|
||||
////}
|
||||
|
@ -14,4 +14,14 @@
|
|||
goTo.marker("1");
|
||||
verify.occurrencesAtPositionCount(1);
|
||||
|
||||
verify.rangesAreRenameLocations();
|
||||
const [C, B0, B1] = test.ranges();
|
||||
verify.rangesReferenceEachOther();
|
||||
|
||||
goTo.rangeStart(C);
|
||||
verify.renameLocations(false, false, [C, B0, B1]);
|
||||
|
||||
const rangesInB = [B0, B1];
|
||||
for (const r of rangesInB) {
|
||||
goTo.rangeStart(r);
|
||||
verify.renameLocations(false, false, rangesInB);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue