diff --git a/Jakefile.js b/Jakefile.js index a0ec0d880fe..517f5e862d5 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -715,3 +715,9 @@ task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function }); ex.run(); }, { async: true }); + +desc("Updates the sublime plugin's tsserver"); +task("update-sublime", [serverFile], function() { + jake.cpR(serverFile, "../TypeScript-Sublime-Plugin/tsserver/"); + jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/"); +}); diff --git a/scripts/errorCheck.ts b/scripts/errorCheck.ts new file mode 100644 index 00000000000..36489c5f312 --- /dev/null +++ b/scripts/errorCheck.ts @@ -0,0 +1,87 @@ +declare var require: any; +let fs = require('fs'); +let async = require('async'); +let glob = require('glob'); + +fs.readFile('src/compiler/diagnosticMessages.json', 'utf-8', (err, data) => { + if (err) { + throw err; + } + + let messages = JSON.parse(data); + let keys = Object.keys(messages); + console.log('Loaded ' + keys.length + ' errors'); + + for (let k of keys) { + messages[k]['seen'] = false; + } + + let errRegex = /\(\d+,\d+\): error TS([^:]+):/g; + + let baseDir = 'tests/baselines/reference/'; + fs.readdir(baseDir, (err, files) => { + files = files.filter(f => f.indexOf('.errors.txt') > 0); + let tasks: Array<(callback: () => void) => void> = []; + files.forEach(f => tasks.push(done => { + fs.readFile(baseDir + f, 'utf-8', (err, baseline) => { + if (err) throw err; + + let g: string[]; + while (g = errRegex.exec(baseline)) { + var errCode = +g[1]; + let msg = keys.filter(k => messages[k].code === errCode)[0]; + messages[msg]['seen'] = true; + } + + done(); + }); + })); + + async.parallelLimit(tasks, 25, done => { + console.log('== List of errors not present in baselines =='); + let count = 0; + for (let k of keys) { + if (messages[k]['seen'] !== true) { + console.log(k); + count++; + } + } + console.log(count + ' of ' + keys.length + ' errors are not in baselines'); + }); + }); +}); + +fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err, data) => { + let errorRegexp = /\s(\w+): \{ code/g; + let errorNames: string[] = []; + let errMatch: string[]; + while (errMatch = errorRegexp.exec(data)) { + errorNames.push(errMatch[1]); + } + + let allSrc: string = ''; + glob('./src/**/*.ts', {}, (err, files) => { + console.log('Reading ' + files.length + ' source files'); + for (let file of files) { + if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) { + continue; + } + + let src = fs.readFileSync(file, 'utf-8'); + allSrc = allSrc + src; + } + + console.log('Consumed ' + allSrc.length + ' characters of source'); + + let count = 0; + console.log('== List of errors not used in source ==') + for (let errName of errorNames) { + if (allSrc.indexOf(errName) < 0) { + console.log(errName); + count++; + } + } + console.log(count + ' of ' + errorNames.length + ' errors are not used in source'); + }); +}); + diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index c4e93d359d1..d3333435d14 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -173,6 +173,14 @@ namespace ts { return node.name ? declarationNameToString(node.name) : getDeclarationName(node); } + /** + * Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names. + * @param symbolTable - The symbol table which node will be added to. + * @param parent - node's parent declaration. + * @param node - The declaration to be added to the symbol table + * @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.) + * @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations. + */ function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol { Debug.assert(!hasDynamicName(node)); @@ -181,10 +189,11 @@ namespace ts { let symbol: Symbol; if (name !== undefined) { + // Check and see if the symbol table already has a symbol with this name. If not, // create a new symbol with this name and add it to the table. Note that we don't // give the new symbol any flags *yet*. This ensures that it will not conflict - // witht he 'excludes' flags we pass in. + // with the 'excludes' flags we pass in. // // If we do get an existing symbol, see if it conflicts with the new symbol we're // creating. For example, a 'var' symbol and a 'class' symbol will conflict within @@ -314,6 +323,7 @@ namespace ts { addToContainerChain(container); } + else if (containerFlags & ContainerFlags.IsBlockScopedContainer) { blockScopeContainer = node; blockScopeContainer.locals = undefined; @@ -882,7 +892,8 @@ namespace ts { case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: checkStrictModeFunctionName(node); - return bindAnonymousDeclaration(node, SymbolFlags.Function, "__function"); + let bindingName = (node).name ? (node).name.text : "__function"; + return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName); case SyntaxKind.ClassExpression: case SyntaxKind.ClassDeclaration: return bindClassLikeDeclaration(node); @@ -954,7 +965,8 @@ namespace ts { bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); } else { - bindAnonymousDeclaration(node, SymbolFlags.Class, "__class"); + let bindingName = node.name ? node.name.text : "__class"; + bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName); } let symbol = node.symbol; @@ -1044,4 +1056,4 @@ namespace ts { : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } } -} \ No newline at end of file +} diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 62b4cfb4d55..a380c6c9b84 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22,6 +22,17 @@ namespace ts { } export function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker { + // Cancellation that controls whether or not we can cancel in the middle of type checking. + // In general cancelling is *not* safe for the type checker. We might be in the middle of + // computing something, and we will leave our internals in an inconsistent state. Callers + // who set the cancellation token should catch if a cancellation exception occurs, and + // should throw away and create a new TypeChecker. + // + // Currently we only support setting the cancellation token when getting diagnostics. This + // is because diagnostics can be quite expensive, and we want to allow hosts to bail out if + // they no longer need the information (for example, if the user started editing again). + let cancellationToken: CancellationToken; + let Symbol = objectAllocator.getSymbolConstructor(); let Type = objectAllocator.getTypeConstructor(); let Signature = objectAllocator.getSignatureConstructor(); @@ -74,6 +85,9 @@ namespace ts { getAliasedSymbol: resolveAlias, getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + + getJsxElementAttributesType, + getJsxIntrinsicTagNames }; let unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); @@ -104,6 +118,8 @@ namespace ts { let globalESSymbolConstructorSymbol: Symbol; + let getGlobalPromiseConstructorSymbol: () => Symbol; + let globalObjectType: ObjectType; let globalFunctionType: ObjectType; let globalArrayType: GenericType; @@ -113,19 +129,35 @@ namespace ts { let globalRegExpType: ObjectType; let globalTemplateStringsArrayType: ObjectType; let globalESSymbolType: ObjectType; + let jsxElementType: ObjectType; + /** Lazily loaded, use getJsxIntrinsicElementType() */ + let jsxIntrinsicElementsType: ObjectType; let globalIterableType: GenericType; let globalIteratorType: GenericType; let globalIterableIteratorType: GenericType; let anyArrayType: Type; + let getGlobalClassDecoratorType: () => ObjectType; + let getGlobalParameterDecoratorType: () => ObjectType; + let getGlobalPropertyDecoratorType: () => ObjectType; + let getGlobalMethodDecoratorType: () => ObjectType; let getGlobalTypedPropertyDescriptorType: () => ObjectType; + let getGlobalPromiseType: () => ObjectType; + let tryGetGlobalPromiseType: () => ObjectType; + let getGlobalPromiseLikeType: () => ObjectType; + let getInstantiatedGlobalPromiseLikeType: () => ObjectType; + let getGlobalPromiseConstructorLikeType: () => ObjectType; + let getGlobalThenableType: () => ObjectType; let tupleTypes: Map = {}; let unionTypes: Map = {}; + let intersectionTypes: Map = {}; let stringLiteralTypes: Map = {}; let emitExtends = false; let emitDecorate = false; let emitParam = false; + let emitAwaiter = false; + let emitGenerator = false; let resolutionTargets: Object[] = []; let resolutionResults: boolean[] = []; @@ -134,6 +166,7 @@ namespace ts { let symbolLinks: SymbolLinks[] = []; let nodeLinks: NodeLinks[] = []; let potentialThisCollisions: Node[] = []; + let awaitedTypeStack: number[] = []; let diagnostics = createDiagnosticCollection(); @@ -156,6 +189,14 @@ namespace ts { } }; + const JsxNames = { + JSX: "JSX", + IntrinsicElements: "IntrinsicElements", + ElementClass: "ElementClass", + ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + Element: "Element" + }; + let subtypeRelation: Map = {}; let assignableRelation: Map = {}; let identityRelation: Map = {}; @@ -164,10 +205,10 @@ namespace ts { return checker; - function getEmitResolver(sourceFile?: SourceFile) { + function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationToken) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. - getDiagnostics(sourceFile); + getDiagnostics(sourceFile, cancellationToken); return emitResolver; } @@ -485,7 +526,7 @@ namespace ts { } break; case SyntaxKind.Decorator: - // Decorators are resolved at the class declaration. Resolving at the parameter + // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // // function y() {} @@ -1165,7 +1206,9 @@ namespace ts { // Check if symbol is any of the alias return forEachValue(symbols, symbolFromSymbolTable => { - if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.name !== "export=") { + if (symbolFromSymbolTable.flags & SymbolFlags.Alias + && symbolFromSymbolTable.name !== "export=" + && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) { if (!useOnlyExternalAliasing || // We can use any type of alias to get the name // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration)) { @@ -1207,7 +1250,7 @@ namespace ts { } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & SymbolFlags.Alias) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & SymbolFlags.Alias && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -1544,8 +1587,8 @@ namespace ts { else if (type.flags & TypeFlags.Tuple) { writeTupleType(type); } - else if (type.flags & TypeFlags.Union) { - writeUnionType(type, flags); + else if (type.flags & TypeFlags.UnionOrIntersection) { + writeUnionOrIntersectionType(type, flags); } else if (type.flags & TypeFlags.Anonymous) { writeAnonymousType(type, flags); @@ -1564,16 +1607,16 @@ namespace ts { } } - function writeTypeList(types: Type[], union: boolean) { + function writeTypeList(types: Type[], delimiter: SyntaxKind) { for (let i = 0; i < types.length; i++) { if (i > 0) { - if (union) { + if (delimiter !== SyntaxKind.CommaToken) { writeSpace(writer); } - writePunctuation(writer, union ? SyntaxKind.BarToken : SyntaxKind.CommaToken); + writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], union ? TypeFormatFlags.InElementType : TypeFormatFlags.None); + writeType(types[i], delimiter === SyntaxKind.CommaToken ? TypeFormatFlags.None : TypeFormatFlags.InElementType); } } @@ -1631,15 +1674,15 @@ namespace ts { function writeTupleType(type: TupleType) { writePunctuation(writer, SyntaxKind.OpenBracketToken); - writeTypeList(type.elementTypes, /*union*/ false); + writeTypeList(type.elementTypes, SyntaxKind.CommaToken); writePunctuation(writer, SyntaxKind.CloseBracketToken); } - function writeUnionType(type: UnionType, flags: TypeFormatFlags) { + function writeUnionOrIntersectionType(type: UnionOrIntersectionType, flags: TypeFormatFlags) { if (flags & TypeFormatFlags.InElementType) { writePunctuation(writer, SyntaxKind.OpenParenToken); } - writeTypeList(type.types, /*union*/ true); + writeTypeList(type.types, type.flags & TypeFlags.Union ? SyntaxKind.BarToken : SyntaxKind.AmpersandToken); if (flags & TypeFormatFlags.InElementType) { writePunctuation(writer, SyntaxKind.CloseParenToken); } @@ -1716,7 +1759,7 @@ namespace ts { } function writeLiteralType(type: ObjectType, flags: TypeFormatFlags) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, SyntaxKind.OpenBraceToken); @@ -2009,7 +2052,7 @@ namespace ts { // If the binding pattern is empty, this variable declaration is not visible return false; } - // Otherwise fall through + // Otherwise fall through case SyntaxKind.ModuleDeclaration: case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: @@ -2051,10 +2094,11 @@ namespace ts { case SyntaxKind.ArrayType: case SyntaxKind.TupleType: case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: case SyntaxKind.ParenthesizedType: return isDeclarationVisible(node.parent); - // Default binding, import specifier and namespace import is visible + // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible case SyntaxKind.ImportClause: case SyntaxKind.NamespaceImport: @@ -2203,8 +2247,8 @@ namespace ts { // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. type = getTypeOfPropertyOfType(parentType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || - getIndexTypeOfType(parentType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || + getIndexTypeOfType(parentType, IndexKind.String); if (!type) { error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name)); return unknownType; @@ -2587,7 +2631,7 @@ namespace ts { // Appends the outer type parameters of a node to a set of type parameters and returns the resulting set. The function // allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set in-place and // returns the same array. - function appendOuterTypeParameters(typeParameters: TypeParameter[], node: Node): TypeParameter[]{ + function appendOuterTypeParameters(typeParameters: TypeParameter[], node: Node): TypeParameter[] { while (true) { node = node.parent; if (!node) { @@ -2673,7 +2717,7 @@ namespace ts { if (baseConstructorType.flags & TypeFlags.ObjectType) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. - resolveObjectOrUnionTypeMembers(baseConstructorType); + resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { error(type.symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); @@ -3003,7 +3047,7 @@ namespace ts { } function resolveTupleTypeMembers(type: TupleType) { - let arrayType = resolveObjectOrUnionTypeMembers(createArrayType(getUnionType(type.elementTypes))); + let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); let members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -3069,6 +3113,26 @@ namespace ts { setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function intersectTypes(type1: Type, type2: Type): Type { + return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); + } + + 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 stringIndexType: Type = undefined; + let numberIndexType: Type = undefined; + for (let t of type.types) { + callSignatures = concatenate(callSignatures, getSignaturesOfType(t, SignatureKind.Call)); + constructSignatures = concatenate(constructSignatures, getSignaturesOfType(t, SignatureKind.Construct)); + stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, IndexKind.String)); + numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, IndexKind.Number)); + } + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveAnonymousTypeMembers(type: ObjectType) { let symbol = type.symbol; let members: SymbolTable; @@ -3113,7 +3177,7 @@ namespace ts { setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function resolveObjectOrUnionTypeMembers(type: ObjectType): ResolvedType { + function resolveStructuredTypeMembers(type: ObjectType): ResolvedType { if (!(type).members) { if (type.flags & (TypeFlags.Class | TypeFlags.Interface)) { resolveClassOrInterfaceMembers(type); @@ -3127,6 +3191,9 @@ namespace ts { else if (type.flags & TypeFlags.Union) { resolveUnionTypeMembers(type); } + else if (type.flags & TypeFlags.Intersection) { + resolveIntersectionTypeMembers(type); + } else { resolveTypeReferenceMembers(type); } @@ -3137,16 +3204,16 @@ namespace ts { // Return properties of an object type or an empty array for other types function getPropertiesOfObjectType(type: Type): Symbol[] { if (type.flags & TypeFlags.ObjectType) { - return resolveObjectOrUnionTypeMembers(type).properties; + return resolveStructuredTypeMembers(type).properties; } return emptyArray; } - // If the given type is an object type and that type has a property by the given name, return - // the symbol for that property. Otherwise return undefined. + // If the given type is an object type and that type has a property by the given name, + // return the symbol for that property.Otherwise return undefined. function getPropertyOfObjectType(type: Type, name: string): Symbol { if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (hasProperty(resolved.members, name)) { let symbol = resolved.members[name]; if (symbolIsValue(symbol)) { @@ -3156,25 +3223,30 @@ namespace ts { } } - function getPropertiesOfUnionType(type: UnionType): Symbol[] { - let result: Symbol[] = []; - forEach(getPropertiesOfType(type.types[0]), prop => { - let unionProp = getPropertyOfUnionType(type, prop.name); - if (unionProp) { - result.push(unionProp); + function getPropertiesOfUnionOrIntersectionType(type: UnionOrIntersectionType): Symbol[] { + for (let current of type.types) { + for (let prop of getPropertiesOfType(current)) { + getPropertyOfUnionOrIntersectionType(type, prop.name); } - }); - return result; + // The properties of a union type are those that are present in all constituent types, so + // we only need to check the properties of the first type + if (type.flags & TypeFlags.Union) { + break; + } + } + return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; } function getPropertiesOfType(type: Type): Symbol[] { type = getApparentType(type); - return type.flags & TypeFlags.Union ? getPropertiesOfUnionType(type) : getPropertiesOfObjectType(type); + return type.flags & TypeFlags.UnionOrIntersection ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - // For a type parameter, return the base constraint of the type parameter. For the string, number, - // boolean, and symbol primitive types, return the corresponding object types. Otherwise return the - // type itself. Note that the apparent type of a union type is the union type itself. + /** + * For a type parameter, return the base constraint of the type parameter. For the string, number, + * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the + * type itself. Note that the apparent type of a union type is the union type itself. + */ function getApparentType(type: Type): Type { if (type.flags & TypeFlags.Union) { type = getReducedTypeOfUnionType(type); @@ -3202,24 +3274,33 @@ namespace ts { return type; } - function createUnionProperty(unionType: UnionType, name: string): Symbol { - let types = unionType.types; + function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: string): Symbol { + let types = containingType.types; let props: Symbol[]; for (let current of types) { let type = getApparentType(current); if (type !== unknownType) { let prop = getPropertyOfType(type, name); - if (!prop || getDeclarationFlagsFromSymbol(prop) & (NodeFlags.Private | NodeFlags.Protected)) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (NodeFlags.Private | NodeFlags.Protected))) { + if (!props) { + props = [prop]; + } + else if (!contains(props, prop)) { + props.push(prop); + } + } + else if (containingType.flags & TypeFlags.Union) { + // A union type requires the property to be present in all constituent types return undefined; } - if (!props) { - props = [prop]; - } - else { - props.push(prop); - } } } + if (!props) { + return undefined; + } + if (props.length === 1) { + return props[0]; + } let propTypes: Type[] = []; let declarations: Declaration[] = []; for (let prop of props) { @@ -3228,19 +3309,19 @@ namespace ts { } propTypes.push(getTypeOfSymbol(prop)); } - let result = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | SymbolFlags.UnionProperty, name); - result.unionType = unionType; + let result = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | SymbolFlags.SyntheticProperty, name); + result.containingType = containingType; result.declarations = declarations; - result.type = getUnionType(propTypes); + result.type = containingType.flags & TypeFlags.Union ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } - function getPropertyOfUnionType(type: UnionType, name: string): Symbol { + function getPropertyOfUnionOrIntersectionType(type: UnionOrIntersectionType, name: string): Symbol { let properties = type.resolvedProperties || (type.resolvedProperties = {}); if (hasProperty(properties, name)) { return properties[name]; } - let property = createUnionProperty(type, name); + let property = createUnionOrIntersectionProperty(type, name); if (property) { properties[name] = property; } @@ -3253,7 +3334,7 @@ namespace ts { function getPropertyOfType(type: Type, name: string): Symbol { type = getApparentType(type); if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (hasProperty(resolved.members, name)) { let symbol = resolved.members[name]; if (symbolIsValue(symbol)) { @@ -3268,15 +3349,15 @@ namespace ts { } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & TypeFlags.Union) { - return getPropertyOfUnionType(type, name); + if (type.flags & TypeFlags.UnionOrIntersection) { + return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } - function getSignaturesOfObjectOrUnionType(type: Type, kind: SignatureKind): Signature[] { - if (type.flags & (TypeFlags.ObjectType | TypeFlags.Union)) { - let resolved = resolveObjectOrUnionTypeMembers(type); + function getSignaturesOfStructuredType(type: Type, kind: SignatureKind): Signature[] { + if (type.flags & TypeFlags.StructuredType) { + let resolved = resolveStructuredTypeMembers(type); return kind === SignatureKind.Call ? resolved.callSignatures : resolved.constructSignatures; } return emptyArray; @@ -3285,22 +3366,21 @@ namespace ts { // Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and // maps primitive types and type parameters are to their apparent types. function getSignaturesOfType(type: Type, kind: SignatureKind): Signature[] { - return getSignaturesOfObjectOrUnionType(getApparentType(type), kind); + return getSignaturesOfStructuredType(getApparentType(type), kind); } function typeHasCallOrConstructSignatures(type: Type): boolean { let apparentType = getApparentType(type); - if (apparentType.flags & (TypeFlags.ObjectType | TypeFlags.Union)) { - let resolved = resolveObjectOrUnionTypeMembers(type); - return resolved.callSignatures.length > 0 - || resolved.constructSignatures.length > 0; + if (apparentType.flags & TypeFlags.StructuredType) { + let resolved = resolveStructuredTypeMembers(type); + return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; } return false; } - function getIndexTypeOfObjectOrUnionType(type: Type, kind: IndexKind): Type { - if (type.flags & (TypeFlags.ObjectType | TypeFlags.Union)) { - let resolved = resolveObjectOrUnionTypeMembers(type); + function getIndexTypeOfStructuredType(type: Type, kind: IndexKind): Type { + if (type.flags & TypeFlags.StructuredType) { + let resolved = resolveStructuredTypeMembers(type); return kind === IndexKind.String ? resolved.stringIndexType : resolved.numberIndexType; } } @@ -3308,7 +3388,7 @@ namespace ts { // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and // maps primitive types and type parameters are to their apparent types. function getIndexTypeOfType(type: Type, kind: IndexKind): Type { - return getIndexTypeOfObjectOrUnionType(getApparentType(type), kind); + return getIndexTypeOfStructuredType(getApparentType(type), kind); } // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual @@ -3785,6 +3865,20 @@ namespace ts { return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); } + function tryGetGlobalType(name: string, arity = 0): ObjectType { + return getTypeOfGlobalSymbol(getGlobalSymbol(name, SymbolFlags.Type, /*diagnostic*/ undefined), arity); + } + + /** + * Returns a type that is inside a namespace at the global scope, e.g. + * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type + */ + function getExportedTypeFromNamespace(namespace: string, name: string): Type { + var namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); + var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type); + return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); + } + function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -3844,25 +3938,20 @@ namespace ts { return links.resolvedType; } - function addTypeToSortedSet(sortedSet: Type[], type: Type) { - if (type.flags & TypeFlags.Union) { - addTypesToSortedSet(sortedSet, (type).types); + function addTypeToSet(typeSet: Type[], type: Type, typeSetKind: TypeFlags) { + if (type.flags & typeSetKind) { + addTypesToSet(typeSet, (type).types, typeSetKind); } - else { - let i = 0; - let id = type.id; - while (i < sortedSet.length && sortedSet[i].id < id) { - i++; - } - if (i === sortedSet.length || sortedSet[i].id !== id) { - sortedSet.splice(i, 0, type); - } + else if (!contains(typeSet, type)) { + typeSet.push(type); } } - function addTypesToSortedSet(sortedTypes: Type[], types: Type[]) { + // Add the given types to the given type set. Order is preserved, duplicates are removed, + // and nested types of the given kind are flattened into the set. + function addTypesToSet(typeSet: Type[], types: Type[], typeSetKind: TypeFlags) { for (let type of types) { - addTypeToSortedSet(sortedTypes, type); + addTypeToSet(typeSet, type, typeSetKind); } } @@ -3904,6 +3993,10 @@ namespace ts { } } + function compareTypeIds(type1: Type, type2: Type): number { + return type1.id - type2.id; + } + // The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag // is true when creating a union type from a type node and when instantiating a union type. In both of those // cases subtype reduction has to be deferred to properly support recursive union types. For example, a @@ -3912,26 +4005,27 @@ namespace ts { if (types.length === 0) { return emptyObjectType; } - let sortedTypes: Type[] = []; - addTypesToSortedSet(sortedTypes, types); + let typeSet: Type[] = []; + addTypesToSet(typeSet, types, TypeFlags.Union); + typeSet.sort(compareTypeIds); if (noSubtypeReduction) { - if (containsTypeAny(sortedTypes)) { + if (containsTypeAny(typeSet)) { return anyType; } - removeAllButLast(sortedTypes, undefinedType); - removeAllButLast(sortedTypes, nullType); + removeAllButLast(typeSet, undefinedType); + removeAllButLast(typeSet, nullType); } else { - removeSubtypes(sortedTypes); + removeSubtypes(typeSet); } - if (sortedTypes.length === 1) { - return sortedTypes[0]; + if (typeSet.length === 1) { + return typeSet[0]; } - let id = getTypeListId(sortedTypes); + let id = getTypeListId(typeSet); let type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(TypeFlags.Union | getWideningFlagsOfTypes(sortedTypes)); - type.types = sortedTypes; + type = unionTypes[id] = createObjectType(TypeFlags.Union | getWideningFlagsOfTypes(typeSet)); + type.types = typeSet; type.reducedType = noSubtypeReduction ? undefined : type; } return type; @@ -3963,6 +4057,40 @@ namespace ts { return links.resolvedType; } + // We do not perform supertype reduction on intersection types. Intersection types are created only by the & + // type operator and we can't reduce those because we want to support recursive intersection types. For example, + // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. + // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution + // for intersections of types with signatures can be deterministic. + function getIntersectionType(types: Type[]): Type { + if (types.length === 0) { + return emptyObjectType; + } + let typeSet: Type[] = []; + addTypesToSet(typeSet, types, TypeFlags.Intersection); + if (containsTypeAny(typeSet)) { + return anyType; + } + if (typeSet.length === 1) { + return typeSet[0]; + } + let id = getTypeListId(typeSet); + let type = intersectionTypes[id]; + if (!type) { + type = intersectionTypes[id] = createObjectType(TypeFlags.Intersection | getWideningFlagsOfTypes(typeSet)); + type.types = typeSet; + } + return type; + } + + function getTypeFromIntersectionTypeNode(node: IntersectionTypeNode): Type { + let links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIntersectionType(map(node.types, getTypeFromTypeNode)); + } + return links.resolvedType; + } + function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node: Node): Type { let links = getNodeLinks(node); if (!links.resolvedType) { @@ -4020,6 +4148,8 @@ namespace ts { return getTypeFromTupleTypeNode(node); case SyntaxKind.UnionType: return getTypeFromUnionTypeNode(node); + case SyntaxKind.IntersectionType: + return getTypeFromIntersectionTypeNode(node); case SyntaxKind.ParenthesizedType: return getTypeFromTypeNode((node).type); case SyntaxKind.FunctionType: @@ -4207,6 +4337,9 @@ namespace ts { if (type.flags & TypeFlags.Union) { return getUnionType(instantiateList((type).types, mapper, instantiateType), /*noSubtypeReduction*/ true); } + if (type.flags & TypeFlags.Intersection) { + return getIntersectionType(instantiateList((type).types, mapper, instantiateType)); + } } return type; } @@ -4247,7 +4380,7 @@ namespace ts { function getTypeWithoutSignatures(type: Type): Type { if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { let result = createObjectType(TypeFlags.Anonymous, type.symbol); result.members = resolved.members; @@ -4292,6 +4425,16 @@ namespace ts { return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); } + /** + * Checks if 'source' is related to 'target' (e.g.: is a assignable to). + * @param source The left-hand-side of the relation. + * @param target The right-hand-side of the relation. + * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. + * Used as both to determine which checks are performed and as a cache of previously computed results. + * @param errorNode The node upon which all errors will be reported, if defined. + * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. + * @param containingMessageChain A chain of errors to prepend any new errors found. + */ function checkTypeRelatedTo( source: Type, target: Type, @@ -4357,37 +4500,10 @@ namespace ts { } } let saveErrorInfo = errorInfo; - if (source.flags & TypeFlags.Union || target.flags & TypeFlags.Union) { - if (relation === identityRelation) { - if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union) { - if (result = unionTypeRelatedToUnionType(source, target)) { - if (result &= unionTypeRelatedToUnionType(target, source)) { - return result; - } - } - } - else if (source.flags & TypeFlags.Union) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else { - if (result = unionTypeRelatedToType(target, source, reportErrors)) { - return result; - } - } - } - else { - if (source.flags & TypeFlags.Union) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else { - if (result = typeRelatedToUnionType(source, target, reportErrors)) { - return result; - } - } + if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typesRelatedTo((source).typeArguments, (target).typeArguments, reportErrors)) { + return result; } } else if (source.flags & TypeFlags.TypeParameter && target.flags & TypeFlags.TypeParameter) { @@ -4395,10 +4511,43 @@ namespace ts { return result; } } - else if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo((source).typeArguments, (target).typeArguments, reportErrors)) { - return result; + else if (relation !== identityRelation) { + // Note that the "each" checks must precede the "some" checks to produce the correct results + if (source.flags & TypeFlags.Union) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { + return result; + } + } + else if (target.flags & TypeFlags.Intersection) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else { + // It is necessary to try "each" checks on both sides because there may be nested "some" checks + // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or + // A & B = (A & B) | (C & D). + if (source.flags & TypeFlags.Intersection) { + // If target is a union type the following check will report errors so we suppress them here + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & TypeFlags.Union))) { + return result; + } + } + if (target.flags & TypeFlags.Union) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; + } + } + } + } + else { + if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union || + source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Intersection) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } } } @@ -4406,17 +4555,20 @@ namespace ts { // it may hold in a structural comparison. // Report structural errors only if we haven't reported any errors yet let reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - // identity relation does not use apparent type + // Identity relation does not use apparent type let sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType) { + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (sourceOrApparentType.flags & (TypeFlags.ObjectType | TypeFlags.Intersection) && target.flags & TypeFlags.ObjectType) { if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & TypeFlags.TypeParameter && sourceOrApparentType.flags & TypeFlags.Union) { + else if (source.flags & TypeFlags.TypeParameter && sourceOrApparentType.flags & TypeFlags.UnionOrIntersection) { // We clear the errors first because the following check often gives a better error than - // the union comparison above if it is applicable. + // the union or intersection comparison above if it is applicable. errorInfo = saveErrorInfo; if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { return result; @@ -4436,11 +4588,11 @@ namespace ts { return Ternary.False; } - function unionTypeRelatedToUnionType(source: UnionType, target: UnionType): Ternary { + function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType): Ternary { let result = Ternary.True; let sourceTypes = source.types; for (let sourceType of sourceTypes) { - let related = typeRelatedToUnionType(sourceType, target, false); + let related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return Ternary.False; } @@ -4449,7 +4601,7 @@ namespace ts { return result; } - function typeRelatedToUnionType(source: Type, target: UnionType, reportErrors: boolean): Ternary { + function typeRelatedToSomeType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean): Ternary { let targetTypes = target.types; for (let i = 0, len = targetTypes.length; i < len; i++) { let related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); @@ -4460,7 +4612,31 @@ namespace ts { return Ternary.False; } - function unionTypeRelatedToType(source: UnionType, target: Type, reportErrors: boolean): Ternary { + function typeRelatedToEachType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean): Ternary { + let result = Ternary.True; + let targetTypes = target.types; + for (let targetType of targetTypes) { + let related = isRelatedTo(source, targetType, reportErrors); + if (!related) { + return Ternary.False; + } + result &= related; + } + return result; + } + + function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean): Ternary { + let sourceTypes = source.types; + for (let i = 0, len = sourceTypes.length; i < len; i++) { + let related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + if (related) { + return related; + } + } + return Ternary.False; + } + + function eachTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean): Ternary { let result = Ternary.True; let sourceTypes = source.types; for (let sourceType of sourceTypes) { @@ -4515,7 +4691,7 @@ namespace ts { // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion // and issue an error. Otherwise, actually compare the structure of the two types. - function objectTypeRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { + function objectTypeRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (overflow) { return Ternary.False; } @@ -4590,7 +4766,7 @@ namespace ts { return result; } - function propertiesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { + function propertiesRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } @@ -4599,6 +4775,7 @@ namespace ts { let requireOptionalProperties = relation === subtypeRelation && !(source.flags & TypeFlags.ObjectLiteral); for (let targetProp of properties) { let sourceProp = getPropertyOfType(source, targetProp.name); + if (sourceProp !== targetProp) { if (!sourceProp) { if (!(targetProp.flags & SymbolFlags.Optional) || requireOptionalProperties) { @@ -4609,24 +4786,24 @@ namespace ts { } } else if (!(targetProp.flags & SymbolFlags.Prototype)) { - let sourceFlags = getDeclarationFlagsFromSymbol(sourceProp); - let targetFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourceFlags & NodeFlags.Private || targetFlags & NodeFlags.Private) { + let sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); + let targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); + if (sourcePropFlags & NodeFlags.Private || targetPropFlags & NodeFlags.Private) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourceFlags & NodeFlags.Private && targetFlags & NodeFlags.Private) { + if (sourcePropFlags & NodeFlags.Private && targetPropFlags & NodeFlags.Private) { reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), - typeToString(sourceFlags & NodeFlags.Private ? source : target), - typeToString(sourceFlags & NodeFlags.Private ? target : source)); + typeToString(sourcePropFlags & NodeFlags.Private ? source : target), + typeToString(sourcePropFlags & NodeFlags.Private ? target : source)); } } return Ternary.False; } } - else if (targetFlags & NodeFlags.Protected) { + else if (targetPropFlags & NodeFlags.Protected) { let sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & SymbolFlags.Class; let sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; let targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -4638,7 +4815,7 @@ namespace ts { return Ternary.False; } } - else if (sourceFlags & NodeFlags.Protected) { + else if (sourcePropFlags & NodeFlags.Protected) { if (reportErrors) { reportError(Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); @@ -4673,7 +4850,10 @@ namespace ts { return result; } - function propertiesIdenticalTo(source: ObjectType, target: ObjectType): Ternary { + function propertiesIdenticalTo(source: Type, target: Type): Ternary { + if (!(source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType)) { + return Ternary.False; + } let sourceProperties = getPropertiesOfObjectType(source); let targetProperties = getPropertiesOfObjectType(target); if (sourceProperties.length !== targetProperties.length) { @@ -4694,7 +4874,7 @@ namespace ts { return result; } - function signaturesRelatedTo(source: ObjectType, target: ObjectType, kind: SignatureKind, reportErrors: boolean): Ternary { + function signaturesRelatedTo(source: Type, target: Type, kind: SignatureKind, reportErrors: boolean): Ternary { if (relation === identityRelation) { return signaturesIdenticalTo(source, target, kind); } @@ -4820,7 +5000,7 @@ namespace ts { return result & isRelatedTo(s, t, reportErrors); } - function signaturesIdenticalTo(source: ObjectType, target: ObjectType, kind: SignatureKind): Ternary { + function signaturesIdenticalTo(source: Type, target: Type, kind: SignatureKind): Ternary { let sourceSignatures = getSignaturesOfType(source, kind); let targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { @@ -4837,7 +5017,7 @@ namespace ts { return result; } - function stringIndexTypesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { + function stringIndexTypesRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (relation === identityRelation) { return indexTypesIdenticalTo(IndexKind.String, source, target); } @@ -4862,7 +5042,7 @@ namespace ts { return Ternary.True; } - function numberIndexTypesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { + function numberIndexTypesRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (relation === identityRelation) { return indexTypesIdenticalTo(IndexKind.Number, source, target); } @@ -4895,7 +5075,7 @@ namespace ts { return Ternary.True; } - function indexTypesIdenticalTo(indexKind: IndexKind, source: ObjectType, target: ObjectType): Ternary { + function indexTypesIdenticalTo(indexKind: IndexKind, source: Type, target: Type): Ternary { let targetType = getIndexTypeOfType(target, indexKind); let sourceType = getIndexTypeOfType(source, indexKind); if (!sourceType && !targetType) { @@ -5279,11 +5459,11 @@ namespace ts { inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (target.flags & TypeFlags.Union) { - let targetTypes = (target).types; + else if (target.flags & TypeFlags.UnionOrIntersection) { + let targetTypes = (target).types; let typeParameterCount = 0; let typeParameter: TypeParameter; - // First infer to each type in union that isn't a type parameter + // First infer to each type in union or intersection that isn't a type parameter for (let t of targetTypes) { if (t.flags & TypeFlags.TypeParameter && contains(context.typeParameters, t)) { typeParameter = t; @@ -5293,16 +5473,19 @@ namespace ts { inferFromTypes(source, t); } } - // If union contains a single naked type parameter, make a secondary inference to that type parameter - if (typeParameterCount === 1) { + // Next, if target is a union type containing a single naked type parameter, make a + // secondary inference to that type parameter. We don't do this for intersection types + // because in a target type like Foo & T we don't know how which parts of the source type + // should be matched by Foo and which should be inferred to T. + if (target.flags & TypeFlags.Union && typeParameterCount === 1) { inferiority++; inferFromTypes(source, typeParameter); inferiority--; } } - else if (source.flags & TypeFlags.Union) { - // Source is a union type, infer from each consituent type - let sourceTypes = (source).types; + else if (source.flags & TypeFlags.UnionOrIntersection) { + // Source is a union or intersection type, infer from each consituent type + let sourceTypes = (source).types; for (let sourceType of sourceTypes) { inferFromTypes(sourceType, target); } @@ -5538,12 +5721,15 @@ namespace ts { case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.PrefixUnaryExpression: case SyntaxKind.DeleteExpression: + case SyntaxKind.AwaitExpression: case SyntaxKind.TypeOfExpression: case SyntaxKind.VoidExpression: case SyntaxKind.PostfixUnaryExpression: + case SyntaxKind.YieldExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.SpreadElementExpression: case SyntaxKind.Block: @@ -5564,6 +5750,12 @@ namespace ts { case SyntaxKind.ThrowStatement: case SyntaxKind.TryStatement: case SyntaxKind.CatchClause: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxAttribute: + case SyntaxKind.JsxSpreadAttribute: + case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxExpression: return forEachChild(node, isAssignedIn); } return false; @@ -5854,8 +6046,18 @@ namespace ts { // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects - if (symbol === argumentsSymbol && getContainingFunction(node).kind === SyntaxKind.ArrowFunction && languageVersion < ScriptTarget.ES6) { - error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + if (symbol === argumentsSymbol) { + let container = getContainingFunction(node); + if (container.kind === SyntaxKind.ArrowFunction) { + if (languageVersion < ScriptTarget.ES6) { + error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + } + } + + if (node.parserContextFlags & ParserContextFlags.Await) { + getNodeLinks(container).flags |= NodeCheckFlags.CaptureArguments; + getNodeLinks(node).flags |= NodeCheckFlags.LexicalArguments; + } } if (symbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -6033,20 +6235,20 @@ namespace ts { if (container && isClassLike(container.parent)) { if (container.flags & NodeFlags.Static) { canUseSuperExpression = - container.kind === SyntaxKind.MethodDeclaration || - container.kind === SyntaxKind.MethodSignature || - container.kind === SyntaxKind.GetAccessor || - container.kind === SyntaxKind.SetAccessor; + container.kind === SyntaxKind.MethodDeclaration || + container.kind === SyntaxKind.MethodSignature || + container.kind === SyntaxKind.GetAccessor || + container.kind === SyntaxKind.SetAccessor; } else { canUseSuperExpression = - container.kind === SyntaxKind.MethodDeclaration || - container.kind === SyntaxKind.MethodSignature || - container.kind === SyntaxKind.GetAccessor || - container.kind === SyntaxKind.SetAccessor || - container.kind === SyntaxKind.PropertyDeclaration || - container.kind === SyntaxKind.PropertySignature || - container.kind === SyntaxKind.Constructor; + container.kind === SyntaxKind.MethodDeclaration || + container.kind === SyntaxKind.MethodSignature || + container.kind === SyntaxKind.GetAccessor || + container.kind === SyntaxKind.SetAccessor || + container.kind === SyntaxKind.PropertyDeclaration || + container.kind === SyntaxKind.PropertySignature || + container.kind === SyntaxKind.Constructor; } } } @@ -6166,6 +6368,18 @@ namespace ts { return undefined; } + function isInParameterInitializerBeforeContainingFunction(node: Node) { + while (node.parent && !isFunctionLike(node.parent)) { + if (node.parent.kind === SyntaxKind.Parameter && (node.parent).initializer === node) { + return true; + } + + node = node.parent; + } + + return false; + } + function getContextualReturnType(functionDecl: FunctionLikeDeclaration): Type { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed @@ -6254,13 +6468,13 @@ namespace ts { function getTypeOfPropertyOfContextualType(type: Type, name: string) { return applyToContextualType(type, t => { - let prop = getPropertyOfObjectType(t, name); + let prop = t.flags & TypeFlags.StructuredType ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } function getIndexTypeOfContextualType(type: Type, kind: IndexKind) { - return applyToContextualType(type, t => getIndexTypeOfObjectOrUnionType(t, kind)); + return applyToContextualType(type, t => getIndexTypeOfStructuredType(t, kind)); } // Return true if the given contextual type is a tuple-like type @@ -6270,7 +6484,7 @@ namespace ts { // Return true if the given contextual type provides an index signature of the given kind function contextualTypeHasIndexSignature(type: Type, kind: IndexKind): boolean { - return !!(type.flags & TypeFlags.Union ? forEach((type).types, t => getIndexTypeOfObjectOrUnionType(t, kind)) : getIndexTypeOfObjectOrUnionType(type, kind)); + return !!(type.flags & TypeFlags.Union ? forEach((type).types, t => getIndexTypeOfStructuredType(t, kind)) : getIndexTypeOfStructuredType(type, kind)); } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of @@ -6330,9 +6544,34 @@ namespace ts { return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } + function getContextualTypeForJsxExpression(expr: JsxExpression|JsxSpreadAttribute): Type { + // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) + if (expr.parent.kind === SyntaxKind.JsxAttribute) { + let attrib = expr.parent; + let attrsType = getJsxElementAttributesType(attrib.parent); + if (!attrsType || isTypeAny(attrsType)) { + return undefined; + } + else { + return getTypeOfPropertyOfType(attrsType, attrib.name.text); + } + } + + if (expr.kind === SyntaxKind.JsxSpreadAttribute) { + return getJsxElementAttributesType(expr.parent); + } + + return undefined; + } + // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. function getContextualType(node: Expression): Type { + let type = getContextualTypeWorker(node); + return type && getApparentType(type); + } + + function getContextualTypeWorker(node: Expression): Type { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -6357,7 +6596,8 @@ namespace ts { case SyntaxKind.NewExpression: return getContextualTypeForArgument(parent, node); case SyntaxKind.TypeAssertionExpression: - return getTypeFromTypeNode((parent).type); + case SyntaxKind.AsExpression: + return getTypeFromTypeNode((parent).type); case SyntaxKind.BinaryExpression: return getContextualTypeForBinaryOperand(node); case SyntaxKind.PropertyAssignment: @@ -6371,6 +6611,9 @@ namespace ts { return getContextualTypeForSubstitutionExpression(parent.parent, node); case SyntaxKind.ParenthesizedExpression: return getContextualType(parent); + case SyntaxKind.JsxExpression: + case SyntaxKind.JsxSpreadAttribute: + return getContextualTypeForJsxExpression(parent); } return undefined; } @@ -6378,7 +6621,7 @@ namespace ts { // If the given type is an object or union type, if that type has a single signature, and if // that signature is non-generic, return the signature. Otherwise return undefined. function getNonGenericSignature(type: Type): Signature { - let signatures = getSignaturesOfObjectOrUnionType(type, SignatureKind.Call); + let signatures = getSignaturesOfStructuredType(type, SignatureKind.Call); if (signatures.length === 1) { let signature = signatures[0]; if (!signature.typeParameters) { @@ -6420,7 +6663,7 @@ namespace ts { // The signature set of all constituent type with call signatures should match // So number of signatures allowed is either 0 or 1 if (signatureList && - getSignaturesOfObjectOrUnionType(current, SignatureKind.Call).length > 1) { + getSignaturesOfStructuredType(current, SignatureKind.Call).length > 1) { return undefined; } @@ -6503,7 +6746,7 @@ namespace ts { // c is represented in the tree as a spread element in an array literal. // But c really functions as a rest element, and its purpose is to provide // a contextual type for the right hand side of the assignment. Therefore, - // instead of calling checkExpression on "...c", which will give an error + // instead of calling checkExpression on "...c", which will give an error // if c is not iterable/array-like, we need to act as if we are trying to // get the contextual element type from it. So we do something similar to // getContextualTypeForElementExpression, which will crucially not error @@ -6511,8 +6754,7 @@ namespace ts { let restArrayType = checkExpression((e).expression, contextualMapper); let restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || (languageVersion >= ScriptTarget.ES6 ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); - - if (restElementType) { + if (restElementType) { elementTypes.push(restElementType); } } @@ -6671,52 +6913,549 @@ namespace ts { } } + + function checkJsxSelfClosingElement(node: JsxSelfClosingElement) { + checkJsxOpeningLikeElement(node); + return jsxElementType || anyType; + } + + function tagNamesAreEquivalent(lhs: EntityName, rhs: EntityName): boolean { + if (lhs.kind !== rhs.kind) { + return false; + } + + if (lhs.kind === SyntaxKind.Identifier) { + return (lhs).text === (rhs).text; + } + + return (lhs).right.text === (rhs).right.text && + tagNamesAreEquivalent((lhs).left, (rhs).left); + } + + function checkJsxElement(node: JsxElement) { + // Check that the closing tag matches + if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { + error(node.closingElement, Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, getTextOfNode(node.openingElement.tagName)); + } + + // Check attributes + checkJsxOpeningLikeElement(node.openingElement); + + // Check children + for (let child of node.children) { + switch (child.kind) { + case SyntaxKind.JsxExpression: + checkJsxExpression(child); + break; + case SyntaxKind.JsxElement: + checkJsxElement(child); + break; + case SyntaxKind.JsxSelfClosingElement: + checkJsxSelfClosingElement(child); + break; + default: + // No checks for JSX Text + Debug.assert(child.kind === SyntaxKind.JsxText); + } + } + + return jsxElementType || anyType; + } + + /** + * Returns true iff the JSX element name would be a valid JS identifier, ignoring restrictions about keywords not being identifiers + */ + function isUnhyphenatedJsxName(name: string) { + // - is the only character supported in JSX attribute names that isn't valid in JavaScript identifiers + return name.indexOf("-") < 0; + } + + /** + * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name + */ + function isJsxIntrinsicIdentifier(tagName: Identifier|QualifiedName) { + if (tagName.kind === SyntaxKind.QualifiedName) { + return false; + } + else { + return isIntrinsicJsxName((tagName).text); + } + } + + function checkJsxAttribute(node: JsxAttribute, elementAttributesType: Type, nameTable: Map) { + let correspondingPropType: Type = undefined; + + // Look up the corresponding property for this attribute + if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { + // If there is no 'props' property, you may not have non-"data-" attributes + error(node.parent, Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); + } + else if (elementAttributesType && !isTypeAny(elementAttributesType)) { + let correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); + correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); + // If there's no corresponding property with this name, error + if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { + error(node.name, Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } + + let exprType: Type; + if (node.initializer) { + exprType = checkExpression(node.initializer); + } + else { + // is sugar for + exprType = booleanType; + } + + if (correspondingPropType) { + checkTypeAssignableTo(exprType, correspondingPropType, node); + } + + nameTable[node.name.text] = true; + return exprType; + } + + function checkJsxSpreadAttribute(node: JsxSpreadAttribute, elementAttributesType: Type, nameTable: Map) { + let type = checkExpression(node.expression); + let props = getPropertiesOfType(type); + for (let prop of props) { + // Is there a corresponding property in the element attributes type? Skip checking of properties + // that have already been assigned to, as these are not actually pushed into the resulting type + if (!nameTable[prop.name]) { + let targetPropSym = getPropertyOfType(elementAttributesType, prop.name); + if (targetPropSym) { + let msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); + checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); + } + + nameTable[prop.name] = true; + } + } + return type; + } + + /// Returns the type JSX.IntrinsicElements. May return `unknownType` if that type is not present. + function getJsxIntrinsicElementsType() { + if (!jsxIntrinsicElementsType) { + jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; + } + return jsxIntrinsicElementsType; + } + + /// Given a JSX opening element or self-closing element, return the symbol of the property that the tag name points to if + /// this is an intrinsic tag. This might be a named + /// property of the IntrinsicElements interface, or its string indexer. + /// If this is a class-based tag (otherwise returns undefined), returns the symbol of the class + /// type or factory function. + /// Otherwise, returns unknownSymbol. + function getJsxElementTagSymbol(node: JsxOpeningLikeElement): Symbol { + let flags: JsxFlags = JsxFlags.UnknownElement; + let links = getNodeLinks(node); + if (!links.resolvedSymbol) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + links.resolvedSymbol = lookupIntrinsicTag(node); + } else { + links.resolvedSymbol = lookupClassTag(node); + } + } + return links.resolvedSymbol; + + function lookupIntrinsicTag(node: JsxOpeningLikeElement): Symbol { + let intrinsicElementsType = getJsxIntrinsicElementsType(); + if (intrinsicElementsType !== unknownType) { + // Property case + let intrinsicProp = getPropertyOfType(intrinsicElementsType, (node.tagName).text); + if (intrinsicProp) { + links.jsxFlags |= JsxFlags.IntrinsicNamedElement; + return intrinsicProp; + } + + // Intrinsic string indexer case + let indexSignatureType = getIndexTypeOfType(intrinsicElementsType, IndexKind.String); + if (indexSignatureType) { + links.jsxFlags |= JsxFlags.IntrinsicIndexedElement; + return intrinsicElementsType.symbol; + } + + // Wasn't found + error(node, Diagnostics.Property_0_does_not_exist_on_type_1, (node.tagName).text, 'JSX.' + JsxNames.IntrinsicElements); + return unknownSymbol; + } + else { + if (compilerOptions.noImplicitAny) { + error(node, Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); + } + } + } + + function lookupClassTag(node: JsxOpeningLikeElement): Symbol { + let valueSymbol: Symbol; + + // Look up the value in the current scope + if (node.tagName.kind === SyntaxKind.Identifier) { + valueSymbol = getResolvedSymbol(node.tagName); + } + else { + valueSymbol = checkQualifiedName(node.tagName).symbol; + } + + if (valueSymbol !== unknownSymbol) { + links.jsxFlags |= JsxFlags.ClassElement; + } + + return valueSymbol || unknownSymbol; + } + } + + /** + * Given a JSX element that is a class element, finds the Element Instance Type. If the + * element is not a class element, or the class element type cannot be determined, returns 'undefined'. + * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). + */ + function getJsxElementInstanceType(node: JsxOpeningLikeElement) { + if (!(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement)) { + // There is no such thing as an instance type for a non-class element + return undefined; + } + + let classSymbol = getJsxElementTagSymbol(node); + if (classSymbol === unknownSymbol) { + // Couldn't find the class instance type. Error has already been issued + return anyType; + } + + let valueType = getTypeOfSymbol(classSymbol); + if (isTypeAny(valueType)) { + // Short-circuit if the class tag is using an element type 'any' + return anyType; + } + + // Resolve the signatures, preferring constructors + let signatures = getSignaturesOfType(valueType, SignatureKind.Construct); + if (signatures.length === 0) { + // No construct signatures, try call signatures + signatures = getSignaturesOfType(valueType, SignatureKind.Call); + + if (signatures.length === 0) { + // We found no signatures at all, which is an error + error(node.tagName, Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, getTextOfNode(node.tagName)); + return undefined; + } + } + + // Check that the constructor/factory returns an object type + let returnType = getUnionType(signatures.map(s => getReturnTypeOfSignature(s))); + if (!isTypeAny(returnType) && !(returnType.flags & TypeFlags.ObjectType)) { + error(node.tagName, Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); + return undefined; + } + + // Issue an error if this return type isn't assignable to JSX.ElementClass + let elemClassType = getJsxGlobalElementClassType(); + if (elemClassType) { + checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + + return returnType; + } + + /// e.g. "props" for React.d.ts, + /// or 'undefined' if ElementAttributesPropery doesn't exist (which means all + /// non-intrinsic elements' attributes type is 'any'), + /// or '' if it has 0 properties (which means every + /// non-instrinsic elements' attributes type is the element instance type) + function getJsxElementPropertiesName() { + // JSX + let jsxNamespace = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, /*diagnosticMessage*/undefined); + // JSX.ElementAttributesProperty [symbol] + let attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, SymbolFlags.Type); + // JSX.ElementAttributesProperty [type] + let attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); + // The properites of JSX.ElementAttributesProperty + let attribProperties = attribPropType && getPropertiesOfType(attribPropType); + + if (attribProperties) { + // Element Attributes has zero properties, so the element attributes type will be the class instance type + if (attribProperties.length === 0) { + return ""; + } + // Element Attributes has one property, so the element attributes type will be the type of the corresponding + // property of the class instance type + else if (attribProperties.length === 1) { + return attribProperties[0].name; + } + // More than one property on ElementAttributesProperty is an error + else { + error(attribsPropTypeSym.declarations[0], Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); + return undefined; + } + } + else { + // No interface exists, so the element attributes type will be an implicit any + return undefined; + } + } + + /** + * Given an opening/self-closing element, get the 'element attributes type', i.e. the type that tells + * us which attributes are valid on a given element. + */ + function getJsxElementAttributesType(node: JsxOpeningLikeElement): Type { + let links = getNodeLinks(node); + if (!links.resolvedJsxType) { + let sym = getJsxElementTagSymbol(node); + + if (links.jsxFlags & JsxFlags.ClassElement) { + let elemInstanceType = getJsxElementInstanceType(node); + + if (isTypeAny(elemInstanceType)) { + return links.resolvedJsxType = anyType; + } + + var propsName = getJsxElementPropertiesName(); + if (propsName === undefined) { + // There is no type ElementAttributesProperty, return 'any' + return links.resolvedJsxType = anyType; + } + else if (propsName === "") { + // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead + return links.resolvedJsxType = elemInstanceType; + } + else { + var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); + + if (!attributesType) { + // There is no property named 'props' on this instance type + return links.resolvedJsxType = emptyObjectType; + } + else if (isTypeAny(attributesType) || (attributesType === unknownType)) { + return links.resolvedJsxType = attributesType; + } + else if (!(attributesType.flags & TypeFlags.ObjectType)) { + error(node.tagName, Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); + return links.resolvedJsxType = anyType; + } + else { + return links.resolvedJsxType = attributesType; + } + } + } + else if (links.jsxFlags & JsxFlags.IntrinsicNamedElement) { + return links.resolvedJsxType = getTypeOfSymbol(sym); + } + else if (links.jsxFlags & JsxFlags.IntrinsicIndexedElement) { + return links.resolvedJsxType = getIndexTypeOfSymbol(sym, IndexKind.String); + } + else { + // Resolution failed, so we don't know + return links.resolvedJsxType = anyType; + } + } + + return links.resolvedJsxType; + } + + /** + * Given a JSX attribute, returns the symbol for the corresponds property + * of the element attributes type. Will return unknownSymbol for attributes + * that have no matching element attributes type property. + */ + function getJsxAttributePropertySymbol(attrib: JsxAttribute): Symbol { + let attributesType = getJsxElementAttributesType(attrib.parent); + let prop = getPropertyOfType(attributesType, attrib.name.text); + return prop || unknownSymbol; + } + + let jsxElementClassType: Type = undefined; + function getJsxGlobalElementClassType(): Type { + if (!jsxElementClassType) { + jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + } + return jsxElementClassType; + } + + /// Returns all the properties of the Jsx.IntrinsicElements interface + function getJsxIntrinsicTagNames(): Symbol[] { + let intrinsics = getJsxIntrinsicElementsType(); + return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; + } + + function checkJsxPreconditions(errorNode: Node) { + // Preconditions for using JSX + if ((compilerOptions.jsx || JsxEmit.None) === JsxEmit.None) { + error(errorNode, Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); + } + + if (jsxElementType === undefined) { + if (compilerOptions.noImplicitAny) { + error(errorNode, Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); + } + } + } + + function checkJsxOpeningLikeElement(node: JsxOpeningLikeElement) { + checkGrammarJsxElement(node); + checkJsxPreconditions(node); + + // If we're compiling under --jsx react, the symbol 'React' should + // be marked as 'used' so we don't incorrectly elide its import. And if there + // is no 'React' symbol in scope, we should issue an error. + if (compilerOptions.jsx === JsxEmit.React) { + let reactSym = resolveName(node.tagName, 'React', SymbolFlags.Value, Diagnostics.Cannot_find_name_0, 'React'); + if (reactSym) { + getSymbolLinks(reactSym).referenced = true; + } + } + + let targetAttributesType = getJsxElementAttributesType(node); + + if (getNodeLinks(node).jsxFlags & JsxFlags.ClassElement) { + if (node.tagName.kind === SyntaxKind.Identifier) { + checkIdentifier(node.tagName); + } + else { + checkQualifiedName(node.tagName); + } + } + + let nameTable: Map = {}; + // Process this array in right-to-left order so we know which + // attributes (mostly from spreads) are being overwritten and + // thus should have their types ignored + let sawSpreadedAny = false; + for (let i = node.attributes.length - 1; i >= 0; i--) { + if (node.attributes[i].kind === SyntaxKind.JsxAttribute) { + checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); + } + else { + Debug.assert(node.attributes[i].kind === SyntaxKind.JsxSpreadAttribute); + let spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); + if (isTypeAny(spreadType)) { + sawSpreadedAny = true; + } + } + } + + // Check that all required properties have been provided. If an 'any' + // was spreaded in, though, assume that it provided all required properties + if (targetAttributesType && !sawSpreadedAny) { + let targetProperties = getPropertiesOfType(targetAttributesType); + for (let i = 0; i < targetProperties.length; i++) { + if (!(targetProperties[i].flags & SymbolFlags.Optional) && + nameTable[targetProperties[i].name] === undefined) { + + error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); + } + } + } + } + + function checkJsxExpression(node: JsxExpression) { + if (node.expression) { + return checkExpression(node.expression); + } + else { + return unknownType; + } + } + // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s: Symbol) { return s.valueDeclaration ? s.valueDeclaration.kind : SyntaxKind.PropertyDeclaration; } - function getDeclarationFlagsFromSymbol(s: Symbol) { + function getDeclarationFlagsFromSymbol(s: Symbol): NodeFlags { return s.valueDeclaration ? getCombinedNodeFlags(s.valueDeclaration) : s.flags & SymbolFlags.Prototype ? NodeFlags.Public | NodeFlags.Static : 0; } - function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol) { + /** + * Check whether the requested property access is valid. + * Returns true if node is a valid property access, and false otherwise. + * @param node The node to be checked. + * @param left The left hand side of the property access (e.g.: the super in `super.foo`). + * @param type The type of left. + * @param prop The symbol for the right hand side of the property access. + */ + function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol): boolean { let flags = getDeclarationFlagsFromSymbol(prop); - // Public properties are always accessible - if (!(flags & (NodeFlags.Private | NodeFlags.Protected))) { - return; + let declaringClass = getDeclaredTypeOfSymbol(prop.parent);; + + if (left.kind === SyntaxKind.SuperKeyword) { + let errorNode = node.kind === SyntaxKind.PropertyAccessExpression ? + (node).name : + (node).right; + + // TS 1.0 spec (April 2014): 4.8.2 + // - In a constructor, instance member function, instance member accessor, or + // instance member variable initializer where this references a derived class instance, + // a super property access is permitted and must specify a public instance member function of the base class. + // - 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 (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. + + error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } + + if (flags & NodeFlags.Abstract) { + // A method cannot be accessed in a super property access if the method is abstract. + // This error could mask a private property access error. But, a member + // cannot simultaneously be private and abstract, so this will trigger an + // additional error elsewhere. + + error(errorNode, Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + return false; + } } + + // Public properties are otherwise accessible. + if (!(flags & (NodeFlags.Private | NodeFlags.Protected))) { + return true; + } + // Property is known to be private or protected at this point // Get the declaring and enclosing class instance types let enclosingClassDeclaration = getContainingClass(node); + let enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - let declaringClass = getDeclaredTypeOfSymbol(prop.parent); + // Private property is accessible if declaring and enclosing class are the same if (flags & NodeFlags.Private) { if (declaringClass !== enclosingClass) { error(node, Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + return false; } - return; + return true; } + // Property is known to be protected at this point + // All protected properties of a supertype are accessible in a super access if (left.kind === SyntaxKind.SuperKeyword) { - return; + return true; } // A protected property is accessible in the declaring class and classes derived from it if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { error(node, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); - return; + return false; } // No further restrictions for static properties if (flags & NodeFlags.Static) { - return; + return true; } // An instance property must be accessed through an instance of the enclosing class + // TODO: why is the first part of this check here? if (!(getTargetType(type).flags & (TypeFlags.Class | TypeFlags.Interface) && hasBaseType(type, enclosingClass))) { error(node, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); + return false; } + return true; } function checkPropertyAccessExpression(node: PropertyAccessExpression) { @@ -6745,21 +7484,11 @@ namespace ts { } return unknownType; } + getNodeLinks(node).resolvedSymbol = prop; + if (prop.parent && prop.parent.flags & SymbolFlags.Class) { - // TS 1.0 spec (April 2014): 4.8.2 - // - In a constructor, instance member function, instance member accessor, or - // instance member variable initializer where this references a derived class instance, - // a super property access is permitted and must specify a public instance member function of the base class. - // - 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 (left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { - error(right, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - } - else { - checkClassPropertyAccess(node, left, type, prop); - } + checkClassPropertyAccess(node, left, type, prop); } return getTypeOfSymbol(prop); } @@ -6773,14 +7502,7 @@ namespace ts { if (type !== unknownType && !isTypeAny(type)) { let prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & SymbolFlags.Class) { - if (left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { - return false; - } - else { - let modificationCount = diagnostics.getModificationCount(); - checkClassPropertyAccess(node, left, type, prop); - return diagnostics.getModificationCount() === modificationCount; - } + return checkClassPropertyAccess(node, left, type, prop); } } return true; @@ -7104,7 +7826,7 @@ namespace ts { // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type: Type): Signature { if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { return resolved.callSignatures[0]; @@ -7159,7 +7881,7 @@ namespace ts { let paramType = getTypeAtPosition(signature, i); let argType = getEffectiveArgumentType(node, i, arg); - // If the effective argument type is 'undefined', there is no synthetic type + // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { // For context sensitive arguments we pass the identityMapper, which is a signal to treat all @@ -7232,7 +7954,7 @@ namespace ts { let paramType = getTypeAtPosition(signature, i); let argType = getEffectiveArgumentType(node, i, arg); - // If the effective argument type is 'undefined', there is no synthetic type + // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { argType = arg.kind === SyntaxKind.StringLiteral && !reportErrors @@ -7289,13 +8011,13 @@ namespace ts { * Returns the effective argument count for a node that works like a function invocation. * If 'node' is a Decorator, the number of arguments is derived from the decoration * target and the signature: - * If 'node.target' is a class declaration or class expression, the effective argument + * If 'node.target' is a class declaration or class expression, the effective argument * count is 1. * If 'node.target' is a parameter declaration, the effective argument count is 3. * If 'node.target' is a property declaration, the effective argument count is 2. - * If 'node.target' is a method or accessor declaration, the effective argument count + * If 'node.target' is a method or accessor declaration, the effective argument count * is 3, although it can be 2 if the signature only accepts two arguments, allowing - * us to match a property decorator. + * us to match a property decorator. * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node: CallLikeExpression, args: Expression[], signature: Signature) { @@ -7307,7 +8029,7 @@ namespace ts { return 1; case SyntaxKind.PropertyDeclaration: - // A property declaration decorator will have two arguments (see + // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; @@ -7316,12 +8038,12 @@ namespace ts { case SyntaxKind.SetAccessor: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) - // If the method decorator signature only accepts a target and a key, we will only + // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; case SyntaxKind.Parameter: - // A parameter declaration decorator will have three arguments (see + // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -7337,41 +8059,41 @@ namespace ts { * If 'node' is a class declaration or class expression, the effective argument type * is the type of the static side of the class. * If 'node' is a parameter declaration, the effective argument type is either the type - * of the static or instance side of the class for the parameter's parent method, + * of the static or instance side of the class for the parameter's parent method, * depending on whether the method is declared static. * For a constructor, the type is always the type of the static side of the class. - * If 'node' is a property, method, or accessor declaration, the effective argument - * type is the type of the static or instance side of the parent class for class - * element, depending on whether the element is declared static. + * If 'node' is a property, method, or accessor declaration, the effective argument + * type is the type of the static or instance side of the parent class for class + * element, depending on whether the element is declared static. */ function getEffectiveDecoratorFirstArgumentType(node: Node): Type { // The first argument to a decorator is its `target`. switch (node.kind) { case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: - // For a class decorator, the `target` is the type of the class (e.g. the + // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) let classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); case SyntaxKind.Parameter: - // For a parameter decorator, the `target` is the parent type of the - // parameter's containing method. + // For a parameter decorator, the `target` is the parent type of the + // parameter's containing method. node = node.parent; if (node.kind === SyntaxKind.Constructor) { let classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } + + // fall-through - // fall-through - - case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertyDeclaration: case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is - // declared "static"; otherwise, it is the "instance"-side type of the + // declared "static"; otherwise, it is the "instance"-side type of the // parent of the member. return getParentTypeOfClassElement(node); @@ -7384,15 +8106,15 @@ namespace ts { /** * Returns the effective type for the second argument to a decorator. * If 'node' is a parameter, its effective argument type is one of the following: - * If 'node.parent' is a constructor, the effective argument type is 'any', as we + * If 'node.parent' is a constructor, the effective argument type is 'any', as we * will emit `undefined`. - * If 'node.parent' is a member with an identifier, numeric, or string literal name, + * If 'node.parent' is a member with an identifier, numeric, or string literal name, * the effective argument type will be a string literal type for the member name. - * If 'node.parent' is a computed property name, the effective argument type will + * If 'node.parent' is a computed property name, the effective argument type will * either be a symbol type or the string type. - * If 'node' is a member with an identifier, numeric, or string literal name, the + * If 'node' is a member with an identifier, numeric, or string literal name, the * effective argument type will be a string literal type for the member name. - * If 'node' is a computed property name, the effective argument type will either + * If 'node' is a computed property name, the effective argument type will either * be a symbol type or the string type. * A class decorator does not have a second argument type. */ @@ -7409,18 +8131,18 @@ namespace ts { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } - - // For a non-constructor parameter decorator, the `propertyKey` will be either - // a string or a symbol, based on the name of the parameter's containing method. - - // fall-through - - case SyntaxKind.PropertyDeclaration: + + // For a non-constructor parameter decorator, the `propertyKey` will be either + // a string or a symbol, based on the name of the parameter's containing method. + + // fall-through + + case SyntaxKind.PropertyDeclaration: case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: // The `propertyKey` for a property or method decorator will be a - // string literal type if the member name is an identifier, number, or string; + // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. let element = node; @@ -7444,7 +8166,8 @@ namespace ts { return unknownType; } - default: + + default: Debug.fail("Unsupported decorator target."); return unknownType; } @@ -7453,7 +8176,7 @@ namespace ts { /** * Returns the effective argument type for the third argument to a decorator. * If 'node' is a parameter, the effective argument type is the number type. - * If 'node' is a method or accessor, the effective argument type is a + * If 'node' is a method or accessor, the effective argument type is a * `TypedPropertyDescriptor` instantiated with the type of the member. * Class and property decorators do not have a third effective argument. */ @@ -7509,7 +8232,7 @@ namespace ts { * Gets the effective argument type for an argument in a call expression. */ function getEffectiveArgumentType(node: CallLikeExpression, argIndex: number, arg: Expression): Type { - // Decorators provide special arguments, a tagged template expression provides + // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors if (node.kind === SyntaxKind.Decorator) { @@ -7520,12 +8243,12 @@ namespace ts { } // This is not a synthetic argument, so we return 'undefined' - // to signal that the caller needs to check the argument. + // to signal that the caller needs to check the argument. return undefined; } /** - * Gets the effective argument expression for an argument in a call expression. + * Gets the effective argument expression for an argument in a call expression. */ function getEffectiveArgument(node: CallLikeExpression, args: Expression[], argIndex: number) { // For a decorator or the first argument of a tagged template expression we return undefined. @@ -7591,7 +8314,7 @@ namespace ts { // For a tagged template, then the first argument be 'undefined' if necessary // because it represents a TemplateStringsArray. // - // For a decorator, no arguments are susceptible to contextual typing due to the fact + // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. let excludeArgument: boolean[]; if (!isDecorator) { @@ -7854,7 +8577,7 @@ namespace ts { let expressionType = checkExpression(node.expression); - // If ConstructExpr's apparent type(section 3.8.1) is an object type with one or + // If expressionType's apparent type(section 3.8.1) is an object type with one or // more construct signatures, the expression is processed in the same manner as a // function call, but using the construct signatures as the initial set of candidate // signatures for overload resolution. The result type of the function call becomes @@ -7865,8 +8588,18 @@ namespace ts { return resolveErrorCall(node); } + // If the expression is a class of abstract type, then it cannot be instantiated. + // Note, only class declarations can be declared abstract. + // In the case of a merged class-module or class-interface declaration, + // only the class declaration node will have the Abstract flag set. + let valueDecl = expressionType.symbol && getDeclarationOfKind(expressionType.symbol, SyntaxKind.ClassDeclaration); + if (valueDecl && valueDecl.flags & NodeFlags.Abstract) { + error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name)); + return resolveErrorCall(node); + } + // TS 1.0 spec: 4.11 - // If ConstructExpr is of type Any, Args can be any argument + // If expressionType is of type Any, Args can be any argument // list and the result of the operation is of type Any. if (isTypeAny(expressionType)) { if (node.typeArguments) { @@ -7884,7 +8617,7 @@ namespace ts { return resolveCall(node, constructSignatures, candidatesOutArray); } - // If ConstructExpr's apparent type is an object type with no construct signatures but + // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. @@ -8003,6 +8736,11 @@ namespace ts { return links.resolvedSignature; } + /** + * Syntactically and semantically checks a call or new expression. + * @param node The call/new expression to be checked. + * @returns On success, the expression's signature's return type. On failure, anyType. + */ function checkCallExpression(node: CallExpression): Type { // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); @@ -8013,6 +8751,7 @@ namespace ts { } if (node.kind === SyntaxKind.NewExpression) { let declaration = signature.declaration; + if (declaration && declaration.kind !== SyntaxKind.Constructor && declaration.kind !== SyntaxKind.ConstructSignature && @@ -8032,7 +8771,7 @@ namespace ts { return getReturnTypeOfSignature(getResolvedSignature(node)); } - function checkTypeAssertion(node: TypeAssertion): Type { + function checkAssertion(node: AssertionExpression) { let exprType = checkExpression(node.expression); let targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { @@ -8064,14 +8803,35 @@ namespace ts { } } + function createPromiseType(promisedType: Type): Type { + // creates a `Promise` type where `T` is the promisedType argument + let globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyObjectType) { + // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type + promisedType = getAwaitedType(promisedType); + return createTypeReference(globalPromiseType, [promisedType]); + } + + return emptyObjectType; + } + function getReturnTypeFromBody(func: FunctionLikeDeclaration, contextualMapper?: TypeMapper): Type { let contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (!func.body) { return unknownType; } + + let isAsync = isAsyncFunctionLike(func); let type: Type; if (func.body.kind !== SyntaxKind.Block) { type = checkExpressionCached(func.body, contextualMapper); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body should be unwrapped to its awaited type, which we will wrap in + // the native Promise type later in this function. + type = checkAwaitedType(type, func, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } } else { let types: Type[]; @@ -8088,12 +8848,23 @@ namespace ts { } } else { - types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); + types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); if (types.length === 0) { - return voidType; + if (isAsync) { + // For an async function, the return type will not be void, but rather a Promise for void. + let promiseType = createPromiseType(voidType); + if (promiseType === emptyObjectType) { + error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + + return promiseType; + } + else { + return voidType; + } } } - // When yield/return statements are contextually typed we allow the return type to be a union type. // Otherwise we require the yield/return expressions to have a best common supertype. type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); @@ -8115,7 +8886,23 @@ namespace ts { if (!contextualSignature) { reportErrorsFromWidening(func, type); } - return getWidenedType(type); + + let widenedType = getWidenedType(type); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body is awaited type of the body, wrapped in a native Promise type. + let promiseType = createPromiseType(widenedType); + if (promiseType === emptyObjectType) { + error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + + return promiseType; + } + else { + return widenedType; + } } function checkAndAggregateYieldOperandTypes(body: Block, contextualMapper?: TypeMapper): Type[] { @@ -8140,13 +8927,21 @@ namespace ts { return aggregatedTypes; } - function checkAndAggregateReturnExpressionTypes(body: Block, contextualMapper?: TypeMapper): Type[] { + function checkAndAggregateReturnExpressionTypes(body: Block, contextualMapper?: TypeMapper, isAsync?: boolean): Type[] { let aggregatedTypes: Type[] = []; forEachReturnStatement(body, returnStatement => { let expr = returnStatement.expression; if (expr) { let type = checkExpressionCached(expr, contextualMapper); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body should be unwrapped to its awaited type, which should be wrapped in + // the native Promise type by the caller. + type = checkAwaitedType(type, body.parent, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } + if (!contains(aggregatedTypes, type)) { aggregatedTypes.push(type); } @@ -8216,6 +9011,12 @@ namespace ts { if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; } + + let isAsync = isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + let links = getNodeLinks(node); let type = getTypeOfSymbol(node.symbol); // Check if function expression is contextually typed and assign parameter types if so @@ -8252,8 +9053,20 @@ namespace ts { function checkFunctionExpressionOrObjectLiteralMethodBody(node: FunctionExpression | MethodDeclaration) { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); - if (node.type && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); + + let isAsync = isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + + let returnType = node.type && getTypeFromTypeNode(node.type); + let promisedType: Type; + if (returnType && isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + + if (returnType && !node.asteriskToken) { + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } if (node.body) { @@ -8270,10 +9083,22 @@ namespace ts { checkSourceElement(node.body); } else { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so we + // should not be checking assignability of a promise to the return type. Instead, we need to + // check assignability of the awaited type of the expression body against the promised type of + // its return type annotation. let exprType = checkExpression(node.body); - if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, /*headMessage*/ undefined); + if (returnType) { + if (isAsync) { + let awaitedType = checkAwaitedType(exprType, node.body, Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, promisedType, node.body); + } + else { + checkTypeAssignableTo(exprType, returnType, node.body); + } } + checkFunctionAndClassExpressionBodies(node.body); } } @@ -8380,6 +9205,22 @@ namespace ts { return undefinedType; } + function checkAwaitExpression(node: AwaitExpression): Type { + // Grammar checking + if (produceDiagnostics) { + if (!(node.parserContextFlags & ParserContextFlags.Await)) { + grammarErrorOnFirstToken(node, Diagnostics.await_expression_is_only_allowed_within_an_async_function); + } + + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); + } + } + + let operandType = checkExpression(node.expression); + return checkAwaitedType(operandType, node); + } + function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type { let operandType = checkExpression(node.operand); switch (node.operator) { @@ -8424,8 +9265,8 @@ namespace ts { if (type.flags & kind) { return true; } - if (type.flags & TypeFlags.Union) { - let types = (type).types; + if (type.flags & TypeFlags.UnionOrIntersection) { + let types = (type).types; for (let current of types) { if (current.flags & kind) { return true; @@ -8436,13 +9277,13 @@ namespace ts { return false; } - // Return true if type has the given flags, or is a union type composed of types that all have those flags. + // Return true if type has the given flags, or is a union or intersection type composed of types that all have those flags. function allConstituentTypesHaveKind(type: Type, kind: TypeFlags): boolean { if (type.flags & kind) { return true; } - if (type.flags & TypeFlags.Union) { - let types = (type).types; + if (type.flags & TypeFlags.UnionOrIntersection) { + let types = (type).types; for (let current of types) { if (!(current.flags & kind)) { return false; @@ -8500,8 +9341,8 @@ namespace ts { let type = isTypeAny(sourceType) ? sourceType : getTypeOfPropertyOfType(sourceType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || - getIndexTypeOfType(sourceType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || + getIndexTypeOfType(sourceType, IndexKind.String); if (type) { checkDestructuringAssignment((p).initializer || name, type); } @@ -8689,7 +9530,7 @@ namespace ts { if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - // Fall through + // Fall through case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: @@ -8717,8 +9558,8 @@ namespace ts { function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean { let offendingSymbolOperand = someConstituentTypeHasKind(leftType, TypeFlags.ESSymbol) ? node.left : - someConstituentTypeHasKind(rightType, TypeFlags.ESSymbol) ? node.right : - undefined; + someConstituentTypeHasKind(rightType, TypeFlags.ESSymbol) ? node.right : + undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator)); return false; @@ -8785,8 +9626,14 @@ namespace ts { function checkYieldExpression(node: YieldExpression): Type { // Grammar checking - if (!(node.parserContextFlags & ParserContextFlags.Yield) || isYieldExpressionInClass(node)) { - grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + if (produceDiagnostics) { + if (!(node.parserContextFlags & ParserContextFlags.Yield) || isYieldExpressionInClass(node)) { + grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + } + + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); + } } if (node.expression) { @@ -8973,8 +9820,6 @@ namespace ts { return checkCallExpression(node); case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); - case SyntaxKind.TypeAssertionExpression: - return checkTypeAssertion(node); case SyntaxKind.ParenthesizedExpression: return checkExpression((node).expression, contextualMapper); case SyntaxKind.ClassExpression: @@ -8984,10 +9829,15 @@ namespace ts { return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case SyntaxKind.TypeOfExpression: return checkTypeOfExpression(node); + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: + return checkAssertion(node); case SyntaxKind.DeleteExpression: return checkDeleteExpression(node); case SyntaxKind.VoidExpression: return checkVoidExpression(node); + case SyntaxKind.AwaitExpression: + return checkAwaitExpression(node); case SyntaxKind.PrefixUnaryExpression: return checkPrefixUnaryExpression(node); case SyntaxKind.PostfixUnaryExpression: @@ -9002,6 +9852,14 @@ namespace ts { return undefinedType; case SyntaxKind.YieldExpression: return checkYieldExpression(node); + case SyntaxKind.JsxExpression: + return checkJsxExpression(node); + case SyntaxKind.JsxElement: + return checkJsxElement(node); + case SyntaxKind.JsxSelfClosingElement: + return checkJsxSelfClosingElement(node); + case SyntaxKind.JsxOpeningElement: + Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; } @@ -9260,6 +10118,12 @@ namespace ts { // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionLikeDeclaration(node); + + // Abstract methods cannot have an implementation. + // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. + if(node.flags & NodeFlags.Abstract && node.body) { + error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); + } } function checkConstructorDeclaration(node: ConstructorDeclaration) { @@ -9444,7 +10308,7 @@ namespace ts { forEach(node.elementTypes, checkSourceElement); } - function checkUnionType(node: UnionTypeNode) { + function checkUnionOrIntersectionType(node: UnionOrIntersectionTypeNode) { forEach(node.types, checkSourceElement); } @@ -9494,7 +10358,7 @@ namespace ts { error(signatureDeclarationNode, Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); } - function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags) { + function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags): NodeFlags { let flags = getCombinedNodeFlags(n); if (n.parent.kind !== SyntaxKind.InterfaceDeclaration && isInAmbientContext(n)) { if (!(flags & NodeFlags.Ambient)) { @@ -9540,6 +10404,9 @@ namespace ts { else if (deviation & (NodeFlags.Private | NodeFlags.Protected)) { error(o.name, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } + else if (deviation & NodeFlags.Abstract) { + error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + } }); } } @@ -9556,7 +10423,7 @@ namespace ts { } } - let flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.Protected; + let flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.Protected | NodeFlags.Abstract; let someNodeFlags: NodeFlags = 0; let allNodeFlags = flagsToCheck; let someHaveQuestionToken = false; @@ -9606,7 +10473,14 @@ namespace ts { error(errorNode, Diagnostics.Constructor_implementation_is_missing); } else { - error(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + // Report different errors regarding non-consecutive blocks of declarations depending on whether + // the node in question is abstract. + if (node.flags & NodeFlags.Abstract) { + error(errorNode, Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); + } + else { + error(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + } } } @@ -9678,7 +10552,9 @@ namespace ts { }); } - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body) { + // Abstract methods can't have an implementation -- in particular, they don't need one. + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && + !(lastSeenNonAmbientDeclaration.flags & NodeFlags.Abstract) ) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } @@ -9789,6 +10665,260 @@ namespace ts { } } + function checkNonThenableType(type: Type, location?: Node, message?: DiagnosticMessage) { + if (!(type.flags & TypeFlags.Any) && isTypeAssignableTo(type, getGlobalThenableType())) { + if (location) { + if (!message) { + message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; + } + + error(location, message); + } + + return unknownType; + } + + return type; + } + + /** + * Gets the "promised type" of a promise. + * @param type The type of the promise. + * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. + */ + function getPromisedType(promise: Type): Type { + // + // { // promise + // then( // thenFunction + // onfulfilled: ( // onfulfilledParameterType + // value: T // valueParameterType + // ) => any + // ): any; + // } + // + + if (promise.flags & TypeFlags.Any) { + return undefined; + } + + if ((promise.flags & TypeFlags.Reference) && (promise).target === tryGetGlobalPromiseType()) { + return (promise).typeArguments[0]; + } + + let globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); + if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { + return undefined; + } + + let thenFunction = getTypeOfPropertyOfType(promise, "then"); + if (thenFunction && (thenFunction.flags & TypeFlags.Any)) { + return undefined; + } + + let thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, SignatureKind.Call) : emptyArray; + if (thenSignatures.length === 0) { + return undefined; + } + + let onfulfilledParameterType = getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)); + if (onfulfilledParameterType.flags & TypeFlags.Any) { + return undefined; + } + + let onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, SignatureKind.Call); + if (onfulfilledParameterSignatures.length === 0) { + return undefined; + } + + let valueParameterType = getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); + return valueParameterType; + } + + function getTypeOfFirstParameterOfSignature(signature: Signature) { + return getTypeAtPosition(signature, 0); + } + + /** + * Gets the "awaited type" of a type. + * @param type The type to await. + * @remarks The "awaited type" of an expression is its "promised type" if the expression is a + * Promise-like type; otherwise, it is the type of the expression. This is used to reflect + * The runtime behavior of the `await` keyword. + */ + function getAwaitedType(type: Type) { + return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); + } + + function checkAwaitedType(type: Type, location?: Node, message?: DiagnosticMessage) { + return checkAwaitedTypeWorker(type); + + function checkAwaitedTypeWorker(type: Type): Type { + if (type.flags & TypeFlags.Union) { + let types: Type[] = []; + for (let constituentType of (type).types) { + types.push(checkAwaitedTypeWorker(constituentType)); + } + + return getUnionType(types); + } + else { + let promisedType = getPromisedType(type); + if (promisedType === undefined) { + // The type was not a PromiseLike, so it could not be unwrapped any further. + // As long as the type does not have a callable "then" property, it is + // safe to return the type; otherwise, an error will have been reported in + // the call to checkNonThenableType and we will return unknownType. + // + // An example of a non-promise "thenable" might be: + // + // await { then(): void {} } + // + // The "thenable" does not match the minimal definition for a PromiseLike. When + // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise + // will never settle. We treat this as an error to help flag an early indicator + // of a runtime problem. If the user wants to return this value from an async + // function, they would need to wrap it in some other value. If they want it to + // be treated as a promise, they can cast to . + return checkNonThenableType(type, location, message); + } + else { + if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { + // We have a bad actor in the form of a promise whose promised type is + // the same promise type, or a mutually recursive promise. Return the + // unknown type as we cannot guess the shape. If this were the actual + // case in the JavaScript, this Promise would never resolve. + // + // An example of a bad actor with a singly-recursive promise type might + // be: + // + // interface BadPromise { + // then( + // onfulfilled: (value: BadPromise) => any, + // onrejected: (error: any) => any): BadPromise; + // } + // + // The above interface will pass the PromiseLike check, and return a + // promised type of `BadPromise`. Since this is a self reference, we + // don't want to keep recursing ad infinitum. + // + // An example of a bad actor in the form of a mutually-recursive + // promise type might be: + // + // interface BadPromiseA { + // then( + // onfulfilled: (value: BadPromiseB) => any, + // onrejected: (error: any) => any): BadPromiseB; + // } + // + // interface BadPromiseB { + // then( + // onfulfilled: (value: BadPromiseA) => any, + // onrejected: (error: any) => any): BadPromiseA; + // } + // + if (location) { + error( + location, + Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, + symbolToString(type.symbol)); + } + + return unknownType; + } + + // Keep track of the type we're about to unwrap to avoid bad recursive promise types. + // See the comments above for more information. + awaitedTypeStack.push(type.id); + let awaitedType = checkAwaitedTypeWorker(promisedType); + awaitedTypeStack.pop(); + return awaitedType; + } + } + } + } + + /** + * Checks the return type of an async function to ensure it is a compatible + * Promise implementation. + * @param node The signature to check + * @param returnType The return type for the function + * @remarks + * This checks that an async function has a valid Promise-compatible return type, + * and returns the *awaited type* of the promise. An async function has a valid + * Promise-compatible return type if the resolved value of the return type has a + * construct signature that takes in an `initializer` function that in turn supplies + * a `resolve` function as one of its arguments and results in an object with a + * callable `then` signature. + */ + function checkAsyncFunctionReturnType(node: FunctionLikeDeclaration): Type { + let globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + // If we couldn't resolve the global PromiseConstructorLike type we cannot verify + // compatibility with __awaiter. + return unknownType; + } + + // As part of our emit for an async function, we will need to emit the entity name of + // the return type annotation as an expression. To meet the necessary runtime semantics + // for __awaiter, we must also check that the type of the declaration (e.g. the static + // side or "constructor" of the promise type) is compatible `PromiseConstructorLike`. + // + // An example might be (from lib.es6.d.ts): + // + // interface Promise { ... } + // interface PromiseConstructor { + // new (...): Promise; + // } + // declare var Promise: PromiseConstructor; + // + // When an async function declares a return type annotation of `Promise`, we + // need to get the type of the `Promise` variable declaration above, which would + // be `PromiseConstructor`. + // + // The same case applies to a class: + // + // declare class Promise { + // constructor(...); + // then(...): Promise; + // } + // + // When we get the type of the `Promise` symbol here, we get the type of the static + // side of the `Promise` class, which would be `{ new (...): Promise }`. + + let promiseType = getTypeFromTypeNode(node.type); + if (promiseType === unknownType && compilerOptions.isolatedModules) { + // If we are compiling with isolatedModules, we may not be able to resolve the + // type as a value. As such, we will just return unknownType; + return unknownType; + } + + let promiseConstructor = getMergedSymbol(promiseType.symbol); + if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { + error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + return unknownType + } + + // Validate the promise constructor type. + let promiseConstructorType = getTypeOfSymbol(promiseConstructor); + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { + return unknownType; + } + + // Verify there is no local declaration that could collide with the promise constructor. + let promiseName = getEntityNameFromTypeNode(node.type); + let root = getFirstIdentifier(promiseName); + let rootSymbol = getSymbol(node.locals, root.text, SymbolFlags.Value); + if (rootSymbol) { + error(rootSymbol.valueDeclaration, Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, + root.text, + getFullyQualifiedName(promiseConstructor)); + return unknownType; + } + + // Get and return the awaited type of the return type. + return checkAwaitedType(promiseType, node, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + } + /** Check a decorator */ function checkDecorator(node: Decorator): void { let signature = getResolvedSignature(node); @@ -9842,7 +10972,7 @@ namespace ts { /** Checks a type reference node as an expression. */ function checkTypeNodeAsExpression(node: TypeNode) { // When we are emitting type metadata for decorators, we need to try to check the type - // as if it were an expression so that we can emit the type in a value position when we + // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. if (node && node.kind === SyntaxKind.TypeReference) { let type = getTypeFromTypeNode(node); @@ -9857,7 +10987,7 @@ namespace ts { } /** - * Checks the type annotation of an accessor declaration or property declaration as + * Checks the type annotation of an accessor declaration or property declaration as * an expression if it is a type reference to a type with a value declaration. */ function checkTypeAnnotationAsExpression(node: AccessorDeclaration | PropertyDeclaration | ParameterDeclaration | MethodDeclaration) { @@ -9916,7 +11046,7 @@ namespace ts { case SyntaxKind.MethodDeclaration: checkParameterTypeAnnotationsAsExpressions(node); - // fall-through + // fall-through case SyntaxKind.SetAccessor: case SyntaxKind.GetAccessor: @@ -9948,6 +11078,14 @@ namespace ts { function checkFunctionLikeDeclaration(node: FunctionLikeDeclaration): void { checkDecorators(node); checkSignatureDeclaration(node); + let isAsync = isAsyncFunctionLike(node); + if (isAsync) { + if (!compilerOptions.experimentalAsyncFunctions) { + error(node, Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); + } + + emitAwaiter = true; + } // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including @@ -9982,7 +11120,13 @@ namespace ts { checkSourceElement(node.body); if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); + let returnType = getTypeFromTypeNode(node.type); + let promisedType: Type; + if (isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { @@ -10312,7 +11456,14 @@ namespace ts { function checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node: Node) { if (node.modifiers) { if (inBlockOrObjectLiteralExpression(node)) { - return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); + if (isAsyncFunctionLike(node)) { + if (node.modifiers.length > 1) { + return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); + } + } + else { + return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); + } } } } @@ -10325,6 +11476,8 @@ namespace ts { node = node.parent; } + + return false; } function checkExpressionStatement(node: ExpressionStatement) { @@ -10757,14 +11910,26 @@ namespace ts { } } else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { - checkTypeAssignableTo(exprType, returnType, node.expression, /*headMessage*/ undefined); + if (isAsyncFunctionLike(func)) { + let promisedType = getPromisedType(returnType); + let awaitedType = checkAwaitedType(exprType, node.expression, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } + else { + checkTypeAssignableTo(exprType, returnType, node.expression); + } } } } } function checkWithStatement(node: WithStatement) { - checkGrammarStatementInAmbientContext(node); + // Grammar checking for withStatement + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.parserContextFlags & ParserContextFlags.Await) { + grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); + } + } checkExpression(node.expression); error(node.expression, Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); @@ -11009,6 +12174,12 @@ namespace ts { grammarErrorOnFirstToken(node, Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); + + // Interfaces cannot be merged with non-ambient classes. + if (getSymbolOfNode(node).flags & SymbolFlags.Interface && !isInAmbientContext(node)) { + error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface) + } + forEach(node.members, checkSourceElement); } @@ -11044,6 +12215,7 @@ namespace ts { checkTypeAssignableTo(type, baseType, 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 (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class)) { // 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 @@ -11118,45 +12290,67 @@ namespace ts { } let derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); + let baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); + + Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); + if (derived) { - let baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); - let derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) { - // either base or derived property is private - not override, skip it - continue; - } + // In order to resolve whether the inherited method was overriden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration - if ((baseDeclarationFlags & NodeFlags.Static) !== (derivedDeclarationFlags & NodeFlags.Static)) { - // value of 'static' is not the same for properties - not override, skip it - continue; - } + let derivedClassDecl = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); - if ((base.flags & derived.flags & SymbolFlags.Method) || ((base.flags & SymbolFlags.PropertyOrAccessor) && (derived.flags & SymbolFlags.PropertyOrAccessor))) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; - } - - let errorMessage: DiagnosticMessage; - if (base.flags & SymbolFlags.Method) { - if (derived.flags & SymbolFlags.Accessor) { - errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if ( baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) { + error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, + typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } - else { - Debug.assert((derived.flags & SymbolFlags.Property) !== 0); - errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - else if (base.flags & SymbolFlags.Property) { - Debug.assert((derived.flags & SymbolFlags.Method) !== 0); - errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - Debug.assert((base.flags & SymbolFlags.Accessor) !== 0); - Debug.assert((derived.flags & SymbolFlags.Method) !== 0); - errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } + // derived overrides base. + let derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); + if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) { + // either base or derived property is private - not override, skip it + continue; + } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + if ((baseDeclarationFlags & NodeFlags.Static) !== (derivedDeclarationFlags & NodeFlags.Static)) { + // value of 'static' is not the same for properties - not override, skip it + continue; + } + + if ((base.flags & derived.flags & SymbolFlags.Method) || ((base.flags & SymbolFlags.PropertyOrAccessor) && (derived.flags & SymbolFlags.PropertyOrAccessor))) { + // method is overridden with method or property/accessor is overridden with property/accessor - correct case + continue; + } + + let errorMessage: DiagnosticMessage; + if (base.flags & SymbolFlags.Method) { + if (derived.flags & SymbolFlags.Accessor) { + errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + Debug.assert((derived.flags & SymbolFlags.Property) !== 0); + errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + else if (base.flags & SymbolFlags.Property) { + Debug.assert((derived.flags & SymbolFlags.Method) !== 0); + errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + Debug.assert((base.flags & SymbolFlags.Accessor) !== 0); + Debug.assert((derived.flags & SymbolFlags.Method) !== 0); + errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + + error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + } } } } @@ -11258,6 +12452,16 @@ namespace ts { checkIndexConstraints(type); } } + + // Interfaces cannot merge with non-ambient classes. + if (symbol && symbol.declarations) { + for (let declaration of symbol.declarations) { + if (declaration.kind === SyntaxKind.ClassDeclaration && !isInAmbientContext(declaration)) { + error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); + break; + } + } + } } forEach(getInterfaceBaseTypeNodes(node), heritageElement => { if (!isSupportedExpressionWithTypeArguments(heritageElement)) { @@ -11265,6 +12469,7 @@ namespace ts { } checkTypeReferenceNode(heritageElement); }); + forEach(node.members, checkSourceElement); if (produceDiagnostics) { @@ -11577,7 +12782,7 @@ namespace ts { } } - // if the module merges with a class declaration in the same lexical scope, + // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. let mergedClass = getDeclarationOfKind(symbol, SyntaxKind.ClassDeclaration); if (mergedClass && @@ -11843,8 +13048,24 @@ namespace ts { } function checkSourceElement(node: Node): void { - if (!node) return; - switch (node.kind) { + if (!node) { + return; + } + + let kind = node.kind; + if (cancellationToken) { + // Only bother checking on a few construct kinds. We don't want to be excessivly + // hitting the cancellation token on every node we check. + switch (kind) { + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.FunctionDeclaration: + cancellationToken.throwIfCancellationRequested(); + } + } + + switch (kind) { case SyntaxKind.TypeParameter: return checkTypeParameter(node); case SyntaxKind.Parameter: @@ -11880,7 +13101,8 @@ namespace ts { case SyntaxKind.TupleType: return checkTupleType(node); case SyntaxKind.UnionType: - return checkUnionType(node); + case SyntaxKind.IntersectionType: + return checkUnionOrIntersectionType(node); case SyntaxKind.ParenthesizedType: return checkSourceElement((node).type); case SyntaxKind.FunctionDeclaration: @@ -12006,15 +13228,18 @@ namespace ts { case SyntaxKind.TemplateExpression: case SyntaxKind.TemplateSpan: case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.TypeOfExpression: case SyntaxKind.VoidExpression: + case SyntaxKind.AwaitExpression: case SyntaxKind.DeleteExpression: case SyntaxKind.PrefixUnaryExpression: case SyntaxKind.PostfixUnaryExpression: case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.SpreadElementExpression: + case SyntaxKind.YieldExpression: case SyntaxKind.Block: case SyntaxKind.ModuleBlock: case SyntaxKind.VariableStatement: @@ -12043,6 +13268,12 @@ namespace ts { case SyntaxKind.EnumMember: case SyntaxKind.ExportAssignment: case SyntaxKind.SourceFile: + case SyntaxKind.JsxExpression: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxAttribute: + case SyntaxKind.JsxSpreadAttribute: + case SyntaxKind.JsxOpeningElement: forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -12098,11 +13329,32 @@ namespace ts { links.flags |= NodeCheckFlags.EmitParam; } + if (emitAwaiter) { + links.flags |= NodeCheckFlags.EmitAwaiter; + } + + if (emitGenerator || (emitAwaiter && languageVersion < ScriptTarget.ES6)) { + links.flags |= NodeCheckFlags.EmitGenerator; + } + links.flags |= NodeCheckFlags.TypeChecked; } } - function getDiagnostics(sourceFile?: SourceFile): Diagnostic[] { + function getDiagnostics(sourceFile: SourceFile, ct: CancellationToken): Diagnostic[] { + try { + // Record the cancellation token so it can be checked later on during checkSourceElement. + // Do this in a finally block so we can ensure that it gets reset back to nothing after + // this call is done. + cancellationToken = ct; + return getDiagnosticsWorker(sourceFile); + } + finally { + cancellationToken = undefined; + } + } + + function getDiagnosticsWorker(sourceFile: SourceFile): Diagnostic[] { throwIfNonDiagnosticsProducing(); if (sourceFile) { checkSourceFile(sourceFile); @@ -12172,7 +13424,7 @@ namespace ts { if ((location).name) { copySymbol(location.symbol, meaning); } - // Fall through + // Fall through case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: if (!(memberFlags & NodeFlags.Static)) { @@ -12296,6 +13548,9 @@ namespace ts { meaning |= SymbolFlags.Alias; return resolveEntityName(entityName, meaning); } + else if ((entityName.parent.kind === SyntaxKind.JsxOpeningElement) || (entityName.parent.kind === SyntaxKind.JsxSelfClosingElement)) { + return getJsxElementTagSymbol(entityName.parent); + } else if (isExpression(entityName)) { if (nodeIsMissing(entityName)) { // Missing entity name. @@ -12330,6 +13585,9 @@ namespace ts { meaning |= SymbolFlags.Alias; return resolveEntityName(entityName, meaning); } + else if (entityName.parent.kind === SyntaxKind.JsxAttribute) { + return getJsxAttributePropertySymbol(entityName.parent); + } if (entityName.parent.kind === SyntaxKind.TypePredicate) { return resolveEntityName(entityName, /*meaning*/ SymbolFlags.FunctionScopedVariable); @@ -12383,8 +13641,8 @@ namespace ts { (node.parent).moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } + // Fall through - // fall through case SyntaxKind.NumericLiteral: // index access if (node.parent.kind === SyntaxKind.ElementAccessExpression && (node.parent).argumentExpression === node) { @@ -12464,6 +13722,7 @@ namespace ts { return unknownType; } + function getTypeOfExpression(expr: Expression): Type { if (isRightSideOfQualifiedNameOrPropertyAccess(expr)) { expr = expr.parent; @@ -12472,7 +13731,7 @@ namespace ts { } /** - * Gets either the static or instance type of a class element, based on + * Gets either the static or instance type of a class element, based on * whether the element is declared as "static". */ function getParentTypeOfClassElement(node: ClassElement) { @@ -12498,10 +13757,10 @@ namespace ts { } function getRootSymbols(symbol: Symbol): Symbol[] { - if (symbol.flags & SymbolFlags.UnionProperty) { + if (symbol.flags & SymbolFlags.SyntheticProperty) { let symbols: Symbol[] = []; let name = symbol.name; - forEach(getSymbolLinks(symbol).unionType.types, t => { + forEach(getSymbolLinks(symbol).containingType.types, t => { symbols.push(getPropertyOfType(t, name)); }); return symbols; @@ -12571,7 +13830,7 @@ namespace ts { if (links.isNestedRedeclaration === undefined) { let container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } return links.isNestedRedeclaration; } @@ -12798,6 +14057,7 @@ namespace ts { case SyntaxKind.TypeQuery: case SyntaxKind.TypeLiteral: case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: case SyntaxKind.AnyKeyword: break; default: @@ -12819,7 +14079,7 @@ namespace ts { // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. // * The serialized type of any other FunctionLikeDeclaration is "Function". // * The serialized type of any other node is "void 0". - // + // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { case SyntaxKind.ClassDeclaration: return "Function"; @@ -12840,7 +14100,7 @@ namespace ts { // // * If the declaration is a class, the parameters of the first constructor with a body are used. // * If the declaration is function-like and has a body, the parameters of the function are used. - // + // // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { let valueDeclaration: FunctionLikeDeclaration; @@ -13018,7 +14278,19 @@ namespace ts { globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); + jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); + getGlobalClassDecoratorType = memoize(() => getGlobalType("ClassDecorator")); + getGlobalPropertyDecoratorType = memoize(() => getGlobalType("PropertyDecorator")); + getGlobalMethodDecoratorType = memoize(() => getGlobalType("MethodDecorator")); + getGlobalParameterDecoratorType = memoize(() => getGlobalType("ParameterDecorator")); getGlobalTypedPropertyDescriptorType = memoize(() => getGlobalType("TypedPropertyDescriptor", /*arity*/ 1)); + getGlobalPromiseType = memoize(() => getGlobalType("Promise", /*arity*/ 1)); + tryGetGlobalPromiseType = memoize(() => getGlobalSymbol("Promise", SymbolFlags.Type, /*diagnostic*/ undefined) && getGlobalPromiseType()); + getGlobalPromiseLikeType = memoize(() => getGlobalType("PromiseLike", /*arity*/ 1)); + getInstantiatedGlobalPromiseLikeType = memoize(createInstantiatedPromiseLikeType); + getGlobalPromiseConstructorSymbol = memoize(() => getGlobalValueSymbol("Promise")); + getGlobalPromiseConstructorLikeType = memoize(() => getGlobalType("PromiseConstructorLike")); + getGlobalThenableType = memoize(createThenableType); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. @@ -13046,8 +14318,29 @@ namespace ts { anyArrayType = createArrayType(anyType); } - // GRAMMAR CHECKING + function createInstantiatedPromiseLikeType(): ObjectType { + let promiseLikeType = getGlobalPromiseLikeType(); + if (promiseLikeType !== emptyObjectType) { + return createTypeReference(promiseLikeType, [anyType]); + } + return emptyObjectType; + } + + function createThenableType() { + // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. + let thenPropertySymbol = createSymbol(SymbolFlags.Transient | SymbolFlags.Property, "then"); + getSymbolLinks(thenPropertySymbol).type = globalFunctionType; + + let thenableType = createObjectType(TypeFlags.Anonymous); + thenableType.properties = [thenPropertySymbol]; + thenableType.members = createSymbolTable(thenableType.properties); + thenableType.callSignatures = []; + thenableType.constructSignatures = []; + return thenableType; + } + + // GRAMMAR CHECKING function checkGrammarDecorators(node: Node): boolean { if (!node.decorators) { return false; @@ -13084,10 +14377,15 @@ namespace ts { case SyntaxKind.ExportAssignment: case SyntaxKind.Parameter: break; + case SyntaxKind.FunctionDeclaration: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== SyntaxKind.AsyncKeyword) && + node.parent.kind !== SyntaxKind.ModuleBlock && node.parent.kind !== SyntaxKind.SourceFile) { + return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); + } + break; case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.VariableStatement: - case SyntaxKind.FunctionDeclaration: case SyntaxKind.TypeAliasDeclaration: if (node.modifiers && node.parent.kind !== SyntaxKind.ModuleBlock && node.parent.kind !== SyntaxKind.SourceFile) { return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); @@ -13107,7 +14405,7 @@ namespace ts { return; } - let lastStatic: Node, lastPrivate: Node, lastProtected: Node, lastDeclare: Node; + let lastStatic: Node, lastPrivate: Node, lastProtected: Node, lastDeclare: Node, lastAsync: Node; let flags = 0; for (let modifier of node.modifiers) { switch (modifier.kind) { @@ -13133,9 +14431,20 @@ namespace ts { else if (flags & NodeFlags.Static) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); + } else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } + else if (flags & NodeFlags.Abstract) { + if (modifier.kind === SyntaxKind.PrivateKeyword) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); + } + else { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); + } + } flags |= modifierToFlag(modifier.kind); break; @@ -13143,12 +14452,18 @@ namespace ts { if (flags & NodeFlags.Static) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "static"); } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); + } else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } else if (node.kind === SyntaxKind.Parameter) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } + else if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } flags |= NodeFlags.Static; lastStatic = modifier; break; @@ -13160,6 +14475,12 @@ namespace ts { else if (flags & NodeFlags.Ambient) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } + else if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); + } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); + } else if (node.parent.kind === SyntaxKind.ClassDeclaration) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } @@ -13173,6 +14494,9 @@ namespace ts { if (flags & NodeFlags.Ambient) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "declare"); } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } else if (node.parent.kind === SyntaxKind.ClassDeclaration) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } @@ -13184,7 +14508,43 @@ namespace ts { } flags |= NodeFlags.Ambient; lastDeclare = modifier; + break; + + case SyntaxKind.AbstractKeyword: + if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "abstract"); + } + if (node.kind !== SyntaxKind.ClassDeclaration) { + if (node.kind !== SyntaxKind.MethodDeclaration) { + return grammarErrorOnNode(modifier, Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + } + if (!(node.parent.kind === SyntaxKind.ClassDeclaration && node.parent.flags & NodeFlags.Abstract)) { + return grammarErrorOnNode(modifier, Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); + } + if (flags & NodeFlags.Static) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + if (flags & NodeFlags.Private) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); + } + } + + flags |= NodeFlags.Abstract; break; + + case SyntaxKind.AsyncKeyword: + if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "async"); + } + else if (flags & NodeFlags.Ambient || isInAmbientContext(node.parent)) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.kind === SyntaxKind.Parameter) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); + } + flags |= NodeFlags.Async; + lastAsync = modifier; + break; } } @@ -13192,19 +14552,48 @@ namespace ts { if (flags & NodeFlags.Static) { return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } + if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); + } else if (flags & NodeFlags.Protected) { return grammarErrorOnNode(lastProtected, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } else if (flags & NodeFlags.Private) { return grammarErrorOnNode(lastPrivate, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(lastAsync, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); + } + return; } else if ((node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration) && flags & NodeFlags.Ambient) { - return grammarErrorOnNode(lastDeclare, Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); + return grammarErrorOnNode(lastDeclare, Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === SyntaxKind.Parameter && (flags & NodeFlags.AccessibilityModifier) && isBindingPattern((node).name)) { return grammarErrorOnNode(node, Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } + if (flags & NodeFlags.Async) { + return checkGrammarAsyncModifier(node, lastAsync); + } + } + + function checkGrammarAsyncModifier(node: Node, asyncModifier: Node): boolean { + if (languageVersion < ScriptTarget.ES6) { + return grammarErrorOnNode(asyncModifier, Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + + switch (node.kind) { + case SyntaxKind.MethodDeclaration: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + if (!(node).asteriskToken) { + return false; + } + break; + } + + return grammarErrorOnNode(asyncModifier, Diagnostics._0_modifier_cannot_be_used_here, "async"); } function checkGrammarForDisallowedTrailingComma(list: NodeArray): boolean { @@ -13499,13 +14888,13 @@ namespace ts { let currentKind: number; if (prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment) { // Grammar checking for computedPropertName and shorthandPropertyAssignment - checkGrammarForInvalidQuestionMark(prop,(prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); + checkGrammarForInvalidQuestionMark(prop, (prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === SyntaxKind.NumericLiteral) { checkGrammarNumericLiteral(name); } currentKind = Property; } - else if ( prop.kind === SyntaxKind.MethodDeclaration) { + else if (prop.kind === SyntaxKind.MethodDeclaration) { currentKind = Property; } else if (prop.kind === SyntaxKind.GetAccessor) { @@ -13541,6 +14930,29 @@ namespace ts { } } + function checkGrammarJsxElement(node: JsxOpeningElement|JsxSelfClosingElement) { + const seen: Map = {}; + for (let attr of node.attributes) { + if (attr.kind === SyntaxKind.JsxSpreadAttribute) { + continue; + } + + let jsxAttr = (attr); + let name = jsxAttr.name; + if (!hasProperty(seen, name.text)) { + seen[name.text] = true; + } + else { + return grammarErrorOnNode(name, Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + } + + let initializer = jsxAttr.initializer; + if (initializer && initializer.kind === SyntaxKind.JsxExpression && !(initializer).expression) { + return grammarErrorOnNode(jsxAttr.initializer, Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); + } + } + } + function checkGrammarForInOrForOfStatement(forInOrOfStatement: ForInStatement | ForOfStatement): boolean { if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; @@ -13769,7 +15181,7 @@ namespace ts { } } - let checkLetConstNames = languageVersion >= ScriptTarget.ES6 && (isLet(node) || isConst(node)); + let checkLetConstNames = languageVersion >= ScriptTarget.ES6 && (isLet(node) || isConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". @@ -13917,6 +15329,11 @@ namespace ts { } } + function isEvalOrArgumentsIdentifier(node: Node): boolean { + return node.kind === SyntaxKind.Identifier && + ((node).text === "eval" || (node).text === "arguments"); + } + function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) { if (node.typeParameters) { return grammarErrorAtPos(getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f0f71b4874e..d2eefc4ec9b 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -38,6 +38,16 @@ namespace ts { name: "inlineSources", type: "boolean", }, + { + name: "jsx", + type: { + "preserve": JsxEmit.Preserve, + "react": JsxEmit.React + }, + paramType: Diagnostics.KIND, + description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + error: Diagnostics.Argument_for_jsx_must_be_preserve_or_react + }, { name: "listFiles", type: "boolean", @@ -193,6 +203,11 @@ namespace ts { type: "boolean", description: Diagnostics.Watch_input_files, }, + { + name: "experimentalAsyncFunctions", + type: "boolean", + description: Diagnostics.Enables_experimental_support_for_ES7_async_functions + }, { name: "experimentalDecorators", type: "boolean", @@ -348,7 +363,7 @@ namespace ts { * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse * @param basePath A root directory to resolve relative path entries in the config - * file to. e.g. outDir + * file to. e.g. outDir */ export function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine { let errors: Diagnostic[] = []; @@ -410,10 +425,21 @@ namespace ts { } else { let exclude = json["exclude"] instanceof Array ? map(json["exclude"], normalizeSlashes) : undefined; - let sysFiles = host.readDirectory(basePath, ".ts", exclude); + let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (let i = 0; i < sysFiles.length; i++) { let name = sysFiles[i]; - if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { + if (fileExtensionIs(name, ".d.ts")) { + let baseName = name.substr(0, name.length - ".d.ts".length); + if (!contains(sysFiles, baseName + ".tsx") && !contains(sysFiles, baseName + ".ts")) { + fileNames.push(name); + } + } + else if (fileExtensionIs(name, ".ts")) { + if (!contains(sysFiles, name + "x")) { + fileNames.push(name) + } + } + else { fileNames.push(name); } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index adc212d9dde..322c5193936 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2,17 +2,19 @@ /* @internal */ namespace ts { - // Ternary values are defined such that - // x & y is False if either x or y is False. - // x & y is Maybe if either x or y is Maybe, but neither x or y is False. - // x & y is True if both x and y are True. - // x | y is False if both x and y are False. - // x | y is Maybe if either x or y is Maybe, but neither x or y is True. - // x | y is True if either x or y is True. + /** + * Ternary values are defined such that + * x & y is False if either x or y is False. + * x & y is Maybe if either x or y is Maybe, but neither x or y is False. + * x & y is True if both x and y are True. + * x | y is False if both x and y are False. + * x | y is Maybe if either x or y is Maybe, but neither x or y is True. + * x | y is True if either x or y is True. + */ export const enum Ternary { False = 0, Maybe = 1, - True = -1 + True = -1 } export function createFileMap(getCanonicalFileName: (fileName: string) => string): FileMap { @@ -59,6 +61,11 @@ namespace ts { export interface StringSet extends Map { } + /** + * Iterates through 'array' by index and performs the callback on each element of array until the callback + * returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array and undefined is returned. + */ export function forEach(array: T[], callback: (element: T, index: number) => U): U { if (array) { for (let i = 0, len = array.length; i < len; i++) { @@ -702,9 +709,9 @@ namespace ts { /** * List of supported extensions in order of file resolution precedence. */ - export const supportedExtensions = [".ts", ".d.ts"]; + export const supportedExtensions = [".tsx", ".ts", ".d.ts"]; - const extensionsToRemove = [".d.ts", ".ts", ".js"]; + const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; export function removeFileExtension(path: string): string { for (let ext of extensionsToRemove) { if (fileExtensionIs(path, ext)) { @@ -757,8 +764,8 @@ namespace ts { } Node.prototype = { kind: kind, - pos: 0, - end: 0, + pos: -1, + end: -1, flags: 0, parent: undefined, }; @@ -798,4 +805,4 @@ namespace ts { Debug.assert(false, message); } } -} +} diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 4f722fe12c4..7eaf5cef2cd 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -340,6 +340,8 @@ namespace ts { return emitTupleType(type); case SyntaxKind.UnionType: return emitUnionType(type); + case SyntaxKind.IntersectionType: + return emitIntersectionType(type); case SyntaxKind.ParenthesizedType: return emitParenType(type); case SyntaxKind.FunctionType: @@ -416,6 +418,10 @@ namespace ts { emitSeparatedList(type.types, " | ", emitType); } + function emitIntersectionType(type: IntersectionTypeNode) { + emitSeparatedList(type.types, " & ", emitType); + } + function emitParenType(type: ParenthesizedTypeNode) { write("("); emitType(type.type); @@ -588,6 +594,9 @@ namespace ts { if (node.flags & NodeFlags.Static) { write("static "); } + if (node.flags & NodeFlags.Abstract) { + write("abstract "); + } } function writeImportEqualsDeclaration(node: ImportEqualsDeclaration) { @@ -912,6 +921,10 @@ namespace ts { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); + if (node.flags & NodeFlags.Abstract) { + write("abstract "); + } + write("class "); writeTextOfNode(currentSourceFile, node.name); let prevEnclosingDeclaration = enclosingDeclaration; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index d94777fd561..a17f8857590 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -20,22 +20,21 @@ namespace ts { An_index_signature_must_have_a_type_annotation: { code: 1021, category: DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, - A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, - An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, - A_class_can_only_extend_a_single_class: { code: 1026, category: DiagnosticCategory.Error, key: "A class can only extend a single class." }, - A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: DiagnosticCategory.Error, key: "A class declaration can only have one 'implements' clause." }, Accessibility_modifier_already_seen: { code: 1028, category: DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, _0_modifier_must_precede_1_modifier: { code: 1029, category: DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, _0_modifier_already_seen: { code: 1030, category: DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, - An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: DiagnosticCategory.Error, key: "An interface declaration cannot have an 'implements' clause." }, super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, Only_ambient_modules_can_use_quoted_names: { code: 1035, category: DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, + _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used in an ambient context." }, + _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a class declaration." }, + _0_modifier_cannot_be_used_here: { code: 1042, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used here." }, + _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a data property." }, _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, - A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, + A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, @@ -44,12 +43,18 @@ namespace ts { A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, A_get_accessor_cannot_have_parameters: { code: 1054, category: DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, + Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: DiagnosticCategory.Error, key: "Type '{0}' is not a valid async function return type." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, + An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, + Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." }, + Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: DiagnosticCategory.Error, key: "Return expression in async function does not have a valid callable 'then' member." }, + Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: DiagnosticCategory.Error, key: "Expression body for async arrow function does not have a valid callable 'then' member." }, Enum_member_must_have_initializer: { code: 1061, category: DiagnosticCategory.Error, key: "Enum member must have initializer." }, + _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, - A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, + A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, @@ -94,7 +99,6 @@ namespace ts { case_or_default_expected: { code: 1130, category: DiagnosticCategory.Error, key: "'case' or 'default' expected." }, Property_or_signature_expected: { code: 1131, category: DiagnosticCategory.Error, key: "Property or signature expected." }, Enum_member_expected: { code: 1132, category: DiagnosticCategory.Error, key: "Enum member expected." }, - Type_reference_expected: { code: 1133, category: DiagnosticCategory.Error, key: "Type reference expected." }, Variable_declaration_expected: { code: 1134, category: DiagnosticCategory.Error, key: "Variable declaration expected." }, Argument_expression_expected: { code: 1135, category: DiagnosticCategory.Error, key: "Argument expression expected." }, Property_assignment_expected: { code: 1136, category: DiagnosticCategory.Error, key: "Property assignment expected." }, @@ -111,9 +115,6 @@ namespace ts { Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - var_let_or_const_expected: { code: 1152, category: DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, - let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, @@ -124,7 +125,6 @@ namespace ts { Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, @@ -140,7 +140,6 @@ namespace ts { Property_destructuring_pattern_expected: { code: 1180, category: DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, Array_element_destructuring_pattern_expected: { code: 1181, category: DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts." }, An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, Modifiers_cannot_appear_here: { code: 1184, category: DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, Merge_conflict_marker_encountered: { code: 1185, category: DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, @@ -191,12 +190,20 @@ namespace ts { An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, + Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, + abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: DiagnosticCategory.Error, key: "'abstract' modifier can only appear on a class or method declaration." }, + _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, + Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -205,7 +212,6 @@ namespace ts { Module_0_has_no_exported_member_1: { code: 2305, category: DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, File_0_is_not_a_module: { code: 2306, category: DiagnosticCategory.Error, key: "File '{0}' is not a module." }, Cannot_find_module_0: { code: 2307, category: DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, - A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." }, An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, A_class_may_only_extend_another_class: { code: 2311, category: DiagnosticCategory.Error, key: "A class may only extend another class." }, @@ -233,10 +239,10 @@ namespace ts { this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, Property_0_does_not_exist_on_type_1: { code: 2339, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" }, + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, @@ -395,6 +401,29 @@ namespace ts { No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, + Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: DiagnosticCategory.Error, key: "Overload signatures must all be abstract or not abstract." }, + Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, + Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, + Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, + All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, + Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type" }, + Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." }, + Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, + Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, + The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, + yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, + await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, + JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, + The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, + JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: DiagnosticCategory.Error, key: "JSX element type '{0}' does not have any construct or call signatures." }, + JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: DiagnosticCategory.Error, key: "JSX element type '{0}' is not a constructor function for JSX elements." }, + Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -531,15 +560,18 @@ namespace ts { File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Preserve_new_lines_when_emitting_code: { code: 6057, category: DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, + Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, + Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -556,6 +588,7 @@ namespace ts { _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." }, @@ -573,5 +606,12 @@ namespace ts { enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + class_expressions_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, + JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." }, + JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, + Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, + JSX_attribute_expected: { code: 17003, category: DiagnosticCategory.Error, key: "JSX attribute expected." }, + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, }; } \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index a4c9cb0fdda..94be4f53c97 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -67,22 +67,6 @@ "category": "Error", "code": 1023 }, - "A class or interface declaration can only have one 'extends' clause.": { - "category": "Error", - "code": 1024 - }, - "An 'extends' clause must precede an 'implements' clause.": { - "category": "Error", - "code": 1025 - }, - "A class can only extend a single class.": { - "category": "Error", - "code": 1026 - }, - "A class declaration can only have one 'implements' clause.": { - "category": "Error", - "code": 1027 - }, "Accessibility modifier already seen.": { "category": "Error", "code": 1028 @@ -99,10 +83,6 @@ "category": "Error", "code": 1031 }, - "An interface declaration cannot have an 'implements' clause.": { - "category": "Error", - "code": 1032 - }, "'super' must be followed by an argument list or member access.": { "category": "Error", "code": 1034 @@ -123,11 +103,27 @@ "category": "Error", "code": 1039 }, + "'{0}' modifier cannot be used in an ambient context.": { + "category": "Error", + "code": 1040 + }, + "'{0}' modifier cannot be used with a class declaration.": { + "category": "Error", + "code": 1041 + }, + "'{0}' modifier cannot be used here.": { + "category": "Error", + "code": 1042 + }, + "'{0}' modifier cannot appear on a data property.": { + "category": "Error", + "code": 1043 + }, "'{0}' modifier cannot appear on a module element.": { "category": "Error", "code": 1044 }, - "A 'declare' modifier cannot be used with an interface declaration.": { + "A '{0}' modifier cannot be used with an interface declaration.": { "category": "Error", "code": 1045 }, @@ -163,14 +159,38 @@ "category": "Error", "code": 1054 }, + "Type '{0}' is not a valid async function return type.": { + "category": "Error", + "code": 1055 + }, "Accessors are only available when targeting ECMAScript 5 and higher.": { "category": "Error", "code": 1056 }, + "An async function or method must have a valid awaitable return type.": { + "category": "Error", + "code": 1057 + }, + "Operand for 'await' does not have a valid callable 'then' member.": { + "category": "Error", + "code": 1058 + }, + "Return expression in async function does not have a valid callable 'then' member.": { + "category": "Error", + "code": 1059 + }, + "Expression body for async arrow function does not have a valid callable 'then' member.": { + "category": "Error", + "code": 1060 + }, "Enum member must have initializer.": { "category": "Error", "code": 1061 }, + "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method.": { + "category": "Error", + "code": 1062 + }, "An export assignment cannot be used in a namespace.": { "category": "Error", "code": 1063 @@ -183,7 +203,7 @@ "category": "Error", "code": 1068 }, - "A 'declare' modifier cannot be used with an import declaration.": { + "A '{0}' modifier cannot be used with an import declaration.": { "category": "Error", "code": 1079 }, @@ -363,10 +383,6 @@ "category": "Error", "code": 1132 }, - "Type reference expected.": { - "category": "Error", - "code": 1133 - }, "Variable declaration expected.": { "category": "Error", "code": 1134 @@ -431,18 +447,6 @@ "category": "Error", "code": 1150 }, - "'var', 'let' or 'const' expected.": { - "category": "Error", - "code": 1152 - }, - "'let' declarations are only available when targeting ECMAScript 6 and higher.": { - "category": "Error", - "code": 1153 - }, - "'const' declarations are only available when targeting ECMAScript 6 and higher.": { - "category": "Error", - "code": 1154 - }, "'const' declarations must be initialized": { "category": "Error", "code": 1155 @@ -483,10 +487,6 @@ "category": "Error", "code": 1166 }, - "Computed property names are only available when targeting ECMAScript 6 and higher.": { - "category": "Error", - "code": 1167 - }, "A computed property name in a method overload must directly refer to a built-in symbol.": { "category": "Error", "code": 1168 @@ -547,10 +547,6 @@ "category": "Error", "code": 1182 }, - "Destructuring declarations are not allowed in ambient contexts.": { - "category": "Error", - "code": 1183 - }, "An implementation cannot be declared in ambient contexts.": { "category": "Error", "code": 1184 @@ -686,7 +682,7 @@ "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.": { "category": "Error", "code": 1219 - }, + }, "Generators are only available when targeting ECMAScript 6 or higher.": { "category": "Error", "code": 1220 @@ -751,8 +747,24 @@ "category": "Error", "code": 1235 }, + "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning.": { + "category": "Error", + "code": 1236 + }, + "'with' statements are not allowed in an async function block.": { + "category": "Error", + "code": 1300 + }, + "'await' expression is only allowed within an async function.": { + "category": "Error", + "code": 1308 + }, + "Async functions are only available when targeting ECMAScript 6 and higher.": { + "category": "Error", + "code": 1311 + }, "The return type of a property decorator function must be either 'void' or 'any'.": { "category": "Error", "code": 1236 @@ -777,7 +789,22 @@ "category": "Error", "code": 1241 }, - + "'abstract' modifier can only appear on a class or method declaration.": { + "category": "Error", + "code": 1242 + }, + "'{0}' modifier cannot be used with '{1}' modifier.": { + "category": "Error", + "code": 1243 + }, + "Abstract methods can only appear within an abstract class.": { + "category": "Error", + "code": 1244 + }, + "Method '{0}' cannot have an implementation because it is marked abstract.": { + "category": "Error", + "code": 1245 + }, "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 @@ -810,10 +837,6 @@ "category": "Error", "code": 2307 }, - "A module cannot have more than one export assignment.": { - "category": "Error", - "code": 2308 - }, "An export assignment cannot be used in a module with other exported elements.": { "category": "Error", "code": 2309 @@ -922,11 +945,11 @@ "category": "Error", "code": 2336 }, - "Super calls are not permitted outside constructors or in nested functions inside constructors": { + "Super calls are not permitted outside constructors or in nested functions inside constructors.": { "category": "Error", "code": 2337 }, - "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class": { + "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { "category": "Error", "code": 2338 }, @@ -934,7 +957,7 @@ "category": "Error", "code": 2339 }, - "Only public and protected methods of the base class are accessible via the 'super' keyword": { + "Only public and protected methods of the base class are accessible via the 'super' keyword.": { "category": "Error", "code": 2340 }, @@ -1570,7 +1593,98 @@ "category": "Error", "code": 2510 }, - + "Cannot create an instance of the abstract class '{0}'.": { + "category": "Error", + "code": 2511 + }, + "Overload signatures must all be abstract or not abstract.": { + "category": "Error", + "code": 2512 + }, + "Abstract method '{0}' in class '{1}' cannot be accessed via super expression.": { + "category": "Error", + "code": 2513 + }, + "Classes containing abstract methods must be marked abstract.": { + "category": "Error", + "code": 2514 + }, + "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'.": { + "category": "Error", + "code": 2515 + }, + "All declarations of an abstract method must be consecutive.": { + "category": "Error", + "code": 2516 + }, + "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type": { + "category": "Error", + "code":2517 + }, + "Only an ambient class can be merged with an interface.": { + "category": "Error", + "code": 2518 + }, + "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.": { + "category": "Error", + "code": 2520 + }, + "Expression resolves to variable declaration '{0}' that compiler uses to support async functions.": { + "category": "Error", + "code": 2521 + }, + "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression.": { + "category": "Error", + "code": 2522 + }, + "'yield' expressions cannot be used in a parameter initializer.": { + "category": "Error", + "code": 2523 + }, + "'await' expressions cannot be used in a parameter initializer.": { + "category": "Error", + "code": 2524 + }, + "JSX element attributes type '{0}' must be an object type.": { + "category": "Error", + "code": 2600 + }, + "The return type of a JSX element constructor must return an object type.": { + "category": "Error", + "code": 2601 + }, + "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist.": { + "category": "Error", + "code": 2602 + }, + "Property '{0}' in type '{1}' is not assignable to type '{2}'": { + "category": "Error", + "code": 2603 + }, + "JSX element type '{0}' does not have any construct or call signatures.": { + "category": "Error", + "code": 2604 + }, + "JSX element type '{0}' is not a constructor function for JSX elements.": { + "category": "Error", + "code": 2605 + }, + "Property '{0}' of JSX spread attribute is not assignable to target property.": { + "category": "Error", + "code": 2606 + }, + "JSX element class does not support attributes because it does not have a '{0}' property": { + "category": "Error", + "code": 2607 + }, + "The global type 'JSX.{0}' may not have more than one property": { + "category": "Error", + "code": 2608 + }, + "Cannot emit namespaced JSX elements in React": { + "category": "Error", + "code": 2650 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 @@ -1939,7 +2053,7 @@ "category": "Error", "code": 5050 }, - "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": { + "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": { "category": "Error", "code": 5051 }, @@ -2116,10 +2230,6 @@ "category": "Message", "code": 6056 }, - "Preserve new-lines when emitting code.": { - "category": "Message", - "code": 6057 - }, "Specifies the root directory of input files. Use to control the output directory structure with --outDir.": { "category": "Message", "code": 6058 @@ -2132,14 +2242,22 @@ "category": "Message", "code": 6060 }, - "NEWLINE": { - "category": "Message", + "NEWLINE": { + "category": "Message", "code": 6061 }, "Argument for '--newLine' option must be 'CRLF' or 'LF'.": { - "category": "Error", + "category": "Error", "code": 6062 }, + "Specify JSX code generation: 'preserve' or 'react'": { + "category": "Message", + "code": 6080 + }, + "Argument for '--jsx' must be 'preserve' or 'react'.": { + "category": "Message", + "code": 6081 + }, "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified.": { "category": "Error", "code": 6064 @@ -2152,6 +2270,14 @@ "category": "Message", "code": 6066 }, + "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower.": { + "category": "Message", + "code": 6067 + }, + "Enables experimental support for ES7 async functions.": { + "category": "Message", + "code": 6068 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", @@ -2217,6 +2343,12 @@ "category": "Error", "code": 7025 }, + "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists": { + "category": "Error", + "code": 7026 + }, + + "You cannot rename this element.": { "category": "Error", "code": 8000 @@ -2284,5 +2416,34 @@ "'decorators' can only be used in a .ts file.": { "category": "Error", "code": 8017 + }, + + "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.": { + "category": "Error", + "code": 9002 + }, + "'class' expressions are not currently supported.": { + "category": "Error", + "code": 9003 + }, + "JSX attributes must only be assigned a non-empty 'expression'.": { + "category": "Error", + "code": 17000 + }, + "JSX elements cannot have multiple attributes with the same name.": { + "category": "Error", + "code": 17001 + }, + "Expected corresponding JSX closing tag for '{0}'.": { + "category": "Error", + "code": 17002 + }, + "JSX attribute expected.": { + "category": "Error", + "code": 17003 + }, + "Cannot use JSX unless the '--jsx' flag is provided.": { + "category": "Error", + "code": 17004 } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index b9d7f664f80..024af715948 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -47,16 +47,33 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } };`; + const awaiterHelper = ` +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { + return new Promise(function (resolve, reject) { + generator = generator.call(thisArg, _arguments); + function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } + function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } + function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } + function step(verb, value) { + var result = generator[verb](value); + result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); + } + step("next", void 0); + }); +};`; + let compilerOptions = host.getCompilerOptions(); let languageVersion = compilerOptions.target || ScriptTarget.ES3; let sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; let diagnostics: Diagnostic[] = []; let newLine = host.getNewLine(); + let jsxDesugaring = host.getCompilerOptions().jsx !== JsxEmit.Preserve; + let shouldEmitJsx = (s: SourceFile) => (s.languageVariant === LanguageVariant.JSX && !jsxDesugaring); if (targetSourceFile === undefined) { forEach(host.getSourceFiles(), sourceFile => { if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, ".js"); + let jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, sourceFile); } }); @@ -68,7 +85,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { else { // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!isDeclarationFile(targetSourceFile) && compilerOptions.out) { @@ -112,7 +129,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { let writeLine = writer.writeLine; let increaseIndent = writer.increaseIndent; let decreaseIndent = writer.decreaseIndent; - + let currentSourceFile: SourceFile; // name of an exporter function if file is a System external module // System.register([...], function () {...}) @@ -129,6 +146,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { let extendsEmitted = false; let decorateEmitted = false; let paramEmitted = false; + let awaiterEmitted = false; let tempFlags = 0; let tempVariables: Identifier[]; let tempParameters: Identifier[]; @@ -1111,6 +1129,224 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emit(span.literal); } + function jsxEmitReact(node: JsxElement|JsxSelfClosingElement) { + /// Emit a tag name, which is either '"div"' for lower-cased names, or + /// 'Div' for upper-cased or dotted names + function emitTagName(name: Identifier|QualifiedName) { + if (name.kind === SyntaxKind.Identifier && isIntrinsicJsxName((name).text)) { + write('"'); + emit(name); + write('"'); + } + else { + emit(name); + } + } + + /// Emit an attribute name, which is quoted if it needs to be quoted. Because + /// these emit into an object literal property name, we don't need to be worried + /// about keywords, just non-identifier characters + function emitAttributeName(name: Identifier) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write('"'); + emit(name); + write('"'); + } + else { + emit(name); + } + } + + /// Emit an name/value pair for an attribute (e.g. "x: 3") + function emitJsxAttribute(node: JsxAttribute) { + emitAttributeName(node.name); + write(": "); + if (node.initializer) { + emit(node.initializer); + } + else { + write("true"); + } + } + + function emitJsxElement(openingNode: JsxOpeningLikeElement, children?: JsxChild[]) { + // Call React.createElement(tag, ... + emitLeadingComments(openingNode); + write("React.createElement("); + emitTagName(openingNode.tagName); + write(", "); + + // Attribute list + if (openingNode.attributes.length === 0) { + // When there are no attributes, React wants "null" + write("null"); + } + else { + // Either emit one big object literal (no spread attribs), or + // a call to React.__spread + let attrs = openingNode.attributes; + if (forEach(attrs, attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) { + write("React.__spread("); + + let haveOpenedObjectLiteral = false; + for (let i = 0; i < attrs.length; i++) { + if (attrs[i].kind === SyntaxKind.JsxSpreadAttribute) { + // If this is the first argument, we need to emit a {} as the first argument + if (i === 0) { + write("{}, "); + } + + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i > 0) { + write(", "); + } + emit((attrs[i]).expression); + } + else { + Debug.assert(attrs[i].kind === SyntaxKind.JsxAttribute); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i]); + } + } + if (haveOpenedObjectLiteral) write("}"); + + write(")"); // closing paren to React.__spread( + } + else { + // One object literal with all the attributes in them + write("{"); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) { + write(", "); + } + emitJsxAttribute(attrs[i]); + } + write("}"); + } + } + + // Children + if (children) { + for (var i = 0; i < children.length; i++) { + // Don't emit empty expressions + if (children[i].kind === SyntaxKind.JsxExpression && !((children[i]).expression)) { + continue; + } + + // Don't emit empty strings + if (children[i].kind === SyntaxKind.JsxText) { + let text = getTextToEmit(children[i]); + if(text !== undefined) { + write(', "'); + write(text); + write('"'); + } + } + else { + write(", "); + emit(children[i]); + } + + } + } + + // Closing paren + write(")"); // closes "React.createElement(" + emitTrailingComments(openingNode); + } + + if (node.kind === SyntaxKind.JsxElement) { + emitJsxElement((node).openingElement, (node).children); + } + else { + Debug.assert(node.kind === SyntaxKind.JsxSelfClosingElement); + emitJsxElement(node); + } + } + + function jsxEmitPreserve(node: JsxElement|JsxSelfClosingElement) { + function emitJsxAttribute(node: JsxAttribute) { + emit(node.name); + write("="); + emit(node.initializer); + } + + function emitJsxSpreadAttribute(node: JsxSpreadAttribute) { + write("{..."); + emit(node.expression); + write("}"); + } + + function emitAttributes(attribs: NodeArray) { + for (let i = 0, n = attribs.length; i < n; i++) { + if (i > 0) { + write(" "); + } + + if (attribs[i].kind === SyntaxKind.JsxSpreadAttribute) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + Debug.assert(attribs[i].kind === SyntaxKind.JsxAttribute); + emitJsxAttribute(attribs[i]); + } + } + } + + function emitJsxOpeningOrSelfClosingElement(node: JsxOpeningElement|JsxSelfClosingElement) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === SyntaxKind.JsxSelfClosingElement)) { + write(" "); + } + + emitAttributes(node.attributes); + + if (node.kind === SyntaxKind.JsxSelfClosingElement) { + write("/>"); + } + else { + write(">"); + } + } + + function emitJsxClosingElement(node: JsxClosingElement) { + write(""); + } + + function emitJsxElement(node: JsxElement) { + emitJsxOpeningOrSelfClosingElement(node.openingElement); + + for (var i = 0, n = node.children.length; i < n; i++) { + emit(node.children[i]); + } + + emitJsxClosingElement(node.closingElement); + } + + if (node.kind === SyntaxKind.JsxElement) { + emitJsxElement(node); + } + else { + Debug.assert(node.kind === SyntaxKind.JsxSelfClosingElement); + emitJsxOpeningOrSelfClosingElement(node); + } + } + // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. @@ -1187,6 +1423,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { case SyntaxKind.ForInStatement: case SyntaxKind.ForOfStatement: case SyntaxKind.IfStatement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxOpeningElement: case SyntaxKind.NewExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.PostfixUnaryExpression: @@ -1226,6 +1464,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function emitExpressionIdentifier(node: Identifier) { + if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.LexicalArguments) { + write("_arguments"); + return; + } + let container = resolver.getReferencedExportContainer(node); if (container) { if (container.kind === SyntaxKind.SourceFile) { @@ -1365,6 +1608,30 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emit(node.expression); } } + + function emitAwaitExpression(node: AwaitExpression) { + let needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(tokenToString(SyntaxKind.YieldKeyword)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + + function needsParenthesisForAwaitExpressionAsYield(node: AwaitExpression) { + if (node.parent.kind === SyntaxKind.BinaryExpression && !isAssignmentOperator((node.parent).operatorToken.kind)) { + return true; + } + else if (node.parent.kind === SyntaxKind.ConditionalExpression && (node.parent).condition === node) { + return true; + } + + return false; + } function needsParenthesisForPropertyAccessOrInvocation(node: Expression) { switch (node.kind) { @@ -1663,8 +1930,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { function parenthesizeForAccess(expr: Expression): LeftHandSideExpression { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === SyntaxKind.TypeAssertionExpression) { - expr = (expr).expression; + while (expr.kind === SyntaxKind.TypeAssertionExpression || expr.kind === SyntaxKind.AsExpression) { + expr = (expr).expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -1824,8 +2091,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function skipParentheses(node: Expression): Expression { - while (node.kind === SyntaxKind.ParenthesizedExpression || node.kind === SyntaxKind.TypeAssertionExpression) { - node = (node).expression; + while (node.kind === SyntaxKind.ParenthesizedExpression || node.kind === SyntaxKind.TypeAssertionExpression || node.kind === SyntaxKind.AsExpression) { + node = (node).expression; } return node; } @@ -1975,12 +2242,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // not the user. If we didn't want them, the emitter would not have put them // there. if (!nodeIsSynthesized(node) && node.parent.kind !== SyntaxKind.ArrowFunction) { - if (node.expression.kind === SyntaxKind.TypeAssertionExpression) { + if (node.expression.kind === SyntaxKind.TypeAssertionExpression || node.expression.kind === SyntaxKind.AsExpression) { let operand = (node.expression).expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === SyntaxKind.TypeAssertionExpression) { + while (operand.kind === SyntaxKind.TypeAssertionExpression || operand.kind === SyntaxKind.AsExpression) { operand = (operand).expression; } @@ -3345,8 +3612,149 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emit(node.parameters[0]); return; } + emitSignatureParameters(node); } + + function emitAsyncFunctionBodyForES6(node: FunctionLikeDeclaration) { + let promiseConstructor = getEntityNameFromTypeNode(node.type); + let isArrowFunction = node.kind === SyntaxKind.ArrowFunction; + let hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0; + let args: string; + + // An async function is emit as an outer function that calls an inner + // generator function. To preserve lexical bindings, we pass the current + // `this` and `arguments` objects to `__awaiter`. The generator function + // passed to `__awaiter` is executed inside of the callback to the + // promise constructor. + // + // The emit for an async arrow without a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await b; } + // + // // output + // let a = (b) => __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // + // The emit for an async arrow with a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await arguments[0]; } + // + // // output + // let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) { + // yield arguments[0]; + // }); + // + // The emit for an async function expression without a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await b; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, void 0, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // and a return type annotation might be: + // + // // input + // let a = async function (b): MyPromise { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, MyPromise, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + + // If this is not an async arrow, emit the opening brace of the function body + // and the start of the return statement. + if (!isArrowFunction) { + write(" {"); + increaseIndent(); + writeLine(); + write("return"); + } + + write(" __awaiter(this"); + if (hasLexicalArguments) { + write(", arguments"); + } + else { + write(", void 0"); + } + + if (promiseConstructor) { + write(", "); + emitNodeWithoutSourceMap(promiseConstructor); + } + else { + write(", Promise"); + } + + // Emit the call to __awaiter. + if (hasLexicalArguments) { + write(", function* (_arguments)"); + } + else { + write(", function* ()"); + } + + // Emit the signature and body for the inner generator function. + emitFunctionBody(node); + write(")"); + + // If this is not an async arrow, emit the closing brace of the outer function body. + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + + function emitFunctionBody(node: FunctionLikeDeclaration) { + if (!node.body) { + // There can be no body when there are parse errors. Just emit an empty block + // in that case. + write(" { }"); + } + else { + if (node.body.kind === SyntaxKind.Block) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } function emitSignatureAndBody(node: FunctionLikeDeclaration) { let saveTempFlags = tempFlags; @@ -3364,19 +3772,15 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { else { emitSignatureParameters(node); } - - if (!node.body) { - // There can be no body when there are parse errors. Just emit an empty block - // in that case. - write(" { }"); - } - else if (node.body.kind === SyntaxKind.Block) { - emitBlockFunctionBody(node, node.body); + + let isAsync = isAsyncFunctionLike(node); + if (isAsync && languageVersion === ScriptTarget.ES6) { + emitAsyncFunctionBodyForES6(node); } else { - emitExpressionFunctionBody(node, node.body); + emitFunctionBody(node); } - + if (!isES6ExportedDeclaration(node)) { emitExportMemberAssignment(node); } @@ -3394,7 +3798,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function emitExpressionFunctionBody(node: FunctionLikeDeclaration, body: Expression) { - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES6 || node.flags & NodeFlags.Async) { emitDownLevelExpressionFunctionBody(node, body); return; } @@ -5692,6 +6096,99 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } } + function emitJsxElement(node: JsxElement | JsxSelfClosingElement) { + switch (compilerOptions.jsx) { + case JsxEmit.React: + jsxEmitReact(node); + break; + case JsxEmit.Preserve: + // Fall back to preserve if None was specified (we'll error earlier) + default: + jsxEmitPreserve(node); + break; + } + } + + function trimReactWhitespace(node: JsxText): string { + let result: string = undefined; + let text = getTextOfNode(node); + let firstNonWhitespace = 0; + let lastNonWhitespace = -1; + + // JSX trims whitespace at the end and beginning of lines, except that the + // start/end of a tag is considered a start/end of a line only if that line is + // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx + for (let i = 0; i < text.length; i++) { + let c = text.charCodeAt(i); + if (isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + let part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + result = (result ? result + '" + \' \' + "' : '') + part; + } + firstNonWhitespace = -1; + } + else if (!isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } + } + } + if (firstNonWhitespace !== -1) { + let part = text.substr(firstNonWhitespace); + result = (result ? result + '" + \' \' + "' : '') + part; + } + + return result; + } + + function getTextToEmit(node: JsxText) { + switch (compilerOptions.jsx) { + case JsxEmit.React: + let text = trimReactWhitespace(node); + if (text.length === 0) { + return undefined; + } + else { + return text; + } + case JsxEmit.Preserve: + default: + return getTextOfNode(node, true); + } + } + + function emitJsxText(node: JsxText) { + switch (compilerOptions.jsx) { + case JsxEmit.React: + write('"'); + write(trimReactWhitespace(node)); + write('"'); + break; + + case JsxEmit.Preserve: + default: // Emit JSX-preserve as default when no --jsx flag is specified + write(getTextOfNode(node, true)); + break; + } + } + + function emitJsxExpression(node: JsxExpression) { + if (node.expression) { + switch (compilerOptions.jsx) { + case JsxEmit.Preserve: + default: + write('{'); + emit(node.expression); + write('}'); + break; + case JsxEmit.React: + emit(node.expression); + break; + } + } + } + function emitDirectivePrologues(statements: Node[], startWithNewLine: boolean): number { for (let i = 0; i < statements.length; ++i) { if (isPrologueDirective(statements[i])) { @@ -5748,6 +6245,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { writeLines(paramHelper); paramEmitted = true; } + + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitAwaiter) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } } if (isExternalModule(node) || compilerOptions.isolatedModules) { @@ -5879,6 +6381,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return emitTemplateExpression(node); case SyntaxKind.TemplateSpan: return emitTemplateSpan(node); + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: + return emitJsxElement(node); + case SyntaxKind.JsxText: + return emitJsxText(node); + case SyntaxKind.JsxExpression: + return emitJsxExpression(node); case SyntaxKind.QualifiedName: return emitQualifiedName(node); case SyntaxKind.ObjectBindingPattern: @@ -5909,6 +6418,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return emitTaggedTemplateExpression(node); case SyntaxKind.TypeAssertionExpression: return emit((node).expression); + case SyntaxKind.AsExpression: + return emit((node).expression); case SyntaxKind.ParenthesizedExpression: return emitParenExpression(node); case SyntaxKind.FunctionDeclaration: @@ -5921,6 +6432,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return emitTypeOfExpression(node); case SyntaxKind.VoidExpression: return emitVoidExpression(node); + case SyntaxKind.AwaitExpression: + return emitAwaitExpression(node); case SyntaxKind.PrefixUnaryExpression: return emitPrefixUnaryExpression(node); case SyntaxKind.PostfixUnaryExpression: @@ -6173,4 +6686,4 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } } } -} \ No newline at end of file +} diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 3144b6a1892..72c211cc3b5 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -115,7 +115,8 @@ namespace ts { case SyntaxKind.TupleType: return visitNodes(cbNodes, (node).elementTypes); case SyntaxKind.UnionType: - return visitNodes(cbNodes, (node).types); + case SyntaxKind.IntersectionType: + return visitNodes(cbNodes, (node).types); case SyntaxKind.ParenthesizedType: return visitNode(cbNode, (node).type); case SyntaxKind.ObjectBindingPattern: @@ -156,12 +157,17 @@ namespace ts { case SyntaxKind.YieldExpression: return visitNode(cbNode, (node).asteriskToken) || visitNode(cbNode, (node).expression); + case SyntaxKind.AwaitExpression: + return visitNode(cbNode, (node).expression); case SyntaxKind.PostfixUnaryExpression: return visitNode(cbNode, (node).operand); case SyntaxKind.BinaryExpression: return visitNode(cbNode, (node).left) || visitNode(cbNode, (node).operatorToken) || visitNode(cbNode, (node).right); + case SyntaxKind.AsExpression: + return visitNode(cbNode, (node).expression) || + visitNode(cbNode, (node).type); case SyntaxKind.ConditionalExpression: return visitNode(cbNode, (node).condition) || visitNode(cbNode, (node).questionToken) || @@ -319,6 +325,25 @@ namespace ts { return visitNode(cbNode, (node).expression); case SyntaxKind.MissingDeclaration: return visitNodes(cbNodes, node.decorators); + + case SyntaxKind.JsxElement: + return visitNode(cbNode, (node).openingElement) || + visitNodes(cbNodes, (node).children) || + visitNode(cbNode, (node).closingElement); + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxOpeningElement: + return visitNode(cbNode, (node).tagName) || + visitNodes(cbNodes, (node).attributes); + case SyntaxKind.JsxAttribute: + return visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).initializer); + case SyntaxKind.JsxSpreadAttribute: + return visitNode(cbNode, (node).expression); + case SyntaxKind.JsxExpression: + return visitNode(cbNode, (node).expression); + case SyntaxKind.JsxClosingElement: + return visitNode(cbNode, (node).tagName); + case SyntaxKind.JSDocTypeExpression: return visitNode(cbNode, (node).type); case SyntaxKind.JSDocUnionType: @@ -522,6 +547,7 @@ namespace ts { scanner.setText(sourceText); scanner.setOnError(scanError); scanner.setScriptTarget(languageVersion); + scanner.setLanguageVariant(isTsx(fileName) ? LanguageVariant.JSX : LanguageVariant.Standard); } function clearState() { @@ -634,6 +660,7 @@ namespace ts { sourceFile.languageVersion = languageVersion; sourceFile.fileName = normalizePath(fileName); sourceFile.flags = fileExtensionIs(sourceFile.fileName, ".d.ts") ? NodeFlags.DeclarationFile : 0; + sourceFile.languageVariant = isTsx(sourceFile.fileName) ? LanguageVariant.JSX : LanguageVariant.Standard; return sourceFile; } @@ -655,103 +682,112 @@ namespace ts { setContextFlag(val, ParserContextFlags.Yield); } - function setGeneratorParameterContext(val: boolean) { - setContextFlag(val, ParserContextFlags.GeneratorParameter); - } - function setDecoratorContext(val: boolean) { setContextFlag(val, ParserContextFlags.Decorator); } - - function doOutsideOfContext(flags: ParserContextFlags, func: () => T): T { - let currentContextFlags = contextFlags & flags; - if (currentContextFlags) { - setContextFlag(false, currentContextFlags); + + function setAwaitContext(val: boolean) { + setContextFlag(val, ParserContextFlags.Await); + } + + function doOutsideOfContext(context: ParserContextFlags, func: () => T): T { + // contextFlagsToClear will contain only the context flags that are + // currently set that we need to temporarily clear + // We don't just blindly reset to the previous flags to ensure + // that we do not mutate cached flags for the incremental + // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and + // HasAggregatedChildData). + let contextFlagsToClear = context & contextFlags; + if (contextFlagsToClear) { + // clear the requested context flags + setContextFlag(false, contextFlagsToClear); let result = func(); - setContextFlag(true, currentContextFlags); + // restore the context flags we just cleared + setContextFlag(true, contextFlagsToClear); return result; } // no need to do anything special as we are not in any of the requested contexts return func(); } - - function allowInAnd(func: () => T): T { - if (contextFlags & ParserContextFlags.DisallowIn) { - setDisallowInContext(false); + + function doInsideOfContext(context: ParserContextFlags, func: () => T): T { + // contextFlagsToSet will contain only the context flags that + // are not currently set that we need to temporarily enable. + // We don't just blindly reset to the previous flags to ensure + // that we do not mutate cached flags for the incremental + // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and + // HasAggregatedChildData). + let contextFlagsToSet = context & ~contextFlags; + if (contextFlagsToSet) { + // set the requested context flags + setContextFlag(true, contextFlagsToSet); let result = func(); - setDisallowInContext(true); + // reset the context flags we just set + setContextFlag(false, contextFlagsToSet); return result; } - - // no need to do anything special if 'in' is already allowed. + + // no need to do anything special as we are already in all of the requested contexts return func(); } + + function allowInAnd(func: () => T): T { + return doOutsideOfContext(ParserContextFlags.DisallowIn, func); + } function disallowInAnd(func: () => T): T { - if (contextFlags & ParserContextFlags.DisallowIn) { - // no need to do anything special if 'in' is already disallowed. - return func(); - } - - setDisallowInContext(true); - let result = func(); - setDisallowInContext(false); - return result; + return doInsideOfContext(ParserContextFlags.DisallowIn, func); } - + function doInYieldContext(func: () => T): T { - if (contextFlags & ParserContextFlags.Yield) { - // no need to do anything special if we're already in the [Yield] context. - return func(); - } - - setYieldContext(true); - let result = func(); - setYieldContext(false); - return result; + return doInsideOfContext(ParserContextFlags.Yield, func); } function doOutsideOfYieldContext(func: () => T): T { - if (contextFlags & ParserContextFlags.Yield) { - setYieldContext(false); - let result = func(); - setYieldContext(true); - return result; - } - - // no need to do anything special if we're not in the [Yield] context. - return func(); + return doOutsideOfContext(ParserContextFlags.Yield, func); } function doInDecoratorContext(func: () => T): T { - if (contextFlags & ParserContextFlags.Decorator) { - // no need to do anything special if we're already in the [Decorator] context. - return func(); - } - - setDecoratorContext(true); - let result = func(); - setDecoratorContext(false); - return result; + return doInsideOfContext(ParserContextFlags.Decorator, func); + } + + function doInAwaitContext(func: () => T): T { + return doInsideOfContext(ParserContextFlags.Await, func); + } + + function doOutsideOfAwaitContext(func: () => T): T { + return doOutsideOfContext(ParserContextFlags.Await, func); + } + + function doInYieldAndAwaitContext(func: () => T): T { + return doInsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func); + } + + function doOutsideOfYieldAndAwaitContext(func: () => T): T { + return doOutsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func); + } + + function inContext(flags: ParserContextFlags) { + return (contextFlags & flags) !== 0; } function inYieldContext() { - return (contextFlags & ParserContextFlags.Yield) !== 0; - } - - function inGeneratorParameterContext() { - return (contextFlags & ParserContextFlags.GeneratorParameter) !== 0; + return inContext(ParserContextFlags.Yield); } function inDisallowInContext() { - return (contextFlags & ParserContextFlags.DisallowIn) !== 0; + return inContext(ParserContextFlags.DisallowIn); } function inDecoratorContext() { - return (contextFlags & ParserContextFlags.Decorator) !== 0; + return inContext(ParserContextFlags.Decorator); } + function inAwaitContext() { + return inContext(ParserContextFlags.Await); + } + function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void { let start = scanner.getTokenPos(); let length = scanner.getTextPos() - start; @@ -804,6 +840,10 @@ namespace ts { return token = scanner.reScanTemplateToken(); } + function scanJsxIdentifier(): SyntaxKind { + return token = scanner.scanJsxIdentifier(); + } + function speculationHelper(callback: () => T, isLookAhead: boolean): T { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). @@ -863,6 +903,12 @@ namespace ts { if (token === SyntaxKind.YieldKeyword && inYieldContext()) { return false; } + + // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is + // considered a keyword and is not an identifier. + if (token === SyntaxKind.AwaitKeyword && inAwaitContext()) { + return false; + } return token > SyntaxKind.LastReservedWord; } @@ -1038,29 +1084,16 @@ namespace ts { } function parseComputedPropertyName(): ComputedPropertyName { - // PropertyName[Yield,GeneratorParameter] : - // LiteralPropertyName - // [+GeneratorParameter] ComputedPropertyName - // [~GeneratorParameter] ComputedPropertyName[?Yield] - // - // ComputedPropertyName[Yield] : - // [ AssignmentExpression[In, ?Yield] ] - // + // PropertyName [Yield]: + // LiteralPropertyName + // ComputedPropertyName[?Yield] let node = createNode(SyntaxKind.ComputedPropertyName); parseExpected(SyntaxKind.OpenBracketToken); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. - let yieldContext = inYieldContext(); - if (inGeneratorParameterContext()) { - setYieldContext(false); - } - node.expression = allowInAnd(parseExpression); - if (inGeneratorParameterContext()) { - setYieldContext(yieldContext); - } parseExpected(SyntaxKind.CloseBracketToken); return finishNode(node); @@ -1069,7 +1102,7 @@ namespace ts { function parseContextualModifier(t: SyntaxKind): boolean { return token === t && tryParse(nextTokenCanFollowModifier); } - + function nextTokenCanFollowModifier() { if (token === SyntaxKind.ConstKeyword) { // 'const' is only a modifier if followed by 'enum'. @@ -1088,7 +1121,7 @@ namespace ts { nextToken(); return canFollowModifier(); } - + function parseAnyContextualModifier(): boolean { return isModifier(token) && tryParse(nextTokenCanFollowModifier); } @@ -1175,6 +1208,10 @@ namespace ts { return isHeritageClause(); case ParsingContext.ImportOrExportSpecifiers: return isIdentifierOrKeyword(); + case ParsingContext.JsxAttributes: + return isIdentifierOrKeyword() || token === SyntaxKind.OpenBraceToken; + case ParsingContext.JsxChildren: + return true; case ParsingContext.JSDocFunctionParameters: case ParsingContext.JSDocTypeArguments: case ParsingContext.JSDocTupleTypes: @@ -1209,6 +1246,11 @@ namespace ts { return isIdentifier(); } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return isIdentifierOrKeyword(); + } + function isHeritageClauseExtendsOrImplementsKeyword(): boolean { if (token === SyntaxKind.ImplementsKeyword || token === SyntaxKind.ExtendsKeyword) { @@ -1265,6 +1307,10 @@ namespace ts { return token === SyntaxKind.GreaterThanToken || token === SyntaxKind.OpenParenToken; case ParsingContext.HeritageClauses: return token === SyntaxKind.OpenBraceToken || token === SyntaxKind.CloseBraceToken; + case ParsingContext.JsxAttributes: + return token === SyntaxKind.GreaterThanToken || token === SyntaxKind.SlashToken; + case ParsingContext.JsxChildren: + return token === SyntaxKind.LessThanToken && lookAhead(nextTokenIsSlash); case ParsingContext.JSDocFunctionParameters: return token === SyntaxKind.CloseParenToken || token === SyntaxKind.ColonToken || token === SyntaxKind.CloseBraceToken; case ParsingContext.JSDocTypeArguments: @@ -1481,6 +1527,12 @@ namespace ts { // name list, and there can be left hand side expressions (which can have type // arguments.) case ParsingContext.HeritageClauseElement: + + // Perhaps safe to reuse, but it's unlikely we'd see more than a dozen attributes + // on any given element. Same for children. + case ParsingContext.JsxAttributes: + case ParsingContext.JsxChildren: + } return false; @@ -1647,6 +1699,8 @@ namespace ts { case ParsingContext.TupleElementTypes: return Diagnostics.Type_expected; case ParsingContext.HeritageClauses: return Diagnostics.Unexpected_token_expected; case ParsingContext.ImportOrExportSpecifiers: return Diagnostics.Identifier_expected; + case ParsingContext.JsxAttributes: return Diagnostics.Identifier_expected; + case ParsingContext.JsxChildren: return Diagnostics.Identifier_expected; case ParsingContext.JSDocFunctionParameters: return Diagnostics.Parameter_declaration_expected; case ParsingContext.JSDocTypeArguments: return Diagnostics.Type_argument_expected; case ParsingContext.JSDocTupleTypes: return Diagnostics.Type_expected; @@ -1934,11 +1988,10 @@ namespace ts { setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); - // SingleNameBinding[Yield,GeneratorParameter] : See 13.2.3 - // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt - // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt + // FormalParameter [Yield,Await]: + // BindingElement[?Yield,?Await] - node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifierOrPattern) : parseIdentifierOrPattern(); + node.name = parseIdentifierOrPattern(); if (getFullWidth(node.name) === 0 && node.flags === 0 && isModifier(token)) { // in cases like @@ -1954,7 +2007,7 @@ namespace ts { node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken); node.type = parseParameterType(); - node.initializer = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseParameterInitializer) : parseParameterInitializer(); + node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not // a grammar error because the grammar allows arbitrary call signatures in @@ -1966,19 +2019,25 @@ namespace ts { // ambient contexts. return finishNode(node); } + + function parseBindingElementInitializer(inParameter: boolean) { + return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); + } function parseParameterInitializer() { return parseInitializer(/*inParameter*/ true); } - + function fillSignature( - returnToken: SyntaxKind, - yieldAndGeneratorParameterContext: boolean, - requireCompleteParameterList: boolean, - signature: SignatureDeclaration): void { + returnToken: SyntaxKind, + yieldContext: boolean, + awaitContext: boolean, + requireCompleteParameterList: boolean, + signature: SignatureDeclaration): void { + let returnTokenRequired = returnToken === SyntaxKind.EqualsGreaterThanToken; signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList); + signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); @@ -1989,37 +2048,32 @@ namespace ts { } } - // Note: after careful analysis of the grammar, it does not appear to be possible to - // have 'Yield' And 'GeneratorParameter' not in sync. i.e. any production calling - // this FormalParameters production either always sets both to true, or always sets - // both to false. As such we only have a single parameter to represent both. - function parseParameterList(yieldAndGeneratorParameterContext: boolean, requireCompleteParameterList: boolean) { - // FormalParameters[Yield,GeneratorParameter] : - // ... + function parseParameterList(yieldContext: boolean, awaitContext: boolean, requireCompleteParameterList: boolean) { + // FormalParameters [Yield,Await]: (modified) + // [empty] + // FormalParameterList[?Yield,Await] // - // FormalParameter[Yield,GeneratorParameter] : - // BindingElement[?Yield, ?GeneratorParameter] + // FormalParameter[Yield,Await]: (modified) + // BindingElement[?Yield,Await] // - // BindingElement[Yield, GeneratorParameter ] : See 13.2.3 - // SingleNameBinding[?Yield, ?GeneratorParameter] - // [+GeneratorParameter]BindingPattern[?Yield, GeneratorParameter]Initializer[In]opt - // [~GeneratorParameter]BindingPattern[?Yield]Initializer[In, ?Yield]opt + // BindingElement [Yield,Await]: (modified) + // SingleNameBinding[?Yield,?Await] + // BindingPattern[?Yield,?Await]Initializer [In, ?Yield,?Await] opt // - // SingleNameBinding[Yield, GeneratorParameter] : See 13.2.3 - // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt - // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt + // SingleNameBinding [Yield,Await]: + // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt if (parseExpected(SyntaxKind.OpenParenToken)) { let savedYieldContext = inYieldContext(); - let savedGeneratorParameterContext = inGeneratorParameterContext(); - - setYieldContext(yieldAndGeneratorParameterContext); - setGeneratorParameterContext(yieldAndGeneratorParameterContext); - + let savedAwaitContext = inAwaitContext(); + + setYieldContext(yieldContext); + setAwaitContext(awaitContext); + let result = parseDelimitedList(ParsingContext.Parameters, parseParameter); - + setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); - + setAwaitContext(savedAwaitContext); + if (!parseExpected(SyntaxKind.CloseParenToken) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. @@ -2034,7 +2088,7 @@ namespace ts { // then just return an empty set of parameters. return requireCompleteParameterList ? undefined : createMissingList(); } - + function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. @@ -2051,7 +2105,7 @@ namespace ts { if (kind === SyntaxKind.ConstructSignature) { parseExpected(SyntaxKind.NewKeyword); } - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -2140,8 +2194,8 @@ namespace ts { method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither - // [Yield] nor [GeneratorParameter] - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*requireCompleteParameterList*/ false, method); + // [Yield] nor [Await] + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } @@ -2280,7 +2334,7 @@ namespace ts { if (kind === SyntaxKind.ConstructorType) { parseExpected(SyntaxKind.NewKeyword); } - fillSignature(SyntaxKind.EqualsGreaterThanToken, /*yieldAndGeneratorParameterContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(SyntaxKind.EqualsGreaterThanToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } @@ -2353,22 +2407,30 @@ namespace ts { return type; } - function parseUnionTypeOrHigher(): TypeNode { - let type = parseArrayTypeOrHigher(); - if (token === SyntaxKind.BarToken) { + function parseUnionOrIntersectionType(kind: SyntaxKind, parseConstituentType: () => TypeNode, operator: SyntaxKind): TypeNode { + let type = parseConstituentType(); + if (token === operator) { let types = >[type]; types.pos = type.pos; - while (parseOptional(SyntaxKind.BarToken)) { - types.push(parseArrayTypeOrHigher()); + while (parseOptional(operator)) { + types.push(parseConstituentType()); } types.end = getNodeEnd(); - let node = createNode(SyntaxKind.UnionType, type.pos); + let node = createNode(kind, type.pos); node.types = types; type = finishNode(node); } return type; } + function parseIntersectionTypeOrHigher(): TypeNode { + return parseUnionOrIntersectionType(SyntaxKind.IntersectionType, parseArrayTypeOrHigher, SyntaxKind.AmpersandToken); + } + + function parseUnionTypeOrHigher(): TypeNode { + return parseUnionOrIntersectionType(SyntaxKind.UnionType, parseIntersectionTypeOrHigher, SyntaxKind.BarToken); + } + function isStartOfFunctionType(): boolean { if (token === SyntaxKind.LessThanToken) { return true; @@ -2409,19 +2471,8 @@ namespace ts { function parseType(): TypeNode { // The rules about 'yield' only apply to actual code/expression contexts. They don't - // apply to 'type' contexts. So we disable these parameters here before moving on. - let savedYieldContext = inYieldContext(); - let savedGeneratorParameterContext = inGeneratorParameterContext(); - - setYieldContext(false); - setGeneratorParameterContext(false); - - let result = parseTypeWorker(); - - setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); - - return result; + // apply to 'type' contexts. So we disable these parameters here before moving on. + return doOutsideOfContext(ParserContextFlags.TypeExcludesFlags, parseTypeWorker); } function parseTypeWorker(): TypeNode { @@ -2481,10 +2532,11 @@ namespace ts { case SyntaxKind.PlusPlusToken: case SyntaxKind.MinusMinusToken: case SyntaxKind.LessThanToken: + case SyntaxKind.AwaitKeyword: case SyntaxKind.YieldKeyword: - // Yield always starts an expression. Either it is an identifier (in which case + // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in - // a generator, or in strict mode (or both)) and it started a yield expression. + // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. return true; default: // Error tolerance. If we see the start of some binary operator, we consider @@ -2507,6 +2559,10 @@ namespace ts { token !== SyntaxKind.AtToken && isStartOfExpression(); } + + function allowInAndParseExpression(): Expression { + return allowInAnd(parseExpression); + } function parseExpression(): Expression { // Expression[in]: @@ -2681,19 +2737,18 @@ namespace ts { node.parameters.end = parameter.end; node.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, false, Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(); + node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false); return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression(): Expression { let triState = isParenthesizedArrowFunctionExpression(); - if (triState === Tristate.False) { // It's definitely not a parenthesized arrow function expression. return undefined; } - + // If we definitely have an arrow function, then we can just parse one, not requiring a // following => or { token. Otherwise, we *might* have an arrow function. Try to parse // it out, but don't allow any ambiguity, and return 'undefined' if this could be an @@ -2706,13 +2761,15 @@ namespace ts { // Didn't appear to actually be a parenthesized arrow function. Just bail out. return undefined; } + + let isAsync = !!(arrowFunction.flags & NodeFlags.Async); // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. let lastToken = token; arrowFunction.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition*/false, Diagnostics._0_expected, "=>"); arrowFunction.body = (lastToken === SyntaxKind.EqualsGreaterThanToken || lastToken === SyntaxKind.OpenBraceToken) - ? parseArrowFunctionExpressionBody() + ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -2723,7 +2780,7 @@ namespace ts { // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression(): Tristate { - if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) { + if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken || token === SyntaxKind.AsyncKeyword) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } @@ -2738,6 +2795,16 @@ namespace ts { } function isParenthesizedArrowFunctionExpressionWorker() { + if (token === SyntaxKind.AsyncKeyword) { + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return Tristate.False; + } + if (token !== SyntaxKind.OpenParenToken && token !== SyntaxKind.LessThanToken) { + return Tristate.False; + } + } + let first = token; let second = nextToken(); @@ -2802,6 +2869,33 @@ namespace ts { return Tristate.False; } + // JSX overrides + if (sourceFile.languageVariant === LanguageVariant.JSX) { + let isArrowFunctionInJsx = lookAhead(() => { + let third = nextToken(); + if (third === SyntaxKind.ExtendsKeyword) { + let fourth = nextToken(); + switch (fourth) { + case SyntaxKind.EqualsToken: + case SyntaxKind.GreaterThanToken: + return false; + default: + return true; + } + } + else if (third === SyntaxKind.CommaToken) { + return true; + } + return false; + }); + + if (isArrowFunctionInJsx) { + return Tristate.True; + } + + return Tristate.False; + } + // This *could* be a parenthesized arrow function. return Tristate.Unknown; } @@ -2813,6 +2907,9 @@ namespace ts { function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction { let node = createNode(SyntaxKind.ArrowFunction); + setModifiers(node, parseModifiersForArrowFunction()); + let isAsync = !!(node.flags & NodeFlags.Async); + // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -2820,7 +2917,7 @@ namespace ts { // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*requireCompleteParameterList*/ !allowAmbiguity, node); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { @@ -2843,9 +2940,9 @@ namespace ts { return node; } - function parseArrowFunctionExpressionBody(): Block | Expression { + function parseArrowFunctionExpressionBody(isAsync: boolean): Block | Expression { if (token === SyntaxKind.OpenBraceToken) { - return parseFunctionBlock(/*allowYield*/ false, /*ignoreMissingOpenBrace*/ false); + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } if (token !== SyntaxKind.SemicolonToken && @@ -2867,10 +2964,12 @@ namespace ts { // up preemptively closing the containing construct. // // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. - return parseFunctionBlock(/*allowYield*/ false, /*ignoreMissingOpenBrace*/ true); + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true); } - - return parseAssignmentExpressionOrHigher(); + + return isAsync + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand: Expression): Expression { @@ -2918,7 +3017,23 @@ namespace ts { break; } - leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + if (token === SyntaxKind.AsKeyword) { + // Make sure we *do* perform ASI for constructs like this: + // var x = foo + // as (Bar) + // This should be parsed as an initialized variable, followed + // by a function call to 'as' with the argument 'Bar' + if (scanner.hasPrecedingLineBreak()) { + break; + } + else { + nextToken(); + leftOperand = makeAsExpression(leftOperand, parseType()); + } + } + else { + leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + } } return leftOperand; @@ -2955,6 +3070,7 @@ namespace ts { case SyntaxKind.GreaterThanEqualsToken: case SyntaxKind.InstanceOfKeyword: case SyntaxKind.InKeyword: + case SyntaxKind.AsKeyword: return 7; case SyntaxKind.LessThanLessThanToken: case SyntaxKind.GreaterThanGreaterThanToken: @@ -2982,6 +3098,13 @@ namespace ts { return finishNode(node); } + function makeAsExpression(left: Expression, right: TypeNode): AsExpression { + let node = createNode(SyntaxKind.AsExpression, left.pos); + node.expression = left; + node.type = right; + return finishNode(node); + } + function parsePrefixUnaryExpression() { let node = createNode(SyntaxKind.PrefixUnaryExpression); node.operator = token; @@ -3010,8 +3133,32 @@ namespace ts { node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } + + function isAwaitExpression(): boolean { + if (token === SyntaxKind.AwaitKeyword) { + if (inAwaitContext()) { + return true; + } + + // here we are using similar heuristics as 'isYieldExpression' + return lookAhead(nextTokenIsIdentifierOnSameLine); + } + + return false; + } + + function parseAwaitExpression() { + var node = createNode(SyntaxKind.AwaitExpression); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } function parseUnaryExpressionOrHigher(): UnaryExpression { + if (isAwaitExpression()) { + return parseAwaitExpression(); + } + switch (token) { case SyntaxKind.PlusToken: case SyntaxKind.MinusToken: @@ -3027,7 +3174,13 @@ namespace ts { case SyntaxKind.VoidKeyword: return parseVoidExpression(); case SyntaxKind.LessThanToken: - return parseTypeAssertion(); + if (sourceFile.languageVariant !== LanguageVariant.JSX) { + return parseTypeAssertion(); + } + if(lookAhead(nextTokenIsIdentifierOrKeyword)) { + return parseJsxElementOrSelfClosingElement(); + } + // Fall through default: return parsePostfixExpressionOrHigher(); } @@ -3154,6 +3307,154 @@ namespace ts { node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } + + function parseJsxElementOrSelfClosingElement(): JsxElement|JsxSelfClosingElement { + let opening = parseJsxOpeningOrSelfClosingElement(); + if (opening.kind === SyntaxKind.JsxOpeningElement) { + let node = createNode(SyntaxKind.JsxElement, opening.pos); + node.openingElement = opening; + + node.children = parseJsxChildren(node.openingElement.tagName); + node.closingElement = parseJsxClosingElement(); + return finishNode(node); + } + else { + Debug.assert(opening.kind === SyntaxKind.JsxSelfClosingElement); + // Nothing else to do for self-closing elements + return opening; + } + } + + function parseJsxText(): JsxText { + let node = createNode(SyntaxKind.JsxText, scanner.getStartPos()); + token = scanner.scanJsxToken(); + return finishNode(node); + } + + function parseJsxChild(): JsxChild { + switch (token) { + case SyntaxKind.JsxText: + return parseJsxText(); + case SyntaxKind.OpenBraceToken: + return parseJsxExpression(); + case SyntaxKind.LessThanToken: + return parseJsxElementOrSelfClosingElement(); + } + Debug.fail('Unknown JSX child kind ' + token); + } + + function parseJsxChildren(openingTagName: EntityName): NodeArray { + let result = >[]; + result.pos = scanner.getStartPos(); + let saveParsingContext = parsingContext; + parsingContext |= 1 << ParsingContext.JsxChildren; + + while(true) { + token = scanner.reScanJsxToken(); + if (token === SyntaxKind.LessThanSlashToken) { + break; + } + else if (token === SyntaxKind.EndOfFileToken) { + parseErrorAtCurrentToken(Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, getTextOfNodeFromSourceText(sourceText, openingTagName)); + break; + } + result.push(parseJsxChild()); + } + + result.end = scanner.getTokenPos(); + + parsingContext = saveParsingContext; + + return result; + } + + function parseJsxOpeningOrSelfClosingElement(): JsxOpeningElement|JsxSelfClosingElement { + let fullStart = scanner.getStartPos(); + + parseExpected(SyntaxKind.LessThanToken); + + let tagName = parseJsxElementName(); + + let attributes = parseList(ParsingContext.JsxAttributes, parseJsxAttribute); + let node: JsxOpeningLikeElement; + + if (parseOptional(SyntaxKind.GreaterThanToken)) { + node = createNode(SyntaxKind.JsxOpeningElement, fullStart); + } + else { + parseExpected(SyntaxKind.SlashToken); + parseExpected(SyntaxKind.GreaterThanToken); + node = createNode(SyntaxKind.JsxSelfClosingElement, fullStart); + } + + node.tagName = tagName; + node.attributes = attributes; + + return finishNode(node); + } + + function parseJsxElementName(): EntityName { + scanJsxIdentifier(); + let elementName: EntityName = parseIdentifierName(); + while (parseOptional(SyntaxKind.DotToken)) { + scanJsxIdentifier(); + let node = createNode(SyntaxKind.QualifiedName, elementName.pos); + node.left = elementName; + node.right = parseIdentifierName(); + elementName = finishNode(node); + } + return elementName; + } + + function parseJsxExpression(): JsxExpression { + let node = createNode(SyntaxKind.JsxExpression); + + parseExpected(SyntaxKind.OpenBraceToken); + if (token !== SyntaxKind.CloseBraceToken) { + node.expression = parseExpression(); + } + parseExpected(SyntaxKind.CloseBraceToken); + + return finishNode(node); + } + + function parseJsxAttribute(): JsxAttribute | JsxSpreadAttribute { + if (token === SyntaxKind.OpenBraceToken) { + return parseJsxSpreadAttribute(); + } + + scanJsxIdentifier(); + let node = createNode(SyntaxKind.JsxAttribute); + node.name = parseIdentifierName(); + if (parseOptional(SyntaxKind.EqualsToken)) { + switch (token) { + case SyntaxKind.StringLiteral: + node.initializer = parseLiteralNode(); + break; + default: + node.initializer = parseJsxExpression(); + break; + } + } + return finishNode(node); + } + + function parseJsxSpreadAttribute(): JsxSpreadAttribute { + let node = createNode(SyntaxKind.JsxSpreadAttribute); + parseExpected(SyntaxKind.OpenBraceToken); + parseExpected(SyntaxKind.DotDotDotToken); + node.expression = parseExpression(); + parseExpected(SyntaxKind.CloseBraceToken); + return finishNode(node); + } + + function parseJsxClosingElement(): JsxClosingElement { + let node = createNode(SyntaxKind.JsxClosingElement); + parseExpected(SyntaxKind.LessThanSlashToken); + node.tagName = parseJsxElementName(); + parseExpected(SyntaxKind.GreaterThanToken); + return finishNode(node); + } function parseTypeAssertion(): TypeAssertion { let node = createNode(SyntaxKind.TypeAssertionExpression); @@ -3325,6 +3626,15 @@ namespace ts { return parseArrayLiteralExpression(); case SyntaxKind.OpenBraceToken: return parseObjectLiteralExpression(); + case SyntaxKind.AsyncKeyword: + // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. + // If we encounter `async [no LineTerminator here] function` then this is an async + // function; otherwise, its an identifier. + if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { + break; + } + + return parseFunctionExpression(); case SyntaxKind.ClassKeyword: return parseClassExpression(); case SyntaxKind.FunctionKeyword: @@ -3440,23 +3750,36 @@ namespace ts { } function parseFunctionExpression(): FunctionExpression { - // GeneratorExpression : - // function * BindingIdentifier[Yield]opt (FormalParameters[Yield, GeneratorParameter]) { GeneratorBody[Yield] } + // GeneratorExpression: + // function* BindingIdentifier [Yield][opt](FormalParameters[Yield]){ GeneratorBody } + // // FunctionExpression: - // function BindingIdentifieropt(FormalParameters) { FunctionBody } + // function BindingIdentifier[opt](FormalParameters){ FunctionBody } let saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); } + let node = createNode(SyntaxKind.FunctionExpression); + setModifiers(node, parseModifiers()); parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); - node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ !!node.asteriskToken, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlock(/*allowYield*/ !!node.asteriskToken, /* ignoreMissingOpenBrace */ false); + + let isGenerator = !!node.asteriskToken; + let isAsync = !!(node.flags & NodeFlags.Async); + node.name = + isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : + isGenerator ? doInYieldContext(parseOptionalIdentifier) : + isAsync ? doInAwaitContext(parseOptionalIdentifier) : + parseOptionalIdentifier(); + + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); + if (saveDecoratorContext) { setDecoratorContext(true); } + return finishNode(node); } @@ -3489,9 +3812,12 @@ namespace ts { return finishNode(node); } - function parseFunctionBlock(allowYield: boolean, ignoreMissingOpenBrace: boolean, diagnosticMessage?: DiagnosticMessage): Block { + function parseFunctionBlock(allowYield: boolean, allowAwait: boolean, ignoreMissingOpenBrace: boolean, diagnosticMessage?: DiagnosticMessage): Block { let savedYieldContext = inYieldContext(); setYieldContext(allowYield); + + let savedAwaitContext = inAwaitContext(); + setAwaitContext(allowAwait); // We may be in a [Decorator] context when parsing a function expression or // arrow function. The body of the function is not in [Decorator] context. @@ -3507,6 +3833,7 @@ namespace ts { } setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); return block; } @@ -3754,6 +4081,11 @@ namespace ts { nextToken(); return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } + + function nextTokenIsFunctionKeywordOnSameLine() { + nextToken(); + return token === SyntaxKind.FunctionKeyword && !scanner.hasPrecedingLineBreak(); + } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -3798,6 +4130,7 @@ namespace ts { case SyntaxKind.ModuleKeyword: case SyntaxKind.NamespaceKeyword: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case SyntaxKind.AsyncKeyword: case SyntaxKind.DeclareKeyword: nextToken(); // ASI takes effect for this modifier. @@ -3817,10 +4150,12 @@ namespace ts { return true; } continue; + case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.StaticKeyword: + case SyntaxKind.AbstractKeyword: nextToken(); continue; default: @@ -3866,6 +4201,7 @@ namespace ts { case SyntaxKind.ImportKeyword: return isStartOfDeclaration(); + case SyntaxKind.AsyncKeyword: case SyntaxKind.DeclareKeyword: case SyntaxKind.InterfaceKeyword: case SyntaxKind.ModuleKeyword: @@ -3944,7 +4280,7 @@ namespace ts { return parseDebuggerStatement(); case SyntaxKind.AtToken: return parseDeclaration(); - + case SyntaxKind.AsyncKeyword: case SyntaxKind.InterfaceKeyword: case SyntaxKind.TypeKeyword: case SyntaxKind.ModuleKeyword: @@ -3957,6 +4293,7 @@ namespace ts { case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.PublicKeyword: + case SyntaxKind.AbstractKeyword: case SyntaxKind.StaticKeyword: if (isStartOfDeclaration()) { return parseDeclaration(); @@ -4013,13 +4350,13 @@ namespace ts { return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === SyntaxKind.StringLiteral); } - function parseFunctionBlockOrSemicolon(isGenerator: boolean, diagnosticMessage?: DiagnosticMessage): Block { + function parseFunctionBlockOrSemicolon(isGenerator: boolean, isAsync: boolean, diagnosticMessage?: DiagnosticMessage): Block { if (token !== SyntaxKind.OpenBraceToken && canParseSemicolon()) { parseSemicolon(); return; } - return parseFunctionBlock(isGenerator, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); + return parseFunctionBlock(isGenerator, isAsync, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); } // DECLARATIONS @@ -4031,7 +4368,7 @@ namespace ts { let node = createNode(SyntaxKind.BindingElement); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); node.name = parseIdentifierOrPattern(); - node.initializer = parseInitializer(/*inParameter*/ false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } @@ -4048,7 +4385,7 @@ namespace ts { node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseInitializer(/*inParameter*/ false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } @@ -4154,8 +4491,10 @@ namespace ts { parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier(); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ !!node.asteriskToken, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken, Diagnostics.or_expected); + let isGenerator = !!node.asteriskToken; + let isAsync = !!(node.flags & NodeFlags.Async); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, Diagnostics.or_expected); return finishNode(node); } @@ -4164,8 +4503,8 @@ namespace ts { node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.ConstructorKeyword); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, Diagnostics.or_expected); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, Diagnostics.or_expected); return finishNode(node); } @@ -4176,8 +4515,10 @@ namespace ts { method.asteriskToken = asteriskToken; method.name = name; method.questionToken = questionToken; - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ !!asteriskToken, /*requireCompleteParameterList*/ false, method); - method.body = parseFunctionBlockOrSemicolon(!!asteriskToken, diagnosticMessage); + let isGenerator = !!asteriskToken; + let isAsync = !!(method.flags & NodeFlags.Async); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } @@ -4230,8 +4571,8 @@ namespace ts { node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return finishNode(node); } @@ -4353,6 +4694,7 @@ namespace ts { modifiers = []; modifiers.pos = modifierStart; } + flags |= modifierToFlag(modifierKind); modifiers.push(finishNode(createNode(modifierKind, modifierStart))); } @@ -4363,6 +4705,24 @@ namespace ts { return modifiers; } + function parseModifiersForArrowFunction(): ModifiersArray { + let flags = 0; + let modifiers: ModifiersArray; + if (token === SyntaxKind.AsyncKeyword) { + let modifierStart = scanner.getStartPos(); + let modifierKind = token; + nextToken(); + modifiers = []; + modifiers.pos = modifierStart; + flags |= modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + + return modifiers; + } + function parseClassElement(): ClassElement { if (token === SyntaxKind.SemicolonToken) { let result = createNode(SyntaxKind.SemicolonClassElement); @@ -4419,7 +4779,7 @@ namespace ts { function parseClassDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ClassDeclaration { return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, SyntaxKind.ClassDeclaration); } - + function parseClassDeclarationOrExpression(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, kind: SyntaxKind): ClassLikeDeclaration { let node = createNode(kind, fullStart); node.decorators = decorators; @@ -4430,13 +4790,9 @@ namespace ts { node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); if (parseExpected(SyntaxKind.OpenBraceToken)) { - // ClassTail[Yield,GeneratorParameter] : See 14.5 - // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } - // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } - - node.members = inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseClassMembers) - : parseClassMembers(); + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } + node.members = parseClassMembers(); parseExpected(SyntaxKind.CloseBraceToken); } else { @@ -4447,14 +4803,11 @@ namespace ts { } function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray { - // ClassTail[Yield,GeneratorParameter] : See 14.5 - // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } - // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return isClassHeritageClause && inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseHeritageClausesWorker) - : parseHeritageClausesWorker(); + return parseList(ParsingContext.HeritageClauses, parseHeritageClause); } return undefined; @@ -4602,6 +4955,10 @@ namespace ts { return nextToken() === SyntaxKind.OpenParenToken; } + function nextTokenIsSlash() { + return nextToken() === SyntaxKind.SlashToken; + } + function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === SyntaxKind.CommaToken || @@ -4802,7 +5159,7 @@ namespace ts { } function processReferenceComments(sourceFile: SourceFile): void { - let triviaScanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/false, sourceText); + let triviaScanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/false, LanguageVariant.Standard, sourceText); let referencedFiles: FileReference[] = []; let amdDependencies: { path: string; name: string }[] = []; let amdModuleName: string; @@ -4889,6 +5246,8 @@ namespace ts { ArrayBindingElements, // Binding elements in array binding list ArgumentExpressions, // Expressions in argument list ObjectLiteralMembers, // Members in object literal + JsxAttributes, // Attributes in jsx element + JsxChildren, // Things between opening and closing JSX tags ArrayLiteralMembers, // Members in array literal Parameters, // Parameters in parameter list TypeParameters, // Type parameters in type parameter list diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c780b8709ba..2924b30114e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -104,14 +104,14 @@ namespace ts { }; } - export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile): Diagnostic[] { - let diagnostics = program.getOptionsDiagnostics().concat( - program.getSyntacticDiagnostics(sourceFile), - program.getGlobalDiagnostics(), - program.getSemanticDiagnostics(sourceFile)); + export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[] { + let diagnostics = program.getOptionsDiagnostics(cancellationToken).concat( + program.getSyntacticDiagnostics(sourceFile, cancellationToken), + program.getGlobalDiagnostics(cancellationToken), + program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } return sortAndDeduplicateDiagnostics(diagnostics); @@ -233,10 +233,15 @@ namespace ts { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback): EmitResult { + function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult { + return runWithCancellationToken(() => emitWorker(this, sourceFile, writeFileCallback, cancellationToken)); + } + + function emitWorker(program: Program, sourceFile: SourceFile, writeFileCallback: WriteFileCallback, cancellationToken: CancellationToken): EmitResult { // If the noEmitOnError flag is set, then check if we have any errors so far. If so, - // immediately bail out. - if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) { + // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we + // get any preEmit diagnostics, not just the ones + if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } @@ -265,55 +270,88 @@ namespace ts { return filesByName.get(fileName); } - function getDiagnosticsHelper(sourceFile: SourceFile, getDiagnostics: (sourceFile: SourceFile) => Diagnostic[]): Diagnostic[] { + function getDiagnosticsHelper( + sourceFile: SourceFile, + getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationToken) => Diagnostic[], + cancellationToken: CancellationToken): Diagnostic[] { if (sourceFile) { - return getDiagnostics(sourceFile); + return getDiagnostics(sourceFile, cancellationToken); } let allDiagnostics: Diagnostic[] = []; forEach(program.getSourceFiles(), sourceFile => { - addRange(allDiagnostics, getDiagnostics(sourceFile)); + if (cancellationToken) { + cancellationToken.throwIfCancellationRequested(); + } + addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); }); return sortAndDeduplicateDiagnostics(allDiagnostics); } - function getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[] { - return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile); + function getSyntacticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); } - function getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[] { - return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile); + function getSemanticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); } - function getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[] { - return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile); + function getDeclarationDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } - function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { + function getSyntacticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return sourceFile.parseDiagnostics; } - function getSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { - let typeChecker = getDiagnosticsProducingTypeChecker(); + function runWithCancellationToken(func: () => T): T { + try { + return func(); + } + catch (e) { + if (e instanceof OperationCanceledException) { + // We were canceled while performing the operation. Because our type checker + // might be a bad state, we need to throw it away. + // + // Note: we are overly agressive here. We do not actually *have* to throw away + // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep + // the lifetimes of these two TypeCheckers the same. Also, we generally only + // cancel when the user has made a change anyways. And, in that case, we (the + // program instance) will get thrown away anyways. So trying to keep one of + // these type checkers alive doesn't serve much purpose. + noDiagnosticsTypeChecker = undefined; + diagnosticsProducingTypeChecker = undefined; + } - Debug.assert(!!sourceFile.bindDiagnostics); - let bindDiagnostics = sourceFile.bindDiagnostics; - let checkDiagnostics = typeChecker.getDiagnostics(sourceFile); - let programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); - - return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); - } - - function getDeclarationDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { - if (!isDeclarationFile(sourceFile)) { - let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); - // Don't actually write any files since we're just getting diagnostics. - let writeFile: WriteFileCallback = () => { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + throw e; } } + function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + return runWithCancellationToken(() => { + let typeChecker = getDiagnosticsProducingTypeChecker(); + + Debug.assert(!!sourceFile.bindDiagnostics); + let bindDiagnostics = sourceFile.bindDiagnostics; + let checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); + let programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); + + return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); + }); + } + + function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + return runWithCancellationToken(() => { + if (!isDeclarationFile(sourceFile)) { + let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); + // Don't actually write any files since we're just getting diagnostics. + var writeFile: WriteFileCallback = () => { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + } + }); + } + function getOptionsDiagnostics(): Diagnostic[] { let allDiagnostics: Diagnostic[] = []; addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); @@ -475,7 +513,7 @@ namespace ts { } else if (node.kind === SyntaxKind.ModuleDeclaration && (node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 - // An AmbientExternalModuleDeclaration declares an external module. + // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. // The StringLiteral must specify a top - level external module name. // Relative external module names are not permitted @@ -487,7 +525,7 @@ namespace ts { let moduleName = nameLiteral.text; if (moduleName) { // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules // only through top - level external module names. Relative external module names are not permitted. let searchName = normalizePath(combinePaths(basePath, moduleName)); forEach(supportedExtensions, extension => findModuleSourceFile(searchName + extension, nameLiteral)); @@ -626,7 +664,7 @@ namespace ts { } } else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) { - // We cannot use createDiagnosticFromNode because nodes do not have parents yet + // We cannot use createDiagnosticFromNode because nodes do not have parents yet let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } @@ -653,7 +691,7 @@ namespace ts { } if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== directorySeparator) { - // Make sure directory path ends with directory separator so this string can directly + // Make sure directory path ends with directory separator so this string can directly // used to replace with "" to get the relative path of the source file and the relative path doesn't // start with / making it rooted path commonSourceDirectory += directorySeparator; @@ -674,6 +712,11 @@ namespace ts { !options.experimentalDecorators) { diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); } + + if (options.experimentalAsyncFunctions && + options.target !== ScriptTarget.ES6) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); + } } } } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index a6fbf4e4466..024326440ef 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -21,26 +21,31 @@ namespace ts { reScanGreaterToken(): SyntaxKind; reScanSlashToken(): SyntaxKind; reScanTemplateToken(): SyntaxKind; + scanJsxIdentifier(): SyntaxKind; + reScanJsxToken(): SyntaxKind; + scanJsxToken(): SyntaxKind; scan(): SyntaxKind; // Sets the text for the scanner to scan. An optional subrange starting point and length // can be provided to have the scanner only scan a portion of the text. setText(text: string, start?: number, length?: number): void; setOnError(onError: ErrorCallback): void; setScriptTarget(scriptTarget: ScriptTarget): void; + setLanguageVariant(variant: LanguageVariant): void; setTextPos(textPos: number): void; - // Invokes the provided callback then unconditionally restores the scanner to the state it + // Invokes the provided callback then unconditionally restores the scanner to the state it // was in immediately prior to invoking the callback. The result of invoking the callback // is returned from this function. lookAhead(callback: () => T): T; // Invokes the provided callback. If the callback returns something falsy, then it restores - // the scanner to the state it was in immediately prior to invoking the callback. If the + // the scanner to the state it was in immediately prior to invoking the callback. If the // callback returns something truthy, then the scanner state is not rolled back. The result // of invoking the callback is returned from this function. tryScan(callback: () => T): T; } let textToToken: Map = { + "abstract": SyntaxKind.AbstractKeyword, "any": SyntaxKind.AnyKeyword, "as": SyntaxKind.AsKeyword, "boolean": SyntaxKind.BooleanKeyword, @@ -49,423 +54,426 @@ namespace ts { "catch": SyntaxKind.CatchKeyword, "class": SyntaxKind.ClassKeyword, "continue": SyntaxKind.ContinueKeyword, - "const": SyntaxKind.ConstKeyword, - "constructor": SyntaxKind.ConstructorKeyword, - "debugger": SyntaxKind.DebuggerKeyword, - "declare": SyntaxKind.DeclareKeyword, - "default": SyntaxKind.DefaultKeyword, - "delete": SyntaxKind.DeleteKeyword, - "do": SyntaxKind.DoKeyword, - "else": SyntaxKind.ElseKeyword, - "enum": SyntaxKind.EnumKeyword, - "export": SyntaxKind.ExportKeyword, - "extends": SyntaxKind.ExtendsKeyword, - "false": SyntaxKind.FalseKeyword, - "finally": SyntaxKind.FinallyKeyword, - "for": SyntaxKind.ForKeyword, - "from": SyntaxKind.FromKeyword, - "function": SyntaxKind.FunctionKeyword, - "get": SyntaxKind.GetKeyword, - "if": SyntaxKind.IfKeyword, - "implements": SyntaxKind.ImplementsKeyword, - "import": SyntaxKind.ImportKeyword, - "in": SyntaxKind.InKeyword, - "instanceof": SyntaxKind.InstanceOfKeyword, - "interface": SyntaxKind.InterfaceKeyword, - "is": SyntaxKind.IsKeyword, - "let": SyntaxKind.LetKeyword, - "module": SyntaxKind.ModuleKeyword, - "namespace": SyntaxKind.NamespaceKeyword, - "new": SyntaxKind.NewKeyword, - "null": SyntaxKind.NullKeyword, - "number": SyntaxKind.NumberKeyword, - "package": SyntaxKind.PackageKeyword, - "private": SyntaxKind.PrivateKeyword, - "protected": SyntaxKind.ProtectedKeyword, - "public": SyntaxKind.PublicKeyword, - "require": SyntaxKind.RequireKeyword, - "return": SyntaxKind.ReturnKeyword, - "set": SyntaxKind.SetKeyword, - "static": SyntaxKind.StaticKeyword, - "string": SyntaxKind.StringKeyword, - "super": SyntaxKind.SuperKeyword, - "switch": SyntaxKind.SwitchKeyword, - "symbol": SyntaxKind.SymbolKeyword, - "this": SyntaxKind.ThisKeyword, - "throw": SyntaxKind.ThrowKeyword, - "true": SyntaxKind.TrueKeyword, - "try": SyntaxKind.TryKeyword, - "type": SyntaxKind.TypeKeyword, - "typeof": SyntaxKind.TypeOfKeyword, - "var": SyntaxKind.VarKeyword, - "void": SyntaxKind.VoidKeyword, - "while": SyntaxKind.WhileKeyword, - "with": SyntaxKind.WithKeyword, - "yield": SyntaxKind.YieldKeyword, - "of": SyntaxKind.OfKeyword, - "{": SyntaxKind.OpenBraceToken, - "}": SyntaxKind.CloseBraceToken, - "(": SyntaxKind.OpenParenToken, - ")": SyntaxKind.CloseParenToken, - "[": SyntaxKind.OpenBracketToken, - "]": SyntaxKind.CloseBracketToken, - ".": SyntaxKind.DotToken, - "...": SyntaxKind.DotDotDotToken, - ";": SyntaxKind.SemicolonToken, - ",": SyntaxKind.CommaToken, - "<": SyntaxKind.LessThanToken, - ">": SyntaxKind.GreaterThanToken, - "<=": SyntaxKind.LessThanEqualsToken, - ">=": SyntaxKind.GreaterThanEqualsToken, - "==": SyntaxKind.EqualsEqualsToken, - "!=": SyntaxKind.ExclamationEqualsToken, - "===": SyntaxKind.EqualsEqualsEqualsToken, - "!==": SyntaxKind.ExclamationEqualsEqualsToken, - "=>": SyntaxKind.EqualsGreaterThanToken, - "+": SyntaxKind.PlusToken, - "-": SyntaxKind.MinusToken, - "*": SyntaxKind.AsteriskToken, - "/": SyntaxKind.SlashToken, - "%": SyntaxKind.PercentToken, - "++": SyntaxKind.PlusPlusToken, - "--": SyntaxKind.MinusMinusToken, - "<<": SyntaxKind.LessThanLessThanToken, - ">>": SyntaxKind.GreaterThanGreaterThanToken, - ">>>": SyntaxKind.GreaterThanGreaterThanGreaterThanToken, - "&": SyntaxKind.AmpersandToken, - "|": SyntaxKind.BarToken, - "^": SyntaxKind.CaretToken, - "!": SyntaxKind.ExclamationToken, - "~": SyntaxKind.TildeToken, - "&&": SyntaxKind.AmpersandAmpersandToken, - "||": SyntaxKind.BarBarToken, - "?": SyntaxKind.QuestionToken, - ":": SyntaxKind.ColonToken, - "=": SyntaxKind.EqualsToken, - "+=": SyntaxKind.PlusEqualsToken, - "-=": SyntaxKind.MinusEqualsToken, - "*=": SyntaxKind.AsteriskEqualsToken, - "/=": SyntaxKind.SlashEqualsToken, - "%=": SyntaxKind.PercentEqualsToken, - "<<=": SyntaxKind.LessThanLessThanEqualsToken, - ">>=": SyntaxKind.GreaterThanGreaterThanEqualsToken, - ">>>=": SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken, - "&=": SyntaxKind.AmpersandEqualsToken, - "|=": SyntaxKind.BarEqualsToken, - "^=": SyntaxKind.CaretEqualsToken, - "@": SyntaxKind.AtToken, - }; + "const": SyntaxKind.ConstKeyword, + "constructor": SyntaxKind.ConstructorKeyword, + "debugger": SyntaxKind.DebuggerKeyword, + "declare": SyntaxKind.DeclareKeyword, + "default": SyntaxKind.DefaultKeyword, + "delete": SyntaxKind.DeleteKeyword, + "do": SyntaxKind.DoKeyword, + "else": SyntaxKind.ElseKeyword, + "enum": SyntaxKind.EnumKeyword, + "export": SyntaxKind.ExportKeyword, + "extends": SyntaxKind.ExtendsKeyword, + "false": SyntaxKind.FalseKeyword, + "finally": SyntaxKind.FinallyKeyword, + "for": SyntaxKind.ForKeyword, + "from": SyntaxKind.FromKeyword, + "function": SyntaxKind.FunctionKeyword, + "get": SyntaxKind.GetKeyword, + "if": SyntaxKind.IfKeyword, + "implements": SyntaxKind.ImplementsKeyword, + "import": SyntaxKind.ImportKeyword, + "in": SyntaxKind.InKeyword, + "instanceof": SyntaxKind.InstanceOfKeyword, + "interface": SyntaxKind.InterfaceKeyword, + "is": SyntaxKind.IsKeyword, + "let": SyntaxKind.LetKeyword, + "module": SyntaxKind.ModuleKeyword, + "namespace": SyntaxKind.NamespaceKeyword, + "new": SyntaxKind.NewKeyword, + "null": SyntaxKind.NullKeyword, + "number": SyntaxKind.NumberKeyword, + "package": SyntaxKind.PackageKeyword, + "private": SyntaxKind.PrivateKeyword, + "protected": SyntaxKind.ProtectedKeyword, + "public": SyntaxKind.PublicKeyword, + "require": SyntaxKind.RequireKeyword, + "return": SyntaxKind.ReturnKeyword, + "set": SyntaxKind.SetKeyword, + "static": SyntaxKind.StaticKeyword, + "string": SyntaxKind.StringKeyword, + "super": SyntaxKind.SuperKeyword, + "switch": SyntaxKind.SwitchKeyword, + "symbol": SyntaxKind.SymbolKeyword, + "this": SyntaxKind.ThisKeyword, + "throw": SyntaxKind.ThrowKeyword, + "true": SyntaxKind.TrueKeyword, + "try": SyntaxKind.TryKeyword, + "type": SyntaxKind.TypeKeyword, + "typeof": SyntaxKind.TypeOfKeyword, + "var": SyntaxKind.VarKeyword, + "void": SyntaxKind.VoidKeyword, + "while": SyntaxKind.WhileKeyword, + "with": SyntaxKind.WithKeyword, + "yield": SyntaxKind.YieldKeyword, + "async": SyntaxKind.AsyncKeyword, + "await": SyntaxKind.AwaitKeyword, + "of": SyntaxKind.OfKeyword, + "{": SyntaxKind.OpenBraceToken, + "}": SyntaxKind.CloseBraceToken, + "(": SyntaxKind.OpenParenToken, + ")": SyntaxKind.CloseParenToken, + "[": SyntaxKind.OpenBracketToken, + "]": SyntaxKind.CloseBracketToken, + ".": SyntaxKind.DotToken, + "...": SyntaxKind.DotDotDotToken, + ";": SyntaxKind.SemicolonToken, + ",": SyntaxKind.CommaToken, + "<": SyntaxKind.LessThanToken, + ">": SyntaxKind.GreaterThanToken, + "<=": SyntaxKind.LessThanEqualsToken, + ">=": SyntaxKind.GreaterThanEqualsToken, + "==": SyntaxKind.EqualsEqualsToken, + "!=": SyntaxKind.ExclamationEqualsToken, + "===": SyntaxKind.EqualsEqualsEqualsToken, + "!==": SyntaxKind.ExclamationEqualsEqualsToken, + "=>": SyntaxKind.EqualsGreaterThanToken, + "+": SyntaxKind.PlusToken, + "-": SyntaxKind.MinusToken, + "*": SyntaxKind.AsteriskToken, + "/": SyntaxKind.SlashToken, + "%": SyntaxKind.PercentToken, + "++": SyntaxKind.PlusPlusToken, + "--": SyntaxKind.MinusMinusToken, + "<<": SyntaxKind.LessThanLessThanToken, + ">": SyntaxKind.GreaterThanGreaterThanToken, + ">>>": SyntaxKind.GreaterThanGreaterThanGreaterThanToken, + "&": SyntaxKind.AmpersandToken, + "|": SyntaxKind.BarToken, + "^": SyntaxKind.CaretToken, + "!": SyntaxKind.ExclamationToken, + "~": SyntaxKind.TildeToken, + "&&": SyntaxKind.AmpersandAmpersandToken, + "||": SyntaxKind.BarBarToken, + "?": SyntaxKind.QuestionToken, + ":": SyntaxKind.ColonToken, + "=": SyntaxKind.EqualsToken, + "+=": SyntaxKind.PlusEqualsToken, + "-=": SyntaxKind.MinusEqualsToken, + "*=": SyntaxKind.AsteriskEqualsToken, + "/=": SyntaxKind.SlashEqualsToken, + "%=": SyntaxKind.PercentEqualsToken, + "<<=": SyntaxKind.LessThanLessThanEqualsToken, + ">>=": SyntaxKind.GreaterThanGreaterThanEqualsToken, + ">>>=": SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken, + "&=": SyntaxKind.AmpersandEqualsToken, + "|=": SyntaxKind.BarEqualsToken, + "^=": SyntaxKind.CaretEqualsToken, + "@": SyntaxKind.AtToken, + }; - /* - As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers - IdentifierStart :: - Can contain Unicode 3.0.0 categories: - Uppercase letter (Lu), - Lowercase letter (Ll), - Titlecase letter (Lt), - Modifier letter (Lm), - Other letter (Lo), or - Letter number (Nl). - IdentifierPart :: = - Can contain IdentifierStart + Unicode 3.0.0 categories: - Non-spacing mark (Mn), - Combining spacing mark (Mc), - Decimal number (Nd), or - Connector punctuation (Pc). + /* + As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers + IdentifierStart :: + Can contain Unicode 3.0.0 categories: + Uppercase letter (Lu), + Lowercase letter (Ll), + Titlecase letter (Lt), + Modifier letter (Lm), + Other letter (Lo), or + Letter number (Nl). + IdentifierPart :: = + Can contain IdentifierStart + Unicode 3.0.0 categories: + Non-spacing mark (Mn), + Combining spacing mark (Mc), + Decimal number (Nd), or + Connector punctuation (Pc). - Codepoint ranges for ES3 Identifiers are extracted from the Unicode 3.0.0 specification at: - http://www.unicode.org/Public/3.0-Update/UnicodeData-3.0.0.txt - */ - let unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; - let unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; + Codepoint ranges for ES3 Identifiers are extracted from the Unicode 3.0.0 specification at: + http://www.unicode.org/Public/3.0-Update/UnicodeData-3.0.0.txt + */ + let unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; + let unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; - /* - As per ECMAScript Language Specification 5th Edition, Section 7.6: ISyntaxToken Names and Identifiers - IdentifierStart :: - Can contain Unicode 6.2 categories: - Uppercase letter (Lu), - Lowercase letter (Ll), - Titlecase letter (Lt), - Modifier letter (Lm), - Other letter (Lo), or - Letter number (Nl). - IdentifierPart :: - Can contain IdentifierStart + Unicode 6.2 categories: - Non-spacing mark (Mn), - Combining spacing mark (Mc), - Decimal number (Nd), - Connector punctuation (Pc), - , or - . + /* + As per ECMAScript Language Specification 5th Edition, Section 7.6: ISyntaxToken Names and Identifiers + IdentifierStart :: + Can contain Unicode 6.2 categories: + Uppercase letter (Lu), + Lowercase letter (Ll), + Titlecase letter (Lt), + Modifier letter (Lm), + Other letter (Lo), or + Letter number (Nl). + IdentifierPart :: + Can contain IdentifierStart + Unicode 6.2 categories: + Non-spacing mark (Mn), + Combining spacing mark (Mc), + Decimal number (Nd), + Connector punctuation (Pc), + , or + . - Codepoint ranges for ES5 Identifiers are extracted from the Unicode 6.2 specification at: - http://www.unicode.org/Public/6.2.0/ucd/UnicodeData.txt - */ - let unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; - let unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; + Codepoint ranges for ES5 Identifiers are extracted from the Unicode 6.2 specification at: + http://www.unicode.org/Public/6.2.0/ucd/UnicodeData.txt + */ + let unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; + let unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; - function lookupInUnicodeMap(code: number, map: number[]): boolean { - // Bail out quickly if it couldn't possibly be in the map. - if (code < map[0]) { - return false; - } + function lookupInUnicodeMap(code: number, map: number[]): boolean { + // Bail out quickly if it couldn't possibly be in the map. + if (code < map[0]) { + return false; + } - // Perform binary search in one of the Unicode range maps - let lo: number = 0; - let hi: number = map.length; - let mid: number; + // Perform binary search in one of the Unicode range maps + let lo: number = 0; + let hi: number = map.length; + let mid: number; - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - // mid has to be even to catch a range's beginning - mid -= mid % 2; - if (map[mid] <= code && code <= map[mid + 1]) { - return true; - } + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + // mid has to be even to catch a range's beginning + mid -= mid % 2; + if (map[mid] <= code && code <= map[mid + 1]) { + return true; + } - if (code < map[mid]) { - hi = mid; - } - else { - lo = mid + 2; - } - } + if (code < map[mid]) { + hi = mid; + } + else { + lo = mid + 2; + } + } - return false; - } + return false; + } - /* @internal */ export function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget) { - return languageVersion >= ScriptTarget.ES5 ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); - } + /* @internal */ export function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget) { + return languageVersion >= ScriptTarget.ES5 ? + lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); + } - function isUnicodeIdentifierPart(code: number, languageVersion: ScriptTarget) { - return languageVersion >= ScriptTarget.ES5 ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); - } + function isUnicodeIdentifierPart(code: number, languageVersion: ScriptTarget) { + return languageVersion >= ScriptTarget.ES5 ? + lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); + } - function makeReverseMap(source: Map): string[] { - let result: string[] = []; - for (let name in source) { - if (source.hasOwnProperty(name)) { - result[source[name]] = name; - } - } - return result; - } + function makeReverseMap(source: Map): string[] { + let result: string[] = []; + for (let name in source) { + if (source.hasOwnProperty(name)) { + result[source[name]] = name; + } + } + return result; + } - let tokenStrings = makeReverseMap(textToToken); + let tokenStrings = makeReverseMap(textToToken); - export function tokenToString(t: SyntaxKind): string { - return tokenStrings[t]; - } + export function tokenToString(t: SyntaxKind): string { + return tokenStrings[t]; + } - /* @internal */ - export function stringToToken(s: string): SyntaxKind { - return textToToken[s]; - } + /* @internal */ + export function stringToToken(s: string): SyntaxKind { + return textToToken[s]; + } - /* @internal */ - export function computeLineStarts(text: string): number[] { - let result: number[] = new Array(); - let pos = 0; - let lineStart = 0; - while (pos < text.length) { - let ch = text.charCodeAt(pos++); - switch (ch) { - case CharacterCodes.carriageReturn: - if (text.charCodeAt(pos) === CharacterCodes.lineFeed) { - pos++; - } - case CharacterCodes.lineFeed: - result.push(lineStart); - lineStart = pos; - break; - default: - if (ch > CharacterCodes.maxAsciiCharacter && isLineBreak(ch)) { - result.push(lineStart); - lineStart = pos; - } - break; - } - } - result.push(lineStart); - return result; - } + /* @internal */ + export function computeLineStarts(text: string): number[] { + let result: number[] = new Array(); + let pos = 0; + let lineStart = 0; + while (pos < text.length) { + let ch = text.charCodeAt(pos++); + switch (ch) { + case CharacterCodes.carriageReturn: + if (text.charCodeAt(pos) === CharacterCodes.lineFeed) { + pos++; + } + case CharacterCodes.lineFeed: + result.push(lineStart); + lineStart = pos; + break; + default: + if (ch > CharacterCodes.maxAsciiCharacter && isLineBreak(ch)) { + result.push(lineStart); + lineStart = pos; + } + break; + } + } + result.push(lineStart); + return result; + } - export function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number { - return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character); - } + export function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number { + return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character); + } - /* @internal */ - export function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number { - Debug.assert(line >= 0 && line < lineStarts.length); - return lineStarts[line] + character; - } + /* @internal */ + export function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number { + Debug.assert(line >= 0 && line < lineStarts.length); + return lineStarts[line] + character; + } - /* @internal */ - export function getLineStarts(sourceFile: SourceFile): number[] { - return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); - } + /* @internal */ + export function getLineStarts(sourceFile: SourceFile): number[] { + return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); + } - /* @internal */ - export function computeLineAndCharacterOfPosition(lineStarts: number[], position: number) { - let lineNumber = binarySearch(lineStarts, position); - if (lineNumber < 0) { - // If the actual position was not found, - // the binary search returns the negative value of the next line start - // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 - // then the search will return -2 - lineNumber = ~lineNumber - 1; - } - return { - line: lineNumber, - character: position - lineStarts[lineNumber] - }; - } + /* @internal */ + export function computeLineAndCharacterOfPosition(lineStarts: number[], position: number) { + let lineNumber = binarySearch(lineStarts, position); + if (lineNumber < 0) { + // If the actual position was not found, + // the binary search returns the negative value of the next line start + // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 + // then the search will return -2 + lineNumber = ~lineNumber - 1; + } + return { + line: lineNumber, + character: position - lineStarts[lineNumber] + }; + } - export function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter { - return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); - } + export function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter { + return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); + } - let hasOwnProperty = Object.prototype.hasOwnProperty; + let hasOwnProperty = Object.prototype.hasOwnProperty; - export function isWhiteSpace(ch: number): boolean { - // Note: nextLine is in the Zs space, and should be considered to be a whitespace. - // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. - return ch === CharacterCodes.space || - ch === CharacterCodes.tab || - ch === CharacterCodes.verticalTab || - ch === CharacterCodes.formFeed || - ch === CharacterCodes.nonBreakingSpace || - ch === CharacterCodes.nextLine || - ch === CharacterCodes.ogham || - ch >= CharacterCodes.enQuad && ch <= CharacterCodes.zeroWidthSpace || - ch === CharacterCodes.narrowNoBreakSpace || - ch === CharacterCodes.mathematicalSpace || - ch === CharacterCodes.ideographicSpace || - ch === CharacterCodes.byteOrderMark; - } + export function isWhiteSpace(ch: number): boolean { + // Note: nextLine is in the Zs space, and should be considered to be a whitespace. + // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. + return ch === CharacterCodes.space || + ch === CharacterCodes.tab || + ch === CharacterCodes.verticalTab || + ch === CharacterCodes.formFeed || + ch === CharacterCodes.nonBreakingSpace || + ch === CharacterCodes.nextLine || + ch === CharacterCodes.ogham || + ch >= CharacterCodes.enQuad && ch <= CharacterCodes.zeroWidthSpace || + ch === CharacterCodes.narrowNoBreakSpace || + ch === CharacterCodes.mathematicalSpace || + ch === CharacterCodes.ideographicSpace || + ch === CharacterCodes.byteOrderMark; + } - export function isLineBreak(ch: number): boolean { - // ES5 7.3: - // The ECMAScript line terminator characters are listed in Table 3. - // Table 3: Line Terminator Characters - // Code Unit Value Name Formal Name - // \u000A Line Feed - // \u000D Carriage Return - // \u2028 Line separator - // \u2029 Paragraph separator - // Only the characters in Table 3 are treated as line terminators. Other new line or line - // breaking characters are treated as white space but not as line terminators. + export function isLineBreak(ch: number): boolean { + // ES5 7.3: + // The ECMAScript line terminator characters are listed in Table 3. + // Table 3: Line Terminator Characters + // Code Unit Value Name Formal Name + // \u000A Line Feed + // \u000D Carriage Return + // \u2028 Line separator + // \u2029 Paragraph separator + // Only the characters in Table 3 are treated as line terminators. Other new line or line + // breaking characters are treated as white space but not as line terminators. - return ch === CharacterCodes.lineFeed || - ch === CharacterCodes.carriageReturn || - ch === CharacterCodes.lineSeparator || - ch === CharacterCodes.paragraphSeparator; - } + return ch === CharacterCodes.lineFeed || + ch === CharacterCodes.carriageReturn || + ch === CharacterCodes.lineSeparator || + ch === CharacterCodes.paragraphSeparator; + } - function isDigit(ch: number): boolean { - return ch >= CharacterCodes._0 && ch <= CharacterCodes._9; - } + function isDigit(ch: number): boolean { + return ch >= CharacterCodes._0 && ch <= CharacterCodes._9; + } - /* @internal */ - export function isOctalDigit(ch: number): boolean { - return ch >= CharacterCodes._0 && ch <= CharacterCodes._7; - } + /* @internal */ + export function isOctalDigit(ch: number): boolean { + return ch >= CharacterCodes._0 && ch <= CharacterCodes._7; + } - export function couldStartTrivia(text: string, pos: number): boolean { - // Keep in sync with skipTrivia - let ch = text.charCodeAt(pos); - switch (ch) { - case CharacterCodes.carriageReturn: - case CharacterCodes.lineFeed: - case CharacterCodes.tab: - case CharacterCodes.verticalTab: - case CharacterCodes.formFeed: - case CharacterCodes.space: - case CharacterCodes.slash: - // starts of normal trivia - case CharacterCodes.lessThan: - case CharacterCodes.equals: - case CharacterCodes.greaterThan: - // Starts of conflict marker trivia - return true; - default: - return ch > CharacterCodes.maxAsciiCharacter; - } - } + export function couldStartTrivia(text: string, pos: number): boolean { + // Keep in sync with skipTrivia + let ch = text.charCodeAt(pos); + switch (ch) { + case CharacterCodes.carriageReturn: + case CharacterCodes.lineFeed: + case CharacterCodes.tab: + case CharacterCodes.verticalTab: + case CharacterCodes.formFeed: + case CharacterCodes.space: + case CharacterCodes.slash: + // starts of normal trivia + case CharacterCodes.lessThan: + case CharacterCodes.equals: + case CharacterCodes.greaterThan: + // Starts of conflict marker trivia + return true; + default: + return ch > CharacterCodes.maxAsciiCharacter; + } + } - /* @internal */ - export function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number { - // Keep in sync with couldStartTrivia - while (true) { - let ch = text.charCodeAt(pos); - switch (ch) { - case CharacterCodes.carriageReturn: - if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) { - pos++; - } - case CharacterCodes.lineFeed: - pos++; - if (stopAfterLineBreak) { - return pos; - } - continue; - case CharacterCodes.tab: - case CharacterCodes.verticalTab: - case CharacterCodes.formFeed: - case CharacterCodes.space: - pos++; - continue; - case CharacterCodes.slash: - if (text.charCodeAt(pos + 1) === CharacterCodes.slash) { - pos += 2; - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - continue; - } - if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) { - pos += 2; - while (pos < text.length) { - if (text.charCodeAt(pos) === CharacterCodes.asterisk && text.charCodeAt(pos + 1) === CharacterCodes.slash) { - pos += 2; - break; - } - pos++; - } - continue; - } - break; + /* @internal */ + export function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number { + // Keep in sync with couldStartTrivia + while (true) { + let ch = text.charCodeAt(pos); + switch (ch) { + case CharacterCodes.carriageReturn: + if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) { + pos++; + } + case CharacterCodes.lineFeed: + pos++; + if (stopAfterLineBreak) { + return pos; + } + continue; + case CharacterCodes.tab: + case CharacterCodes.verticalTab: + case CharacterCodes.formFeed: + case CharacterCodes.space: + pos++; + continue; + case CharacterCodes.slash: + if (text.charCodeAt(pos + 1) === CharacterCodes.slash) { + pos += 2; + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + continue; + } + if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) { + pos += 2; + while (pos < text.length) { + if (text.charCodeAt(pos) === CharacterCodes.asterisk && text.charCodeAt(pos + 1) === CharacterCodes.slash) { + pos += 2; + break; + } + pos++; + } + continue; + } + break; - case CharacterCodes.lessThan: - case CharacterCodes.equals: - case CharacterCodes.greaterThan: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos); - continue; - } - break; + case CharacterCodes.lessThan: + case CharacterCodes.equals: + case CharacterCodes.greaterThan: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos); + continue; + } + break; - default: - if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch) || isLineBreak(ch))) { - pos++; - continue; - } - break; - } - return pos; - } - } + default: + if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch) || isLineBreak(ch))) { + pos++; + continue; + } + break; + } + return pos; + } + } - // All conflict markers consist of the same character repeated seven times. If it is - // a <<<<<<< or >>>>>>> marker then it is also followd by a space. + // All conflict markers consist of the same character repeated seven times. If it is + // a <<<<<<< or >>>>>>> marker then it is also followd by a space. let mergeConflictMarkerLength = "<<<<<<<".length; function isConflictMarkerTrivia(text: string, pos: number) { @@ -520,12 +528,12 @@ namespace ts { return pos; } - // Extract comments from the given source text starting at the given position. If trailing is - // false, whitespace is skipped until the first line break and comments between that location - // and the next token are returned.If trailing is true, comments occurring between the given - // position and the next line break are returned.The return value is an array containing a - // TextRange for each comment. Single-line comment ranges include the beginning '//' characters - // but not the ending line break. Multi - line comment ranges include the beginning '/* and + // Extract comments from the given source text starting at the given position. If trailing is + // false, whitespace is skipped until the first line break and comments between that location + // and the next token are returned.If trailing is true, comments occurring between the given + // position and the next line break are returned.The return value is an array containing a + // TextRange for each comment. Single-line comment ranges include the beginning '//' characters + // but not the ending line break. Multi - line comment ranges include the beginning '/* and // ending '*/' characters.The return value is undefined if no comments were found. function getCommentRanges(text: string, pos: number, trailing: boolean): CommentRange[] { let result: CommentRange[]; @@ -621,11 +629,12 @@ namespace ts { ch >= CharacterCodes._0 && ch <= CharacterCodes._9 || ch === CharacterCodes.$ || ch === CharacterCodes._ || ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion); } - + /* @internal */ - // Creates a scanner over a (possibly unspecified) range of a piece of text. + // Creates a scanner over a (possibly unspecified) range of a piece of text. export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, + languageVariant = LanguageVariant.Standard, text?: string, onError?: ErrorCallback, start?: number, @@ -665,9 +674,13 @@ namespace ts { reScanGreaterToken, reScanSlashToken, reScanTemplateToken, + scanJsxIdentifier, + reScanJsxToken, + scanJsxToken, scan, setText, setScriptTarget, + setLanguageVariant, setOnError, setTextPos, tryScan, @@ -1302,6 +1315,9 @@ namespace ts { if (text.charCodeAt(pos + 1) === CharacterCodes.equals) { return pos += 2, token = SyntaxKind.LessThanEqualsToken; } + if (text.charCodeAt(pos + 1) === CharacterCodes.slash && languageVariant === LanguageVariant.JSX) { + return pos += 2, token = SyntaxKind.LessThanSlashToken; + } return pos++, token = SyntaxKind.LessThanToken; case CharacterCodes.equals: if (isConflictMarkerTrivia(text, pos)) { @@ -1481,6 +1497,62 @@ namespace ts { return token = scanTemplateAndSetTokenValue(); } + function reScanJsxToken(): SyntaxKind { + pos = tokenPos = startPos; + return token = scanJsxToken(); + } + + function scanJsxToken(): SyntaxKind { + startPos = tokenPos = pos; + + if (pos >= end) { + return token = SyntaxKind.EndOfFileToken; + } + + let char = text.charCodeAt(pos); + if (char === CharacterCodes.lessThan) { + if (text.charCodeAt(pos + 1) === CharacterCodes.slash) { + pos += 2; + return token = SyntaxKind.LessThanSlashToken; + } + pos++; + return token = SyntaxKind.LessThanToken; + } + + if (char === CharacterCodes.openBrace) { + pos++; + return token = SyntaxKind.OpenBraceToken; + } + + while (pos < end) { + pos++; + char = text.charCodeAt(pos); + if ((char === CharacterCodes.openBrace) || (char === CharacterCodes.lessThan)) { + break; + } + } + return token = SyntaxKind.JsxText; + } + + // Scans a JSX identifier; these differ from normal identifiers in that + // they allow dashes + function scanJsxIdentifier(): SyntaxKind { + if (token === SyntaxKind.Identifier) { + let firstCharPosition = pos; + while (pos < end) { + let ch = text.charCodeAt(pos); + if (ch === CharacterCodes.minus || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + pos++; + } + else { + break; + } + } + tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); + } + return token; + } + function speculationHelper(callback: () => T, isLookahead: boolean): T { let savePos = pos; let saveStartPos = startPos; @@ -1525,6 +1597,10 @@ namespace ts { languageVersion = scriptTarget; } + function setLanguageVariant(variant: LanguageVariant) { + languageVariant = variant; + } + function setTextPos(textPos: number) { Debug.assert(textPos >= 0); pos = textPos; diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 017b5679d4b..4d00e579677 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -191,7 +191,8 @@ namespace ts { return sys.exit(ExitStatus.Success); } - if (commandLine.options.watch) { + // Firefox has Object.prototype.watch + if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) { if (!sys.watchFile) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c30de7b32e6..b150b53349f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -48,6 +48,7 @@ namespace ts { SemicolonToken, CommaToken, LessThanToken, + LessThanSlashToken, GreaterThanToken, LessThanEqualsToken, GreaterThanEqualsToken, @@ -139,8 +140,11 @@ namespace ts { StaticKeyword, YieldKeyword, // Contextual keywords + AbstractKeyword, AsKeyword, AnyKeyword, + AsyncKeyword, + AwaitKeyword, BooleanKeyword, ConstructorKeyword, DeclareKeyword, @@ -187,6 +191,7 @@ namespace ts { ArrayType, TupleType, UnionType, + IntersectionType, ParenthesizedType, // Binding patterns ObjectBindingPattern, @@ -207,6 +212,7 @@ namespace ts { DeleteExpression, TypeOfExpression, VoidExpression, + AwaitExpression, PrefixUnaryExpression, PostfixUnaryExpression, BinaryExpression, @@ -217,6 +223,8 @@ namespace ts { ClassExpression, OmittedExpression, ExpressionWithTypeArguments, + AsExpression, + // Misc TemplateSpan, SemicolonClassElement, @@ -265,6 +273,16 @@ namespace ts { // Module references ExternalModuleReference, + //JSX + JsxElement, + JsxSelfClosingElement, + JsxOpeningElement, + JsxText, + JsxClosingElement, + JsxAttribute, + JsxSpreadAttribute, + JsxExpression, + // Clauses CaseClause, DefaultClause, @@ -343,17 +361,19 @@ namespace ts { Private = 0x00000020, // Property/Method Protected = 0x00000040, // Property/Method Static = 0x00000080, // Property/Method - Default = 0x00000100, // Function/Class (export default declaration) - MultiLine = 0x00000200, // Multi-line array or object literal - Synthetic = 0x00000400, // Synthetic node (for full fidelity) - DeclarationFile = 0x00000800, // Node is a .d.ts file - Let = 0x00001000, // Variable declaration - Const = 0x00002000, // Variable declaration - OctalLiteral = 0x00004000, // Octal numeric literal - Namespace = 0x00008000, // Namespace declaration - ExportContext = 0x00010000, // Export context (initialized by binding) + Abstract = 0x00000100, // Class/Method/ConstructSignature + Async = 0x00000200, // Property/Method/Function + Default = 0x00000400, // Function/Class (export default declaration) + MultiLine = 0x00000800, // Multi-line array or object literal + Synthetic = 0x00001000, // Synthetic node (for full fidelity) + DeclarationFile = 0x00002000, // Node is a .d.ts file + Let = 0x00004000, // Variable declaration + Const = 0x00008000, // Variable declaration + OctalLiteral = 0x00010000, // Octal numeric literal + Namespace = 0x00020000, // Namespace declaration + ExportContext = 0x00040000, // Export context (initialized by binding) - Modifier = Export | Ambient | Public | Private | Protected | Static | Default, + Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async, AccessibilityModifier = Public | Private | Protected, BlockScoped = Let | Const } @@ -363,39 +383,53 @@ namespace ts { None = 0, // If this node was parsed in a context where 'in-expressions' are not allowed. - DisallowIn = 1 << 1, + DisallowIn = 1 << 0, // If this node was parsed in the 'yield' context created when parsing a generator. - Yield = 1 << 2, - - // If this node was parsed in the parameters of a generator. - GeneratorParameter = 1 << 3, + Yield = 1 << 1, // If this node was parsed as part of a decorator - Decorator = 1 << 4, + Decorator = 1 << 2, + + // If this node was parsed in the 'await' context created when parsing an async function. + Await = 1 << 3, // If the parser encountered an error when parsing the code that created this node. Note // the parser only sets this directly on the node it creates right after encountering the // error. - ThisNodeHasError = 1 << 5, + ThisNodeHasError = 1 << 4, // This node was parsed in a JavaScript file and can be processed differently. For example // its type can be specified usign a JSDoc comment. - JavaScriptFile = 1 << 6, + JavaScriptFile = 1 << 5, // Context flags set directly by the parser. - ParserGeneratedFlags = DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError, + ParserGeneratedFlags = DisallowIn | Yield | Decorator | ThisNodeHasError | Await, + + // Exclude these flags when parsing a Type + TypeExcludesFlags = Yield | Await, // Context flags computed by aggregating child flags upwards. // Used during incremental parsing to determine if this node or any of its children had an // error. Computed only once and then cached. - ThisNodeOrAnySubNodesHasError = 1 << 7, + ThisNodeOrAnySubNodesHasError = 1 << 6, // Used to know if we've computed data from children and cached it in this node. - HasAggregatedChildData = 1 << 8 + HasAggregatedChildData = 1 << 7 } + export const enum JsxFlags { + None = 0, + IntrinsicNamedElement = 1 << 0, + IntrinsicIndexedElement = 1 << 1, + ClassElement = 1 << 2, + UnknownElement = 1 << 3, + + IntrinsicElement = IntrinsicNamedElement | IntrinsicIndexedElement + } + + /* @internal */ export const enum RelationComparisonResult { Succeeded = 1, // Should be truthy @@ -634,10 +668,14 @@ namespace ts { elementTypes: NodeArray; } - export interface UnionTypeNode extends TypeNode { + export interface UnionOrIntersectionTypeNode extends TypeNode { types: NodeArray; } + export interface UnionTypeNode extends UnionOrIntersectionTypeNode { } + + export interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { } + export interface ParenthesizedTypeNode extends TypeNode { type: TypeNode; } @@ -702,6 +740,10 @@ namespace ts { expression: UnaryExpression; } + export interface AwaitExpression extends UnaryExpression { + expression: UnaryExpression; + } + export interface YieldExpression extends Expression { asteriskToken?: Node; expression?: Expression; @@ -799,11 +841,64 @@ namespace ts { export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; + export interface AsExpression extends Expression { + expression: Expression; + type: TypeNode; + } + export interface TypeAssertion extends UnaryExpression { type: TypeNode; expression: UnaryExpression; } + export type AssertionExpression = TypeAssertion | AsExpression; + + /// A JSX expression of the form ... + export interface JsxElement extends PrimaryExpression { + openingElement: JsxOpeningElement; + children: NodeArray; + closingElement: JsxClosingElement; + } + + /// The opening element of a ... JsxElement + export interface JsxOpeningElement extends Expression { + _openingElementBrand?: any; + tagName: EntityName; + attributes: NodeArray; + } + + /// A JSX expression of the form + export interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { + _selfClosingElementBrand?: any; + } + + /// Either the opening tag in a ... pair, or the lone in a self-closing form + export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + + export interface JsxAttribute extends Node { + name: Identifier; + /// JSX attribute initializers are optional; is sugar for + initializer?: Expression; + } + + export interface JsxSpreadAttribute extends Node { + expression: Expression; + } + + export interface JsxClosingElement extends Node { + tagName: EntityName; + } + + export interface JsxExpression extends Expression { + expression?: Expression; + } + + export interface JsxText extends Node { + _jsxTextExpressionBrand: any; + } + + export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; + export interface Statement extends Node { _statementBrand: any; } @@ -1144,6 +1239,7 @@ namespace ts { amdDependencies: {path: string; name: string}[]; moduleName: string; referencedFiles: FileReference[]; + languageVariant: LanguageVariant; /** * lib.d.ts should have a reference comment like @@ -1194,6 +1290,15 @@ namespace ts { (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; } + export class OperationCanceledException { } + + export interface CancellationToken { + isCancellationRequested(): boolean; + + /** @throws OperationCanceledException if isCancellationRequested is true */ + throwIfCancellationRequested(): void; + } + export interface Program extends ScriptReferenceHost { /** * Get a list of files in the program @@ -1210,15 +1315,15 @@ namespace ts { * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the JavaScript and declaration files. */ - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult; - getOptionsDiagnostics(): Diagnostic[]; - getGlobalDiagnostics(): Diagnostic[]; - getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; - getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; - getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - /** + /** * Gets a type checker that can be used to semantically analyze source fils in the program. */ getTypeChecker(): TypeChecker; @@ -1323,10 +1428,13 @@ namespace ts { getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; + getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getJsxIntrinsicTagNames(): Symbol[]; + // Should not be called directly. Should only be accessed through the Program instance. - /* @internal */ getDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + /* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; /* @internal */ getGlobalDiagnostics(): Diagnostic[]; - /* @internal */ getEmitResolver(sourceFile?: SourceFile): EmitResolver; + /* @internal */ getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken): EmitResolver; /* @internal */ getNodeCount(): number; /* @internal */ getIdentifierCount(): number; @@ -1479,7 +1587,7 @@ namespace ts { Merged = 0x02000000, // Merged symbol (created during program binding) Transient = 0x04000000, // Transient symbol (created during type check) Prototype = 0x08000000, // Prototype property (no source representation) - UnionProperty = 0x10000000, // Property in union type + SyntheticProperty = 0x10000000, // Property in union or intersection type Optional = 0x20000000, // Optional property ExportStar = 0x40000000, // Export * declaration @@ -1503,8 +1611,8 @@ namespace ts { PropertyExcludes = Value, EnumMemberExcludes = Value, FunctionExcludes = Value & ~(Function | ValueModule), - ClassExcludes = (Value | Type) & ~ValueModule, - InterfaceExcludes = Type & ~Interface, + ClassExcludes = (Value | Type) & ~(ValueModule | Interface), // class-interface mergability done in checker.ts + InterfaceExcludes = Type & ~(Interface | Class), RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule), @@ -1529,7 +1637,7 @@ namespace ts { Export = ExportNamespace | ExportType | ExportValue, /* @internal */ - // The set of things we consider semantically classifiable. Used to speed up the LS during + // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. Classifiable = Class | Enum | TypeAlias | Interface | TypeParameter | Module, } @@ -1558,7 +1666,7 @@ namespace ts { instantiations?: Map; // Instantiations of generic type alias (undefined if non-generic) mapper?: TypeMapper; // Type mapper for instantiation alias referenced?: boolean; // True if alias symbol has been referenced as a value - unionType?: UnionType; // Containing union type for union property + containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property resolvedExports?: SymbolTable; // Resolved exports of module exportsChecked?: boolean; // True if exports of external module have been checked isNestedRedeclaration?: boolean; // True if symbol is block scoped redeclaration @@ -1577,21 +1685,26 @@ namespace ts { LexicalThis = 0x00000002, // Lexical 'this' reference CaptureThis = 0x00000004, // Lexical 'this' used in body EmitExtends = 0x00000008, // Emit __extends - SuperInstance = 0x00000010, // Instance 'super' reference - SuperStatic = 0x00000020, // Static 'super' reference - ContextChecked = 0x00000040, // Contextual types have been assigned + EmitDecorate = 0x00000010, // Emit __decorate + EmitParam = 0x00000020, // Emit __param helper for decorators + EmitAwaiter = 0x00000040, // Emit __awaiter + EmitGenerator = 0x00000080, // Emit __generator + SuperInstance = 0x00000100, // Instance 'super' reference + SuperStatic = 0x00000200, // Static 'super' reference + ContextChecked = 0x00000400, // Contextual types have been assigned + LexicalArguments = 0x00000800, + CaptureArguments = 0x00001000, // Lexical 'arguments' used in body (for async functions) // Values for enum members have been computed, and any errors have been reported for them. - EnumValuesComputed = 0x00000080, - BlockScopedBindingInLoop = 0x00000100, - EmitDecorate = 0x00000200, // Emit __decorate - EmitParam = 0x00000400, // Emit __param helper for decorators - LexicalModuleMergesWithClass = 0x00000800, // Instantiated lexical module declaration is merged with a previous class declaration. + EnumValuesComputed = 0x00002000, + BlockScopedBindingInLoop = 0x00004000, + LexicalModuleMergesWithClass= 0x00008000, // Instantiated lexical module declaration is merged with a previous class declaration. } /* @internal */ export interface NodeLinks { resolvedType?: Type; // Cached type of type node + resolvedAwaitedType?: Type; // Cached awaited type of type node resolvedSignature?: Signature; // Cached signature of signature node or call expression resolvedSymbol?: Symbol; // Cached name resolution result flags?: NodeCheckFlags; // Set of flags specific to Node @@ -1603,6 +1716,8 @@ namespace ts { assignmentChecks?: Map; // Cache of assignment checks hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context importOnRightSide?: Symbol; // for import declarations - import that appear on the right side + jsxFlags?: JsxFlags; // flags for knowning what kind of element/attributes we're dealing with + resolvedJsxType?: Type; // resolved element attributes type of a JSX openinglike element } export const enum TypeFlags { @@ -1620,17 +1735,18 @@ namespace ts { Interface = 0x00000800, // Interface Reference = 0x00001000, // Generic type reference Tuple = 0x00002000, // Tuple - Union = 0x00004000, // Union - Anonymous = 0x00008000, // Anonymous - Instantiated = 0x00010000, // Instantiated anonymous type + Union = 0x00004000, // Union (T | U) + Intersection = 0x00008000, // Intersection (T & U) + Anonymous = 0x00010000, // Anonymous + Instantiated = 0x00020000, // Instantiated anonymous type /* @internal */ - FromSignature = 0x00020000, // Created for signature assignment check - ObjectLiteral = 0x00040000, // Originates in an object literal + FromSignature = 0x00040000, // Created for signature assignment check + ObjectLiteral = 0x00080000, // Originates in an object literal /* @internal */ - ContainsUndefinedOrNull = 0x00080000, // Type is or contains Undefined or Null type + ContainsUndefinedOrNull = 0x00100000, // Type is or contains Undefined or Null type /* @internal */ - ContainsObjectLiteral = 0x00100000, // Type is or contains object literal type - ESSymbol = 0x00200000, // Type of symbol primitive introduced in ES6 + ContainsObjectLiteral = 0x00200000, // Type is or contains object literal type + ESSymbol = 0x00400000, // Type of symbol primitive introduced in ES6 /* @internal */ Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null, @@ -1639,8 +1755,10 @@ namespace ts { StringLike = String | StringLiteral, NumberLike = Number | Enum, ObjectType = Class | Interface | Reference | Tuple | Anonymous, + UnionOrIntersection = Union | Intersection, + StructuredType = ObjectType | Union | Intersection, /* @internal */ - RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral + RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral } // Properties common to all types @@ -1698,7 +1816,7 @@ namespace ts { baseArrayType: TypeReference; // Array where T is best common type of element types } - export interface UnionType extends Type { + export interface UnionOrIntersectionType extends Type { types: Type[]; // Constituent types /* @internal */ reducedType: Type; // Reduced union type (all subtypes removed) @@ -1706,9 +1824,13 @@ namespace ts { resolvedProperties: SymbolTable; // Cache of resolved properties } + export interface UnionType extends UnionOrIntersectionType { } + + export interface IntersectionType extends UnionOrIntersectionType { } + /* @internal */ - // Resolved object or union type - export interface ResolvedType extends ObjectType, UnionType { + // Resolved object, union, or intersection type + export interface ResolvedType extends ObjectType, UnionOrIntersectionType { members: SymbolTable; // Properties by name properties: Symbol[]; // Properties callSignatures: Signature[]; // Call signatures of type @@ -1834,6 +1956,7 @@ namespace ts { help?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; + jsx?: JsxEmit; listFiles?: boolean; locale?: string; mapRoot?: string; @@ -1860,6 +1983,7 @@ namespace ts { watch?: boolean; isolatedModules?: boolean; experimentalDecorators?: boolean; + experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; /* @internal */ stripInternal?: boolean; @@ -1877,6 +2001,12 @@ namespace ts { System = 4, } + export const enum JsxEmit { + None = 0, + Preserve = 1, + React = 2 + } + export const enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1, @@ -1897,6 +2027,11 @@ namespace ts { Latest = ES6, } + export const enum LanguageVariant { + Standard, + JSX + } + export interface ParsedCommandLine { options: CompilerOptions; fileNames: string[]; @@ -2052,14 +2187,9 @@ namespace ts { verticalTab = 0x0B, // \v } - export interface CancellationToken { - isCancellationRequested(): boolean; - } - export interface CompilerHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; getDefaultLibFileName(options: CompilerOptions): string; - getCancellationToken? (): CancellationToken; writeFile: WriteFileCallback; getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index bd785c7a817..bec4ece0491 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -144,7 +144,7 @@ namespace ts { return true; } - return node.pos === node.end && node.kind !== SyntaxKind.EndOfFileToken; + return node.pos === node.end && node.pos >= 0 && node.kind !== SyntaxKind.EndOfFileToken; } export function nodeIsPresent(node: Node) { @@ -169,13 +169,13 @@ namespace ts { return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); } - export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string { + export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia = false): string { if (nodeIsMissing(node)) { return ""; } let text = sourceFile.text; - return text.substring(skipTrivia(text, node.pos), node.end); + return text.substring(includeTrivia ? node.pos : skipTrivia(text, node.pos), node.end); } export function getTextOfNodeFromSourceText(sourceText: string, node: Node): string { @@ -186,8 +186,8 @@ namespace ts { return sourceText.substring(skipTrivia(sourceText, node.pos), node.end); } - export function getTextOfNode(node: Node): string { - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node); + export function getTextOfNode(node: Node, includeTrivia = false): string { + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } // Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' @@ -274,7 +274,7 @@ namespace ts { } export function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan { - let scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.text, /*onError:*/ undefined, pos); + let scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); scanner.scan(); let start = scanner.getTokenPos(); return createTextSpanFromBounds(start, scanner.getTextPos()); @@ -746,6 +746,22 @@ namespace ts { } } } + + export function getEntityNameFromTypeNode(node: TypeNode): EntityName | Expression { + if (node) { + switch (node.kind) { + case SyntaxKind.TypeReference: + return (node).typeName; + case SyntaxKind.ExpressionWithTypeArguments: + return (node).expression + case SyntaxKind.Identifier: + case SyntaxKind.QualifiedName: + return (node); + } + } + + return undefined; + } export function getInvokedExpression(node: CallLikeExpression): Expression { if (node.kind === SyntaxKind.TaggedTemplateExpression) { @@ -848,6 +864,7 @@ namespace ts { case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.AsExpression: case SyntaxKind.TypeAssertionExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.FunctionExpression: @@ -864,6 +881,8 @@ namespace ts { case SyntaxKind.TemplateExpression: case SyntaxKind.NoSubstitutionTemplateLiteral: case SyntaxKind.OmittedExpression: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.YieldExpression: return true; case SyntaxKind.QualifiedName: @@ -910,7 +929,8 @@ namespace ts { return (forInStatement.initializer === node && forInStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || forInStatement.expression === node; case SyntaxKind.TypeAssertionExpression: - return node === (parent).expression; + case SyntaxKind.AsExpression: + return node === (parent).expression; case SyntaxKind.TemplateSpan: return node === (parent).expression; case SyntaxKind.ComputedPropertyName: @@ -1317,6 +1337,10 @@ namespace ts { return SyntaxKind.FirstTriviaToken <= token && token <= SyntaxKind.LastTriviaToken; } + export function isAsyncFunctionLike(node: Node): boolean { + return isFunctionLike(node) && (node.flags & NodeFlags.Async) !== 0 && !isAccessor(node); + } + /** * A declaration has a dynamic name if both of the following are true: * 1. The declaration has a computed property name @@ -1367,14 +1391,16 @@ namespace ts { export function isModifier(token: SyntaxKind): boolean { switch (token) { + case SyntaxKind.AbstractKeyword: + case SyntaxKind.AsyncKeyword: + case SyntaxKind.ConstKeyword: + case SyntaxKind.DeclareKeyword: + case SyntaxKind.DefaultKeyword: + case SyntaxKind.ExportKeyword: case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.StaticKeyword: - case SyntaxKind.ExportKeyword: - case SyntaxKind.DeclareKeyword: - case SyntaxKind.ConstKeyword: - case SyntaxKind.DefaultKeyword: return true; } return false; @@ -1402,8 +1428,6 @@ namespace ts { export function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node { let node = createNode(kind); - node.pos = -1; - node.end = -1; node.startsOnNewLine = startsOnNewLine; return node; } @@ -1530,6 +1554,11 @@ namespace ts { } } + export function isIntrinsicJsxName(name: string) { + let ch = name.substr(0, 1); + return ch.toLowerCase() === ch; + } + function get16BitUnicodeEscapeSequence(charCode: number): string { let hexCharCode = charCode.toString(16).toUpperCase(); let paddedHexCode = ("0000" + hexCharCode).slice(-4); @@ -1870,10 +1899,12 @@ namespace ts { case SyntaxKind.PublicKeyword: return NodeFlags.Public; case SyntaxKind.ProtectedKeyword: return NodeFlags.Protected; case SyntaxKind.PrivateKeyword: return NodeFlags.Private; + case SyntaxKind.AbstractKeyword: return NodeFlags.Abstract; case SyntaxKind.ExportKeyword: return NodeFlags.Export; case SyntaxKind.DeclareKeyword: return NodeFlags.Ambient; case SyntaxKind.ConstKeyword: return NodeFlags.Const; case SyntaxKind.DefaultKeyword: return NodeFlags.Default; + case SyntaxKind.AsyncKeyword: return NodeFlags.Async; } return 0; } @@ -1885,6 +1916,8 @@ namespace ts { case SyntaxKind.ElementAccessExpression: case SyntaxKind.NewExpression: case SyntaxKind.CallExpression: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.ParenthesizedExpression: @@ -1936,7 +1969,7 @@ namespace ts { return false; } } - + export function isRightSideOfQualifiedNameOrPropertyAccess(node: Node) { return (node.parent.kind === SyntaxKind.QualifiedName && (node.parent).right === node) || (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node); @@ -1950,6 +1983,10 @@ namespace ts { return fileExtensionIs(fileName, ".js"); } + export function isTsx(fileName: string) { + return fileExtensionIs(fileName, ".tsx"); + } + /** * Replace each instance of non-ascii characters by one, two, three, or four escape sequences * representing the UTF-8 encoding of the character, and return the expanded char code list. diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 21e88b9e41a..1b399e1b706 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -149,7 +149,7 @@ class CompilerBaselineRunner extends RunnerBase { // check errors it('Correct errors for ' + fileName, () => { if (this.errors) { - Harness.Baseline.runBaseline('Correct errors for ' + fileName, justName.replace(/\.ts$/, '.errors.txt'), (): string => { + Harness.Baseline.runBaseline('Correct errors for ' + fileName, justName.replace(/\.tsx?$/, '.errors.txt'), (): string => { if (result.errors.length === 0) return null; return getErrorBaseline(toBeCompiled, otherFiles, result); }); @@ -159,7 +159,7 @@ class CompilerBaselineRunner extends RunnerBase { // Source maps? it('Correct sourcemap content for ' + fileName, () => { if (options.sourceMap || options.inlineSourceMap) { - Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.ts$/, '.sourcemap.txt'), () => { + Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.tsx?$/, '.sourcemap.txt'), () => { var record = result.getSourceMapRecord(); if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) { // Because of the noEmitOnError option no files are created. We need to return null because baselining isn't required. @@ -177,7 +177,7 @@ class CompilerBaselineRunner extends RunnerBase { } // check js output - Harness.Baseline.runBaseline('Correct JS output for ' + fileName, justName.replace(/\.ts/, '.js'), () => { + Harness.Baseline.runBaseline('Correct JS output for ' + fileName, justName.replace(/\.tsx?/, '.js'), () => { var tsCode = ''; var tsSources = otherFiles.concat(toBeCompiled); if (tsSources.length > 1) { @@ -235,7 +235,7 @@ class CompilerBaselineRunner extends RunnerBase { throw new Error('Number of sourcemap files should be same as js files.'); } - Harness.Baseline.runBaseline('Correct Sourcemap output for ' + fileName, justName.replace(/\.ts/, '.js.map'), () => { + Harness.Baseline.runBaseline('Correct Sourcemap output for ' + fileName, justName.replace(/\.tsx?/, '.js.map'), () => { if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) { // We need to return null here or the runBaseLine will actually create a empty file. // Baselining isn't required here because there is no output. @@ -320,11 +320,11 @@ class CompilerBaselineRunner extends RunnerBase { let pullExtension = isSymbolBaseLine ? '.symbols.pull' : '.types.pull'; if (fullBaseLine !== pullBaseLine) { - Harness.Baseline.runBaseline('Correct full information for ' + fileName, justName.replace(/\.ts/, fullExtension), () => fullBaseLine); - Harness.Baseline.runBaseline('Correct pull information for ' + fileName, justName.replace(/\.ts/, pullExtension), () => pullBaseLine); + Harness.Baseline.runBaseline('Correct full information for ' + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); + Harness.Baseline.runBaseline('Correct pull information for ' + fileName, justName.replace(/\.tsx?/, pullExtension), () => pullBaseLine); } else { - Harness.Baseline.runBaseline('Correct information for ' + fileName, justName.replace(/\.ts/, fullExtension), () => fullBaseLine); + Harness.Baseline.runBaseline('Correct information for ' + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); } } @@ -391,7 +391,7 @@ class CompilerBaselineRunner extends RunnerBase { // this will set up a series of describe/it blocks to run between the setup and cleanup phases if (this.tests.length === 0) { - var testFiles = this.enumerateFiles(this.basePath, /\.ts$/, { recursive: true }); + var testFiles = this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true }); testFiles.forEach(fn => { fn = fn.replace(/\\/g, "/"); this.checkTestCodeOutput(fn); diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index ff5baddbb70..208237b8b64 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -190,14 +190,14 @@ module FourSlash { return "\nMarker: " + currentTestState.lastKnownMarker + "\nChecking: " + msg + "\n\n"; } - export class TestCancellationToken implements ts.CancellationToken { + export class TestCancellationToken implements ts.HostCancellationToken { // 0 - cancelled // >0 - not cancelled // <0 - not cancelled and value denotes number of isCancellationRequested after which token become cancelled - private static NotCancelled: number = -1; - private numberOfCallsBeforeCancellation: number = TestCancellationToken.NotCancelled; - public isCancellationRequested(): boolean { + private static NotCanceled: number = -1; + private numberOfCallsBeforeCancellation: number = TestCancellationToken.NotCanceled; + public isCancellationRequested(): boolean { if (this.numberOfCallsBeforeCancellation < 0) { return false; } @@ -216,7 +216,7 @@ module FourSlash { } public resetCancelled(): void { - this.numberOfCallsBeforeCancellation = TestCancellationToken.NotCancelled; + this.numberOfCallsBeforeCancellation = TestCancellationToken.NotCanceled; } } @@ -743,7 +743,7 @@ module FourSlash { var reference = references[i]; if (reference && reference.fileName === fileName && reference.textSpan.start === start && ts.textSpanEnd(reference.textSpan) === end) { if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) { - this.raiseError('verifyReferencesAtPositionListContains failed - item isWriteAccess value doe not match, actual: ' + reference.isWriteAccess + ', expected: ' + isWriteAccess + '.'); + this.raiseError('verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ' + reference.isWriteAccess + ', expected: ' + isWriteAccess + '.'); } return; } @@ -884,8 +884,16 @@ module FourSlash { this.activeFile.fileName, this.currentCaretPosition, findInStrings, findInComments); var ranges = this.getRanges(); + + if (!references) { + if (ranges.length !== 0) { + this.raiseError(`Expected ${ranges.length} rename locations; got none.`); + } + return; + } + if (ranges.length !== references.length) { - this.raiseError(this.assertionMessage("Rename locations", references.length, ranges.length)); + this.raiseError("Rename location count does not match result.\n\nExpected: " + JSON.stringify(ranges) + "\n\nActual:" + JSON.stringify(references)); } ranges = ranges.sort((r1, r2) => r1.start - r2.start); @@ -898,9 +906,7 @@ module FourSlash { if (reference.textSpan.start !== range.start || ts.textSpanEnd(reference.textSpan) !== range.end) { - this.raiseError(this.assertionMessage("Rename location", - "[" + reference.textSpan.start + "," + ts.textSpanEnd(reference.textSpan) + ")", - "[" + range.start + "," + range.end + ")")); + this.raiseError("Rename location results do not match.\n\nExpected: " + JSON.stringify(ranges) + "\n\nActual:" + JSON.stringify(references)); } } } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 6a559488150..9f26887ff90 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -212,7 +212,7 @@ module Utils { } var result = ""; - ts.forEach(Object.getOwnPropertyNames(flags),(v: any) => { + ts.forEach(Object.getOwnPropertyNames(flags), (v: any) => { if (isFinite(v)) { v = +v; if (f === +v) { @@ -410,7 +410,7 @@ module Harness { deleteFile(fileName: string): void; listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; log(text: string): void; - getMemoryUsage? (): number; + getMemoryUsage?(): number; } module IOImpl { @@ -794,7 +794,7 @@ module Harness { public reset() { this.fileCollection = {}; } - public toArray(): { fileName: string; file: WriterAggregator; }[]{ + public toArray(): { fileName: string; file: WriterAggregator; }[] { var result: { fileName: string; file: WriterAggregator; }[] = []; for (var p in this.fileCollection) { if (this.fileCollection.hasOwnProperty(p)) { @@ -1055,6 +1055,10 @@ module Harness { case 'emitdecoratormetadata': options.emitDecoratorMetadata = setting.value === 'true'; break; + + case 'experimentalasyncfunctions': + options.experimentalAsyncFunctions = setting.value === 'true'; + break; case 'noemithelpers': options.noEmitHelpers = setting.value === 'true'; @@ -1166,6 +1170,12 @@ module Harness { options.inlineSources = setting.value === 'true'; break; + case 'jsx': + options.jsx = setting.value.toLowerCase() === 'react' ? ts.JsxEmit.React : + setting.value.toLowerCase() === 'preserve' ? ts.JsxEmit.Preserve : + ts.JsxEmit.None; + break; + default: throw new Error('Unsupported compiler setting ' + setting.flag); } @@ -1229,7 +1239,7 @@ module Harness { } var dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts"; - + return ts.forEach(result.declFilesCode, declFile => declFile.fileName === dTsFileName ? declFile : undefined); } @@ -1428,6 +1438,10 @@ module Harness { return stringEndsWith(fileName, '.ts'); } + export function isTSX(fileName: string) { + return stringEndsWith(fileName, '.tsx'); + } + export function isDTS(fileName: string) { return stringEndsWith(fileName, '.d.ts'); } @@ -1435,6 +1449,9 @@ module Harness { export function isJS(fileName: string) { return stringEndsWith(fileName, '.js'); } + export function isJSX(fileName: string) { + return stringEndsWith(fileName, '.jsx'); + } export function isJSMap(fileName: string) { return stringEndsWith(fileName, '.js.map'); @@ -1455,12 +1472,15 @@ module Harness { if (isDTS(emittedFile.fileName)) { // .d.ts file, add to declFiles emit this.declFilesCode.push(emittedFile); - } else if (isJS(emittedFile.fileName)) { + } + else if (isJS(emittedFile.fileName) || isJSX(emittedFile.fileName)) { // .js file, add to files this.files.push(emittedFile); - } else if (isJSMap(emittedFile.fileName)) { + } + else if (isJSMap(emittedFile.fileName)) { this.sourceMaps.push(emittedFile); - } else { + } + else { throw new Error('Unrecognized file extension for file ' + emittedFile.fileName); } }); @@ -1495,6 +1515,16 @@ module Harness { // Regex for parsing options in the format "@Alpha: Value of any sort" var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines + // List of allowed metadata names + var fileMetadataNames = ["filename", "comments", "declaration", "module", + "nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror", + "noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom", + "errortruncation", "usecasesensitivefilenames", "preserveconstenums", + "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", + "isolatedmodules", "inlinesourcemap", "maproot", "sourceroot", + "inlinesources", "emitdecoratormetadata", "experimentaldecorators", + "skipdefaultlibcheck", "jsx"]; + function extractCompilerSettings(content: string): CompilerSetting[] { var opts: CompilerSetting[] = []; diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 8eb77817533..6cb92df5948 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -103,14 +103,11 @@ module Harness.LanguageService { } } - class CancellationToken { - public static None: CancellationToken = new CancellationToken(null); - - constructor(private cancellationToken: ts.CancellationToken) { - } + class DefaultHostCancellationToken implements ts.HostCancellationToken { + public static Instance = new DefaultHostCancellationToken(); public isCancellationRequested() { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + return false; } } @@ -124,8 +121,8 @@ module Harness.LanguageService { export class LanguageServiceAdapterHost { protected fileNameToScript: ts.Map = {}; - constructor(protected cancellationToken: ts.CancellationToken = CancellationToken.None, - protected settings = ts.getDefaultCompilerOptions()) { + constructor(protected cancellationToken = DefaultHostCancellationToken.Instance, + protected settings = ts.getDefaultCompilerOptions()) { } public getNewLine(): string { @@ -173,8 +170,8 @@ module Harness.LanguageService { /// Native adapter class NativeLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceHost { - getCompilationSettings(): ts.CompilerOptions { return this.settings; } - getCancellationToken(): ts.CancellationToken { return this.cancellationToken; } + getCompilationSettings() { return this.settings; } + getCancellationToken() { return this.cancellationToken; } getCurrentDirectory(): string { return ""; } getDefaultLibFileName(): string { return ""; } getScriptFileNames(): string[] { return this.getFilenames(); } @@ -194,7 +191,7 @@ module Harness.LanguageService { export class NativeLanugageServiceAdapter implements LanguageServiceAdapter { private host: NativeLanguageServiceHost; - constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) { + constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { this.host = new NativeLanguageServiceHost(cancellationToken, options); } getHost() { return this.host; } @@ -206,7 +203,7 @@ module Harness.LanguageService { /// Shim adapter class ShimLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceShimHost, ts.CoreServicesShimHost { private nativeHost: NativeLanguageServiceHost; - constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) { + constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { super(cancellationToken, options); this.nativeHost = new NativeLanguageServiceHost(cancellationToken, options); } @@ -218,7 +215,7 @@ module Harness.LanguageService { positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter { return this.nativeHost.positionToLineAndCharacter(fileName, position); } getCompilationSettings(): string { return JSON.stringify(this.nativeHost.getCompilationSettings()); } - getCancellationToken(): ts.CancellationToken { return this.nativeHost.getCancellationToken(); } + getCancellationToken(): ts.HostCancellationToken { return this.nativeHost.getCancellationToken(); } getCurrentDirectory(): string { return this.nativeHost.getCurrentDirectory(); } getDefaultLibFileName(): string { return this.nativeHost.getDefaultLibFileName(); } getScriptFileNames(): string { return JSON.stringify(this.nativeHost.getScriptFileNames()); } @@ -399,7 +396,7 @@ module Harness.LanguageService { export class ShimLanugageServiceAdapter implements LanguageServiceAdapter { private host: ShimLanguageServiceHost; private factory: ts.TypeScriptServicesFactory; - constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) { + constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { this.host = new ShimLanguageServiceHost(cancellationToken, options); this.factory = new TypeScript.Services.TypeScriptServicesFactory(); } @@ -446,7 +443,7 @@ module Harness.LanguageService { class SessionClientHost extends NativeLanguageServiceHost implements ts.server.SessionClientHost { private client: ts.server.SessionClient; - constructor(cancellationToken: ts.CancellationToken, settings: ts.CompilerOptions) { + constructor(cancellationToken: ts.HostCancellationToken, settings: ts.CompilerOptions) { super(cancellationToken, settings); } @@ -575,7 +572,7 @@ module Harness.LanguageService { export class ServerLanugageServiceAdapter implements LanguageServiceAdapter { private host: SessionClientHost; private client: ts.server.SessionClient; - constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) { + constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { // This is the main host that tests use to direct tests var clientHost = new SessionClientHost(cancellationToken, options); var client = new ts.server.SessionClient(clientHost); diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 1e9c6470421..13d93302f18 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -49,6 +49,7 @@ if (testConfigFile !== '') { if (!option) { continue; } + switch (option) { case 'compiler': runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index 269e889704c..fa8d9d2c597 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -27,7 +27,7 @@ class RunnerBase { var fixedPath = path; // full paths either start with a drive letter or / for *nix, shouldn't have \ in the path at this point - var fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.ts/g; + var fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g; var fullPathList = fixedPath.match(fullPath); if (fullPathList) { fullPathList.forEach((match: string) => fixedPath = fixedPath.replace(match, Harness.Path.getFileName(match))); diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index 78971965664..f177c421f4f 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -1169,3 +1169,16 @@ declare type ClassDecorator = (target: TFunction) => declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; + +declare type PromiseConstructorLike = new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void) => PromiseLike; + +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; +} diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index e1f06f11009..84e959caef8 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -1092,16 +1092,11 @@ interface CanvasRenderingContext2D { clearRect(x: number, y: number, w: number, h: number): void; clip(fillRule?: string): void; closePath(): void; - createImageData(imageDataOrSw: number, sh?: number): ImageData; - createImageData(imageDataOrSw: ImageData, sh?: number): ImageData; + createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData; createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; - createPattern(image: HTMLImageElement, repetition: string): CanvasPattern; - createPattern(image: HTMLCanvasElement, repetition: string): CanvasPattern; - createPattern(image: HTMLVideoElement, repetition: string): CanvasPattern; + createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; - drawImage(image: HTMLImageElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - drawImage(image: HTMLCanvasElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - drawImage(image: HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; fill(fillRule?: string): void; fillRect(x: number, y: number, w: number, h: number): void; fillText(text: string, x: number, y: number, maxWidth?: number): void; @@ -3370,8 +3365,7 @@ interface HTMLAreasCollection extends HTMLCollection { /** * Adds an element to the areas, controlRange, or options collection. */ - add(element: HTMLElement, before?: HTMLElement): void; - add(element: HTMLElement, before?: number): void; + add(element: HTMLElement, before?: HTMLElement | number): void; /** * Removes an element from the collection. */ @@ -6119,8 +6113,7 @@ interface HTMLSelectElement extends HTMLElement { * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. */ - add(element: HTMLElement, before?: HTMLElement): void; - add(element: HTMLElement, before?: number): void; + add(element: HTMLElement, before?: HTMLElement | number): void; /** * Returns whether a form will validate when it is submitted, without having to submit it. */ @@ -10281,8 +10274,7 @@ interface Screen extends EventTarget { systemXDPI: number; systemYDPI: number; width: number; - msLockOrientation(orientations: string): boolean; - msLockOrientation(orientations: string[]): boolean; + msLockOrientation(orientations: string | string[]): boolean; msUnlockOrientation(): void; addEventListener(type: "MSOrientationChange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -10354,8 +10346,7 @@ interface SourceBuffer extends EventTarget { updating: boolean; videoTracks: VideoTrackList; abort(): void; - appendBuffer(data: ArrayBuffer): void; - appendBuffer(data: ArrayBufferView): void; + appendBuffer(data: ArrayBuffer | ArrayBufferView): void; appendStream(stream: MSStream, maxSize?: number): void; remove(start: number, end: number): void; } @@ -10463,33 +10454,18 @@ declare var StyleSheetPageList: { } interface SubtleCrypto { - decrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - decrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; - deriveBits(algorithm: string, baseKey: CryptoKey, length: number): any; - deriveBits(algorithm: Algorithm, baseKey: CryptoKey, length: number): any; - deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - digest(algorithm: string, data: ArrayBufferView): any; - digest(algorithm: Algorithm, data: ArrayBufferView): any; - encrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - encrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; + decrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + deriveBits(algorithm: string | Algorithm, baseKey: CryptoKey, length: number): any; + deriveKey(algorithm: string | Algorithm, baseKey: CryptoKey, derivedKeyType: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + digest(algorithm: string | Algorithm, data: ArrayBufferView): any; + encrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; exportKey(format: string, key: CryptoKey): any; - generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): any; - generateKey(algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: ArrayBufferView, algorithm: string, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: ArrayBufferView, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - sign(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - sign(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - verify(algorithm: string, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; - verify(algorithm: Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; - wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string): any; - wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: Algorithm): any; + generateKey(algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + sign(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): any; } declare var SubtleCrypto: { @@ -10998,11 +10974,8 @@ interface WebGLRenderingContext { blendEquationSeparate(modeRGB: number, modeAlpha: number): void; blendFunc(sfactor: number, dfactor: number): void; blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; - bufferData(target: number, size: number, usage: number): void; - bufferData(target: number, size: ArrayBufferView, usage: number): void; - bufferData(target: number, size: any, usage: number): void; - bufferSubData(target: number, offset: number, data: ArrayBufferView): void; - bufferSubData(target: number, offset: number, data: any): void; + bufferData(target: number, size: number | ArrayBufferView | ArrayBuffer, usage: number): void; + bufferSubData(target: number, offset: number, data: ArrayBufferView | ArrayBuffer): void; checkFramebufferStatus(target: number): number; clear(mask: number): void; clearColor(red: number, green: number, blue: number, alpha: number): void; @@ -11845,8 +11818,7 @@ interface WebSocket extends EventTarget { declare var WebSocket: { prototype: WebSocket; - new(url: string, protocols?: string): WebSocket; - new(url: string, protocols?: any): WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; CLOSED: number; CLOSING: number; CONNECTING: number; @@ -12650,8 +12622,7 @@ interface EventListenerObject { declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { - (event: Event, source?: string, fileno?: number, columnNumber?: number): void; - (event: string, source?: string, fileno?: number, columnNumber?: number): void; + (event: Event | string, source?: string, fileno?: number, columnNumber?: number): void; } interface PositionCallback { (position: Position): void; @@ -12978,4 +12949,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any, declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index 71df6d77436..f3c0a1418fe 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -3573,17 +3573,6 @@ declare module Reflect { function setPrototypeOf(target: any, proto: any): boolean; } -interface PromiseLike { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} - /** * Represents the completion of an asynchronous operation */ @@ -3603,6 +3592,7 @@ interface Promise { * @returns A Promise for the completion of the callback. */ catch(onrejected?: (reason: any) => T | PromiseLike): Promise; + catch(onrejected?: (reason: any) => void): Promise; [Symbol.toStringTag]: string; } diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index 1ab2c7d418f..5c41869e487 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -571,8 +571,7 @@ interface WebSocket extends EventTarget { declare var WebSocket: { prototype: WebSocket; - new(url: string, protocols?: string): WebSocket; - new(url: string, protocols?: any): WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; CLOSED: number; CLOSING: number; CONNECTING: number; @@ -807,8 +806,7 @@ interface EventListenerObject { declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { - (event: Event, source?: string, fileno?: number, columnNumber?: number): void; - (event: string, source?: string, fileno?: number, columnNumber?: number): void; + (event: Event | string, source?: string, fileno?: number, columnNumber?: number): void; } interface PositionCallback { (position: Position): void; diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 84d79be5c6e..1a758886350 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -318,7 +318,7 @@ namespace ts.formatting { this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { @@ -344,7 +344,7 @@ namespace ts.formatting { // decorators this.SpaceBeforeAt = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AtToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.NoSpaceAfterAt = new Rule(RuleDescriptor.create3(SyntaxKind.AtToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space)); + this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space)); this.NoSpaceBetweenFunctionKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Delete)); this.SpaceAfterStarInGeneratorDeclaration = new Rule(RuleDescriptor.create3(SyntaxKind.AsteriskToken, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Space)); @@ -470,6 +470,7 @@ namespace ts.formatting { switch (context.contextNode.kind) { case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: + case SyntaxKind.AsExpression: case SyntaxKind.TypePredicate: return true; diff --git a/src/services/formatting/tokenRange.ts b/src/services/formatting/tokenRange.ts index 3391365f328..19185cdf78d 100644 --- a/src/services/formatting/tokenRange.ts +++ b/src/services/formatting/tokenRange.ts @@ -112,7 +112,7 @@ namespace ts.formatting { static AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([SyntaxKind.MultiLineCommentTrivia])); static Keywords = TokenRange.FromRange(SyntaxKind.FirstKeyword, SyntaxKind.LastKeyword); static BinaryOperators = TokenRange.FromRange(SyntaxKind.FirstBinaryOperator, SyntaxKind.LastBinaryOperator); - static BinaryKeywordOperators = TokenRange.FromTokens([SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword, SyntaxKind.IsKeyword]); + static BinaryKeywordOperators = TokenRange.FromTokens([SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword, SyntaxKind.AsKeyword, SyntaxKind.IsKeyword]); static UnaryPrefixOperators = TokenRange.FromTokens([SyntaxKind.PlusPlusToken, SyntaxKind.MinusMinusToken, SyntaxKind.TildeToken, SyntaxKind.ExclamationToken]); static UnaryPrefixExpressions = TokenRange.FromTokens([SyntaxKind.NumericLiteral, SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.OpenBraceToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]); static UnaryPreincrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]); diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index a4cc7ec2ad5..bc506bc22f9 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -2,7 +2,7 @@ namespace ts.NavigateTo { type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration }; - export function getNavigateToItems(program: Program, cancellationToken: CancellationTokenObject, searchValue: string, maxResultCount: number): NavigateToItem[] { + export function getNavigateToItems(program: Program, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number): NavigateToItem[] { let patternMatcher = createPatternMatcher(searchValue); let rawItems: RawNavigateToItem[] = []; diff --git a/src/services/services.ts b/src/services/services.ts index e11fb32c73b..d79436bb478 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -197,8 +197,8 @@ namespace ts { list._children = []; let pos = nodes.pos; - - + + for (let node of nodes) { if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); @@ -750,6 +750,7 @@ namespace ts { public symbolCount: number; public version: string; public languageVersion: ScriptTarget; + public languageVariant: LanguageVariant; public identifiers: Map; public nameTable: Map; @@ -874,7 +875,7 @@ namespace ts { case SyntaxKind.SetAccessor: case SyntaxKind.TypeLiteral: addDeclaration(node); - // fall through + // fall through case SyntaxKind.Constructor: case SyntaxKind.VariableStatement: case SyntaxKind.VariableDeclarationList: @@ -943,6 +944,10 @@ namespace ts { } } + export interface HostCancellationToken { + isCancellationRequested(): boolean; + } + // // Public interface of the host of a language service instance. // @@ -954,7 +959,7 @@ namespace ts { getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot; getLocalizedDiagnosticMessages?(): any; - getCancellationToken?(): CancellationToken; + getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; getDefaultLibFileName(options: CompilerOptions): string; log? (s: string): void; @@ -1094,7 +1099,7 @@ namespace ts { export const definition = "definition"; export const reference = "reference"; export const writtenReference = "writtenReference"; - } + } export interface HighlightSpan { textSpan: TextSpan; @@ -1493,6 +1498,7 @@ namespace ts { export const exportedModifier = "export"; export const ambientModifier = "declare"; export const staticModifier = "static"; + export const abstractModifier = "abstract"; } export class ClassificationTypeNames { @@ -1609,29 +1615,10 @@ namespace ts { return { target: ScriptTarget.ES5, module: ModuleKind.None, + jsx: JsxEmit.Preserve }; } - export class OperationCanceledException { } - - export class CancellationTokenObject { - - public static None: CancellationTokenObject = new CancellationTokenObject(null) - - constructor(private cancellationToken: CancellationToken) { - } - - public isCancellationRequested() { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); - } - - public throwIfCancellationRequested(): void { - if (this.isCancellationRequested()) { - throw new OperationCanceledException(); - } - } - } - // Cache host information about scrip Should be refreshed // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. @@ -1797,7 +1784,7 @@ namespace ts { let outputText: string; // Create a compilerHost object to allow the compiler to read and write files - var compilerHost: CompilerHost = { + let compilerHost: CompilerHost = { getSourceFile: (fileName, target) => fileName === inputFileName ? sourceFile : undefined, writeFile: (name, text, writeByteOrderMark) => { Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); @@ -1810,7 +1797,7 @@ namespace ts { getNewLine: () => newLine }; - var program = createProgram([inputFileName], options, compilerHost); + let program = createProgram([inputFileName], options, compilerHost); addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); @@ -2398,6 +2385,21 @@ namespace ts { return ScriptElementKind.unknown; } + class CancellationTokenObject implements CancellationToken { + constructor(private cancellationToken: HostCancellationToken) { + } + + public isCancellationRequested() { + return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + } + + public throwIfCancellationRequested(): void { + if (this.isCancellationRequested()) { + throw new OperationCanceledException(); + } + } + } + export function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry = createDocumentRegistry()): LanguageService { let syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host); let ruleProvider: formatting.RulesProvider; @@ -2602,7 +2604,7 @@ namespace ts { function getSyntacticDiagnostics(fileName: string) { synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName)); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); } /** @@ -2624,13 +2626,13 @@ namespace ts { // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. // Therefore only get diagnostics for given file. - let semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile); + let semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); if (!program.getCompilerOptions().declaration) { return semanticDiagnostics; } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface - let declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile); + let declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); return concatenate(semanticDiagnostics, declarationDiagnostics); } @@ -2782,6 +2784,7 @@ namespace ts { case SyntaxKind.ExportKeyword: case SyntaxKind.ConstKeyword: case SyntaxKind.DefaultKeyword: + case SyntaxKind.AbstractKeyword: } } } @@ -2792,7 +2795,8 @@ namespace ts { function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); + return program.getOptionsDiagnostics(cancellationToken).concat( + program.getGlobalDiagnostics(cancellationToken)); } /// Completion @@ -2888,27 +2892,42 @@ namespace ts { log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start)); } - // Check if this is a valid completion location - if (contextToken && isCompletionListBlocker(contextToken)) { - log("Returning an empty list because completion was requested in an invalid position."); - return undefined; - } - - // Find the node where completion is requested on, in the case of a completion after - // a dot, it is the member access expression other wise, it is a request for all - // visible symbols in the scope, and the node is the current location. + // Find the node where completion is requested on. + // Also determine whether we are trying to complete with members of that node + // or attributes of a JSX tag. let node = currentToken; let isRightOfDot = false; - if (contextToken && contextToken.kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.PropertyAccessExpression) { - node = (contextToken.parent).expression; - isRightOfDot = true; - } - else if (contextToken && contextToken.kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.QualifiedName) { - node = (contextToken.parent).left; - isRightOfDot = true; - } + let isRightOfOpenTag = false; let location = getTouchingPropertyName(sourceFile, position); + if (contextToken) { + // Bail out if this is a known invalid completion location + if (isCompletionListBlocker(contextToken)) { + log("Returning an empty list because completion was requested in an invalid position."); + return undefined; + } + + let { parent, kind } = contextToken; + if (kind === SyntaxKind.DotToken) { + if (parent.kind === SyntaxKind.PropertyAccessExpression) { + node = (contextToken.parent).expression; + isRightOfDot = true; + } + else if (parent.kind === SyntaxKind.QualifiedName) { + node = (contextToken.parent).left; + isRightOfDot = true; + } + else { + // There is nothing that precedes the dot, so this likely just a stray character + // or leading into a '...' token. Just bail out instead. + return undefined; + } + } + else if (kind === SyntaxKind.LessThanToken && sourceFile.languageVariant === LanguageVariant.JSX) { + isRightOfOpenTag = true; + location = contextToken; + } + } let semanticStart = new Date().getTime(); let isMemberCompletion: boolean; @@ -2918,6 +2937,17 @@ namespace ts { if (isRightOfDot) { getTypeScriptMemberSymbols(); } + else if (isRightOfOpenTag) { + let tagSymbols = typeChecker.getJsxIntrinsicTagNames(); + if (tryGetGlobalSymbols()) { + symbols = tagSymbols.concat(symbols.filter(s => !!(s.flags & SymbolFlags.Value))); + } + else { + symbols = tagSymbols; + } + isMemberCompletion = true; + isNewIdentifierLocation = false; + } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the // global symbols in scope. These results should be valid for either language as @@ -2929,7 +2959,7 @@ namespace ts { log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot }; + return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; function getTypeScriptMemberSymbols(): void { // Right of dot member completion list @@ -2983,99 +3013,78 @@ namespace ts { } function tryGetGlobalSymbols(): boolean { - let objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); - if (objectLikeContainer) { - // Object literal expression, look up possible property names from contextual type - isMemberCompletion = true; - isNewIdentifierLocation = true; + let objectLikeContainer: ObjectLiteralExpression | BindingPattern; + let importClause: ImportClause; + let jsxContainer: JsxOpeningLikeElement; - let typeForObject: Type; - let existingMembers: Declaration[]; - - if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) { - typeForObject = typeChecker.getContextualType(objectLikeContainer); - existingMembers = (objectLikeContainer).properties; - } - else { - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = (objectLikeContainer).elements; - } - - if (!typeForObject) { - return false; - } - - let typeMembers = typeChecker.getPropertiesOfType(typeForObject); - if (typeMembers && typeMembers.length > 0) { - // Add filtered items to the completion list - symbols = filterObjectMembersList(typeMembers, existingMembers); - } + if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { + return tryGetObjectLikeCompletionSymbols(objectLikeContainer); } - else if (getAncestor(contextToken, SyntaxKind.ImportClause)) { - // cursor is in import clause - // try to show exported member for imported module - isMemberCompletion = true; - isNewIdentifierLocation = true; - if (showCompletionsInImportsClause(contextToken)) { - let importDeclaration = getAncestor(contextToken, SyntaxKind.ImportDeclaration); - Debug.assert(importDeclaration !== undefined); - let exports: Symbol[]; - if (importDeclaration.moduleSpecifier) { - let moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } + if (importClause = getAncestor(contextToken, SyntaxKind.ImportClause)) { + // cursor is in an import clause + // try to show exported member for imported module + return tryGetImportClauseCompletionSymbols(importClause); + } + + if (jsxContainer = tryGetContainingJsxElement(contextToken)) { + let attrsType: Type; + if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) { + // Cursor is inside a JSX self-closing element or opening element + attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + + if (attrsType) { + symbols = filterJsxAttributes((jsxContainer).attributes, typeChecker.getPropertiesOfType(attrsType)); + isMemberCompletion = true; + isNewIdentifierLocation = false; + return true; } - //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); - symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; } } - else { - // Get all entities in the current scope. - isMemberCompletion = false; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); - if (previousToken !== contextToken) { - Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); - } - // We need to find the node that will give us an appropriate scope to begin - // aggregating completion candidates. This is achieved in 'getScopeNode' - // by finding the first node that encompasses a position, accounting for whether a node - // is "complete" to decide whether a position belongs to the node. - // - // However, at the end of an identifier, we are interested in the scope of the identifier - // itself, but fall outside of the identifier. For instance: - // - // xyz => x$ - // - // the cursor is outside of both the 'x' and the arrow function 'xyz => x', - // so 'xyz' is not returned in our results. - // - // We define 'adjustedPosition' so that we may appropriately account for - // being at the end of an identifier. The intention is that if requesting completion - // at the end of an identifier, it should be effectively equivalent to requesting completion - // anywhere inside/at the beginning of the identifier. So in the previous case, the - // 'adjustedPosition' will work as if requesting completion in the following: - // - // xyz => $x - // - // If previousToken !== contextToken, then - // - 'contextToken' was adjusted to the token prior to 'previousToken' - // because we were at the end of an identifier. - // - 'previousToken' is defined. - let adjustedPosition = previousToken !== contextToken ? - previousToken.getStart() : - position; + // Get all entities in the current scope. + isMemberCompletion = false; + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); - let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; - - /// TODO filter meaning based on the current context - let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias; - symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + if (previousToken !== contextToken) { + Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); } + // We need to find the node that will give us an appropriate scope to begin + // aggregating completion candidates. This is achieved in 'getScopeNode' + // by finding the first node that encompasses a position, accounting for whether a node + // is "complete" to decide whether a position belongs to the node. + // + // However, at the end of an identifier, we are interested in the scope of the identifier + // itself, but fall outside of the identifier. For instance: + // + // xyz => x$ + // + // the cursor is outside of both the 'x' and the arrow function 'xyz => x', + // so 'xyz' is not returned in our results. + // + // We define 'adjustedPosition' so that we may appropriately account for + // being at the end of an identifier. The intention is that if requesting completion + // at the end of an identifier, it should be effectively equivalent to requesting completion + // anywhere inside/at the beginning of the identifier. So in the previous case, the + // 'adjustedPosition' will work as if requesting completion in the following: + // + // xyz => $x + // + // If previousToken !== contextToken, then + // - 'contextToken' was adjusted to the token prior to 'previousToken' + // because we were at the end of an identifier. + // - 'previousToken' is defined. + let adjustedPosition = previousToken !== contextToken ? + previousToken.getStart() : + position; + let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + + /// TODO filter meaning based on the current context + let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias; + symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + return true; } @@ -3084,23 +3093,23 @@ namespace ts { * accurately aggregate locals from the closest containing scope. */ function getScopeNode(initialToken: Node, position: number, sourceFile: SourceFile) { - var scope = initialToken; + let scope = initialToken; while (scope && !positionBelongsToNode(scope, position, sourceFile)) { scope = scope.parent; } return scope; } - function isCompletionListBlocker(previousToken: Node): boolean { + function isCompletionListBlocker(contextToken: Node): boolean { let start = new Date().getTime(); - let result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || - isIdentifierDefinitionLocation(previousToken) || - isRightOfIllegalDot(previousToken); + let result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || + isIdentifierDefinitionLocation(contextToken) || + isDotOfNumericLiteral(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } - function showCompletionsInImportsClause(node: Node): boolean { + function shouldShowCompletionsInImportsClause(node: Node): boolean { if (node) { // import {| // import {a,| @@ -3118,7 +3127,7 @@ namespace ts { switch (previousToken.kind) { case SyntaxKind.CommaToken: return containingNodeKind === SyntaxKind.CallExpression // func( a, | - || containingNodeKind === SyntaxKind.Constructor // constructor( a, | public, protected, private keywords are allowed here, so show completion + || containingNodeKind === SyntaxKind.Constructor // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ || containingNodeKind === SyntaxKind.NewExpression // new C(a, | || containingNodeKind === SyntaxKind.ArrayLiteralExpression // [a, | || containingNodeKind === SyntaxKind.BinaryExpression // let x = (a, | @@ -3129,10 +3138,12 @@ namespace ts { || containingNodeKind === SyntaxKind.Constructor // constructor( | || containingNodeKind === SyntaxKind.NewExpression // new C(a| || containingNodeKind === SyntaxKind.ParenthesizedExpression // let x = (a| - || containingNodeKind === SyntaxKind.ParenthesizedType; // function F(pred: (a| this can become an arrow function, where 'a' is the argument + || containingNodeKind === SyntaxKind.ParenthesizedType; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case SyntaxKind.OpenBracketToken: - return containingNodeKind === SyntaxKind.ArrayLiteralExpression; // [ | + return containingNodeKind === SyntaxKind.ArrayLiteralExpression // [ | + || containingNodeKind === SyntaxKind.IndexSignature // [ | : string ] + || containingNodeKind === SyntaxKind.ComputedPropertyName // [ | /* this can become an index signature */ case SyntaxKind.ModuleKeyword: // module | case SyntaxKind.NamespaceKeyword: // namespace | @@ -3172,12 +3183,12 @@ namespace ts { return false; } - function isInStringOrRegularExpressionOrTemplateLiteral(previousToken: Node): boolean { - if (previousToken.kind === SyntaxKind.StringLiteral - || previousToken.kind === SyntaxKind.RegularExpressionLiteral - || isTemplateLiteralKind(previousToken.kind)) { - let start = previousToken.getStart(); - let end = previousToken.getEnd(); + function isInStringOrRegularExpressionOrTemplateLiteral(contextToken: Node): boolean { + if (contextToken.kind === SyntaxKind.StringLiteral + || contextToken.kind === SyntaxKind.RegularExpressionLiteral + || isTemplateLiteralKind(contextToken.kind)) { + let start = contextToken.getStart(); + let end = contextToken.getEnd(); // To be "in" one of these literals, the position has to be: // 1. entirely within the token text. @@ -3188,14 +3199,94 @@ namespace ts { } if (position === end) { - return !!(previousToken).isUnterminated || - previousToken.kind === SyntaxKind.RegularExpressionLiteral; + return !!(contextToken).isUnterminated + || contextToken.kind === SyntaxKind.RegularExpressionLiteral; } } return false; } + /** + * Aggregates relevant symbols for completion in object literals and object binding patterns. + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ + function tryGetObjectLikeCompletionSymbols(objectLikeContainer: ObjectLiteralExpression | BindingPattern): boolean { + // We're looking up possible property names from contextual/inferred/declared type. + isMemberCompletion = true; + + let typeForObject: Type; + let existingMembers: Declaration[]; + + if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) { + // We are completing on contextual types, but may also include properties + // other than those within the declared type. + isNewIdentifierLocation = true; + + typeForObject = typeChecker.getContextualType(objectLikeContainer); + existingMembers = (objectLikeContainer).properties; + } + else if (objectLikeContainer.kind === SyntaxKind.ObjectBindingPattern) { + // We are *only* completing on properties from the type being destructured. + isNewIdentifierLocation = false; + + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = (objectLikeContainer).elements; + } + else { + Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); + } + + if (!typeForObject) { + return false; + } + + let typeMembers = typeChecker.getPropertiesOfType(typeForObject); + if (typeMembers && typeMembers.length > 0) { + // Add filtered items to the completion list + symbols = filterObjectMembersList(typeMembers, existingMembers); + } + return true; + } + + /** + * Aggregates relevant symbols for completion in import clauses; for instance, + * + * import { $ } from "moduleName"; + * + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ + function tryGetImportClauseCompletionSymbols(importClause: ImportClause): boolean { + // cursor is in import clause + // try to show exported member for imported module + if (shouldShowCompletionsInImportsClause(contextToken)) { + isMemberCompletion = true; + isNewIdentifierLocation = false; + + let importDeclaration = importClause.parent; + Debug.assert(importDeclaration !== undefined && importDeclaration.kind === SyntaxKind.ImportDeclaration); + + let exports: Symbol[]; + let moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + } + + //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); + symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; + } + else { + isMemberCompletion = false; + isNewIdentifierLocation = true; + } + + return true; + } + /** * Returns the immediate owning object literal or binding pattern of a context token, * on the condition that one exists and that the context implies completion should be given. @@ -3216,6 +3307,36 @@ namespace ts { return undefined; } + function tryGetContainingJsxElement(contextToken: Node): JsxOpeningLikeElement { + if (contextToken) { + let parent = contextToken.parent; + switch(contextToken.kind) { + case SyntaxKind.LessThanSlashToken: + case SyntaxKind.SlashToken: + case SyntaxKind.Identifier: + if(parent && (parent.kind === SyntaxKind.JsxSelfClosingElement || parent.kind === SyntaxKind.JsxOpeningElement)) { + return parent; + } + break; + + case SyntaxKind.CloseBraceToken: + // The context token is the closing } of an attribute, which means + // its parent is a JsxExpression, whose parent is a JsxAttribute, + // whose parent is a JsxOpeningLikeElement + if(parent && + parent.kind === SyntaxKind.JsxExpression && + parent.parent && + parent.parent.kind === SyntaxKind.JsxAttribute) { + + return parent.parent.parent; + } + + break; + } + } + return undefined; + } + function isFunction(kind: SyntaxKind): boolean { switch (kind) { case SyntaxKind.FunctionExpression: @@ -3233,101 +3354,98 @@ namespace ts { return false; } - function isIdentifierDefinitionLocation(previousToken: Node): boolean { - if (previousToken) { - let containingNodeKind = previousToken.parent.kind; - switch (previousToken.kind) { - case SyntaxKind.CommaToken: - return containingNodeKind === SyntaxKind.VariableDeclaration || - containingNodeKind === SyntaxKind.VariableDeclarationList || - containingNodeKind === SyntaxKind.VariableStatement || - containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, | - isFunction(containingNodeKind) || - containingNodeKind === SyntaxKind.ClassDeclaration || // class A, symbols: Symbol[]): Symbol[] { + let seenNames: Map = {}; + for(let attr of attributes) { + if(attr.kind === SyntaxKind.JsxAttribute) { + seenNames[(attr).name.text] = true; + } + } + let result: Symbol[] = []; + for(let sym of symbols) { + if(!seenNames[sym.name]) { + result.push(sym); + } + } + return result; + } + function getCompletionsAtPosition(fileName: string, position: number): CompletionInfo { synchronizeHostData(); @@ -3485,10 +3619,10 @@ namespace ts { function getCompletionEntriesFromSymbols(symbols: Symbol[]): CompletionEntry[] { let start = new Date().getTime(); - var entries: CompletionEntry[] = []; + let entries: CompletionEntry[] = []; if (symbols) { - var nameToSymbol: Map = {}; + let nameToSymbol: Map = {}; for (let symbol of symbols) { let entry = createCompletionEntry(symbol, location); if (entry) { @@ -3522,13 +3656,13 @@ namespace ts { let symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false) === entryName ? s : undefined); if (symbol) { - let displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, location, SemanticMeaning.All); + let { displayParts, documentation, symbolKind } = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, location, SemanticMeaning.All); return { name: entryName, - kind: displayPartsDocumentationsAndSymbolKind.symbolKind, kindModifiers: getSymbolModifiers(symbol), - displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, - documentation: displayPartsDocumentationsAndSymbolKind.documentation + kind: symbolKind, + displayParts, + documentation }; } } @@ -3597,7 +3731,7 @@ namespace ts { if (flags & SymbolFlags.Constructor) return ScriptElementKind.constructorImplementationElement; if (flags & SymbolFlags.Property) { - if (flags & SymbolFlags.UnionProperty) { + if (flags & SymbolFlags.SyntheticProperty) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property let unionPropertyKind = forEach(typeChecker.getRootSymbols(symbol), rootSymbol => { let rootSymbolFlags = rootSymbol.getFlags(); @@ -4203,7 +4337,7 @@ namespace ts { } if (type.flags & TypeFlags.Union) { - var result: DefinitionInfo[] = []; + let result: DefinitionInfo[] = []; forEach((type).types, t => { if (t.symbol) { addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); @@ -4221,7 +4355,7 @@ namespace ts { function getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] { let results = getOccurrencesAtPositionCore(fileName, position); - + if (results) { let sourceFile = getCanonicalFileName(normalizeSlashes(fileName)); @@ -4265,7 +4399,7 @@ namespace ts { isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - let referencedSymbols = getReferencedSymbolsForNodes(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); + let referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferencedSymbols(referencedSymbols); } @@ -4303,7 +4437,7 @@ namespace ts { function getSyntacticDocumentHighlights(node: Node): DocumentHighlights[] { let fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); + let highlightSpans = getHighlightSpans(node); if (!highlightSpans || highlightSpans.length === 0) { return undefined; } @@ -4881,17 +5015,17 @@ namespace ts { } function findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + let referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); return convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); + let referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferences(referencedSymbols); } function findReferences(fileName: string, position: number): ReferencedSymbol[]{ - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); + let referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); // Only include referenced symbols that have a valid definition. return filter(referencedSymbols, rs => !!rs.definition); @@ -4917,10 +5051,10 @@ namespace ts { } Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.NumericLiteral || node.kind === SyntaxKind.StringLiteral); - return getReferencedSymbolsForNodes(node, program.getSourceFiles(), findInStrings, findInComments); + return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } - function getReferencedSymbolsForNodes(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] { + function getReferencedSymbolsForNode(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] { let typeChecker = program.getTypeChecker(); // Labels @@ -4955,7 +5089,7 @@ namespace ts { let declarations = symbol.declarations; - // The symbol was an internal symbol and does not have a declaration e.g.undefined symbol + // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol if (!declarations || !declarations.length) { return undefined; } @@ -4965,8 +5099,9 @@ namespace ts { // Compute the meaning from the location and the symbol it references let searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); - // Get the text to search for, we need to normalize it as external module names will have quote - let declaredName = getDeclaredName(symbol, node); + // Get the text to search for. + // Note: if this is an external module symbol, the name doesn't include quotes. + let declaredName = getDeclaredName(typeChecker, symbol, node); // 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). @@ -5013,76 +5148,43 @@ namespace ts { }; } - function isImportOrExportSpecifierName(location: Node): boolean { - return location.parent && - (location.parent.kind === SyntaxKind.ImportSpecifier || location.parent.kind === SyntaxKind.ExportSpecifier) && - (location.parent).propertyName === location; - } - function isImportOrExportSpecifierImportSymbol(symbol: Symbol) { return (symbol.flags & SymbolFlags.Alias) && forEach(symbol.declarations, declaration => { return declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ExportSpecifier; }); } - function getDeclaredName(symbol: Symbol, location: Node) { - // Special case for function expressions, whose names are solely local to their bodies. - let functionExpression = forEach(symbol.declarations, d => d.kind === SyntaxKind.FunctionExpression ? d : undefined); - - // When a name gets interned into a SourceFile's 'identifiers' Map, - // its name is escaped and stored in the same way its symbol name/identifier - // name should be stored. Function expressions, however, are a special case, - // because despite sometimes having a name, the binder unconditionally binds them - // to a symbol with the name "__function". - let name: string; - if (functionExpression && functionExpression.name) { - name = functionExpression.name.text; - } - - // 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, the symbol is pointing to the alias (name) - // so check for the propertyName. - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - - name = typeChecker.symbolToString(symbol); - - return stripQuotes(name); - } - function getInternedName(symbol: Symbol, location: Node, declarations: Declaration[]): string { - // 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, the symbol is pointing to the alias (name) - // so check for the propertyName. + // 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(); } - // Special case for function expressions, whose names are solely local to their bodies. - let functionExpression = forEach(declarations, d => d.kind === SyntaxKind.FunctionExpression ? d : undefined); + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + let localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); + symbol = localExportDefaultSymbol || symbol; - // When a name gets interned into a SourceFile's 'identifiers' Map, - // its name is escaped and stored in the same way its symbol name/identifier - // name should be stored. Function expressions, however, are a special case, - // because despite sometimes having a name, the binder unconditionally binds them - // to a symbol with the name "__function". - let name = functionExpression && functionExpression.name - ? functionExpression.name.text - : symbol.name; - - return stripQuotes(name); - } - - function stripQuotes(name: string) { - let length = name.length; - if (length >= 2 && name.charCodeAt(0) === CharacterCodes.doubleQuote && name.charCodeAt(length - 1) === CharacterCodes.doubleQuote) { - return name.substring(1, length - 1); - }; - return name; + return stripQuotes(symbol.name); } + /** + * Determines the smallest scope in which a symbol may have named references. + * Note that not every construct has been accounted for. This function can + * probably be improved. + * + * @returns undefined if the scope cannot be determined, implying that + * a reference to a symbol can occur anywhere. + */ function getSymbolScope(symbol: Symbol): Node { + // If this is the symbol of a function expression, then named references + // are limited to its own scope. + let valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && valueDeclaration.kind === SyntaxKind.FunctionExpression) { + return valueDeclaration; + } + // If this is private property or method, the scope is the containing class if (symbol.flags & (SymbolFlags.Property | SymbolFlags.Method)) { let privateDeclaration = forEach(symbol.getDeclarations(), d => (d.flags & NodeFlags.Private) ? d : undefined); @@ -5099,7 +5201,7 @@ namespace ts { // if this symbol is visible from its parent container, e.g. exported, then bail out // if symbol correspond to the union property - bail out - if (symbol.parent || (symbol.flags & SymbolFlags.UnionProperty)) { + if (symbol.parent || (symbol.flags & SymbolFlags.SyntheticProperty)) { return undefined; } @@ -5190,7 +5292,7 @@ namespace ts { } }); - var definition: DefinitionInfo = { + let definition: DefinitionInfo = { containerKind: "", containerName: "", fileName: targetLabel.getSourceFile().fileName, @@ -5286,10 +5388,10 @@ namespace ts { if (referenceSymbol) { let referenceSymbolDeclaration = referenceSymbol.valueDeclaration; let shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation); + let relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation); if (relatedSymbol) { - var referencedSymbol = getReferencedSymbol(relatedSymbol); + let referencedSymbol = getReferencedSymbol(relatedSymbol); referencedSymbol.references.push(getReferenceEntryFromNode(referenceLocation)); } /* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment @@ -5299,7 +5401,7 @@ namespace ts { * 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) { - var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); + let referencedSymbol = getReferencedSymbol(shorthandValueSymbol); referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); } } @@ -5309,8 +5411,8 @@ namespace ts { return; function getReferencedSymbol(symbol: Symbol): ReferencedSymbol { - var symbolId = getSymbolId(symbol); - var index = symbolToIndex[symbolId]; + let symbolId = getSymbolId(symbol); + let index = symbolToIndex[symbolId]; if (index === undefined) { index = result.length; symbolToIndex[symbolId] = index; @@ -5397,7 +5499,7 @@ namespace ts { } }); - var definition = getDefinition(searchSpaceNode.symbol); + let definition = getDefinition(searchSpaceNode.symbol); return [{ definition, references }]; } @@ -5592,7 +5694,7 @@ namespace ts { // If the reference symbol is an alias, check if what it is aliasing is one of the search // symbols. if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { - var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); + let aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); if (searchSymbols.indexOf(aliasedSymbol) >= 0) { return aliasedSymbol; } @@ -5756,7 +5858,7 @@ namespace ts { }); } - let emitOutput = program.emit(sourceFile, writeFile); + let emitOutput = program.emit(sourceFile, writeFile, cancellationToken); return { outputFiles, @@ -5825,7 +5927,7 @@ namespace ts { } function isTypeReference(node: Node): boolean { - if (isRightSideOfQualifiedNameOrPropertyAccess(node) ) { + if (isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } @@ -5994,16 +6096,36 @@ namespace ts { return BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); } - function getNavigationBarItems(fileName: string): NavigationBarItem[]{ + function getNavigationBarItems(fileName: string): NavigationBarItem[] { let sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); return NavigationBar.getNavigationBarItems(sourceFile); } - function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]{ + function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] { return convertClassifications(getEncodedSemanticClassifications(fileName, span)); } + function checkForClassificationCancellation(kind: SyntaxKind) { + // We don't want to actually call back into our host on every node to find out if we've + // been canceled. That would be an enormous amount of chattyness, along with the all + // the overhead of marshalling the data to/from the host. So instead we pick a few + // reasonable node kinds to bother checking on. These node kinds represent high level + // constructs that we would expect to see commonly, but just at a far less frequent + // interval. + // + // For example, in checker.ts (around 750k) we only have around 600 of these constructs. + // That means we're calling back into the host around every 1.2k of the file we process. + // Lib.d.ts has similar numbers. + switch (kind) { + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.FunctionDeclaration: + cancellationToken.throwIfCancellationRequested(); + } + } + function getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications { synchronizeHostData(); @@ -6071,7 +6193,10 @@ namespace ts { function processNode(node: Node) { // Only walk into nodes that intersect the requested span. if (node && textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { - if (node.kind === SyntaxKind.Identifier && !nodeIsMissing(node)) { + let kind = node.kind; + checkForClassificationCancellation(kind); + + if (kind === SyntaxKind.Identifier && !nodeIsMissing(node)) { let identifier = node; // Only bother calling into the typechecker if this is an identifier that @@ -6129,7 +6254,7 @@ namespace ts { return result; } - function getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]{ + function getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] { return convertClassifications(getEncodedSyntacticClassifications(fileName, span)); } @@ -6140,8 +6265,8 @@ namespace ts { let spanLength = span.length; // Make a scanner we can get trivia from. - let triviaScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.text); - let mergeConflictScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.text); + let triviaScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); + let mergeConflictScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); let result: number[] = []; processElement(sourceFile); @@ -6438,6 +6563,8 @@ namespace ts { // Ignore nodes that don't intersect the original span to classify. if (decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { + checkForClassificationCancellation(element.kind); + let children = element.getChildren(sourceFile); for (let i = 0, n = children.length; i < n; i++) { let child = children[i]; @@ -6496,14 +6623,14 @@ namespace ts { function getMatchingTokenKind(token: Node): ts.SyntaxKind { switch (token.kind) { - case ts.SyntaxKind.OpenBraceToken: return ts.SyntaxKind.CloseBraceToken - case ts.SyntaxKind.OpenParenToken: return ts.SyntaxKind.CloseParenToken; - case ts.SyntaxKind.OpenBracketToken: return ts.SyntaxKind.CloseBracketToken; - case ts.SyntaxKind.LessThanToken: return ts.SyntaxKind.GreaterThanToken; - case ts.SyntaxKind.CloseBraceToken: return ts.SyntaxKind.OpenBraceToken - case ts.SyntaxKind.CloseParenToken: return ts.SyntaxKind.OpenParenToken; - case ts.SyntaxKind.CloseBracketToken: return ts.SyntaxKind.OpenBracketToken; - case ts.SyntaxKind.GreaterThanToken: return ts.SyntaxKind.LessThanToken; + case ts.SyntaxKind.OpenBraceToken: return ts.SyntaxKind.CloseBraceToken + case ts.SyntaxKind.OpenParenToken: return ts.SyntaxKind.CloseParenToken; + case ts.SyntaxKind.OpenBracketToken: return ts.SyntaxKind.CloseBracketToken; + case ts.SyntaxKind.LessThanToken: return ts.SyntaxKind.GreaterThanToken; + case ts.SyntaxKind.CloseBraceToken: return ts.SyntaxKind.OpenBraceToken + case ts.SyntaxKind.CloseParenToken: return ts.SyntaxKind.OpenParenToken; + case ts.SyntaxKind.CloseBracketToken: return ts.SyntaxKind.OpenBracketToken; + case ts.SyntaxKind.GreaterThanToken: return ts.SyntaxKind.LessThanToken; } return undefined; @@ -6718,18 +6845,20 @@ namespace ts { if (defaultLibFileName) { for (let current of declarations) { let sourceFile = current.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); if (sourceFile && getCanonicalFileName(ts.normalizePath(sourceFile.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key)); } } } + let displayName = getDeclaredName(typeChecker, symbol, node); let kind = getSymbolKind(symbol, node); if (kind) { return { canRename: true, localizedErrorMessage: undefined, - displayName: symbol.name, + displayName, fullDisplayName: typeChecker.getFullyQualifiedName(symbol), kind: kind, kindModifiers: getSymbolModifiers(symbol), @@ -6908,7 +7037,7 @@ namespace ts { } function convertClassifications(classifications: Classifications, text: string): ClassificationResult { - var entries: ClassificationInfo[] = []; + let entries: ClassificationInfo[] = []; let dense = classifications.spans; let lastEnd = 0; @@ -6946,7 +7075,7 @@ namespace ts { case ClassificationType.stringLiteral: return TokenClass.StringLiteral; case ClassificationType.whiteSpace: return TokenClass.Whitespace; case ClassificationType.punctuation: return TokenClass.Punctuation; - case ClassificationType.identifier: + case ClassificationType.identifier: case ClassificationType.className: case ClassificationType.enumName: case ClassificationType.interfaceName: @@ -7001,7 +7130,7 @@ namespace ts { case EndOfLineState.InTemplateMiddleOrTail: text = "}\n" + text; offset = 2; - // fallthrough + // fallthrough case EndOfLineState.InTemplateSubstitutionPosition: templateStack.push(SyntaxKind.TemplateHead); break; @@ -7040,9 +7169,9 @@ namespace ts { if (!isTrivia(token)) { if ((token === SyntaxKind.SlashToken || token === SyntaxKind.SlashEqualsToken) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === SyntaxKind.RegularExpressionLiteral) { - token = SyntaxKind.RegularExpressionLiteral; - } + if (scanner.reScanSlashToken() === SyntaxKind.RegularExpressionLiteral) { + token = SyntaxKind.RegularExpressionLiteral; + } } else if (lastNonTriviaToken === SyntaxKind.DotToken && isKeyword(token)) { token = SyntaxKind.Identifier; @@ -7055,7 +7184,7 @@ namespace ts { token = SyntaxKind.Identifier; } else if (lastNonTriviaToken === SyntaxKind.Identifier && - token === SyntaxKind.LessThanToken) { + token === SyntaxKind.LessThanToken) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; @@ -7066,10 +7195,10 @@ namespace ts { angleBracketStack--; } else if (token === SyntaxKind.AnyKeyword || - token === SyntaxKind.StringKeyword || - token === SyntaxKind.NumberKeyword || - token === SyntaxKind.BooleanKeyword || - token === SyntaxKind.SymbolKeyword) { + token === SyntaxKind.StringKeyword || + token === SyntaxKind.NumberKeyword || + token === SyntaxKind.BooleanKeyword || + token === SyntaxKind.SymbolKeyword) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, @@ -7305,7 +7434,7 @@ namespace ts { declare let __dirname: string; /** - * Get the path of the default library file (lib.d.ts) as distributed with the typescript + * Get the path of the default library files (lib.d.ts) as distributed with the typescript * node package. * The functionality is not supported if the ts module is consumed outside of a node module. */ @@ -7325,8 +7454,8 @@ namespace ts { } let proto = kind === SyntaxKind.SourceFile ? new SourceFileObject() : new NodeObject(); proto.kind = kind; - proto.pos = 0; - proto.end = 0; + proto.pos = -1; + proto.end = -1; proto.flags = 0; proto.parent = undefined; Node.prototype = proto; diff --git a/src/services/shims.ts b/src/services/shims.ts index 2e8b3eb774d..6e765eff499 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -51,7 +51,7 @@ namespace ts { getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): ScriptSnapshotShim; getLocalizedDiagnosticMessages(): string; - getCancellationToken(): CancellationToken; + getCancellationToken(): HostCancellationToken; getCurrentDirectory(): string; getDefaultLibFileName(options: string): string; getNewLine?(): string; @@ -326,8 +326,9 @@ namespace ts { } } - public getCancellationToken(): CancellationToken { - return this.shimHost.getCancellationToken(); + public getCancellationToken(): HostCancellationToken { + var hostCancellationToken = this.shimHost.getCancellationToken(); + return new ThrottledCancellationToken(hostCancellationToken); } public getCurrentDirectory(): string { @@ -346,6 +347,29 @@ namespace ts { } } + /** A cancellation that throttles calls to the host */ + class ThrottledCancellationToken implements HostCancellationToken { + // Store when we last tried to cancel. Checking cancellation can be expensive (as we have + // to marshall over to the host layer). So we only bother actually checking once enough + // time has passed. + private lastCancellationCheckTime = 0; + + constructor(private hostCancellationToken: HostCancellationToken) { + } + + public isCancellationRequested(): boolean { + var time = Date.now(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + // Check no more than once every 10 ms. + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + + return false; + } + } + export class CoreServicesShimHostAdapter implements ParseConfigHost { constructor(private shimHost: CoreServicesShimHost) { diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index fce4e2c3025..44b022a7b12 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -178,7 +178,7 @@ namespace ts.SignatureHelp { argumentCount: number; } - export function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationTokenObject): SignatureHelpItems { + export function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationToken): SignatureHelpItems { let typeChecker = program.getTypeChecker(); // Decide whether to show signature help diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 73b88a3df26..517cb24541a 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -429,6 +429,7 @@ namespace ts { if (flags & NodeFlags.Protected) result.push(ScriptElementKindModifier.protectedMemberModifier); if (flags & NodeFlags.Public) result.push(ScriptElementKindModifier.publicMemberModifier); if (flags & NodeFlags.Static) result.push(ScriptElementKindModifier.staticModifier); + if (flags & NodeFlags.Abstract) result.push(ScriptElementKindModifier.abstractModifier); if (flags & NodeFlags.Export) result.push(ScriptElementKindModifier.exportedModifier); if (isInAmbientContext(node)) result.push(ScriptElementKindModifier.ambientModifier); @@ -652,4 +653,34 @@ namespace ts { typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); }); } + + export function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node): string { + // 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 is under the cursor. + if (isImportOrExportSpecifierName(location)) { + return location.getText(); + } + + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + let localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); + + let name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); + + return stripQuotes(name); + } + + export function isImportOrExportSpecifierName(location: Node): boolean { + return location.parent && + (location.parent.kind === SyntaxKind.ImportSpecifier || location.parent.kind === SyntaxKind.ExportSpecifier) && + (location.parent).propertyName === location; + } + + export function stripQuotes(name: string) { + let length = name.length; + if (length >= 2 && name.charCodeAt(0) === CharacterCodes.doubleQuote && name.charCodeAt(length - 1) === CharacterCodes.doubleQuote) { + return name.substring(1, length - 1); + }; + return name; + } } \ No newline at end of file diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 9b2675535f2..30951b90fca 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -75,28 +75,28 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 188 /* WhileStatement */: - case 187 /* DoStatement */: - if (node.statement.kind !== 182 /* Block */) { + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 195 /* WhileStatement */: + case 194 /* DoStatement */: + if (node.statement.kind !== 189 /* Block */) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 186 /* IfStatement */: + case 193 /* IfStatement */: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 182 /* Block */) { + if (ifStatement.thenStatement.kind !== 189 /* Block */) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== 182 /* Block */ && - ifStatement.elseStatement.kind !== 186 /* IfStatement */) { + ifStatement.elseStatement.kind !== 189 /* Block */ && + ifStatement.elseStatement.kind !== 193 /* IfStatement */) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: var op = node.operatorToken.kind; - if (op === 28 /* EqualsEqualsToken */ || op == 29 /* ExclamationEqualsToken */) { + if (op === 29 /* EqualsEqualsToken */ || op == 30 /* ExclamationEqualsToken */) { report(node, "Use '===' and '!=='."); } break; diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt index 35edf48564a..6efd10dce09 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt @@ -1,8 +1,20 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,26): error TS1005: ',' expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS1138: Parameter declaration expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,34): error TS1005: ';' expected. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (5 errors) ==== function * foo(a = yield => yield) { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher. + ~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~ +!!! error TS1005: ',' expected. + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + ~ +!!! error TS1005: ';' expected. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.js b/tests/baselines/reference/FunctionDeclaration10_es6.js index 51694533964..ccff1ac1036 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.js +++ b/tests/baselines/reference/FunctionDeclaration10_es6.js @@ -3,6 +3,6 @@ function * foo(a = yield => yield) { } //// [FunctionDeclaration10_es6.js] -function foo(a) { - if (a === void 0) { a = function (yield) { return yield; }; } +yield; +{ } diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt index 9f696e71084..eae7628f046 100644 --- a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2523: 'yield' expressions cannot be used in a parameter initializer. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (2 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,1 ~ !!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher. ~~~~~ -!!! error TS2304: Cannot find name 'yield'. +!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt index 91fab36ed31..4a9e4bca6d3 100644 --- a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2523: 'yield' expressions cannot be used in a parameter initializer. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (3 errors) ==== @@ -12,6 +12,6 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,2 ~ !!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher. ~~~~~ -!!! error TS2304: Cannot find name 'yield'. +!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. } } \ No newline at end of file diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.js b/tests/baselines/reference/abstractIdentifierNameStrict.js new file mode 100644 index 00000000000..92d159766d7 --- /dev/null +++ b/tests/baselines/reference/abstractIdentifierNameStrict.js @@ -0,0 +1,14 @@ +//// [abstractIdentifierNameStrict.ts] +var abstract = true; + +function foo() { + "use strict"; + var abstract = true; +} + +//// [abstractIdentifierNameStrict.js] +var abstract = true; +function foo() { + "use strict"; + var abstract = true; +} diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.symbols b/tests/baselines/reference/abstractIdentifierNameStrict.symbols new file mode 100644 index 00000000000..c6a374e9bcd --- /dev/null +++ b/tests/baselines/reference/abstractIdentifierNameStrict.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/abstractIdentifierNameStrict.ts === +var abstract = true; +>abstract : Symbol(abstract, Decl(abstractIdentifierNameStrict.ts, 0, 3)) + +function foo() { +>foo : Symbol(foo, Decl(abstractIdentifierNameStrict.ts, 0, 20)) + + "use strict"; + var abstract = true; +>abstract : Symbol(abstract, Decl(abstractIdentifierNameStrict.ts, 4, 7)) +} diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.types b/tests/baselines/reference/abstractIdentifierNameStrict.types new file mode 100644 index 00000000000..7c79ce58a37 --- /dev/null +++ b/tests/baselines/reference/abstractIdentifierNameStrict.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/abstractIdentifierNameStrict.ts === +var abstract = true; +>abstract : boolean +>true : boolean + +function foo() { +>foo : () => void + + "use strict"; +>"use strict" : string + + var abstract = true; +>abstract : boolean +>true : boolean +} diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.js b/tests/baselines/reference/abstractInterfaceIdentifierName.js new file mode 100644 index 00000000000..67058bfc619 --- /dev/null +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.js @@ -0,0 +1,8 @@ +//// [abstractInterfaceIdentifierName.ts] + +interface abstract { + abstract(): void; +} + + +//// [abstractInterfaceIdentifierName.js] diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.symbols b/tests/baselines/reference/abstractInterfaceIdentifierName.symbols new file mode 100644 index 00000000000..c70cdec8ac9 --- /dev/null +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/abstractInterfaceIdentifierName.ts === + +interface abstract { +>abstract : Symbol(abstract, Decl(abstractInterfaceIdentifierName.ts, 0, 0)) + + abstract(): void; +>abstract : Symbol(abstract, Decl(abstractInterfaceIdentifierName.ts, 1, 20)) +} + diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.types b/tests/baselines/reference/abstractInterfaceIdentifierName.types new file mode 100644 index 00000000000..c6d30ca38a0 --- /dev/null +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/abstractInterfaceIdentifierName.ts === + +interface abstract { +>abstract : abstract + + abstract(): void; +>abstract : () => void +} + diff --git a/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols b/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols index 9b68573b378..208646dc101 100644 --- a/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols +++ b/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols @@ -9,9 +9,9 @@ function doubleAndReturnAsArray(x: number, y: number, z: number): [number, numbe let blah = arguments[Symbol.iterator]; >blah : Symbol(blah, Decl(argumentsObjectIterator02_ES6.ts, 2, 7)) >arguments : Symbol(arguments) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) let result = []; >result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7)) diff --git a/tests/baselines/reference/arrayLiterals2ES6.symbols b/tests/baselines/reference/arrayLiterals2ES6.symbols index d8717c2c6d2..faf0b130738 100644 --- a/tests/baselines/reference/arrayLiterals2ES6.symbols +++ b/tests/baselines/reference/arrayLiterals2ES6.symbols @@ -72,14 +72,14 @@ var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; interface myArray extends Array { } >myArray : Symbol(myArray, Decl(arrayLiterals2ES6.ts, 40, 67)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) interface myArray2 extends Array { } >myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] >d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3)) diff --git a/tests/baselines/reference/asOperator1.js b/tests/baselines/reference/asOperator1.js new file mode 100644 index 00000000000..1b23d0a86f7 --- /dev/null +++ b/tests/baselines/reference/asOperator1.js @@ -0,0 +1,19 @@ +//// [asOperator1.ts] +var as = 43; +var x = undefined as number; +var y = (null as string).length; +var z = Date as any as string; + +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32 as number|string; +j = ''; + + +//// [asOperator1.js] +var as = 43; +var x = undefined; +var y = null.length; +var z = Date; +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32; +j = ''; diff --git a/tests/baselines/reference/asOperator1.symbols b/tests/baselines/reference/asOperator1.symbols new file mode 100644 index 00000000000..27353ec7b30 --- /dev/null +++ b/tests/baselines/reference/asOperator1.symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/expressions/asOperator/asOperator1.ts === +var as = 43; +>as : Symbol(as, Decl(asOperator1.ts, 0, 3)) + +var x = undefined as number; +>x : Symbol(x, Decl(asOperator1.ts, 1, 3)) +>undefined : Symbol(undefined) + +var y = (null as string).length; +>y : Symbol(y, Decl(asOperator1.ts, 2, 3)) +>(null as string).length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + +var z = Date as any as string; +>z : Symbol(z, Decl(asOperator1.ts, 3, 3)) +>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) + +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32 as number|string; +>j : Symbol(j, Decl(asOperator1.ts, 6, 3)) + +j = ''; +>j : Symbol(j, Decl(asOperator1.ts, 6, 3)) + diff --git a/tests/baselines/reference/asOperator1.types b/tests/baselines/reference/asOperator1.types new file mode 100644 index 00000000000..3f69871ea09 --- /dev/null +++ b/tests/baselines/reference/asOperator1.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/expressions/asOperator/asOperator1.ts === +var as = 43; +>as : number +>43 : number + +var x = undefined as number; +>x : number +>undefined as number : number +>undefined : undefined + +var y = (null as string).length; +>y : number +>(null as string).length : number +>(null as string) : string +>null as string : string +>null : null +>length : number + +var z = Date as any as string; +>z : string +>Date as any as string : string +>Date as any : any +>Date : DateConstructor + +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32 as number|string; +>j : string | number +>32 as number|string : string | number +>32 : number + +j = ''; +>j = '' : string +>j : string | number +>'' : string + diff --git a/tests/baselines/reference/asOperator2.errors.txt b/tests/baselines/reference/asOperator2.errors.txt new file mode 100644 index 00000000000..3b074038c26 --- /dev/null +++ b/tests/baselines/reference/asOperator2.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/expressions/asOperator/asOperator2.ts(1,9): error TS2352: Neither type 'number' nor type 'string' is assignable to the other. + + +==== tests/cases/conformance/expressions/asOperator/asOperator2.ts (1 errors) ==== + var x = 23 as string; + ~~~~~~~~~~~~ +!!! error TS2352: Neither type 'number' nor type 'string' is assignable to the other. + \ No newline at end of file diff --git a/tests/baselines/reference/asOperator2.js b/tests/baselines/reference/asOperator2.js new file mode 100644 index 00000000000..32962555d51 --- /dev/null +++ b/tests/baselines/reference/asOperator2.js @@ -0,0 +1,6 @@ +//// [asOperator2.ts] +var x = 23 as string; + + +//// [asOperator2.js] +var x = 23; diff --git a/tests/baselines/reference/asOperator3.js b/tests/baselines/reference/asOperator3.js new file mode 100644 index 00000000000..406eae1c9d6 --- /dev/null +++ b/tests/baselines/reference/asOperator3.js @@ -0,0 +1,22 @@ +//// [asOperator3.ts] +declare function tag(...x: any[]): any; + +var a = `${123 + 456 as number}`; +var b = `leading ${123 + 456 as number}`; +var c = `${123 + 456 as number} trailing`; +var d = `Hello ${123} World` as string; +var e = `Hello` as string; +var f = 1 + `${1} end of string` as string; +var g = tag `Hello ${123} World` as string; +var h = tag `Hello` as string; + +//// [asOperator3.js] +var a = "" + 123 + 456; +var b = "leading " + 123 + 456; +var c = 123 + 456 + " trailing"; +var d = ("Hello " + 123 + " World"); +var e = "Hello"; +var f = 1 + (1 + " end of string"); +var g = (_a = ["Hello ", " World"], _a.raw = ["Hello ", " World"], tag(_a, 123)); +var h = (_b = ["Hello"], _b.raw = ["Hello"], tag(_b)); +var _a, _b; diff --git a/tests/baselines/reference/asOperator3.symbols b/tests/baselines/reference/asOperator3.symbols new file mode 100644 index 00000000000..d29a64d3c3a --- /dev/null +++ b/tests/baselines/reference/asOperator3.symbols @@ -0,0 +1,31 @@ +=== tests/cases/conformance/expressions/asOperator/asOperator3.ts === +declare function tag(...x: any[]): any; +>tag : Symbol(tag, Decl(asOperator3.ts, 0, 0)) +>x : Symbol(x, Decl(asOperator3.ts, 0, 21)) + +var a = `${123 + 456 as number}`; +>a : Symbol(a, Decl(asOperator3.ts, 2, 3)) + +var b = `leading ${123 + 456 as number}`; +>b : Symbol(b, Decl(asOperator3.ts, 3, 3)) + +var c = `${123 + 456 as number} trailing`; +>c : Symbol(c, Decl(asOperator3.ts, 4, 3)) + +var d = `Hello ${123} World` as string; +>d : Symbol(d, Decl(asOperator3.ts, 5, 3)) + +var e = `Hello` as string; +>e : Symbol(e, Decl(asOperator3.ts, 6, 3)) + +var f = 1 + `${1} end of string` as string; +>f : Symbol(f, Decl(asOperator3.ts, 7, 3)) + +var g = tag `Hello ${123} World` as string; +>g : Symbol(g, Decl(asOperator3.ts, 8, 3)) +>tag : Symbol(tag, Decl(asOperator3.ts, 0, 0)) + +var h = tag `Hello` as string; +>h : Symbol(h, Decl(asOperator3.ts, 9, 3)) +>tag : Symbol(tag, Decl(asOperator3.ts, 0, 0)) + diff --git a/tests/baselines/reference/asOperator3.types b/tests/baselines/reference/asOperator3.types new file mode 100644 index 00000000000..507dfd8b572 --- /dev/null +++ b/tests/baselines/reference/asOperator3.types @@ -0,0 +1,63 @@ +=== tests/cases/conformance/expressions/asOperator/asOperator3.ts === +declare function tag(...x: any[]): any; +>tag : (...x: any[]) => any +>x : any[] + +var a = `${123 + 456 as number}`; +>a : string +>`${123 + 456 as number}` : string +>123 + 456 as number : number +>123 + 456 : number +>123 : number +>456 : number + +var b = `leading ${123 + 456 as number}`; +>b : string +>`leading ${123 + 456 as number}` : string +>123 + 456 as number : number +>123 + 456 : number +>123 : number +>456 : number + +var c = `${123 + 456 as number} trailing`; +>c : string +>`${123 + 456 as number} trailing` : string +>123 + 456 as number : number +>123 + 456 : number +>123 : number +>456 : number + +var d = `Hello ${123} World` as string; +>d : string +>`Hello ${123} World` as string : string +>`Hello ${123} World` : string +>123 : number + +var e = `Hello` as string; +>e : string +>`Hello` as string : string +>`Hello` : string + +var f = 1 + `${1} end of string` as string; +>f : string +>1 + `${1} end of string` as string : string +>1 + `${1} end of string` : string +>1 : number +>`${1} end of string` : string +>1 : number + +var g = tag `Hello ${123} World` as string; +>g : string +>tag `Hello ${123} World` as string : string +>tag `Hello ${123} World` : any +>tag : (...x: any[]) => any +>`Hello ${123} World` : string +>123 : number + +var h = tag `Hello` as string; +>h : string +>tag `Hello` as string : string +>tag `Hello` : any +>tag : (...x: any[]) => any +>`Hello` : string + diff --git a/tests/baselines/reference/asOperatorASI.js b/tests/baselines/reference/asOperatorASI.js new file mode 100644 index 00000000000..1df39b36e50 --- /dev/null +++ b/tests/baselines/reference/asOperatorASI.js @@ -0,0 +1,26 @@ +//// [asOperatorASI.ts] +class Foo { } +declare function as(...args: any[]); + +// Example 1 +var x = 10 +as `Hello world`; // should not error + +// Example 2 +var y = 20 +as(Foo); // should emit + + +//// [asOperatorASI.js] +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +// Example 1 +var x = 10; +(_a = ["Hello world"], _a.raw = ["Hello world"], as(_a)); // should not error +// Example 2 +var y = 20; +as(Foo); // should emit +var _a; diff --git a/tests/baselines/reference/asOperatorASI.symbols b/tests/baselines/reference/asOperatorASI.symbols new file mode 100644 index 00000000000..7def6d460c1 --- /dev/null +++ b/tests/baselines/reference/asOperatorASI.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/expressions/asOperator/asOperatorASI.ts === +class Foo { } +>Foo : Symbol(Foo, Decl(asOperatorASI.ts, 0, 0)) + +declare function as(...args: any[]); +>as : Symbol(as, Decl(asOperatorASI.ts, 0, 13)) +>args : Symbol(args, Decl(asOperatorASI.ts, 1, 20)) + +// Example 1 +var x = 10 +>x : Symbol(x, Decl(asOperatorASI.ts, 4, 3)) + +as `Hello world`; // should not error +>as : Symbol(as, Decl(asOperatorASI.ts, 0, 13)) + +// Example 2 +var y = 20 +>y : Symbol(y, Decl(asOperatorASI.ts, 8, 3)) + +as(Foo); // should emit +>as : Symbol(as, Decl(asOperatorASI.ts, 0, 13)) +>Foo : Symbol(Foo, Decl(asOperatorASI.ts, 0, 0)) + diff --git a/tests/baselines/reference/asOperatorASI.types b/tests/baselines/reference/asOperatorASI.types new file mode 100644 index 00000000000..61c2d115cf4 --- /dev/null +++ b/tests/baselines/reference/asOperatorASI.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/expressions/asOperator/asOperatorASI.ts === +class Foo { } +>Foo : Foo + +declare function as(...args: any[]); +>as : (...args: any[]) => any +>args : any[] + +// Example 1 +var x = 10 +>x : number +>10 : number + +as `Hello world`; // should not error +>as `Hello world` : any +>as : (...args: any[]) => any +>`Hello world` : string + +// Example 2 +var y = 20 +>y : number +>20 : number + +as(Foo); // should emit +>as(Foo) : any +>as : (...args: any[]) => any +>Foo : typeof Foo + diff --git a/tests/baselines/reference/asOperatorAmbiguity.errors.txt b/tests/baselines/reference/asOperatorAmbiguity.errors.txt new file mode 100644 index 00000000000..cb7c6d4132c --- /dev/null +++ b/tests/baselines/reference/asOperatorAmbiguity.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts(7,14): error TS2339: Property 'm' does not exist on type 'A'. + + +==== tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts (1 errors) ==== + interface A { x: T; } + interface B { m: string; } + + // Make sure this is a type assertion to an array type, and not nested comparison operators. + var x: any; + var y = x as A[]; + var z = y[0].m; // z should be string + ~ +!!! error TS2339: Property 'm' does not exist on type 'A'. + + \ No newline at end of file diff --git a/tests/baselines/reference/asOperatorAmbiguity.js b/tests/baselines/reference/asOperatorAmbiguity.js new file mode 100644 index 00000000000..6c336970b65 --- /dev/null +++ b/tests/baselines/reference/asOperatorAmbiguity.js @@ -0,0 +1,16 @@ +//// [asOperatorAmbiguity.ts] +interface A { x: T; } +interface B { m: string; } + +// Make sure this is a type assertion to an array type, and not nested comparison operators. +var x: any; +var y = x as A[]; +var z = y[0].m; // z should be string + + + +//// [asOperatorAmbiguity.js] +// Make sure this is a type assertion to an array type, and not nested comparison operators. +var x; +var y = x; +var z = y[0].m; // z should be string diff --git a/tests/baselines/reference/asOperatorContextualType.errors.txt b/tests/baselines/reference/asOperatorContextualType.errors.txt new file mode 100644 index 00000000000..c53b407b5cf --- /dev/null +++ b/tests/baselines/reference/asOperatorContextualType.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts(2,9): error TS2352: Neither type '(v: number) => number' nor type '(x: number) => string' is assignable to the other. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts (1 errors) ==== + // should error + var x = (v => v) as (x: number) => string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2352: Neither type '(v: number) => number' nor type '(x: number) => string' is assignable to the other. +!!! error TS2352: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/asOperatorContextualType.js b/tests/baselines/reference/asOperatorContextualType.js new file mode 100644 index 00000000000..7b495ada8f4 --- /dev/null +++ b/tests/baselines/reference/asOperatorContextualType.js @@ -0,0 +1,7 @@ +//// [asOperatorContextualType.ts] +// should error +var x = (v => v) as (x: number) => string; + +//// [asOperatorContextualType.js] +// should error +var x = (function (v) { return v; }); diff --git a/tests/baselines/reference/asOperatorNames.errors.txt b/tests/baselines/reference/asOperatorNames.errors.txt new file mode 100644 index 00000000000..e3dfaab9884 --- /dev/null +++ b/tests/baselines/reference/asOperatorNames.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/expressions/asOperator/asOperatorNames.ts(2,9): error TS2352: Neither type 'number' nor type 'string' is assignable to the other. + + +==== tests/cases/conformance/expressions/asOperator/asOperatorNames.ts (1 errors) ==== + var a = 20; + var b = a as string; + ~~~~~~~~~~~ +!!! error TS2352: Neither type 'number' nor type 'string' is assignable to the other. + var as = "hello"; + var as1 = as as string; + \ No newline at end of file diff --git a/tests/baselines/reference/asOperatorNames.js b/tests/baselines/reference/asOperatorNames.js new file mode 100644 index 00000000000..35e80d080e3 --- /dev/null +++ b/tests/baselines/reference/asOperatorNames.js @@ -0,0 +1,12 @@ +//// [asOperatorNames.ts] +var a = 20; +var b = a as string; +var as = "hello"; +var as1 = as as string; + + +//// [asOperatorNames.js] +var a = 20; +var b = a; +var as = "hello"; +var as1 = as; diff --git a/tests/baselines/reference/asyncArrowFunction10_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction10_es6.errors.txt new file mode 100644 index 00000000000..2476eaec6e3 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es6.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,11): error TS2304: Cannot find name 'async'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,17): error TS1005: ',' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,20): error TS1005: '=' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,24): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(4,11): error TS2304: Cannot find name 'await'. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts (5 errors) ==== + + var foo = async foo(): Promise => { + ~~~~~ +!!! error TS2304: Cannot find name 'async'. + ~~~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1005: '=' expected. + ~~~~~~~~~~~~~ +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. + // Legal to use 'await' in a type context. + var v: await; + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction10_es6.js b/tests/baselines/reference/asyncArrowFunction10_es6.js new file mode 100644 index 00000000000..23b2c3af80e --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es6.js @@ -0,0 +1,13 @@ +//// [asyncArrowFunction10_es6.ts] + +var foo = async foo(): Promise => { + // Legal to use 'await' in a type context. + var v: await; +} + + +//// [asyncArrowFunction10_es6.js] +var foo = async, foo = () => { + // Legal to use 'await' in a type context. + var v; +}; diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.js b/tests/baselines/reference/asyncArrowFunction1_es6.js new file mode 100644 index 00000000000..4f03acc5ced --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es6.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction1_es6.ts] + +var foo = async (): Promise => { +}; + +//// [asyncArrowFunction1_es6.js] +var foo = () => __awaiter(this, void 0, Promise, function* () { +}); diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.symbols b/tests/baselines/reference/asyncArrowFunction1_es6.symbols new file mode 100644 index 00000000000..cb2c5255486 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts === + +var foo = async (): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction1_es6.ts, 1, 3)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +}; diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.types b/tests/baselines/reference/asyncArrowFunction1_es6.types new file mode 100644 index 00000000000..3ecfdeb7919 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts === + +var foo = async (): Promise => { +>foo : () => Promise +>async (): Promise => {} : () => Promise +>Promise : Promise + +}; diff --git a/tests/baselines/reference/asyncArrowFunction2_es6.js b/tests/baselines/reference/asyncArrowFunction2_es6.js new file mode 100644 index 00000000000..9d7f1d10ea6 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es6.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction2_es6.ts] +var f = (await) => { +} + +//// [asyncArrowFunction2_es6.js] +var f = (await) => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction2_es6.symbols b/tests/baselines/reference/asyncArrowFunction2_es6.symbols new file mode 100644 index 00000000000..dd8b4ea2390 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts === +var f = (await) => { +>f : Symbol(f, Decl(asyncArrowFunction2_es6.ts, 0, 3)) +>await : Symbol(await, Decl(asyncArrowFunction2_es6.ts, 0, 9)) +} diff --git a/tests/baselines/reference/asyncArrowFunction2_es6.types b/tests/baselines/reference/asyncArrowFunction2_es6.types new file mode 100644 index 00000000000..98808d175f8 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts === +var f = (await) => { +>f : (await: any) => void +>(await) => {} : (await: any) => void +>await : any +} diff --git a/tests/baselines/reference/asyncArrowFunction3_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction3_es6.errors.txt new file mode 100644 index 00000000000..d0f56df51da --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts (1 errors) ==== + function f(await = await) { + ~~~~~ +!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction3_es6.js b/tests/baselines/reference/asyncArrowFunction3_es6.js new file mode 100644 index 00000000000..9616336d76a --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es6.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction3_es6.ts] +function f(await = await) { +} + +//// [asyncArrowFunction3_es6.js] +function f(await = await) { +} diff --git a/tests/baselines/reference/asyncArrowFunction4_es6.js b/tests/baselines/reference/asyncArrowFunction4_es6.js new file mode 100644 index 00000000000..eb89d98bbeb --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es6.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction4_es6.ts] +var await = () => { +} + +//// [asyncArrowFunction4_es6.js] +var await = () => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction4_es6.symbols b/tests/baselines/reference/asyncArrowFunction4_es6.symbols new file mode 100644 index 00000000000..1c001040720 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts === +var await = () => { +>await : Symbol(await, Decl(asyncArrowFunction4_es6.ts, 0, 3)) +} diff --git a/tests/baselines/reference/asyncArrowFunction4_es6.types b/tests/baselines/reference/asyncArrowFunction4_es6.types new file mode 100644 index 00000000000..e23ff786105 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts === +var await = () => { +>await : () => void +>() => {} : () => void +} diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt new file mode 100644 index 00000000000..fed29620532 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,11): error TS2304: Cannot find name 'async'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,18): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,24): error TS1005: ',' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,33): error TS1005: '=' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,40): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts (6 errors) ==== + + var foo = async (await): Promise => { + ~~~~~ +!!! error TS2304: Cannot find name 'async'. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. + ~ +!!! error TS1005: '=' expected. + ~~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.js b/tests/baselines/reference/asyncArrowFunction5_es6.js new file mode 100644 index 00000000000..ed4035e6175 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es6.js @@ -0,0 +1,9 @@ +//// [asyncArrowFunction5_es6.ts] + +var foo = async (await): Promise => { +} + +//// [asyncArrowFunction5_es6.js] +var foo = async(await), Promise = ; +{ +} diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt new file mode 100644 index 00000000000..111e4ff46d0 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts(2,22): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts(2,27): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts (2 errors) ==== + + var foo = async (a = await): Promise => { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.js b/tests/baselines/reference/asyncArrowFunction6_es6.js new file mode 100644 index 00000000000..54b8aa1f6b1 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es6.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction6_es6.ts] + +var foo = async (a = await): Promise => { +} + +//// [asyncArrowFunction6_es6.js] +var foo = (a = yield ) => __awaiter(this, void 0, Promise, function* () { +}); diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt new file mode 100644 index 00000000000..6376626d0e7 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts(4,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts(4,29): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts (2 errors) ==== + + var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.js b/tests/baselines/reference/asyncArrowFunction7_es6.js new file mode 100644 index 00000000000..ac68a8fd2f8 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es6.js @@ -0,0 +1,14 @@ +//// [asyncArrowFunction7_es6.ts] + +var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + } +} + +//// [asyncArrowFunction7_es6.js] +var bar = () => __awaiter(this, void 0, Promise, function* () { + // 'await' here is an identifier, and not an await expression. + var foo = (a = yield ) => __awaiter(this, void 0, Promise, function* () { + }); +}); diff --git a/tests/baselines/reference/asyncArrowFunction8_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction8_es6.errors.txt new file mode 100644 index 00000000000..7252805cdca --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts(3,19): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts (1 errors) ==== + + var foo = async (): Promise => { + var v = { [await]: foo } + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction8_es6.js b/tests/baselines/reference/asyncArrowFunction8_es6.js new file mode 100644 index 00000000000..9cee5ee1525 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es6.js @@ -0,0 +1,10 @@ +//// [asyncArrowFunction8_es6.ts] + +var foo = async (): Promise => { + var v = { [await]: foo } +} + +//// [asyncArrowFunction8_es6.js] +var foo = () => __awaiter(this, void 0, Promise, function* () { + var v = { [yield ]: foo }; +}); diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt new file mode 100644 index 00000000000..623095e8a5e --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,11): error TS2304: Cannot find name 'async'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,18): error TS2304: Cannot find name 'a'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,37): error TS1005: ',' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,46): error TS1005: '=' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,53): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts (6 errors) ==== + var foo = async (a = await => await): Promise => { + ~~~~~ +!!! error TS2304: Cannot find name 'async'. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. + ~ +!!! error TS1005: '=' expected. + ~~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.js b/tests/baselines/reference/asyncArrowFunction9_es6.js new file mode 100644 index 00000000000..fb2f9d28a17 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es6.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction9_es6.ts] +var foo = async (a = await => await): Promise => { +} + +//// [asyncArrowFunction9_es6.js] +var foo = async(a = await => await), Promise = ; +{ +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js new file mode 100644 index 00000000000..c24259cf0b5 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js @@ -0,0 +1,16 @@ +//// [asyncArrowFunctionCapturesArguments_es6.ts] +class C { + method() { + function other() {} + var fn = async () => await other.apply(this, arguments); + } +} + + +//// [asyncArrowFunctionCapturesArguments_es6.js] +class C { + method() { + function other() { } + var fn = () => __awaiter(this, arguments, Promise, function* (_arguments) { return yield other.apply(this, _arguments); }); + } +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols new file mode 100644 index 00000000000..5f820eec862 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts === +class C { +>C : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 0, 0)) + + method() { +>method : Symbol(method, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 0, 9)) + + function other() {} +>other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 1, 13)) + + var fn = async () => await other.apply(this, arguments); +>fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 3, 9)) +>other.apply : Symbol(Function.apply, Decl(lib.d.ts, 228, 20)) +>other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 1, 13)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, 228, 20)) +>this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 0, 0)) +>arguments : Symbol(arguments) + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types new file mode 100644 index 00000000000..b3f6f18cde8 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts === +class C { +>C : C + + method() { +>method : () => void + + function other() {} +>other : () => void + + var fn = async () => await other.apply(this, arguments); +>fn : () => Promise +>async () => await other.apply(this, arguments) : () => Promise +>other.apply(this, arguments) : any +>other.apply : (thisArg: any, argArray?: any) => any +>other : () => void +>apply : (thisArg: any, argArray?: any) => any +>this : C +>arguments : IArguments + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js new file mode 100644 index 00000000000..0f09e366ef3 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js @@ -0,0 +1,14 @@ +//// [asyncArrowFunctionCapturesThis_es6.ts] +class C { + method() { + var fn = async () => await this; + } +} + + +//// [asyncArrowFunctionCapturesThis_es6.js] +class C { + method() { + var fn = () => __awaiter(this, void 0, Promise, function* () { return yield this; }); + } +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.symbols new file mode 100644 index 00000000000..ae516bb7fe3 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts === +class C { +>C : Symbol(C, Decl(asyncArrowFunctionCapturesThis_es6.ts, 0, 0)) + + method() { +>method : Symbol(method, Decl(asyncArrowFunctionCapturesThis_es6.ts, 0, 9)) + + var fn = async () => await this; +>fn : Symbol(fn, Decl(asyncArrowFunctionCapturesThis_es6.ts, 2, 9)) +>this : Symbol(C, Decl(asyncArrowFunctionCapturesThis_es6.ts, 0, 0)) + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.types b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.types new file mode 100644 index 00000000000..f3cd0f2d2de --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts === +class C { +>C : C + + method() { +>method : () => void + + var fn = async () => await this; +>fn : () => Promise +>async () => await this : () => Promise +>this : C + } +} + diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es6.errors.txt b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.errors.txt new file mode 100644 index 00000000000..068fbb604e1 --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts(1,27): error TS2307: Cannot find module 'missing'. + + +==== tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts (1 errors) ==== + import { MyPromise } from "missing"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'missing'. + + declare var p: Promise; + declare var mp: MyPromise; + + async function f0() { } + async function f1(): Promise { } + async function f3(): MyPromise { } + + let f4 = async function() { } + let f5 = async function(): Promise { } + let f6 = async function(): MyPromise { } + + let f7 = async () => { }; + let f8 = async (): Promise => { }; + let f9 = async (): MyPromise => { }; + let f10 = async () => p; + let f11 = async () => mp; + let f12 = async (): Promise => mp; + let f13 = async (): MyPromise => p; + + let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } + }; + + class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } + } + + module M { + export async function f1() { } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js new file mode 100644 index 00000000000..7007c66ae28 --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js @@ -0,0 +1,118 @@ +//// [asyncAwaitIsolatedModules_es6.ts] +import { MyPromise } from "missing"; + +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} + +//// [asyncAwaitIsolatedModules_es6.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { + return new Promise(function (resolve, reject) { + generator = generator.call(thisArg, _arguments); + function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } + function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } + function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } + function step(verb, value) { + var result = generator[verb](value); + result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); + } + step("next", void 0); + }); +}; +function f0() { + return __awaiter(this, void 0, Promise, function* () { }); +} +function f1() { + return __awaiter(this, void 0, Promise, function* () { }); +} +function f3() { + return __awaiter(this, void 0, MyPromise, function* () { }); +} +let f4 = function () { + return __awaiter(this, void 0, Promise, function* () { }); +}; +let f5 = function () { + return __awaiter(this, void 0, Promise, function* () { }); +}; +let f6 = function () { + return __awaiter(this, void 0, MyPromise, function* () { }); +}; +let f7 = () => __awaiter(this, void 0, Promise, function* () { }); +let f8 = () => __awaiter(this, void 0, Promise, function* () { }); +let f9 = () => __awaiter(this, void 0, MyPromise, function* () { }); +let f10 = () => __awaiter(this, void 0, Promise, function* () { return p; }); +let f11 = () => __awaiter(this, void 0, Promise, function* () { return mp; }); +let f12 = () => __awaiter(this, void 0, Promise, function* () { return mp; }); +let f13 = () => __awaiter(this, void 0, MyPromise, function* () { return p; }); +let o = { + m1() { + return __awaiter(this, void 0, Promise, function* () { }); + }, + m2() { + return __awaiter(this, void 0, Promise, function* () { }); + }, + m3() { + return __awaiter(this, void 0, MyPromise, function* () { }); + } +}; +class C { + m1() { + return __awaiter(this, void 0, Promise, function* () { }); + } + m2() { + return __awaiter(this, void 0, Promise, function* () { }); + } + m3() { + return __awaiter(this, void 0, MyPromise, function* () { }); + } + static m4() { + return __awaiter(this, void 0, Promise, function* () { }); + } + static m5() { + return __awaiter(this, void 0, Promise, function* () { }); + } + static m6() { + return __awaiter(this, void 0, MyPromise, function* () { }); + } +} +var M; +(function (M) { + function f1() { + return __awaiter(this, void 0, Promise, function* () { }); + } + M.f1 = f1; +})(M || (M = {})); diff --git a/tests/baselines/reference/asyncAwait_es6.js b/tests/baselines/reference/asyncAwait_es6.js new file mode 100644 index 00000000000..155a44d339d --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es6.js @@ -0,0 +1,118 @@ +//// [asyncAwait_es6.ts] +type MyPromise = Promise; +declare var MyPromise: typeof Promise; +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} + +//// [asyncAwait_es6.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { + return new Promise(function (resolve, reject) { + generator = generator.call(thisArg, _arguments); + function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } + function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } + function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } + function step(verb, value) { + var result = generator[verb](value); + result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); + } + step("next", void 0); + }); +}; +function f0() { + return __awaiter(this, void 0, Promise, function* () { }); +} +function f1() { + return __awaiter(this, void 0, Promise, function* () { }); +} +function f3() { + return __awaiter(this, void 0, MyPromise, function* () { }); +} +let f4 = function () { + return __awaiter(this, void 0, Promise, function* () { }); +}; +let f5 = function () { + return __awaiter(this, void 0, Promise, function* () { }); +}; +let f6 = function () { + return __awaiter(this, void 0, MyPromise, function* () { }); +}; +let f7 = () => __awaiter(this, void 0, Promise, function* () { }); +let f8 = () => __awaiter(this, void 0, Promise, function* () { }); +let f9 = () => __awaiter(this, void 0, MyPromise, function* () { }); +let f10 = () => __awaiter(this, void 0, Promise, function* () { return p; }); +let f11 = () => __awaiter(this, void 0, Promise, function* () { return mp; }); +let f12 = () => __awaiter(this, void 0, Promise, function* () { return mp; }); +let f13 = () => __awaiter(this, void 0, MyPromise, function* () { return p; }); +let o = { + m1() { + return __awaiter(this, void 0, Promise, function* () { }); + }, + m2() { + return __awaiter(this, void 0, Promise, function* () { }); + }, + m3() { + return __awaiter(this, void 0, MyPromise, function* () { }); + } +}; +class C { + m1() { + return __awaiter(this, void 0, Promise, function* () { }); + } + m2() { + return __awaiter(this, void 0, Promise, function* () { }); + } + m3() { + return __awaiter(this, void 0, MyPromise, function* () { }); + } + static m4() { + return __awaiter(this, void 0, Promise, function* () { }); + } + static m5() { + return __awaiter(this, void 0, Promise, function* () { }); + } + static m6() { + return __awaiter(this, void 0, MyPromise, function* () { }); + } +} +var M; +(function (M) { + function f1() { + return __awaiter(this, void 0, Promise, function* () { }); + } + M.f1 = f1; +})(M || (M = {})); diff --git a/tests/baselines/reference/asyncAwait_es6.symbols b/tests/baselines/reference/asyncAwait_es6.symbols new file mode 100644 index 00000000000..8d4b98a20a1 --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es6.symbols @@ -0,0 +1,118 @@ +=== tests/cases/conformance/async/es6/asyncAwait_es6.ts === +type MyPromise = Promise; +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) +>T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) + +declare var MyPromise: typeof Promise; +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare var mp: MyPromise; +>mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +async function f0() { } +>f0 : Symbol(f0, Decl(asyncAwait_es6.ts, 3, 34)) + +async function f1(): Promise { } +>f1 : Symbol(f1, Decl(asyncAwait_es6.ts, 5, 23)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +async function f3(): MyPromise { } +>f3 : Symbol(f3, Decl(asyncAwait_es6.ts, 6, 38)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +let f4 = async function() { } +>f4 : Symbol(f4, Decl(asyncAwait_es6.ts, 9, 3)) + +let f5 = async function(): Promise { } +>f5 : Symbol(f5, Decl(asyncAwait_es6.ts, 10, 3)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +let f6 = async function(): MyPromise { } +>f6 : Symbol(f6, Decl(asyncAwait_es6.ts, 11, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +let f7 = async () => { }; +>f7 : Symbol(f7, Decl(asyncAwait_es6.ts, 13, 3)) + +let f8 = async (): Promise => { }; +>f8 : Symbol(f8, Decl(asyncAwait_es6.ts, 14, 3)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +let f9 = async (): MyPromise => { }; +>f9 : Symbol(f9, Decl(asyncAwait_es6.ts, 15, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +let f10 = async () => p; +>f10 : Symbol(f10, Decl(asyncAwait_es6.ts, 16, 3)) +>p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11)) + +let f11 = async () => mp; +>f11 : Symbol(f11, Decl(asyncAwait_es6.ts, 17, 3)) +>mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) + +let f12 = async (): Promise => mp; +>f12 : Symbol(f12, Decl(asyncAwait_es6.ts, 18, 3)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) + +let f13 = async (): MyPromise => p; +>f13 : Symbol(f13, Decl(asyncAwait_es6.ts, 19, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) +>p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11)) + +let o = { +>o : Symbol(o, Decl(asyncAwait_es6.ts, 21, 3)) + + async m1() { }, +>m1 : Symbol(m1, Decl(asyncAwait_es6.ts, 21, 9)) + + async m2(): Promise { }, +>m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 22, 16)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + async m3(): MyPromise { } +>m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 23, 31)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +}; + +class C { +>C : Symbol(C, Decl(asyncAwait_es6.ts, 25, 2)) + + async m1() { } +>m1 : Symbol(m1, Decl(asyncAwait_es6.ts, 27, 9)) + + async m2(): Promise { } +>m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 28, 15)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + async m3(): MyPromise { } +>m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 29, 30)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + + static async m4() { } +>m4 : Symbol(C.m4, Decl(asyncAwait_es6.ts, 30, 32)) + + static async m5(): Promise { } +>m5 : Symbol(C.m5, Decl(asyncAwait_es6.ts, 31, 22)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + static async m6(): MyPromise { } +>m6 : Symbol(C.m6, Decl(asyncAwait_es6.ts, 32, 37)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) +} + +module M { +>M : Symbol(M, Decl(asyncAwait_es6.ts, 34, 1)) + + export async function f1() { } +>f1 : Symbol(f1, Decl(asyncAwait_es6.ts, 36, 10)) +} diff --git a/tests/baselines/reference/asyncAwait_es6.types b/tests/baselines/reference/asyncAwait_es6.types new file mode 100644 index 00000000000..5f0cd2cc35a --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es6.types @@ -0,0 +1,129 @@ +=== tests/cases/conformance/async/es6/asyncAwait_es6.ts === +type MyPromise = Promise; +>MyPromise : Promise +>T : T +>Promise : Promise +>T : T + +declare var MyPromise: typeof Promise; +>MyPromise : PromiseConstructor +>Promise : PromiseConstructor + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare var mp: MyPromise; +>mp : Promise +>MyPromise : Promise + +async function f0() { } +>f0 : () => Promise + +async function f1(): Promise { } +>f1 : () => Promise +>Promise : Promise + +async function f3(): MyPromise { } +>f3 : () => Promise +>MyPromise : Promise + +let f4 = async function() { } +>f4 : () => Promise +>async function() { } : () => Promise + +let f5 = async function(): Promise { } +>f5 : () => Promise +>async function(): Promise { } : () => Promise +>Promise : Promise + +let f6 = async function(): MyPromise { } +>f6 : () => Promise +>async function(): MyPromise { } : () => Promise +>MyPromise : Promise + +let f7 = async () => { }; +>f7 : () => Promise +>async () => { } : () => Promise + +let f8 = async (): Promise => { }; +>f8 : () => Promise +>async (): Promise => { } : () => Promise +>Promise : Promise + +let f9 = async (): MyPromise => { }; +>f9 : () => Promise +>async (): MyPromise => { } : () => Promise +>MyPromise : Promise + +let f10 = async () => p; +>f10 : () => Promise +>async () => p : () => Promise +>p : Promise + +let f11 = async () => mp; +>f11 : () => Promise +>async () => mp : () => Promise +>mp : Promise + +let f12 = async (): Promise => mp; +>f12 : () => Promise +>async (): Promise => mp : () => Promise +>Promise : Promise +>mp : Promise + +let f13 = async (): MyPromise => p; +>f13 : () => Promise +>async (): MyPromise => p : () => Promise +>MyPromise : Promise +>p : Promise + +let o = { +>o : { m1(): Promise; m2(): Promise; m3(): Promise; } +>{ async m1() { }, async m2(): Promise { }, async m3(): MyPromise { }} : { m1(): Promise; m2(): Promise; m3(): Promise; } + + async m1() { }, +>m1 : () => Promise + + async m2(): Promise { }, +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => Promise +>MyPromise : Promise + +}; + +class C { +>C : C + + async m1() { } +>m1 : () => Promise + + async m2(): Promise { } +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => Promise +>MyPromise : Promise + + static async m4() { } +>m4 : () => Promise + + static async m5(): Promise { } +>m5 : () => Promise +>Promise : Promise + + static async m6(): MyPromise { } +>m6 : () => Promise +>MyPromise : Promise +} + +module M { +>M : typeof M + + export async function f1() { } +>f1 : () => Promise +} diff --git a/tests/baselines/reference/asyncClass_es6.errors.txt b/tests/baselines/reference/asyncClass_es6.errors.txt new file mode 100644 index 00000000000..ee8a3a85dbc --- /dev/null +++ b/tests/baselines/reference/asyncClass_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/asyncClass_es6.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncClass_es6.ts (1 errors) ==== + async class C { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncClass_es6.js b/tests/baselines/reference/asyncClass_es6.js new file mode 100644 index 00000000000..b5e1498f70c --- /dev/null +++ b/tests/baselines/reference/asyncClass_es6.js @@ -0,0 +1,7 @@ +//// [asyncClass_es6.ts] +async class C { +} + +//// [asyncClass_es6.js] +class C { +} diff --git a/tests/baselines/reference/asyncConstructor_es6.errors.txt b/tests/baselines/reference/asyncConstructor_es6.errors.txt new file mode 100644 index 00000000000..6eb18cf41a1 --- /dev/null +++ b/tests/baselines/reference/asyncConstructor_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es6/asyncConstructor_es6.ts(2,3): error TS1089: 'async' modifier cannot appear on a constructor declaration. + + +==== tests/cases/conformance/async/es6/asyncConstructor_es6.ts (1 errors) ==== + class C { + async constructor() { + ~~~~~ +!!! error TS1089: 'async' modifier cannot appear on a constructor declaration. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncConstructor_es6.js b/tests/baselines/reference/asyncConstructor_es6.js new file mode 100644 index 00000000000..a0cfa7709df --- /dev/null +++ b/tests/baselines/reference/asyncConstructor_es6.js @@ -0,0 +1,11 @@ +//// [asyncConstructor_es6.ts] +class C { + async constructor() { + } +} + +//// [asyncConstructor_es6.js] +class C { + constructor() { + } +} diff --git a/tests/baselines/reference/asyncDeclare_es6.errors.txt b/tests/baselines/reference/asyncDeclare_es6.errors.txt new file mode 100644 index 00000000000..65a4068e140 --- /dev/null +++ b/tests/baselines/reference/asyncDeclare_es6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/async/es6/asyncDeclare_es6.ts(1,9): error TS1040: 'async' modifier cannot be used in an ambient context. + + +==== tests/cases/conformance/async/es6/asyncDeclare_es6.ts (1 errors) ==== + declare async function foo(): Promise; + ~~~~~ +!!! error TS1040: 'async' modifier cannot be used in an ambient context. \ No newline at end of file diff --git a/tests/baselines/reference/asyncDeclare_es6.js b/tests/baselines/reference/asyncDeclare_es6.js new file mode 100644 index 00000000000..096f43a248a --- /dev/null +++ b/tests/baselines/reference/asyncDeclare_es6.js @@ -0,0 +1,4 @@ +//// [asyncDeclare_es6.ts] +declare async function foo(): Promise; + +//// [asyncDeclare_es6.js] diff --git a/tests/baselines/reference/asyncEnum_es6.errors.txt b/tests/baselines/reference/asyncEnum_es6.errors.txt new file mode 100644 index 00000000000..a50853fd8ea --- /dev/null +++ b/tests/baselines/reference/asyncEnum_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/async/es6/asyncEnum_es6.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncEnum_es6.ts (1 errors) ==== + async enum E { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + Value + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncEnum_es6.js b/tests/baselines/reference/asyncEnum_es6.js new file mode 100644 index 00000000000..074de3dd0ae --- /dev/null +++ b/tests/baselines/reference/asyncEnum_es6.js @@ -0,0 +1,10 @@ +//// [asyncEnum_es6.ts] +async enum E { + Value +} + +//// [asyncEnum_es6.js] +var E; +(function (E) { + E[E["Value"] = 0] = "Value"; +})(E || (E = {})); diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt new file mode 100644 index 00000000000..15ceb3e60c7 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,30): error TS1109: Expression expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS1138: Parameter declaration expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,38): error TS1005: ';' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,53): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (7 errors) ==== + async function foo(a = await => await): Promise { + ~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~ +!!! error TS1109: Expression expected. + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js new file mode 100644 index 00000000000..141c0cbab55 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration10_es6.ts] +async function foo(a = await => await): Promise { +} + +//// [asyncFunctionDeclaration10_es6.js] +await; +Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.js b/tests/baselines/reference/asyncFunctionDeclaration11_es6.js new file mode 100644 index 00000000000..a44343cef78 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.js @@ -0,0 +1,9 @@ +//// [asyncFunctionDeclaration11_es6.ts] +async function await(): Promise { +} + +//// [asyncFunctionDeclaration11_es6.js] +function await() { + return __awaiter(this, void 0, Promise, function* () { + }); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols new file mode 100644 index 00000000000..889614387d7 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === +async function await(): Promise { +>await : Symbol(await, Decl(asyncFunctionDeclaration11_es6.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.types b/tests/baselines/reference/asyncFunctionDeclaration11_es6.types new file mode 100644 index 00000000000..65896e7b3b5 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === +async function await(): Promise { +>await : () => Promise +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt new file mode 100644 index 00000000000..978492f0744 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,24): error TS1005: '(' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,29): error TS1005: '=' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,47): error TS1005: '=>' expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts (4 errors) ==== + var v = async function await(): Promise { } + ~~~~~ +!!! error TS1005: '(' expected. + ~ +!!! error TS1005: '=' expected. + ~~~~~~~~~~~~~ +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. + ~ +!!! error TS1005: '=>' expected. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.js b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js new file mode 100644 index 00000000000..dae33682ce6 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js @@ -0,0 +1,5 @@ +//// [asyncFunctionDeclaration12_es6.ts] +var v = async function await(): Promise { } + +//// [asyncFunctionDeclaration12_es6.js] +var v = , await = () => { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration13_es6.errors.txt new file mode 100644 index 00000000000..6cf65ca4e3a --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es6.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts(3,11): error TS2304: Cannot find name 'await'. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts (1 errors) ==== + async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es6.js b/tests/baselines/reference/asyncFunctionDeclaration13_es6.js new file mode 100644 index 00000000000..4257c8691c2 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es6.js @@ -0,0 +1,14 @@ +//// [asyncFunctionDeclaration13_es6.ts] +async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; +} + + +//// [asyncFunctionDeclaration13_es6.js] +function foo() { + return __awaiter(this, void 0, Promise, function* () { + // Legal to use 'await' in a type context. + var v; + }); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.js b/tests/baselines/reference/asyncFunctionDeclaration14_es6.js new file mode 100644 index 00000000000..f32d106f92e --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.js @@ -0,0 +1,11 @@ +//// [asyncFunctionDeclaration14_es6.ts] +async function foo(): Promise { + return; +} + +//// [asyncFunctionDeclaration14_es6.js] +function foo() { + return __awaiter(this, void 0, Promise, function* () { + return; + }); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols new file mode 100644 index 00000000000..626b820e312 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es6.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + return; +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.types b/tests/baselines/reference/asyncFunctionDeclaration14_es6.types new file mode 100644 index 00000000000..7727ffafaeb --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise + + return; +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.js b/tests/baselines/reference/asyncFunctionDeclaration1_es6.js new file mode 100644 index 00000000000..263e27fa35e --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.js @@ -0,0 +1,9 @@ +//// [asyncFunctionDeclaration1_es6.ts] +async function foo(): Promise { +} + +//// [asyncFunctionDeclaration1_es6.js] +function foo() { + return __awaiter(this, void 0, Promise, function* () { + }); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols new file mode 100644 index 00000000000..c71592c0463 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es6.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.types b/tests/baselines/reference/asyncFunctionDeclaration1_es6.types new file mode 100644 index 00000000000..5cba25724f0 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es6.js b/tests/baselines/reference/asyncFunctionDeclaration2_es6.js new file mode 100644 index 00000000000..1c54b9bc056 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration2_es6.ts] +function f(await) { +} + +//// [asyncFunctionDeclaration2_es6.js] +function f(await) { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration2_es6.symbols new file mode 100644 index 00000000000..c709d7f7386 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts === +function f(await) { +>f : Symbol(f, Decl(asyncFunctionDeclaration2_es6.ts, 0, 0)) +>await : Symbol(await, Decl(asyncFunctionDeclaration2_es6.ts, 0, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es6.types b/tests/baselines/reference/asyncFunctionDeclaration2_es6.types new file mode 100644 index 00000000000..9c9a19f3e76 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts === +function f(await) { +>f : (await: any) => void +>await : any +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration3_es6.errors.txt new file mode 100644 index 00000000000..a480bf3d2b8 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts (1 errors) ==== + function f(await = await) { + ~~~~~ +!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es6.js b/tests/baselines/reference/asyncFunctionDeclaration3_es6.js new file mode 100644 index 00000000000..7038858d2c8 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration3_es6.ts] +function f(await = await) { +} + +//// [asyncFunctionDeclaration3_es6.js] +function f(await = await) { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es6.js b/tests/baselines/reference/asyncFunctionDeclaration4_es6.js new file mode 100644 index 00000000000..8bfb7bf642f --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration4_es6.ts] +function await() { +} + +//// [asyncFunctionDeclaration4_es6.js] +function await() { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration4_es6.symbols new file mode 100644 index 00000000000..cdbe1f5a8db --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts === +function await() { +>await : Symbol(await, Decl(asyncFunctionDeclaration4_es6.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es6.types b/tests/baselines/reference/asyncFunctionDeclaration4_es6.types new file mode 100644 index 00000000000..537661e2c66 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts === +function await() { +>await : () => void +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt new file mode 100644 index 00000000000..a6944e0c6e6 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,20): error TS1138: Parameter declaration expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,20): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,25): error TS1005: ';' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,40): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts (5 errors) ==== + async function foo(await): Promise { + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.js b/tests/baselines/reference/asyncFunctionDeclaration5_es6.js new file mode 100644 index 00000000000..8d28c371465 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration5_es6.ts] +async function foo(await): Promise { +} + +//// [asyncFunctionDeclaration5_es6.js] +await; +Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt new file mode 100644 index 00000000000..ee8abb7bdad --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts(1,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts(1,29): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts (2 errors) ==== + async function foo(a = await): Promise { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js new file mode 100644 index 00000000000..8c37968ab4c --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js @@ -0,0 +1,9 @@ +//// [asyncFunctionDeclaration6_es6.ts] +async function foo(a = await): Promise { +} + +//// [asyncFunctionDeclaration6_es6.js] +function foo(a = yield ) { + return __awaiter(this, void 0, Promise, function* () { + }); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt new file mode 100644 index 00000000000..91ba4508ba1 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts(3,26): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts(3,31): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts (2 errors) ==== + async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js new file mode 100644 index 00000000000..ef66df4e413 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js @@ -0,0 +1,17 @@ +//// [asyncFunctionDeclaration7_es6.ts] +async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + } +} + +//// [asyncFunctionDeclaration7_es6.js] +function bar() { + return __awaiter(this, void 0, Promise, function* () { + // 'await' here is an identifier, and not a yield expression. + function foo(a = yield ) { + return __awaiter(this, void 0, Promise, function* () { + }); + } + }); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration8_es6.errors.txt new file mode 100644 index 00000000000..c785ae41b17 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts(1,12): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts(1,20): error TS2304: Cannot find name 'foo'. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts (2 errors) ==== + var v = { [await]: foo } + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~~~ +!!! error TS2304: Cannot find name 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es6.js b/tests/baselines/reference/asyncFunctionDeclaration8_es6.js new file mode 100644 index 00000000000..a363015f8ab --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es6.js @@ -0,0 +1,5 @@ +//// [asyncFunctionDeclaration8_es6.ts] +var v = { [await]: foo } + +//// [asyncFunctionDeclaration8_es6.js] +var v = { [await]: foo }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration9_es6.errors.txt new file mode 100644 index 00000000000..235ef165bed --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts(2,19): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts (1 errors) ==== + async function foo(): Promise { + var v = { [await]: foo } + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es6.js b/tests/baselines/reference/asyncFunctionDeclaration9_es6.js new file mode 100644 index 00000000000..9723a69f2a2 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es6.js @@ -0,0 +1,11 @@ +//// [asyncFunctionDeclaration9_es6.ts] +async function foo(): Promise { + var v = { [await]: foo } +} + +//// [asyncFunctionDeclaration9_es6.js] +function foo() { + return __awaiter(this, void 0, Promise, function* () { + var v = { [yield ]: foo }; + }); +} diff --git a/tests/baselines/reference/asyncGetter_es6.errors.txt b/tests/baselines/reference/asyncGetter_es6.errors.txt new file mode 100644 index 00000000000..5f5a9f6b1d7 --- /dev/null +++ b/tests/baselines/reference/asyncGetter_es6.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/async/es6/asyncGetter_es6.ts(2,3): error TS1042: 'async' modifier cannot be used here. +tests/cases/conformance/async/es6/asyncGetter_es6.ts(2,13): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + + +==== tests/cases/conformance/async/es6/asyncGetter_es6.ts (2 errors) ==== + class C { + async get foo() { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + ~~~ +!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncGetter_es6.js b/tests/baselines/reference/asyncGetter_es6.js new file mode 100644 index 00000000000..606f4d95dc7 --- /dev/null +++ b/tests/baselines/reference/asyncGetter_es6.js @@ -0,0 +1,11 @@ +//// [asyncGetter_es6.ts] +class C { + async get foo() { + } +} + +//// [asyncGetter_es6.js] +class C { + get foo() { + } +} diff --git a/tests/baselines/reference/asyncInterface_es6.errors.txt b/tests/baselines/reference/asyncInterface_es6.errors.txt new file mode 100644 index 00000000000..c7519ba040e --- /dev/null +++ b/tests/baselines/reference/asyncInterface_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/asyncInterface_es6.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncInterface_es6.ts (1 errors) ==== + async interface I { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncInterface_es6.js b/tests/baselines/reference/asyncInterface_es6.js new file mode 100644 index 00000000000..36314fa2141 --- /dev/null +++ b/tests/baselines/reference/asyncInterface_es6.js @@ -0,0 +1,5 @@ +//// [asyncInterface_es6.ts] +async interface I { +} + +//// [asyncInterface_es6.js] diff --git a/tests/baselines/reference/asyncModule_es6.errors.txt b/tests/baselines/reference/asyncModule_es6.errors.txt new file mode 100644 index 00000000000..91e5e8ccdd3 --- /dev/null +++ b/tests/baselines/reference/asyncModule_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/asyncModule_es6.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncModule_es6.ts (1 errors) ==== + async module M { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncModule_es6.js b/tests/baselines/reference/asyncModule_es6.js new file mode 100644 index 00000000000..e3e9306dbcb --- /dev/null +++ b/tests/baselines/reference/asyncModule_es6.js @@ -0,0 +1,5 @@ +//// [asyncModule_es6.ts] +async module M { +} + +//// [asyncModule_es6.js] diff --git a/tests/baselines/reference/asyncSetter_es6.errors.txt b/tests/baselines/reference/asyncSetter_es6.errors.txt new file mode 100644 index 00000000000..e60e05cbc55 --- /dev/null +++ b/tests/baselines/reference/asyncSetter_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es6/asyncSetter_es6.ts(2,3): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncSetter_es6.ts (1 errors) ==== + class C { + async set foo(value) { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncSetter_es6.js b/tests/baselines/reference/asyncSetter_es6.js new file mode 100644 index 00000000000..303e483f9a9 --- /dev/null +++ b/tests/baselines/reference/asyncSetter_es6.js @@ -0,0 +1,11 @@ +//// [asyncSetter_es6.ts] +class C { + async set foo(value) { + } +} + +//// [asyncSetter_es6.js] +class C { + set foo(value) { + } +} diff --git a/tests/baselines/reference/augmentedTypesClass2.errors.txt b/tests/baselines/reference/augmentedTypesClass2.errors.txt index 5881e49dae9..278dca816fa 100644 --- a/tests/baselines/reference/augmentedTypesClass2.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2300: Duplicate identifier 'c11'. -tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2300: Duplicate identifier 'c11'. +tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2300: Duplicate identifier 'c33'. tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate identifier 'c33'. @@ -10,7 +10,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden // class then interface class c11 { // error ~~~ -!!! error TS2300: Duplicate identifier 'c11'. +!!! error TS2518: Only an ambient class can be merged with an interface. foo() { return 1; } @@ -18,7 +18,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden interface c11 { // error ~~~ -!!! error TS2300: Duplicate identifier 'c11'. +!!! error TS2518: Only an ambient class can be merged with an interface. bar(): void; } diff --git a/tests/baselines/reference/augmentedTypesInterface.errors.txt b/tests/baselines/reference/augmentedTypesInterface.errors.txt index a9fc28dd5ae..690bf8b7a99 100644 --- a/tests/baselines/reference/augmentedTypesInterface.errors.txt +++ b/tests/baselines/reference/augmentedTypesInterface.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2300: Duplicate identifier 'i2'. -tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2300: Duplicate identifier 'i2'. +tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2300: Duplicate identifier 'i3'. tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate identifier 'i3'. @@ -18,13 +18,13 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i // interface then class interface i2 { // error ~~ -!!! error TS2300: Duplicate identifier 'i2'. +!!! error TS2518: Only an ambient class can be merged with an interface. foo(): void; } class i2 { // error ~~ -!!! error TS2300: Duplicate identifier 'i2'. +!!! error TS2518: Only an ambient class can be merged with an interface. bar() { return 1; } diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.js b/tests/baselines/reference/awaitBinaryExpression1_es6.js new file mode 100644 index 00000000000..8deb771f5ab --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression1_es6.ts] +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p || a; + "after"; +} + +//// [awaitBinaryExpression1_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = (yield p) || a; + "after"; + }); +} diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols new file mode 100644 index 00000000000..6a72f1b1506 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression1_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression1_es6.ts, 1, 32)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = await p || a; +>b : Symbol(b, Decl(awaitBinaryExpression1_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression1_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.types b/tests/baselines/reference/awaitBinaryExpression1_es6.types new file mode 100644 index 00000000000..59370dda14b --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = await p || a; +>b : boolean +>await p || a : boolean +>p : any +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.js b/tests/baselines/reference/awaitBinaryExpression2_es6.js new file mode 100644 index 00000000000..506af50a0ef --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression2_es6.ts] +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p && a; + "after"; +} + +//// [awaitBinaryExpression2_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = (yield p) && a; + "after"; + }); +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols new file mode 100644 index 00000000000..f81a146f943 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression2_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression2_es6.ts, 1, 32)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = await p && a; +>b : Symbol(b, Decl(awaitBinaryExpression2_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression2_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.types b/tests/baselines/reference/awaitBinaryExpression2_es6.types new file mode 100644 index 00000000000..c3f33bca2fa --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = await p && a; +>b : boolean +>await p && a : boolean +>p : any +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.js b/tests/baselines/reference/awaitBinaryExpression3_es6.js new file mode 100644 index 00000000000..4b298d7b947 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression3_es6.ts] +declare var a: number; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p + a; + "after"; +} + +//// [awaitBinaryExpression3_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = (yield p) + a; + "after"; + }); +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols new file mode 100644 index 00000000000..479b3b30650 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts === +declare var a: number; +>a : Symbol(a, Decl(awaitBinaryExpression3_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression3_es6.ts, 1, 31)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = await p + a; +>b : Symbol(b, Decl(awaitBinaryExpression3_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression3_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.types b/tests/baselines/reference/awaitBinaryExpression3_es6.types new file mode 100644 index 00000000000..786eabadae4 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts === +declare var a: number; +>a : number + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = await p + a; +>b : number +>await p + a : number +>p : any +>a : number + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.js b/tests/baselines/reference/awaitBinaryExpression4_es6.js new file mode 100644 index 00000000000..4d313588984 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression4_es6.ts] +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p, a; + "after"; +} + +//// [awaitBinaryExpression4_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = yield p, a; + "after"; + }); +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols new file mode 100644 index 00000000000..5d15c754793 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression4_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression4_es6.ts, 1, 32)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = await p, a; +>b : Symbol(b, Decl(awaitBinaryExpression4_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression4_es6.ts, 4, 20)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.types b/tests/baselines/reference/awaitBinaryExpression4_es6.types new file mode 100644 index 00000000000..73126b7797d --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = await p, a; +>b : boolean +>p : any +>a : any + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.js b/tests/baselines/reference/awaitBinaryExpression5_es6.js new file mode 100644 index 00000000000..01d6c50f6f0 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.js @@ -0,0 +1,19 @@ +//// [awaitBinaryExpression5_es6.ts] +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var o: { a: boolean; }; + o.a = await p; + "after"; +} + +//// [awaitBinaryExpression5_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var o; + o.a = yield p; + "after"; + }); +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols new file mode 100644 index 00000000000..bc1e2f19310 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression5_es6.ts, 1, 32)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var o: { a: boolean; }; +>o : Symbol(o, Decl(awaitBinaryExpression5_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 4, 12)) + + o.a = await p; +>o.a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 4, 12)) +>o : Symbol(o, Decl(awaitBinaryExpression5_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 4, 12)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.types b/tests/baselines/reference/awaitBinaryExpression5_es6.types new file mode 100644 index 00000000000..922e5887a77 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var o: { a: boolean; }; +>o : { a: boolean; } +>a : boolean + + o.a = await p; +>o.a = await p : boolean +>o.a : boolean +>o : { a: boolean; } +>a : boolean +>p : any + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression1_es6.js b/tests/baselines/reference/awaitCallExpression1_es6.js new file mode 100644 index 00000000000..f9dad87a8b6 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression1_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(a, a, a); + "after"; +} + +//// [awaitCallExpression1_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = fn(a, a, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression1_es6.symbols b/tests/baselines/reference/awaitCallExpression1_es6.symbols new file mode 100644 index 00000000000..7e28d92cd9c --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es6.symbols @@ -0,0 +1,50 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression1_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression1_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression1_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression1_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression1_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression1_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression1_es6.ts, 8, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32)) +>a : Symbol(a, Decl(awaitCallExpression1_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression1_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression1_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression1_es6.types b/tests/baselines/reference/awaitCallExpression1_es6.types new file mode 100644 index 00000000000..334175b7edb --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es6.types @@ -0,0 +1,54 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = fn(a, a, a); +>b : void +>fn(a, a, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression2_es6.js b/tests/baselines/reference/awaitCallExpression2_es6.js new file mode 100644 index 00000000000..87d99cd0793 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression2_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(await p, a, a); + "after"; +} + +//// [awaitCallExpression2_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = fn(yield p, a, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression2_es6.symbols b/tests/baselines/reference/awaitCallExpression2_es6.symbols new file mode 100644 index 00000000000..305a4c77aa3 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es6.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression2_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression2_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression2_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression2_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression2_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = fn(await p, a, a); +>b : Symbol(b, Decl(awaitCallExpression2_es6.ts, 8, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) +>a : Symbol(a, Decl(awaitCallExpression2_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression2_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression2_es6.types b/tests/baselines/reference/awaitCallExpression2_es6.types new file mode 100644 index 00000000000..6c7f02a578a --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es6.types @@ -0,0 +1,54 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = fn(await p, a, a); +>b : void +>fn(await p, a, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>p : any +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression3_es6.js b/tests/baselines/reference/awaitCallExpression3_es6.js new file mode 100644 index 00000000000..f397d83c3a1 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression3_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(a, await p, a); + "after"; +} + +//// [awaitCallExpression3_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = fn(a, yield p, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression3_es6.symbols b/tests/baselines/reference/awaitCallExpression3_es6.symbols new file mode 100644 index 00000000000..715c125bcf0 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es6.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression3_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression3_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression3_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression3_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression3_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = fn(a, await p, a); +>b : Symbol(b, Decl(awaitCallExpression3_es6.ts, 8, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) +>a : Symbol(a, Decl(awaitCallExpression3_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression3_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression3_es6.types b/tests/baselines/reference/awaitCallExpression3_es6.types new file mode 100644 index 00000000000..24d22db3c8c --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es6.types @@ -0,0 +1,54 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = fn(a, await p, a); +>b : void +>fn(a, await p, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>p : any +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression4_es6.js b/tests/baselines/reference/awaitCallExpression4_es6.js new file mode 100644 index 00000000000..d8824d7e7a0 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression4_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = (await pfn)(a, a, a); + "after"; +} + +//// [awaitCallExpression4_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = (yield pfn)(a, a, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression4_es6.symbols b/tests/baselines/reference/awaitCallExpression4_es6.symbols new file mode 100644 index 00000000000..98a995d8117 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es6.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression4_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression4_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression4_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression4_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = (await pfn)(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression4_es6.ts, 8, 7)) +>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression4_es6.types b/tests/baselines/reference/awaitCallExpression4_es6.types new file mode 100644 index 00000000000..04115466427 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es6.types @@ -0,0 +1,55 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = (await pfn)(a, a, a); +>b : void +>(await pfn)(a, a, a) : void +>(await pfn) : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>pfn : any +>a : boolean +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression5_es6.js b/tests/baselines/reference/awaitCallExpression5_es6.js new file mode 100644 index 00000000000..f39a633765d --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression5_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(a, a, a); + "after"; +} + +//// [awaitCallExpression5_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = o.fn(a, a, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression5_es6.symbols b/tests/baselines/reference/awaitCallExpression5_es6.symbols new file mode 100644 index 00000000000..30df9c8d022 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es6.symbols @@ -0,0 +1,52 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression5_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression5_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression5_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression5_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression5_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression5_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = o.fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression5_es6.ts, 8, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression5_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 3, 16)) +>a : Symbol(a, Decl(awaitCallExpression5_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression5_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression5_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression5_es6.types b/tests/baselines/reference/awaitCallExpression5_es6.types new file mode 100644 index 00000000000..5074c007743 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es6.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = o.fn(a, a, a); +>b : void +>o.fn(a, a, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression6_es6.js b/tests/baselines/reference/awaitCallExpression6_es6.js new file mode 100644 index 00000000000..de8477fa938 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression6_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(await p, a, a); + "after"; +} + +//// [awaitCallExpression6_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = o.fn(yield p, a, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression6_es6.symbols b/tests/baselines/reference/awaitCallExpression6_es6.symbols new file mode 100644 index 00000000000..ac1cca1c16f --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es6.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression6_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression6_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression6_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression6_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression6_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = o.fn(await p, a, a); +>b : Symbol(b, Decl(awaitCallExpression6_es6.ts, 8, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression6_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 3, 16)) +>a : Symbol(a, Decl(awaitCallExpression6_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression6_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression6_es6.types b/tests/baselines/reference/awaitCallExpression6_es6.types new file mode 100644 index 00000000000..d18377cebbb --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es6.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = o.fn(await p, a, a); +>b : void +>o.fn(await p, a, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>p : any +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression7_es6.js b/tests/baselines/reference/awaitCallExpression7_es6.js new file mode 100644 index 00000000000..24edc3b9393 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression7_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(a, await p, a); + "after"; +} + +//// [awaitCallExpression7_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = o.fn(a, yield p, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression7_es6.symbols b/tests/baselines/reference/awaitCallExpression7_es6.symbols new file mode 100644 index 00000000000..b48e99ddec1 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es6.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression7_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression7_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression7_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression7_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression7_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = o.fn(a, await p, a); +>b : Symbol(b, Decl(awaitCallExpression7_es6.ts, 8, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression7_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 3, 16)) +>a : Symbol(a, Decl(awaitCallExpression7_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression7_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression7_es6.types b/tests/baselines/reference/awaitCallExpression7_es6.types new file mode 100644 index 00000000000..b213a75dcd6 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es6.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = o.fn(a, await p, a); +>b : void +>o.fn(a, await p, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>p : any +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression8_es6.js b/tests/baselines/reference/awaitCallExpression8_es6.js new file mode 100644 index 00000000000..8bee6112a7a --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression8_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = (await po).fn(a, a, a); + "after"; +} + +//// [awaitCallExpression8_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = (yield po).fn(a, a, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression8_es6.symbols b/tests/baselines/reference/awaitCallExpression8_es6.symbols new file mode 100644 index 00000000000..4dd9d500347 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es6.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression8_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression8_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression8_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression8_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = (await po).fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression8_es6.ts, 8, 7)) +>(await po).fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) +>a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression8_es6.types b/tests/baselines/reference/awaitCallExpression8_es6.types new file mode 100644 index 00000000000..37511a7e3d7 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es6.types @@ -0,0 +1,57 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = (await po).fn(a, a, a); +>b : void +>(await po).fn(a, a, a) : void +>(await po).fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>(await po) : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>po : any +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitUnion_es6.js b/tests/baselines/reference/awaitUnion_es6.js new file mode 100644 index 00000000000..80c68f811ef --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es6.js @@ -0,0 +1,24 @@ +//// [awaitUnion_es6.ts] +declare let a: number | string; +declare let b: PromiseLike | PromiseLike; +declare let c: PromiseLike; +declare let d: number | PromiseLike; +declare let e: number | PromiseLike; +async function f() { + let await_a = await a; + let await_b = await b; + let await_c = await c; + let await_d = await d; + let await_e = await e; +} + +//// [awaitUnion_es6.js] +function f() { + return __awaiter(this, void 0, Promise, function* () { + let await_a = yield a; + let await_b = yield b; + let await_c = yield c; + let await_d = yield d; + let await_e = yield e; + }); +} diff --git a/tests/baselines/reference/awaitUnion_es6.symbols b/tests/baselines/reference/awaitUnion_es6.symbols new file mode 100644 index 00000000000..ca0b9afaf92 --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es6.symbols @@ -0,0 +1,39 @@ +=== tests/cases/conformance/async/es6/awaitUnion_es6.ts === +declare let a: number | string; +>a : Symbol(a, Decl(awaitUnion_es6.ts, 0, 11)) + +declare let b: PromiseLike | PromiseLike; +>b : Symbol(b, Decl(awaitUnion_es6.ts, 1, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) + +declare let c: PromiseLike; +>c : Symbol(c, Decl(awaitUnion_es6.ts, 2, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) + +declare let d: number | PromiseLike; +>d : Symbol(d, Decl(awaitUnion_es6.ts, 3, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) + +declare let e: number | PromiseLike; +>e : Symbol(e, Decl(awaitUnion_es6.ts, 4, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) + +async function f() { +>f : Symbol(f, Decl(awaitUnion_es6.ts, 4, 53)) + + let await_a = await a; +>await_a : Symbol(await_a, Decl(awaitUnion_es6.ts, 6, 4)) + + let await_b = await b; +>await_b : Symbol(await_b, Decl(awaitUnion_es6.ts, 7, 4)) + + let await_c = await c; +>await_c : Symbol(await_c, Decl(awaitUnion_es6.ts, 8, 4)) + + let await_d = await d; +>await_d : Symbol(await_d, Decl(awaitUnion_es6.ts, 9, 4)) + + let await_e = await e; +>await_e : Symbol(await_e, Decl(awaitUnion_es6.ts, 10, 4)) +} diff --git a/tests/baselines/reference/awaitUnion_es6.types b/tests/baselines/reference/awaitUnion_es6.types new file mode 100644 index 00000000000..fc7bef8a28c --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es6.types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/async/es6/awaitUnion_es6.ts === +declare let a: number | string; +>a : string | number + +declare let b: PromiseLike | PromiseLike; +>b : PromiseLike | PromiseLike +>PromiseLike : PromiseLike +>PromiseLike : PromiseLike + +declare let c: PromiseLike; +>c : PromiseLike +>PromiseLike : PromiseLike + +declare let d: number | PromiseLike; +>d : number | PromiseLike +>PromiseLike : PromiseLike + +declare let e: number | PromiseLike; +>e : number | PromiseLike +>PromiseLike : PromiseLike + +async function f() { +>f : () => Promise + + let await_a = await a; +>await_a : string | number +>a : any + + let await_b = await b; +>await_b : string | number +>b : any + + let await_c = await c; +>await_c : string | number +>c : any + + let await_d = await d; +>await_d : string | number +>d : any + + let await_e = await e; +>await_e : string | number +>e : any +} diff --git a/tests/baselines/reference/callWithSpreadES6.symbols b/tests/baselines/reference/callWithSpreadES6.symbols index 008488d0ce9..0e236821020 100644 --- a/tests/baselines/reference/callWithSpreadES6.symbols +++ b/tests/baselines/reference/callWithSpreadES6.symbols @@ -94,7 +94,7 @@ xa[1].foo(1, 2, ...a, "abc"); >a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3)) (xa[1].foo)(...[1, 2, "abc"]); ->Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1355, 1)) +>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1368, 1)) >xa[1].foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) >xa : Symbol(xa, Decl(callWithSpreadES6.ts, 11, 3)) >foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) diff --git a/tests/baselines/reference/class1.errors.txt b/tests/baselines/reference/class1.errors.txt deleted file mode 100644 index b90fae9cb40..00000000000 --- a/tests/baselines/reference/class1.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/class1.ts(1,11): error TS2300: Duplicate identifier 'foo'. -tests/cases/compiler/class1.ts(2,7): error TS2300: Duplicate identifier 'foo'. - - -==== tests/cases/compiler/class1.ts (2 errors) ==== - interface foo{ } // error - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. - class foo{ } // error - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/class1.js b/tests/baselines/reference/class1.js deleted file mode 100644 index 7a104e237b6..00000000000 --- a/tests/baselines/reference/class1.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [class1.ts] -interface foo{ } // error -class foo{ } // error - -//// [class1.js] -var foo = (function () { - function foo() { - } - return foo; -})(); // error diff --git a/tests/baselines/reference/classAbstractAsIdentifier.js b/tests/baselines/reference/classAbstractAsIdentifier.js new file mode 100644 index 00000000000..6adadd346b5 --- /dev/null +++ b/tests/baselines/reference/classAbstractAsIdentifier.js @@ -0,0 +1,15 @@ +//// [classAbstractAsIdentifier.ts] +class abstract { + foo() { return 1; } +} + +new abstract; + +//// [classAbstractAsIdentifier.js] +var abstract = (function () { + function abstract() { + } + abstract.prototype.foo = function () { return 1; }; + return abstract; +})(); +new abstract; diff --git a/tests/baselines/reference/classAbstractAsIdentifier.symbols b/tests/baselines/reference/classAbstractAsIdentifier.symbols new file mode 100644 index 00000000000..f2ce2ebcab5 --- /dev/null +++ b/tests/baselines/reference/classAbstractAsIdentifier.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts === +class abstract { +>abstract : Symbol(abstract, Decl(classAbstractAsIdentifier.ts, 0, 0)) + + foo() { return 1; } +>foo : Symbol(foo, Decl(classAbstractAsIdentifier.ts, 0, 16)) +} + +new abstract; +>abstract : Symbol(abstract, Decl(classAbstractAsIdentifier.ts, 0, 0)) + diff --git a/tests/baselines/reference/classAbstractAsIdentifier.types b/tests/baselines/reference/classAbstractAsIdentifier.types new file mode 100644 index 00000000000..e2894af804d --- /dev/null +++ b/tests/baselines/reference/classAbstractAsIdentifier.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts === +class abstract { +>abstract : abstract + + foo() { return 1; } +>foo : () => number +>1 : number +} + +new abstract; +>new abstract : abstract +>abstract : typeof abstract + diff --git a/tests/baselines/reference/classAbstractConstructor.errors.txt b/tests/baselines/reference/classAbstractConstructor.errors.txt new file mode 100644 index 00000000000..fee9f4cefee --- /dev/null +++ b/tests/baselines/reference/classAbstractConstructor.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts (1 errors) ==== + abstract class A { + abstract constructor() {} + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractConstructor.js b/tests/baselines/reference/classAbstractConstructor.js new file mode 100644 index 00000000000..fa88b0c7d37 --- /dev/null +++ b/tests/baselines/reference/classAbstractConstructor.js @@ -0,0 +1,11 @@ +//// [classAbstractConstructor.ts] +abstract class A { + abstract constructor() {} +} + +//// [classAbstractConstructor.js] +var A = (function () { + function A() { + } + return A; +})(); diff --git a/tests/baselines/reference/classAbstractCrashedOnce.errors.txt b/tests/baselines/reference/classAbstractCrashedOnce.errors.txt new file mode 100644 index 00000000000..c2e38a6cf44 --- /dev/null +++ b/tests/baselines/reference/classAbstractCrashedOnce.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts(8,5): error TS1003: Identifier expected. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts (1 errors) ==== + abstract class foo { + protected abstract test(); + } + + class bar extends foo { + test() { + this. + } + ~ +!!! error TS1003: Identifier expected. + } + var x = new bar(); \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractCrashedOnce.js b/tests/baselines/reference/classAbstractCrashedOnce.js new file mode 100644 index 00000000000..f4268a4a13c --- /dev/null +++ b/tests/baselines/reference/classAbstractCrashedOnce.js @@ -0,0 +1,35 @@ +//// [classAbstractCrashedOnce.ts] +abstract class foo { + protected abstract test(); +} + +class bar extends foo { + test() { + this. + } +} +var x = new bar(); + +//// [classAbstractCrashedOnce.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var foo = (function () { + function foo() { + } + return foo; +})(); +var bar = (function (_super) { + __extends(bar, _super); + function bar() { + _super.apply(this, arguments); + } + bar.prototype.test = function () { + this. + ; + }; + return bar; +})(foo); +var x = new bar(); diff --git a/tests/baselines/reference/classAbstractDeclarations.d.errors.txt b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt new file mode 100644 index 00000000000..20d5ca46933 --- /dev/null +++ b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,28): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(11,15): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(13,15): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(17,15): error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts (5 errors) ==== + declare abstract class A { + abstract constructor() {} + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + ~ +!!! error TS1184: An implementation cannot be declared in ambient contexts. + } + + declare abstract class AA { + abstract foo(); + } + + declare abstract class BB extends AA {} + + declare class CC extends AA {} + ~~ +!!! error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. + + declare class DD extends BB {} + ~~ +!!! error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. + + declare abstract class EE extends BB {} + + declare class FF extends CC {} + ~~ +!!! error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. + + declare abstract class GG extends CC {} + + declare abstract class AAA {} + + declare abstract class BBB extends AAA {} + + declare class CCC extends AAA {} \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractGeneric.errors.txt b/tests/baselines/reference/classAbstractGeneric.errors.txt new file mode 100644 index 00000000000..fb5a4c32a39 --- /dev/null +++ b/tests/baselines/reference/classAbstractGeneric.errors.txt @@ -0,0 +1,46 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(10,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(10,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'foo' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(12,7): error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'bar' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(12,7): error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'foo' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(14,7): error TS2515: Non-abstract class 'E' does not implement inherited abstract member 'bar' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(18,7): error TS2515: Non-abstract class 'F' does not implement inherited abstract member 'foo' from class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts (6 errors) ==== + abstract class A { + t: T; + + abstract foo(): T; + abstract bar(t: T); + } + + abstract class B extends A {} + + class C extends A {} // error -- inherits abstract methods + ~ +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'A'. + ~ +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'foo' from class 'A'. + + class D extends A {} // error -- inherits abstract methods + ~ +!!! error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'bar' from class 'A'. + ~ +!!! error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'foo' from class 'A'. + + class E extends A { // error -- doesn't implement bar + ~ +!!! error TS2515: Non-abstract class 'E' does not implement inherited abstract member 'bar' from class 'A'. + foo() { return this.t; } + } + + class F extends A { // error -- doesn't implement foo + ~ +!!! error TS2515: Non-abstract class 'F' does not implement inherited abstract member 'foo' from class 'A'. + bar(t : T) {} + } + + class G extends A { + foo() { return this.t; } + bar(t: T) { } + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractGeneric.js b/tests/baselines/reference/classAbstractGeneric.js new file mode 100644 index 00000000000..5af7da1601a --- /dev/null +++ b/tests/baselines/reference/classAbstractGeneric.js @@ -0,0 +1,84 @@ +//// [classAbstractGeneric.ts] +abstract class A { + t: T; + + abstract foo(): T; + abstract bar(t: T); +} + +abstract class B extends A {} + +class C extends A {} // error -- inherits abstract methods + +class D extends A {} // error -- inherits abstract methods + +class E extends A { // error -- doesn't implement bar + foo() { return this.t; } +} + +class F extends A { // error -- doesn't implement foo + bar(t : T) {} +} + +class G extends A { + foo() { return this.t; } + bar(t: T) { } +} + +//// [classAbstractGeneric.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); // error -- inherits abstract methods +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(A); // error -- inherits abstract methods +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + E.prototype.foo = function () { return this.t; }; + return E; +})(A); +var F = (function (_super) { + __extends(F, _super); + function F() { + _super.apply(this, arguments); + } + F.prototype.bar = function (t) { }; + return F; +})(A); +var G = (function (_super) { + __extends(G, _super); + function G() { + _super.apply(this, arguments); + } + G.prototype.foo = function () { return this.t; }; + G.prototype.bar = function (t) { }; + return G; +})(A); diff --git a/tests/baselines/reference/classAbstractImportInstantiation.errors.txt b/tests/baselines/reference/classAbstractImportInstantiation.errors.txt new file mode 100644 index 00000000000..76110afa4ff --- /dev/null +++ b/tests/baselines/reference/classAbstractImportInstantiation.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts(4,5): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts(9,1): error TS2511: Cannot create an instance of the abstract class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts (2 errors) ==== + module M { + export abstract class A {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + } + + import myA = M.A; + + new myA; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractImportInstantiation.js b/tests/baselines/reference/classAbstractImportInstantiation.js new file mode 100644 index 00000000000..bb25181f20d --- /dev/null +++ b/tests/baselines/reference/classAbstractImportInstantiation.js @@ -0,0 +1,25 @@ +//// [classAbstractImportInstantiation.ts] +module M { + export abstract class A {} + + new A; +} + +import myA = M.A; + +new myA; + + +//// [classAbstractImportInstantiation.js] +var M; +(function (M) { + var A = (function () { + function A() { + } + return A; + })(); + M.A = A; + new A; +})(M || (M = {})); +var myA = M.A; +new myA; diff --git a/tests/baselines/reference/classAbstractInAModule.errors.txt b/tests/baselines/reference/classAbstractInAModule.errors.txt new file mode 100644 index 00000000000..426da866087 --- /dev/null +++ b/tests/baselines/reference/classAbstractInAModule.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts(6,1): error TS2511: Cannot create an instance of the abstract class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts (1 errors) ==== + module M { + export abstract class A {} + export class B extends A {} + } + + new M.A; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new M.B; \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInAModule.js b/tests/baselines/reference/classAbstractInAModule.js new file mode 100644 index 00000000000..e7ecd66b5bd --- /dev/null +++ b/tests/baselines/reference/classAbstractInAModule.js @@ -0,0 +1,34 @@ +//// [classAbstractInAModule.ts] +module M { + export abstract class A {} + export class B extends A {} +} + +new M.A; +new M.B; + +//// [classAbstractInAModule.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var M; +(function (M) { + var A = (function () { + function A() { + } + return A; + })(); + M.A = A; + var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + })(A); + M.B = B; +})(M || (M = {})); +new M.A; +new M.B; diff --git a/tests/baselines/reference/classAbstractInheritance.errors.txt b/tests/baselines/reference/classAbstractInheritance.errors.txt new file mode 100644 index 00000000000..3e106204415 --- /dev/null +++ b/tests/baselines/reference/classAbstractInheritance.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(13,7): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(15,7): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(19,7): error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts (3 errors) ==== + abstract class A {} + + abstract class B extends A {} + + class C extends A {} + + abstract class AA { + abstract foo(); + } + + abstract class BB extends AA {} + + class CC extends AA {} + ~~ +!!! error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. + + class DD extends BB {} + ~~ +!!! error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. + + abstract class EE extends BB {} + + class FF extends CC {} + ~~ +!!! error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. + + abstract class GG extends CC {} \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInheritance.js b/tests/baselines/reference/classAbstractInheritance.js new file mode 100644 index 00000000000..6656e4687d2 --- /dev/null +++ b/tests/baselines/reference/classAbstractInheritance.js @@ -0,0 +1,95 @@ +//// [classAbstractInheritance.ts] +abstract class A {} + +abstract class B extends A {} + +class C extends A {} + +abstract class AA { + abstract foo(); +} + +abstract class BB extends AA {} + +class CC extends AA {} + +class DD extends BB {} + +abstract class EE extends BB {} + +class FF extends CC {} + +abstract class GG extends CC {} + +//// [classAbstractInheritance.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); +var AA = (function () { + function AA() { + } + return AA; +})(); +var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; +})(AA); +var CC = (function (_super) { + __extends(CC, _super); + function CC() { + _super.apply(this, arguments); + } + return CC; +})(AA); +var DD = (function (_super) { + __extends(DD, _super); + function DD() { + _super.apply(this, arguments); + } + return DD; +})(BB); +var EE = (function (_super) { + __extends(EE, _super); + function EE() { + _super.apply(this, arguments); + } + return EE; +})(BB); +var FF = (function (_super) { + __extends(FF, _super); + function FF() { + _super.apply(this, arguments); + } + return FF; +})(CC); +var GG = (function (_super) { + __extends(GG, _super); + function GG() { + _super.apply(this, arguments); + } + return GG; +})(CC); diff --git a/tests/baselines/reference/classAbstractInstantiations1.errors.txt b/tests/baselines/reference/classAbstractInstantiations1.errors.txt new file mode 100644 index 00000000000..6171ef2efab --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations1.errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(8,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(9,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(11,1): error TS2511: Cannot create an instance of the abstract class 'C'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts (3 errors) ==== + + abstract class A {} + + class B extends A {} + + abstract class C extends B {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new A(1); // should report 1 error + ~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new B; + new C; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. + + var a : A; + var b : B; + var c : C; + + a = new B; + b = new B; + c = new B; + \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInstantiations1.js b/tests/baselines/reference/classAbstractInstantiations1.js new file mode 100644 index 00000000000..f3a0eecada9 --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations1.js @@ -0,0 +1,57 @@ +//// [classAbstractInstantiations1.ts] + +abstract class A {} + +class B extends A {} + +abstract class C extends B {} + +new A; +new A(1); // should report 1 error +new B; +new C; + +var a : A; +var b : B; +var c : C; + +a = new B; +b = new B; +c = new B; + + +//// [classAbstractInstantiations1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(B); +new A; +new A(1); // should report 1 error +new B; +new C; +var a; +var b; +var c; +a = new B; +b = new B; +c = new B; diff --git a/tests/baselines/reference/classAbstractInstantiations2.errors.txt b/tests/baselines/reference/classAbstractInstantiations2.errors.txt new file mode 100644 index 00000000000..b3b01fd656d --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations2.errors.txt @@ -0,0 +1,75 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(17,5): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(26,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2391: Function implementation is missing or not immediately following the declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(50,5): error TS1244: Abstract methods can only appear within an abstract class. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (7 errors) ==== + class A { + // ... + } + + abstract class B { + foo(): number { return this.bar(); } + abstract bar() : number; + } + + new B; // error + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + + var BB: typeof B = B; + var AA: typeof A = BB; // error, AA is not of abstract type. + new AA; + + function constructB(Factory : typeof B) { + new Factory; // error -- Factory is of type typeof B. + ~~~~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + } + + var BB = B; + new BB; // error -- BB is of type typeof B. + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + + var x : any = C; + new x; // okay -- undefined behavior at runtime + + class C extends B { } // error -- not declared abstract + ~ +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'. + + abstract class D extends B { } // okay + + class E extends B { // okay -- implements abstract method + bar() { return 1; } + } + + abstract class F extends B { + abstract foo() : number; + bar() { return 2; } + } + + abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent + + abstract nom(): boolean; + nom(x : number): boolean; // error -- use of modifier abstract must match on all overloads. + ~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + ~~~ +!!! error TS2512: Overload signatures must all be abstract or not abstract. + } + + class H { // error -- not declared abstract + abstract baz() : number; + ~~~~~~~~ +!!! error TS1244: Abstract methods can only appear within an abstract class. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInstantiations2.js b/tests/baselines/reference/classAbstractInstantiations2.js new file mode 100644 index 00000000000..1f45f02da0b --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations2.js @@ -0,0 +1,121 @@ +//// [classAbstractInstantiations2.ts] +class A { + // ... +} + +abstract class B { + foo(): number { return this.bar(); } + abstract bar() : number; +} + +new B; // error + +var BB: typeof B = B; +var AA: typeof A = BB; // error, AA is not of abstract type. +new AA; + +function constructB(Factory : typeof B) { + new Factory; // error -- Factory is of type typeof B. +} + +var BB = B; +new BB; // error -- BB is of type typeof B. + +var x : any = C; +new x; // okay -- undefined behavior at runtime + +class C extends B { } // error -- not declared abstract + +abstract class D extends B { } // okay + +class E extends B { // okay -- implements abstract method + bar() { return 1; } +} + +abstract class F extends B { + abstract foo() : number; + bar() { return 2; } +} + +abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent + + abstract nom(): boolean; + nom(x : number): boolean; // error -- use of modifier abstract must match on all overloads. +} + +class H { // error -- not declared abstract + abstract baz() : number; +} + +//// [classAbstractInstantiations2.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + B.prototype.foo = function () { return this.bar(); }; + return B; +})(); +new B; // error +var BB = B; +var AA = BB; // error, AA is not of abstract type. +new AA; +function constructB(Factory) { + new Factory; // error -- Factory is of type typeof B. +} +var BB = B; +new BB; // error -- BB is of type typeof B. +var x = C; +new x; // okay -- undefined behavior at runtime +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(B); // error -- not declared abstract +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(B); // okay +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + E.prototype.bar = function () { return 1; }; + return E; +})(B); +var F = (function (_super) { + __extends(F, _super); + function F() { + _super.apply(this, arguments); + } + F.prototype.bar = function () { return 2; }; + return F; +})(B); +var G = (function () { + function G() { + } + return G; +})(); +var H = (function () { + function H() { + } + return H; +})(); diff --git a/tests/baselines/reference/classAbstractManyKeywords.errors.txt b/tests/baselines/reference/classAbstractManyKeywords.errors.txt new file mode 100644 index 00000000000..b200404eaf0 --- /dev/null +++ b/tests/baselines/reference/classAbstractManyKeywords.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,25): error TS1005: ';' expected. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(3,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(4,17): error TS1005: '=' expected. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts (4 errors) ==== + export default abstract class A {} + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. + ~~~~~ +!!! error TS1005: ';' expected. + export abstract class B {} + default abstract class C {} + ~~~~~~~ +!!! error TS1128: Declaration or statement expected. + import abstract class D {} + ~~~~~ +!!! error TS1005: '=' expected. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractManyKeywords.js b/tests/baselines/reference/classAbstractManyKeywords.js new file mode 100644 index 00000000000..79191c029e1 --- /dev/null +++ b/tests/baselines/reference/classAbstractManyKeywords.js @@ -0,0 +1,28 @@ +//// [classAbstractManyKeywords.ts] +export default abstract class A {} +export abstract class B {} +default abstract class C {} +import abstract class D {} + +//// [classAbstractManyKeywords.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +exports.B = B; +var C = (function () { + function C() { + } + return C; +})(); +var D = (function () { + function D() { + } + return D; +})(); diff --git a/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt b/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt new file mode 100644 index 00000000000..b3a2dec5e9c --- /dev/null +++ b/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt @@ -0,0 +1,103 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(7,16): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(8,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(10,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(11,16): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(13,16): error TS2300: Duplicate identifier 'CC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(14,7): error TS2300: Duplicate identifier 'CC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(16,7): error TS2300: Duplicate identifier 'CC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(17,16): error TS2300: Duplicate identifier 'CC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(25,24): error TS2300: Duplicate identifier 'DCC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(26,15): error TS2300: Duplicate identifier 'DCC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(28,15): error TS2300: Duplicate identifier 'DCC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(29,24): error TS2300: Duplicate identifier 'DCC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(31,1): error TS2511: Cannot create an instance of the abstract class 'CM'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(32,1): error TS2511: Cannot create an instance of the abstract class 'MC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(33,1): error TS2511: Cannot create an instance of the abstract class 'CI'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(34,1): error TS2511: Cannot create an instance of the abstract class 'IC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(35,1): error TS2511: Cannot create an instance of the abstract class 'CC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(37,1): error TS2511: Cannot create an instance of the abstract class 'DCI'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(38,1): error TS2511: Cannot create an instance of the abstract class 'DIC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(39,1): error TS2511: Cannot create an instance of the abstract class 'DCC1'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts (20 errors) ==== + abstract class CM {} + module CM {} + + module MC {} + abstract class MC {} + + abstract class CI {} + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + interface CI {} + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + + interface IC {} + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + abstract class IC {} + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + + abstract class CC1 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC1'. + class CC1 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC1'. + + class CC2 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC2'. + abstract class CC2 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC2'. + + declare abstract class DCI {} + interface DCI {} + + interface DIC {} + declare abstract class DIC {} + + declare abstract class DCC1 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC1'. + declare class DCC1 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC1'. + + declare class DCC2 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC2'. + declare abstract class DCC2 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC2'. + + new CM; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'CM'. + new MC; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'MC'. + new CI; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'CI'. + new IC; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'IC'. + new CC1; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'CC1'. + new CC2; + new DCI; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'DCI'. + new DIC; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'DIC'. + new DCC1; + ~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'DCC1'. + new DCC2; \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMergedDeclaration.js b/tests/baselines/reference/classAbstractMergedDeclaration.js new file mode 100644 index 00000000000..f6a91f870d2 --- /dev/null +++ b/tests/baselines/reference/classAbstractMergedDeclaration.js @@ -0,0 +1,93 @@ +//// [classAbstractMergedDeclaration.ts] +abstract class CM {} +module CM {} + +module MC {} +abstract class MC {} + +abstract class CI {} +interface CI {} + +interface IC {} +abstract class IC {} + +abstract class CC1 {} +class CC1 {} + +class CC2 {} +abstract class CC2 {} + +declare abstract class DCI {} +interface DCI {} + +interface DIC {} +declare abstract class DIC {} + +declare abstract class DCC1 {} +declare class DCC1 {} + +declare class DCC2 {} +declare abstract class DCC2 {} + +new CM; +new MC; +new CI; +new IC; +new CC1; +new CC2; +new DCI; +new DIC; +new DCC1; +new DCC2; + +//// [classAbstractMergedDeclaration.js] +var CM = (function () { + function CM() { + } + return CM; +})(); +var MC = (function () { + function MC() { + } + return MC; +})(); +var CI = (function () { + function CI() { + } + return CI; +})(); +var IC = (function () { + function IC() { + } + return IC; +})(); +var CC1 = (function () { + function CC1() { + } + return CC1; +})(); +var CC1 = (function () { + function CC1() { + } + return CC1; +})(); +var CC2 = (function () { + function CC2() { + } + return CC2; +})(); +var CC2 = (function () { + function CC2() { + } + return CC2; +})(); +new CM; +new MC; +new CI; +new IC; +new CC1; +new CC2; +new DCI; +new DIC; +new DCC1; +new DCC2; diff --git a/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt new file mode 100644 index 00000000000..412378e267d --- /dev/null +++ b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,5): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts (1 errors) ==== + abstract class A { + abstract foo() {} + ~~~~~~~~~~~~~~~~~ +!!! error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMethodWithImplementation.js b/tests/baselines/reference/classAbstractMethodWithImplementation.js new file mode 100644 index 00000000000..d9319012712 --- /dev/null +++ b/tests/baselines/reference/classAbstractMethodWithImplementation.js @@ -0,0 +1,12 @@ +//// [classAbstractMethodWithImplementation.ts] +abstract class A { + abstract foo() {} +} + +//// [classAbstractMethodWithImplementation.js] +var A = (function () { + function A() { + } + A.prototype.foo = function () { }; + return A; +})(); diff --git a/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt b/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt new file mode 100644 index 00000000000..121c1739632 --- /dev/null +++ b/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(6,13): error TS1243: 'private' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(8,14): error TS1029: 'public' modifier must precede 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(9,14): error TS1029: 'protected' modifier must precede 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(10,14): error TS1243: 'private' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(12,14): error TS1243: 'static' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(14,12): error TS1243: 'static' modifier cannot be used with 'abstract' modifier. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts (6 errors) ==== + abstract class A { + abstract foo_a(); + + public abstract foo_b(); + protected abstract foo_c(); + private abstract foo_d(); + ~~~~~~~~ +!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier. + + abstract public foo_bb(); + ~~~~~~ +!!! error TS1029: 'public' modifier must precede 'abstract' modifier. + abstract protected foo_cc(); + ~~~~~~~~~ +!!! error TS1029: 'protected' modifier must precede 'abstract' modifier. + abstract private foo_dd(); + ~~~~~~~ +!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier. + + abstract static foo_d(); + ~~~~~~ +!!! error TS1243: 'static' modifier cannot be used with 'abstract' modifier. + + static abstract foo_e(); + ~~~~~~~~ +!!! error TS1243: 'static' modifier cannot be used with 'abstract' modifier. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMixedWithModifiers.js b/tests/baselines/reference/classAbstractMixedWithModifiers.js new file mode 100644 index 00000000000..71eb4c61c04 --- /dev/null +++ b/tests/baselines/reference/classAbstractMixedWithModifiers.js @@ -0,0 +1,23 @@ +//// [classAbstractMixedWithModifiers.ts] +abstract class A { + abstract foo_a(); + + public abstract foo_b(); + protected abstract foo_c(); + private abstract foo_d(); + + abstract public foo_bb(); + abstract protected foo_cc(); + abstract private foo_dd(); + + abstract static foo_d(); + + static abstract foo_e(); +} + +//// [classAbstractMixedWithModifiers.js] +var A = (function () { + function A() { + } + return A; +})(); diff --git a/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt b/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt new file mode 100644 index 00000000000..5af440ed4df --- /dev/null +++ b/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(11,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(12,1): error TS2511: Cannot create an instance of the abstract class 'C'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts (3 errors) ==== + abstract class A {} + + abstract + class B {} + + abstract + + class C {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new B; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + new C; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMultiLineDecl.js b/tests/baselines/reference/classAbstractMultiLineDecl.js new file mode 100644 index 00000000000..3a92e2aa1e5 --- /dev/null +++ b/tests/baselines/reference/classAbstractMultiLineDecl.js @@ -0,0 +1,33 @@ +//// [classAbstractMultiLineDecl.ts] +abstract class A {} + +abstract +class B {} + +abstract + +class C {} + +new A; +new B; +new C; + +//// [classAbstractMultiLineDecl.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +var C = (function () { + function C() { + } + return C; +})(); +new A; +new B; +new C; diff --git a/tests/baselines/reference/classAbstractOverloads.errors.txt b/tests/baselines/reference/classAbstractOverloads.errors.txt new file mode 100644 index 00000000000..0a1c96bd30a --- /dev/null +++ b/tests/baselines/reference/classAbstractOverloads.errors.txt @@ -0,0 +1,42 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(7,5): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(10,14): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(12,14): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(15,5): error TS2391: Function implementation is missing or not immediately following the declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(20,14): error TS2516: All declarations of an abstract method must be consecutive. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts (5 errors) ==== + abstract class A { + abstract foo(); + abstract foo() : number; + abstract foo(); + + abstract bar(); + bar(); + ~~~ +!!! error TS2512: Overload signatures must all be abstract or not abstract. + abstract bar(); + + abstract baz(); + ~~~ +!!! error TS2512: Overload signatures must all be abstract or not abstract. + baz(); + abstract baz(); + ~~~ +!!! error TS2512: Overload signatures must all be abstract or not abstract. + baz() {} + + qux(); + ~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + } + + abstract class B { + abstract foo() : number; + abstract foo(); + ~~~ +!!! error TS2516: All declarations of an abstract method must be consecutive. + x : number; + abstract foo(); + abstract foo(); + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractOverloads.js b/tests/baselines/reference/classAbstractOverloads.js new file mode 100644 index 00000000000..1bdff73d5b7 --- /dev/null +++ b/tests/baselines/reference/classAbstractOverloads.js @@ -0,0 +1,38 @@ +//// [classAbstractOverloads.ts] +abstract class A { + abstract foo(); + abstract foo() : number; + abstract foo(); + + abstract bar(); + bar(); + abstract bar(); + + abstract baz(); + baz(); + abstract baz(); + baz() {} + + qux(); +} + +abstract class B { + abstract foo() : number; + abstract foo(); + x : number; + abstract foo(); + abstract foo(); +} + +//// [classAbstractOverloads.js] +var A = (function () { + function A() { + } + A.prototype.baz = function () { }; + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); diff --git a/tests/baselines/reference/classAbstractProperties.errors.txt b/tests/baselines/reference/classAbstractProperties.errors.txt new file mode 100644 index 00000000000..223a3049825 --- /dev/null +++ b/tests/baselines/reference/classAbstractProperties.errors.txt @@ -0,0 +1,34 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(3,12): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(4,15): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(5,13): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(7,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(12,13): error TS1243: 'private' modifier cannot be used with 'abstract' modifier. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts (6 errors) ==== + abstract class A { + abstract x : number; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + public abstract y : number; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + protected abstract z : number; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + private abstract w : number; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + + abstract m: () => void; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + + abstract foo_x() : number; + public abstract foo_y() : number; + protected abstract foo_z() : number; + private abstract foo_w() : number; + ~~~~~~~~ +!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractProperties.js b/tests/baselines/reference/classAbstractProperties.js new file mode 100644 index 00000000000..0cbebcf0de0 --- /dev/null +++ b/tests/baselines/reference/classAbstractProperties.js @@ -0,0 +1,21 @@ +//// [classAbstractProperties.ts] +abstract class A { + abstract x : number; + public abstract y : number; + protected abstract z : number; + private abstract w : number; + + abstract m: () => void; + + abstract foo_x() : number; + public abstract foo_y() : number; + protected abstract foo_z() : number; + private abstract foo_w() : number; +} + +//// [classAbstractProperties.js] +var A = (function () { + function A() { + } + return A; +})(); diff --git a/tests/baselines/reference/classAbstractSuperCalls.errors.txt b/tests/baselines/reference/classAbstractSuperCalls.errors.txt new file mode 100644 index 00000000000..a9dbf0f7ba8 --- /dev/null +++ b/tests/baselines/reference/classAbstractSuperCalls.errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts(14,26): error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts(14,41): error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts (2 errors) ==== + + class A { + foo() { return 1; } + } + + abstract class B extends A { + abstract foo(); + bar() { super.foo(); } + baz() { return this.foo; } + } + + class C extends B { + foo() { return 2; } + qux() { return super.foo() || super.foo; } // 2 errors, foo is abstract + ~~~ +!!! error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. + ~~~ +!!! error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. + norf() { return super.bar(); } + } + + class AA { + foo() { return 1; } + bar() { return this.foo(); } + } + + abstract class BB extends AA { + abstract foo(); + // inherits bar. But BB is abstract, so this is OK. + } + \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractSuperCalls.js b/tests/baselines/reference/classAbstractSuperCalls.js new file mode 100644 index 00000000000..deccaa50ccf --- /dev/null +++ b/tests/baselines/reference/classAbstractSuperCalls.js @@ -0,0 +1,74 @@ +//// [classAbstractSuperCalls.ts] + +class A { + foo() { return 1; } +} + +abstract class B extends A { + abstract foo(); + bar() { super.foo(); } + baz() { return this.foo; } +} + +class C extends B { + foo() { return 2; } + qux() { return super.foo() || super.foo; } // 2 errors, foo is abstract + norf() { return super.bar(); } +} + +class AA { + foo() { return 1; } + bar() { return this.foo(); } +} + +abstract class BB extends AA { + abstract foo(); + // inherits bar. But BB is abstract, so this is OK. +} + + +//// [classAbstractSuperCalls.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + A.prototype.foo = function () { return 1; }; + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + B.prototype.bar = function () { _super.prototype.foo.call(this); }; + B.prototype.baz = function () { return this.foo; }; + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + C.prototype.foo = function () { return 2; }; + C.prototype.qux = function () { return _super.prototype.foo.call(this) || _super.prototype.foo; }; // 2 errors, foo is abstract + C.prototype.norf = function () { return _super.prototype.bar.call(this); }; + return C; +})(B); +var AA = (function () { + function AA() { + } + AA.prototype.foo = function () { return 1; }; + AA.prototype.bar = function () { return this.foo(); }; + return AA; +})(); +var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; +})(AA); diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethod1.errors.txt b/tests/baselines/reference/classAbstractUsingAbstractMethod1.errors.txt new file mode 100644 index 00000000000..df3682a36af --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethod1.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts(16,5): error TS2511: Cannot create an instance of the abstract class 'C'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts (1 errors) ==== + abstract class A { + abstract foo() : number; + } + + class B extends A { + foo() { return 1; } + } + + abstract class C extends A { + abstract foo() : number; + } + + var a = new B; + a.foo(); + + a = new C; // error, cannot instantiate abstract class. + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. + a.foo(); \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethod1.js b/tests/baselines/reference/classAbstractUsingAbstractMethod1.js new file mode 100644 index 00000000000..18d22803a7d --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethod1.js @@ -0,0 +1,49 @@ +//// [classAbstractUsingAbstractMethod1.ts] +abstract class A { + abstract foo() : number; +} + +class B extends A { + foo() { return 1; } +} + +abstract class C extends A { + abstract foo() : number; +} + +var a = new B; +a.foo(); + +a = new C; // error, cannot instantiate abstract class. +a.foo(); + +//// [classAbstractUsingAbstractMethod1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + B.prototype.foo = function () { return 1; }; + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); +var a = new B; +a.foo(); +a = new C; // error, cannot instantiate abstract class. +a.foo(); diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt b/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt new file mode 100644 index 00000000000..e01b233a4c1 --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt @@ -0,0 +1,39 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(2,5): error TS1244: Abstract methods can only appear within an abstract class. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(5,7): error TS2515: Non-abstract class 'B' does not implement inherited abstract member 'foo' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(21,7): error TS2515: Non-abstract class 'BB' does not implement inherited abstract member 'foo' from class 'AA'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts (3 errors) ==== + class A { + abstract foo(); + ~~~~~~~~ +!!! error TS1244: Abstract methods can only appear within an abstract class. + } + + class B extends A {} + ~ +!!! error TS2515: Non-abstract class 'B' does not implement inherited abstract member 'foo' from class 'A'. + + abstract class C extends A {} + + class D extends A { + foo() {} + } + + abstract class E extends A { + foo() {} + } + + abstract class AA { + abstract foo(); + } + + class BB extends AA {} + ~~ +!!! error TS2515: Non-abstract class 'BB' does not implement inherited abstract member 'foo' from class 'AA'. + + abstract class CC extends AA {} + + class DD extends AA { + foo() {} + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethods2.js b/tests/baselines/reference/classAbstractUsingAbstractMethods2.js new file mode 100644 index 00000000000..d5797232929 --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethods2.js @@ -0,0 +1,97 @@ +//// [classAbstractUsingAbstractMethods2.ts] +class A { + abstract foo(); +} + +class B extends A {} + +abstract class C extends A {} + +class D extends A { + foo() {} +} + +abstract class E extends A { + foo() {} +} + +abstract class AA { + abstract foo(); +} + +class BB extends AA {} + +abstract class CC extends AA {} + +class DD extends AA { + foo() {} +} + +//// [classAbstractUsingAbstractMethods2.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + D.prototype.foo = function () { }; + return D; +})(A); +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + E.prototype.foo = function () { }; + return E; +})(A); +var AA = (function () { + function AA() { + } + return AA; +})(); +var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; +})(AA); +var CC = (function (_super) { + __extends(CC, _super); + function CC() { + _super.apply(this, arguments); + } + return CC; +})(AA); +var DD = (function (_super) { + __extends(DD, _super); + function DD() { + _super.apply(this, arguments); + } + DD.prototype.foo = function () { }; + return DD; +})(AA); diff --git a/tests/baselines/reference/classAbstractWithInterface.errors.txt b/tests/baselines/reference/classAbstractWithInterface.errors.txt new file mode 100644 index 00000000000..fa0a3d08957 --- /dev/null +++ b/tests/baselines/reference/classAbstractWithInterface.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts(1,1): error TS1242: 'abstract' modifier can only appear on a class or method declaration. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts (1 errors) ==== + abstract interface I {} + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractWithInterface.js b/tests/baselines/reference/classAbstractWithInterface.js new file mode 100644 index 00000000000..317e393a2f5 --- /dev/null +++ b/tests/baselines/reference/classAbstractWithInterface.js @@ -0,0 +1,4 @@ +//// [classAbstractWithInterface.ts] +abstract interface I {} + +//// [classAbstractWithInterface.js] diff --git a/tests/baselines/reference/classAndInterface1.errors.txt b/tests/baselines/reference/classAndInterface1.errors.txt deleted file mode 100644 index 8d31e847d71..00000000000 --- a/tests/baselines/reference/classAndInterface1.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/classAndInterface1.ts(1,8): error TS2300: Duplicate identifier 'cli'. -tests/cases/compiler/classAndInterface1.ts(2,11): error TS2300: Duplicate identifier 'cli'. - - -==== tests/cases/compiler/classAndInterface1.ts (2 errors) ==== - class cli { } // error - ~~~ -!!! error TS2300: Duplicate identifier 'cli'. - interface cli { } // error - ~~~ -!!! error TS2300: Duplicate identifier 'cli'. \ No newline at end of file diff --git a/tests/baselines/reference/classAndInterface1.js b/tests/baselines/reference/classAndInterface1.js deleted file mode 100644 index 5efabded838..00000000000 --- a/tests/baselines/reference/classAndInterface1.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [classAndInterface1.ts] - class cli { } // error -interface cli { } // error - -//// [classAndInterface1.js] -var cli = (function () { - function cli() { - } - return cli; -})(); // error diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.symbols b/tests/baselines/reference/classAndInterfaceMerge.d.symbols new file mode 100644 index 00000000000..84fc2b129c1 --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMerge.d.symbols @@ -0,0 +1,39 @@ +=== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts === + +interface C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +declare class C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +interface C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +interface C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +declare module M { +>M : Symbol(M, Decl(classAndInterfaceMerge.d.ts, 7, 15), Decl(classAndInterfaceMerge.d.ts, 20, 1)) + + interface C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + class C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + interface C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + interface C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + export class C2 { } +>C2 : Symbol(C2, Decl(classAndInterfaceMerge.d.ts, 17, 20), Decl(classAndInterfaceMerge.d.ts, 22, 18)) +} + +declare module M { +>M : Symbol(M, Decl(classAndInterfaceMerge.d.ts, 7, 15), Decl(classAndInterfaceMerge.d.ts, 20, 1)) + + export interface C2 { } +>C2 : Symbol(C2, Decl(classAndInterfaceMerge.d.ts, 17, 20), Decl(classAndInterfaceMerge.d.ts, 22, 18)) +} diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.types b/tests/baselines/reference/classAndInterfaceMerge.d.types new file mode 100644 index 00000000000..baab121ca6e --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMerge.d.types @@ -0,0 +1,39 @@ +=== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts === + +interface C { } +>C : C + +declare class C { } +>C : C + +interface C { } +>C : C + +interface C { } +>C : C + +declare module M { +>M : typeof M + + interface C1 { } +>C1 : C1 + + class C1 { } +>C1 : C1 + + interface C1 { } +>C1 : C1 + + interface C1 { } +>C1 : C1 + + export class C2 { } +>C2 : C2 +} + +declare module M { +>M : typeof M + + export interface C2 { } +>C2 : C2 +} diff --git a/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.errors.txt b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.errors.txt new file mode 100644 index 00000000000..48e52faae1e --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(2,12): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(6,5): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(10,15): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(14,5): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(18,13): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(22,5): error TS2300: Duplicate identifier 'x'. + + +==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts (6 errors) ==== + declare class C1 { + public x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + interface C1 { + x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + declare class C2 { + protected x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + interface C2 { + x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + declare class C3 { + private x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + interface C3 { + x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.js b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.js new file mode 100644 index 00000000000..07b425383f4 --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.js @@ -0,0 +1,26 @@ +//// [classAndInterfaceMergeConflictingMembers.ts] +declare class C1 { + public x : number; +} + +interface C1 { + x : number; +} + +declare class C2 { + protected x : number; +} + +interface C2 { + x : number; +} + +declare class C3 { + private x : number; +} + +interface C3 { + x : number; +} + +//// [classAndInterfaceMergeConflictingMembers.js] diff --git a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt index aa3e687cf4d..332024b74fd 100644 --- a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt +++ b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt @@ -1,27 +1,39 @@ -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2300: Duplicate identifier 'C'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2300: Duplicate identifier 'C'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2300: Duplicate identifier 'D'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2300: Duplicate identifier 'D'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,11): error TS2300: Duplicate identifier 'foo'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,15): error TS2300: Duplicate identifier 'foo'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(6,9): error TS2300: Duplicate identifier 'bar'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(10,9): error TS2300: Duplicate identifier 'bar'. -==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (4 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (8 errors) ==== class C { foo: string; } ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2518: Only an ambient class can be merged with an interface. + ~~~ +!!! error TS2300: Duplicate identifier 'foo'. interface C { foo: string; } // error ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2518: Only an ambient class can be merged with an interface. + ~~~ +!!! error TS2300: Duplicate identifier 'foo'. module M { class D { ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2518: Only an ambient class can be merged with an interface. bar: string; + ~~~ +!!! error TS2300: Duplicate identifier 'bar'. } interface D { // error ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2518: Only an ambient class can be merged with an interface. bar: string; + ~~~ +!!! error TS2300: Duplicate identifier 'bar'. } } \ No newline at end of file diff --git a/tests/baselines/reference/classExpressionTest2.types b/tests/baselines/reference/classExpressionTest2.types index 5586b451d3a..2ff7d79bc5f 100644 --- a/tests/baselines/reference/classExpressionTest2.types +++ b/tests/baselines/reference/classExpressionTest2.types @@ -28,13 +28,13 @@ function M() { } var v = new m(); ->v : ->new m() : +>v : C +>new m() : C >m : typeof C return v.f(); >v.f() : { t: string; x: number; } >v.f : () => { t: T; x: number; } ->v : +>v : C >f : () => { t: T; x: number; } } diff --git a/tests/baselines/reference/classImplementsMergedClassInterface.errors.txt b/tests/baselines/reference/classImplementsMergedClassInterface.errors.txt new file mode 100644 index 00000000000..3e62e72be84 --- /dev/null +++ b/tests/baselines/reference/classImplementsMergedClassInterface.errors.txt @@ -0,0 +1,41 @@ +tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(9,7): error TS2420: Class 'C2' incorrectly implements interface 'C1'. + Property 'x' is missing in type 'C2'. +tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(12,7): error TS2420: Class 'C3' incorrectly implements interface 'C1'. + Property 'y' is missing in type 'C3'. +tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(16,7): error TS2420: Class 'C4' incorrectly implements interface 'C1'. + Property 'x' is missing in type 'C4'. + + +==== tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts (3 errors) ==== + declare class C1 { + x : number; + } + + interface C1 { + y : number; + } + + class C2 implements C1 { // error -- missing x + ~~ +!!! error TS2420: Class 'C2' incorrectly implements interface 'C1'. +!!! error TS2420: Property 'x' is missing in type 'C2'. + } + + class C3 implements C1 { // error -- missing y + ~~ +!!! error TS2420: Class 'C3' incorrectly implements interface 'C1'. +!!! error TS2420: Property 'y' is missing in type 'C3'. + x : number; + } + + class C4 implements C1 { // error -- missing x + ~~ +!!! error TS2420: Class 'C4' incorrectly implements interface 'C1'. +!!! error TS2420: Property 'x' is missing in type 'C4'. + y : number; + } + + class C5 implements C1 { // okay + x : number; + y : number; + } \ No newline at end of file diff --git a/tests/baselines/reference/classImplementsMergedClassInterface.js b/tests/baselines/reference/classImplementsMergedClassInterface.js new file mode 100644 index 00000000000..64a0198cc16 --- /dev/null +++ b/tests/baselines/reference/classImplementsMergedClassInterface.js @@ -0,0 +1,46 @@ +//// [classImplementsMergedClassInterface.ts] +declare class C1 { + x : number; +} + +interface C1 { + y : number; +} + +class C2 implements C1 { // error -- missing x +} + +class C3 implements C1 { // error -- missing y + x : number; +} + +class C4 implements C1 { // error -- missing x + y : number; +} + +class C5 implements C1 { // okay + x : number; + y : number; +} + +//// [classImplementsMergedClassInterface.js] +var C2 = (function () { + function C2() { + } + return C2; +})(); +var C3 = (function () { + function C3() { + } + return C3; +})(); +var C4 = (function () { + function C4() { + } + return C4; +})(); +var C5 = (function () { + function C5() { + } + return C5; +})(); diff --git a/tests/baselines/reference/clinterfaces.errors.txt b/tests/baselines/reference/clinterfaces.errors.txt index d5eab2c7994..5960e6ae32b 100644 --- a/tests/baselines/reference/clinterfaces.errors.txt +++ b/tests/baselines/reference/clinterfaces.errors.txt @@ -1,50 +1,50 @@ -tests/cases/compiler/clinterfaces.ts(2,11): error TS2300: Duplicate identifier 'C'. -tests/cases/compiler/clinterfaces.ts(3,15): error TS2300: Duplicate identifier 'C'. -tests/cases/compiler/clinterfaces.ts(4,15): error TS2300: Duplicate identifier 'D'. -tests/cases/compiler/clinterfaces.ts(5,11): error TS2300: Duplicate identifier 'D'. -tests/cases/compiler/clinterfaces.ts(8,11): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/clinterfaces.ts(12,7): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/clinterfaces.ts(16,7): error TS2300: Duplicate identifier 'Bar'. -tests/cases/compiler/clinterfaces.ts(20,11): error TS2300: Duplicate identifier 'Bar'. +tests/cases/compiler/clinterfaces.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(3,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(4,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(5,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(8,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(12,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(16,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(20,11): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/clinterfaces.ts (8 errors) ==== module M { class C { } ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2518: Only an ambient class can be merged with an interface. interface C { } ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2518: Only an ambient class can be merged with an interface. interface D { } ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2518: Only an ambient class can be merged with an interface. class D { } ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2518: Only an ambient class can be merged with an interface. } interface Foo { ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. +!!! error TS2518: Only an ambient class can be merged with an interface. a: string; } class Foo{ ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. +!!! error TS2518: Only an ambient class can be merged with an interface. b: number; } class Bar{ ~~~ -!!! error TS2300: Duplicate identifier 'Bar'. +!!! error TS2518: Only an ambient class can be merged with an interface. b: number; } interface Bar { ~~~ -!!! error TS2300: Duplicate identifier 'Bar'. +!!! error TS2518: Only an ambient class can be merged with an interface. a: string; } diff --git a/tests/baselines/reference/clinterfaces.js b/tests/baselines/reference/clinterfaces.js index 02ae7349869..a55924227c9 100644 --- a/tests/baselines/reference/clinterfaces.js +++ b/tests/baselines/reference/clinterfaces.js @@ -49,3 +49,4 @@ var Bar = (function () { } return Bar; })(); +module.exports = Foo; diff --git a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types index e40422450b4..92835611c6d 100644 --- a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types +++ b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types @@ -98,7 +98,7 @@ x2 += E.a; x2 += {}; >x2 += {} : string >x2 : string ->{} : {} +>{} : { [x: number]: undefined; } x2 += null; >x2 += null : string diff --git a/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt index 1dfb605db33..deb80dbcca8 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11 //treatment of other similar violations. [(super(), "prop")]() { } ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. }; } } diff --git a/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt index dc8892fd326..b10d184f799 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11 //treatment of other similar violations. [(super(), "prop")]() { } ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. }; } } diff --git a/tests/baselines/reference/contextualIntersectionType.js b/tests/baselines/reference/contextualIntersectionType.js new file mode 100644 index 00000000000..d61fc52fce7 --- /dev/null +++ b/tests/baselines/reference/contextualIntersectionType.js @@ -0,0 +1,14 @@ +//// [contextualIntersectionType.ts] +var x: { a: (s: string) => string } & { b: (n: number) => number }; +x = { + a: s => s, + b: n => n +}; + + +//// [contextualIntersectionType.js] +var x; +x = { + a: function (s) { return s; }, + b: function (n) { return n; } +}; diff --git a/tests/baselines/reference/contextualIntersectionType.symbols b/tests/baselines/reference/contextualIntersectionType.symbols new file mode 100644 index 00000000000..cb7ac9f3d41 --- /dev/null +++ b/tests/baselines/reference/contextualIntersectionType.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/types/intersection/contextualIntersectionType.ts === +var x: { a: (s: string) => string } & { b: (n: number) => number }; +>x : Symbol(x, Decl(contextualIntersectionType.ts, 0, 3)) +>a : Symbol(a, Decl(contextualIntersectionType.ts, 0, 8)) +>s : Symbol(s, Decl(contextualIntersectionType.ts, 0, 13)) +>b : Symbol(b, Decl(contextualIntersectionType.ts, 0, 39)) +>n : Symbol(n, Decl(contextualIntersectionType.ts, 0, 44)) + +x = { +>x : Symbol(x, Decl(contextualIntersectionType.ts, 0, 3)) + + a: s => s, +>a : Symbol(a, Decl(contextualIntersectionType.ts, 1, 5)) +>s : Symbol(s, Decl(contextualIntersectionType.ts, 2, 6)) +>s : Symbol(s, Decl(contextualIntersectionType.ts, 2, 6)) + + b: n => n +>b : Symbol(b, Decl(contextualIntersectionType.ts, 2, 14)) +>n : Symbol(n, Decl(contextualIntersectionType.ts, 3, 6)) +>n : Symbol(n, Decl(contextualIntersectionType.ts, 3, 6)) + +}; + diff --git a/tests/baselines/reference/contextualIntersectionType.types b/tests/baselines/reference/contextualIntersectionType.types new file mode 100644 index 00000000000..4967979d736 --- /dev/null +++ b/tests/baselines/reference/contextualIntersectionType.types @@ -0,0 +1,27 @@ +=== tests/cases/conformance/types/intersection/contextualIntersectionType.ts === +var x: { a: (s: string) => string } & { b: (n: number) => number }; +>x : { a: (s: string) => string; } & { b: (n: number) => number; } +>a : (s: string) => string +>s : string +>b : (n: number) => number +>n : number + +x = { +>x = { a: s => s, b: n => n} : { a: (s: string) => string; b: (n: number) => number; } +>x : { a: (s: string) => string; } & { b: (n: number) => number; } +>{ a: s => s, b: n => n} : { a: (s: string) => string; b: (n: number) => number; } + + a: s => s, +>a : (s: string) => string +>s => s : (s: string) => string +>s : string +>s : string + + b: n => n +>b : (n: number) => number +>n => n : (n: number) => number +>n : number +>n : number + +}; + diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols index 172336603ab..3e23a7812f5 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols +++ b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols @@ -82,5 +82,7 @@ var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any >IWithCallSignatures : Symbol(IWithCallSignatures, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 9, 1)) >IWithCallSignatures4 : Symbol(IWithCallSignatures4, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 18, 1)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 35, 52)) +>a.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 35, 52)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types index 02dfecf5c08..8e1915d4754 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types +++ b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types @@ -90,10 +90,10 @@ var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any >x4 : IWithCallSignatures | IWithCallSignatures4 >IWithCallSignatures : IWithCallSignatures >IWithCallSignatures4 : IWithCallSignatures4 ->a => /*here a should be any*/ a.toString() : (a: any) => any ->a : any ->a.toString() : any ->a.toString : any ->a : any ->toString : any +>a => /*here a should be any*/ a.toString() : (a: number) => string +>a : number +>a.toString() : string +>a.toString : (radix?: number) => string +>a : number +>toString : (radix?: number) => string diff --git a/tests/baselines/reference/declInput.errors.txt b/tests/baselines/reference/declInput.errors.txt index 8ec341ce15b..179db3598ab 100644 --- a/tests/baselines/reference/declInput.errors.txt +++ b/tests/baselines/reference/declInput.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/declInput.ts(1,11): error TS2300: Duplicate identifier 'bar'. -tests/cases/compiler/declInput.ts(5,7): error TS2300: Duplicate identifier 'bar'. +tests/cases/compiler/declInput.ts(1,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/declInput.ts(5,7): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/declInput.ts (2 errors) ==== interface bar { ~~~ -!!! error TS2300: Duplicate identifier 'bar'. +!!! error TS2518: Only an ambient class can be merged with an interface. } class bar { ~~~ -!!! error TS2300: Duplicate identifier 'bar'. +!!! error TS2518: Only an ambient class can be merged with an interface. public f() { return ''; } public g() { return {a: null, b: undefined, c: void 4 }; } public h(x = 4, y = null, z = '') { x++; } diff --git a/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt b/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt new file mode 100644 index 00000000000..a46dfb0d339 --- /dev/null +++ b/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/classes/classDeclarations/file1.ts(3,15): error TS2300: Duplicate identifier 'C1'. +tests/cases/conformance/classes/classDeclarations/file1.ts(5,15): error TS2300: Duplicate identifier 'C1'. +tests/cases/conformance/classes/classDeclarations/file1.ts(7,15): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/file1.ts(9,11): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/file1.ts(11,15): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/file2.ts(2,15): error TS2300: Duplicate identifier 'C3'. +tests/cases/conformance/classes/classDeclarations/file3.ts(2,15): error TS2300: Duplicate identifier 'C3'. + + +==== tests/cases/conformance/classes/classDeclarations/file1.ts (5 errors) ==== + + + declare class C1 {} + ~~ +!!! error TS2300: Duplicate identifier 'C1'. + + declare class C1 {} + ~~ +!!! error TS2300: Duplicate identifier 'C1'. + + declare class C2 {} + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + + interface C2 {} + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + + declare class C2 {} + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + +==== tests/cases/conformance/classes/classDeclarations/file2.ts (1 errors) ==== + + declare class C3 { } + ~~ +!!! error TS2300: Duplicate identifier 'C3'. + +==== tests/cases/conformance/classes/classDeclarations/file3.ts (1 errors) ==== + + declare class C3 { } + ~~ +!!! error TS2300: Duplicate identifier 'C3'. \ No newline at end of file diff --git a/tests/baselines/reference/declaredClassMergedwithSelf.js b/tests/baselines/reference/declaredClassMergedwithSelf.js new file mode 100644 index 00000000000..a38391d90db --- /dev/null +++ b/tests/baselines/reference/declaredClassMergedwithSelf.js @@ -0,0 +1,26 @@ +//// [tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts] //// + +//// [file1.ts] + + +declare class C1 {} + +declare class C1 {} + +declare class C2 {} + +interface C2 {} + +declare class C2 {} + +//// [file2.ts] + +declare class C3 { } + +//// [file3.ts] + +declare class C3 { } + +//// [file1.js] +//// [file2.js] +//// [file3.js] diff --git a/tests/baselines/reference/decoratorOnClassMethod12.errors.txt b/tests/baselines/reference/decoratorOnClassMethod12.errors.txt index 14845839089..3ad3cabebe2 100644 --- a/tests/baselines/reference/decoratorOnClassMethod12.errors.txt +++ b/tests/baselines/reference/decoratorOnClassMethod12.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10 class C extends S { @super.decorator ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. method() { } } } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt index 40610b5b838..c67bc2479ec 100644 --- a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt +++ b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(8,5): error TS2377: Constructors for derived classes must contain a 'super' call. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(17,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(18,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(18,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(23,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(24,31): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(24,31): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts (5 errors) ==== @@ -30,7 +30,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassC var r2 = () => super(); // error for misplaced super call (nested function) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } ~~~~~ !!! error TS2377: Constructors for derived classes must contain a 'super' call. @@ -42,7 +42,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassC var r = function () { super() } // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } ~~~~~ !!! error TS2377: Constructors for derived classes must contain a 'super' call. diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt index f465afbccad..ab79f8d3e23 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt @@ -1,13 +1,13 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS1110: Type expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(10,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(17,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(10,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(17,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS1110: Type expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(25,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(29,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(25,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(29,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts (10 errors) ==== @@ -22,43 +22,43 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS ~~~~~ !!! error TS1110: Type expected. ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. b() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } get C() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; } set C(v) { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } static a: super(); ~~~~~ !!! error TS1110: Type expected. ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. static b() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } static get C() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; } static set C(v) { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } } \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols index 6af2560504d..c232eb24636 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES5.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES5.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES5.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES5.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES5.ts, 13, 36)) diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols index 84c21ff77e6..89f62f97185 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES6.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES6.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES6.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES6.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES6.ts, 13, 36)) diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt index 6c80d13b2f4..731e9748203 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2300: Duplicate identifier 'I'. -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2300: Duplicate identifier 'I'. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(9,21): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(12,18): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(37,12): error TS2300: Duplicate identifier 'x'. @@ -10,12 +10,12 @@ tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): er module M { export interface I { } ~ -!!! error TS2300: Duplicate identifier 'I'. +!!! error TS2518: Only an ambient class can be merged with an interface. } module M { export class I { } // error ~ -!!! error TS2300: Duplicate identifier 'I'. +!!! error TS2518: Only an ambient class can be merged with an interface. } module M { diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt new file mode 100644 index 00000000000..9867441f770 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt @@ -0,0 +1,68 @@ +tests/cases/compiler/file1.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/file1.ts(3,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/file1.ts(4,7): error TS2300: Duplicate identifier 'C2'. +tests/cases/compiler/file1.ts(5,10): error TS2300: Duplicate identifier 'f'. +tests/cases/compiler/file1.ts(9,12): error TS2300: Duplicate identifier 'x'. +tests/cases/compiler/file2.ts(1,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/file2.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'. +tests/cases/compiler/file2.ts(4,7): error TS2300: Duplicate identifier 'f'. +tests/cases/compiler/file2.ts(7,8): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged +tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. + + +==== tests/cases/compiler/file1.ts (5 errors) ==== + + interface I { } + ~ +!!! error TS2518: Only an ambient class can be merged with an interface. + class C1 { } + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + class C2 { } + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + function f() { } + ~ +!!! error TS2300: Duplicate identifier 'f'. + var v = 3; + + class Foo { + static x: number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + module N { + export module F { + var t; + } + } + +==== tests/cases/compiler/file2.ts (6 errors) ==== + class I { } // error -- cannot merge interface with non-ambient class + ~ +!!! error TS2518: Only an ambient class can be merged with an interface. + interface C1 { } // error -- cannot merge interface with non-ambient class + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + function C2() { } // error -- cannot merge function with non-ambient class + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + class f { } // error -- cannot merge function with non-ambient class + ~ +!!! error TS2300: Duplicate identifier 'f'. + var v = 3; + + module Foo { + ~~~ +!!! error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged + export var x: number; // error for redeclaring var in a different parent + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + declare module N { + export function F(); // no error because function is ambient + } + \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js new file mode 100644 index 00000000000..a2509ea97f4 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js @@ -0,0 +1,110 @@ +//// [tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts] //// + +//// [file1.ts] + +interface I { } +class C1 { } +class C2 { } +function f() { } +var v = 3; + +class Foo { + static x: number; +} + +module N { + export module F { + var t; + } +} + +//// [file2.ts] +class I { } // error -- cannot merge interface with non-ambient class +interface C1 { } // error -- cannot merge interface with non-ambient class +function C2() { } // error -- cannot merge function with non-ambient class +class f { } // error -- cannot merge function with non-ambient class +var v = 3; + +module Foo { + export var x: number; // error for redeclaring var in a different parent +} + +declare module N { + export function F(); // no error because function is ambient +} + + +//// [file1.js] +var C1 = (function () { + function C1() { + } + return C1; +})(); +var C2 = (function () { + function C2() { + } + return C2; +})(); +function f() { } +var v = 3; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +var N; +(function (N) { + var F; + (function (F) { + var t; + })(F = N.F || (N.F = {})); +})(N || (N = {})); +//// [file2.js] +var I = (function () { + function I() { + } + return I; +})(); // error -- cannot merge interface with non-ambient class +function C2() { } // error -- cannot merge function with non-ambient class +var f = (function () { + function f() { + } + return f; +})(); // error -- cannot merge function with non-ambient class +var v = 3; +var Foo; +(function (Foo) { +})(Foo || (Foo = {})); + + +//// [file1.d.ts] +interface I { +} +declare class C1 { +} +declare class C2 { +} +declare function f(): void; +declare var v: number; +declare class Foo { + static x: number; +} +declare module N { + module F { + } +} +//// [file2.d.ts] +declare class I { +} +interface C1 { +} +declare function C2(): void; +declare class f { +} +declare var v: number; +declare module Foo { + var x: number; +} +declare module N { + function F(): any; +} diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols index 48564baf796..ad1482e7f1a 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols @@ -5,7 +5,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1691, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) let arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols index 5f62de9bfa1..42db5aeaa85 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1691, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) const arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols index b54ac35ba78..453e04d7521 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1691, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols index df900ac860e..b686dd19592 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1691, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols index 4d0887c1ff8..4ac60f9b429 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1691, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments; diff --git a/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt b/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt index 7fe090395e3..06211ef771f 100644 --- a/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt +++ b/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/emitThisInSuperMethodCall.ts(10,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/emitThisInSuperMethodCall.ts(17,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/emitThisInSuperMethodCall.ts(10,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/emitThisInSuperMethodCall.ts(17,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ==== tests/cases/compiler/emitThisInSuperMethodCall.ts (3 errors) ==== @@ -15,7 +15,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' function inner() { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } }; } @@ -24,7 +24,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' () => { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } } } @@ -32,7 +32,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' function inner() { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } } } diff --git a/tests/baselines/reference/errorSuperCalls.errors.txt b/tests/baselines/reference/errorSuperCalls.errors.txt index cd1aa23f14d..9ecc7a1565e 100644 --- a/tests/baselines/reference/errorSuperCalls.errors.txt +++ b/tests/baselines/reference/errorSuperCalls.errors.txt @@ -8,10 +8,10 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(30,16): error tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(34,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(38,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(46,14): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(58,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(62,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(67,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(58,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(62,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(67,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts (14 errors) ==== @@ -94,26 +94,26 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error T //super call in class member initializer of derived type t = super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. fn() { //super call in class member function of derived type super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } //super call in class accessor (get and set) of derived type get foo() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return null; } set foo(n) { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } } \ No newline at end of file diff --git a/tests/baselines/reference/errorSuperPropertyAccess.errors.txt b/tests/baselines/reference/errorSuperPropertyAccess.errors.txt index b273b1b6f45..c34ed912046 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.errors.txt +++ b/tests/baselines/reference/errorSuperPropertyAccess.errors.txt @@ -9,30 +9,30 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(25,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(29,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(30,9): error TS2335: 'super' can only be referenced in a derived class. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(57,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(61,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(57,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(61,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(64,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(65,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(65,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(68,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(69,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(73,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(76,40): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(87,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(91,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(69,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(73,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(76,40): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(87,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(91,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(94,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(95,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(95,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(98,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(99,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(109,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(110,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(99,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(109,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(110,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(111,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(113,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(114,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(115,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(114,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(115,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(116,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(119,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(120,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(121,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(120,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(121,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(122,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,16): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,30): error TS2335: 'super' can only be referenced in a derived class. @@ -119,13 +119,13 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess super(); super.publicMember = 1; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } fn() { var x = super.publicMember; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } get a() { @@ -133,7 +133,7 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var x = super.publicMember; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. return undefined; } set a(n) { @@ -141,18 +141,18 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. n = super.publicMember; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } fn2() { function inner() { super.publicFunc(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } var x = { test: function () { return super.publicFunc(); } ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } } } @@ -165,13 +165,13 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess super(); super.privateMember = 1; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } fn() { var x = super.privateMember; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } get a() { @@ -179,7 +179,7 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var x = super.privateMember; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. return undefined; } set a(n) { @@ -187,7 +187,7 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. n = super.privateMember; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } @@ -199,10 +199,10 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess static fn() { super.publicStaticMember = 3; ~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticMember = 3; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticFunc(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. @@ -212,10 +212,10 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. super.publicStaticMember = 3; ~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticMember = 3; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticFunc(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. @@ -226,10 +226,10 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. super.publicStaticMember = 3; ~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticMember = 3; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticFunc(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types index 9d87ec9925d..6b621f4c777 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types @@ -31,8 +31,8 @@ export { c as c2 } from "server"; export { i, m as instantiatedModule } from "server"; >i : any ->m : typeof instantiatedModule ->instantiatedModule : typeof instantiatedModule +>m : typeof m +>instantiatedModule : typeof m export { uninstantiated } from "server"; >uninstantiated : any diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types index 9d87ec9925d..6b621f4c777 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types @@ -31,8 +31,8 @@ export { c as c2 } from "server"; export { i, m as instantiatedModule } from "server"; >i : any ->m : typeof instantiatedModule ->instantiatedModule : typeof instantiatedModule +>m : typeof m +>instantiatedModule : typeof m export { uninstantiated } from "server"; >uninstantiated : any diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.js b/tests/baselines/reference/exportSpecifierForAGlobal.js new file mode 100644 index 00000000000..6b4343a299b --- /dev/null +++ b/tests/baselines/reference/exportSpecifierForAGlobal.js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/exportSpecifierForAGlobal.ts] //// + +//// [a.d.ts] + +declare class X { } + +//// [b.ts] +export {X}; +export function f() { + var x: X; + return x; +} + + +//// [b.js] +function f() { + var x; + return x; +} +exports.f = f; + + +//// [b.d.ts] +export { X }; +export declare function f(): X; diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.symbols b/tests/baselines/reference/exportSpecifierForAGlobal.symbols new file mode 100644 index 00000000000..b38fc7be270 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierForAGlobal.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/a.d.ts === + +declare class X { } +>X : Symbol(X, Decl(a.d.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +export {X}; +>X : Symbol(X, Decl(b.ts, 0, 8)) + +export function f() { +>f : Symbol(f, Decl(b.ts, 0, 11)) + + var x: X; +>x : Symbol(x, Decl(b.ts, 2, 7)) +>X : Symbol(X, Decl(a.d.ts, 0, 0)) + + return x; +>x : Symbol(x, Decl(b.ts, 2, 7)) +} + diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.types b/tests/baselines/reference/exportSpecifierForAGlobal.types new file mode 100644 index 00000000000..e3d728ad0d0 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierForAGlobal.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/a.d.ts === + +declare class X { } +>X : X + +=== tests/cases/compiler/b.ts === +export {X}; +>X : typeof X + +export function f() { +>f : () => X + + var x: X; +>x : X +>X : X + + return x; +>x : X +} + diff --git a/tests/baselines/reference/exportsAndImports3-amd.symbols b/tests/baselines/reference/exportsAndImports3-amd.symbols index 4ab418a9bef..a46d7df2a68 100644 --- a/tests/baselines/reference/exportsAndImports3-amd.symbols +++ b/tests/baselines/reference/exportsAndImports3-amd.symbols @@ -16,17 +16,17 @@ export enum E { >E : Symbol(E, Decl(t1.ts, 6, 1)) A, B, C ->A : Symbol(E1.A, Decl(t1.ts, 7, 15)) ->B : Symbol(E1.B, Decl(t1.ts, 8, 6)) ->C : Symbol(E1.C, Decl(t1.ts, 8, 9)) +>A : Symbol(E.A, Decl(t1.ts, 7, 15)) +>B : Symbol(E.B, Decl(t1.ts, 8, 6)) +>C : Symbol(E.C, Decl(t1.ts, 8, 9)) } export const enum D { >D : Symbol(D, Decl(t1.ts, 9, 1)) A, B, C ->A : Symbol(D1.A, Decl(t1.ts, 10, 21)) ->B : Symbol(D1.B, Decl(t1.ts, 11, 6)) ->C : Symbol(D1.C, Decl(t1.ts, 11, 9)) +>A : Symbol(D.A, Decl(t1.ts, 10, 21)) +>B : Symbol(D.B, Decl(t1.ts, 11, 6)) +>C : Symbol(D.C, Decl(t1.ts, 11, 9)) } export module M { >M : Symbol(M, Decl(t1.ts, 12, 1)) diff --git a/tests/baselines/reference/exportsAndImports3.symbols b/tests/baselines/reference/exportsAndImports3.symbols index 4ab418a9bef..a46d7df2a68 100644 --- a/tests/baselines/reference/exportsAndImports3.symbols +++ b/tests/baselines/reference/exportsAndImports3.symbols @@ -16,17 +16,17 @@ export enum E { >E : Symbol(E, Decl(t1.ts, 6, 1)) A, B, C ->A : Symbol(E1.A, Decl(t1.ts, 7, 15)) ->B : Symbol(E1.B, Decl(t1.ts, 8, 6)) ->C : Symbol(E1.C, Decl(t1.ts, 8, 9)) +>A : Symbol(E.A, Decl(t1.ts, 7, 15)) +>B : Symbol(E.B, Decl(t1.ts, 8, 6)) +>C : Symbol(E.C, Decl(t1.ts, 8, 9)) } export const enum D { >D : Symbol(D, Decl(t1.ts, 9, 1)) A, B, C ->A : Symbol(D1.A, Decl(t1.ts, 10, 21)) ->B : Symbol(D1.B, Decl(t1.ts, 11, 6)) ->C : Symbol(D1.C, Decl(t1.ts, 11, 9)) +>A : Symbol(D.A, Decl(t1.ts, 10, 21)) +>B : Symbol(D.B, Decl(t1.ts, 11, 6)) +>C : Symbol(D.C, Decl(t1.ts, 11, 9)) } export module M { >M : Symbol(M, Decl(t1.ts, 12, 1)) diff --git a/tests/baselines/reference/for-of13.symbols b/tests/baselines/reference/for-of13.symbols index 833ea1d6875..08e5f4ff468 100644 --- a/tests/baselines/reference/for-of13.symbols +++ b/tests/baselines/reference/for-of13.symbols @@ -4,6 +4,6 @@ var v: string; for (v of [""].values()) { } >v : Symbol(v, Decl(for-of13.ts, 0, 3)) ->[""].values : Symbol(Array.values, Decl(lib.d.ts, 1453, 37)) ->values : Symbol(Array.values, Decl(lib.d.ts, 1453, 37)) +>[""].values : Symbol(Array.values, Decl(lib.d.ts, 1466, 37)) +>values : Symbol(Array.values, Decl(lib.d.ts, 1466, 37)) diff --git a/tests/baselines/reference/for-of18.symbols b/tests/baselines/reference/for-of18.symbols index 2c08338ce73..066d9534051 100644 --- a/tests/baselines/reference/for-of18.symbols +++ b/tests/baselines/reference/for-of18.symbols @@ -22,9 +22,9 @@ class StringIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(for-of18.ts, 1, 33)) diff --git a/tests/baselines/reference/for-of19.symbols b/tests/baselines/reference/for-of19.symbols index 6be3c83964a..8c34f6f0d7a 100644 --- a/tests/baselines/reference/for-of19.symbols +++ b/tests/baselines/reference/for-of19.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of19.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of20.symbols b/tests/baselines/reference/for-of20.symbols index 97200f93f35..4e7aaf7e362 100644 --- a/tests/baselines/reference/for-of20.symbols +++ b/tests/baselines/reference/for-of20.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of20.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of21.symbols b/tests/baselines/reference/for-of21.symbols index bbe3504294c..70c1132afbd 100644 --- a/tests/baselines/reference/for-of21.symbols +++ b/tests/baselines/reference/for-of21.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of21.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of22.symbols b/tests/baselines/reference/for-of22.symbols index 4f15b541356..46507255937 100644 --- a/tests/baselines/reference/for-of22.symbols +++ b/tests/baselines/reference/for-of22.symbols @@ -28,9 +28,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of22.ts, 5, 13)) diff --git a/tests/baselines/reference/for-of23.symbols b/tests/baselines/reference/for-of23.symbols index 0f409605e28..8401de024d9 100644 --- a/tests/baselines/reference/for-of23.symbols +++ b/tests/baselines/reference/for-of23.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of23.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of25.symbols b/tests/baselines/reference/for-of25.symbols index 44cc83143af..93e918c4bcd 100644 --- a/tests/baselines/reference/for-of25.symbols +++ b/tests/baselines/reference/for-of25.symbols @@ -10,9 +10,9 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 1, 37)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return x; >x : Symbol(x, Decl(for-of25.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of26.symbols b/tests/baselines/reference/for-of26.symbols index 0218a8b9995..04445f50171 100644 --- a/tests/baselines/reference/for-of26.symbols +++ b/tests/baselines/reference/for-of26.symbols @@ -16,9 +16,9 @@ class StringIterator { >x : Symbol(x, Decl(for-of26.ts, 0, 3)) } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(for-of26.ts, 1, 37)) diff --git a/tests/baselines/reference/for-of27.symbols b/tests/baselines/reference/for-of27.symbols index 82918a19986..4c645d359dd 100644 --- a/tests/baselines/reference/for-of27.symbols +++ b/tests/baselines/reference/for-of27.symbols @@ -7,7 +7,7 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 37)) [Symbol.iterator]: any; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } diff --git a/tests/baselines/reference/for-of28.symbols b/tests/baselines/reference/for-of28.symbols index e4324b05779..6887b46a44d 100644 --- a/tests/baselines/reference/for-of28.symbols +++ b/tests/baselines/reference/for-of28.symbols @@ -10,9 +10,9 @@ class StringIterator { >next : Symbol(next, Decl(for-of28.ts, 2, 22)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(for-of28.ts, 0, 37)) diff --git a/tests/baselines/reference/for-of37.symbols b/tests/baselines/reference/for-of37.symbols index 11de20174a7..a726b7eedc2 100644 --- a/tests/baselines/reference/for-of37.symbols +++ b/tests/baselines/reference/for-of37.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of37.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of37.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1864, 1), Decl(lib.d.ts, 1887, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for (var v of map) { >v : Symbol(v, Decl(for-of37.ts, 1, 8)) diff --git a/tests/baselines/reference/for-of38.symbols b/tests/baselines/reference/for-of38.symbols index 20af2cb65fb..11ff91e1162 100644 --- a/tests/baselines/reference/for-of38.symbols +++ b/tests/baselines/reference/for-of38.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of38.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of38.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1864, 1), Decl(lib.d.ts, 1887, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for (var [k, v] of map) { >k : Symbol(k, Decl(for-of38.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of40.symbols b/tests/baselines/reference/for-of40.symbols index eb77e578510..f6619ff753d 100644 --- a/tests/baselines/reference/for-of40.symbols +++ b/tests/baselines/reference/for-of40.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of40.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of40.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1864, 1), Decl(lib.d.ts, 1887, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for (var [k = "", v = false] of map) { >k : Symbol(k, Decl(for-of40.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of44.symbols b/tests/baselines/reference/for-of44.symbols index 9c6afa04adb..a9ea283d673 100644 --- a/tests/baselines/reference/for-of44.symbols +++ b/tests/baselines/reference/for-of44.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of44.ts === var array: [number, string | boolean | symbol][] = [[0, ""], [0, true], [1, Symbol()]] >array : Symbol(array, Decl(for-of44.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) for (var [num, strBoolSym] of array) { >num : Symbol(num, Decl(for-of44.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of45.symbols b/tests/baselines/reference/for-of45.symbols index b9e5bbacbfa..1d447ea87cc 100644 --- a/tests/baselines/reference/for-of45.symbols +++ b/tests/baselines/reference/for-of45.symbols @@ -5,7 +5,7 @@ var k: string, v: boolean; var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of45.ts, 1, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1864, 1), Decl(lib.d.ts, 1887, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for ([k = "", v = false] of map) { >k : Symbol(k, Decl(for-of45.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of50.symbols b/tests/baselines/reference/for-of50.symbols index f3bd38be1df..6b8012c7929 100644 --- a/tests/baselines/reference/for-of50.symbols +++ b/tests/baselines/reference/for-of50.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of50.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of50.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1864, 1), Decl(lib.d.ts, 1887, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for (const [k, v] of map) { >k : Symbol(k, Decl(for-of50.ts, 1, 12)) diff --git a/tests/baselines/reference/for-of57.symbols b/tests/baselines/reference/for-of57.symbols index 574d52e4c56..b8d01d3bd1b 100644 --- a/tests/baselines/reference/for-of57.symbols +++ b/tests/baselines/reference/for-of57.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of57.ts === var iter: Iterable; >iter : Symbol(iter, Decl(for-of57.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) for (let num of iter) { } >num : Symbol(num, Decl(for-of57.ts, 1, 8)) diff --git a/tests/baselines/reference/functionConstraintSatisfaction3.types b/tests/baselines/reference/functionConstraintSatisfaction3.types index 04963c36519..c58e62f6995 100644 --- a/tests/baselines/reference/functionConstraintSatisfaction3.types +++ b/tests/baselines/reference/functionConstraintSatisfaction3.types @@ -37,12 +37,12 @@ var c: { (): string; (x): string }; >x : any var r1 = foo((x) => x); ->r1 : (x: any) => any ->foo((x) => x) : (x: any) => any +>r1 : (x: string) => string +>foo((x) => x) : (x: string) => string >foo : string>(x: T) => T ->(x) => x : (x: any) => any ->x : any ->x : any +>(x) => x : (x: string) => string +>x : string +>x : string var r2 = foo((x: string) => x); >r2 : (x: string) => string @@ -53,12 +53,12 @@ var r2 = foo((x: string) => x); >x : string var r3 = foo(function (x) { return x }); ->r3 : (x: any) => any ->foo(function (x) { return x }) : (x: any) => any +>r3 : (x: string) => string +>foo(function (x) { return x }) : (x: string) => string >foo : string>(x: T) => T ->function (x) { return x } : (x: any) => any ->x : any ->x : any +>function (x) { return x } : (x: string) => string +>x : string +>x : string var r4 = foo(function (x: string) { return x }); >r4 : (x: string) => string @@ -130,8 +130,8 @@ var c2: { (x: T): T; (x: T, y: T): T }; >T : T var r9 = foo(function (x: U) { return x; }); ->r9 : (x: U) => U ->foo(function (x: U) { return x; }) : (x: U) => U +>r9 : (x: string) => string +>foo(function (x: U) { return x; }) : (x: string) => string >foo : string>(x: T) => T >function (x: U) { return x; } : (x: U) => U >U : U @@ -140,8 +140,8 @@ var r9 = foo(function (x: U) { return x; }); >x : U var r10 = foo((x: U) => x); ->r10 : (x: U) => U ->foo((x: U) => x) : (x: U) => U +>r10 : (x: string) => string +>foo((x: U) => x) : (x: string) => string >foo : string>(x: T) => T >(x: U) => x : (x: U) => U >U : U diff --git a/tests/baselines/reference/generatorES6_6.symbols b/tests/baselines/reference/generatorES6_6.symbols index 4cdac0f12c5..7f30b4f6797 100644 --- a/tests/baselines/reference/generatorES6_6.symbols +++ b/tests/baselines/reference/generatorES6_6.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(generatorES6_6.ts, 0, 0)) *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) let a = yield 1; >a : Symbol(a, Decl(generatorES6_6.ts, 2, 7)) diff --git a/tests/baselines/reference/generatorOverloads4.symbols b/tests/baselines/reference/generatorOverloads4.symbols index afae1c1a808..c4fb9401517 100644 --- a/tests/baselines/reference/generatorOverloads4.symbols +++ b/tests/baselines/reference/generatorOverloads4.symbols @@ -5,15 +5,15 @@ class C { f(s: string): Iterable; >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 1, 6)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) f(s: number): Iterable; >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 2, 6)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) *f(s: any): Iterable { } >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 3, 7)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) } diff --git a/tests/baselines/reference/generatorOverloads5.symbols b/tests/baselines/reference/generatorOverloads5.symbols index 0a14548d197..509ed22d197 100644 --- a/tests/baselines/reference/generatorOverloads5.symbols +++ b/tests/baselines/reference/generatorOverloads5.symbols @@ -5,15 +5,15 @@ module M { function f(s: string): Iterable; >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 1, 15)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) function f(s: number): Iterable; >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 2, 15)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) function* f(s: any): Iterable { } >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 3, 16)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) } diff --git a/tests/baselines/reference/generatorTypeCheck1.symbols b/tests/baselines/reference/generatorTypeCheck1.symbols index 58ee2aa66f8..79cc3e275ad 100644 --- a/tests/baselines/reference/generatorTypeCheck1.symbols +++ b/tests/baselines/reference/generatorTypeCheck1.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck1.ts === function* g1(): Iterator { } >g1 : Symbol(g1, Decl(generatorTypeCheck1.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1662, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck10.symbols b/tests/baselines/reference/generatorTypeCheck10.symbols index c6eeb6b4a3d..6247bd7b85c 100644 --- a/tests/baselines/reference/generatorTypeCheck10.symbols +++ b/tests/baselines/reference/generatorTypeCheck10.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck10.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck10.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) return; } diff --git a/tests/baselines/reference/generatorTypeCheck11.symbols b/tests/baselines/reference/generatorTypeCheck11.symbols index b904dfb446b..dce2524d1ba 100644 --- a/tests/baselines/reference/generatorTypeCheck11.symbols +++ b/tests/baselines/reference/generatorTypeCheck11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck11.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck11.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) return 0; } diff --git a/tests/baselines/reference/generatorTypeCheck12.symbols b/tests/baselines/reference/generatorTypeCheck12.symbols index e596203b9eb..f9c9b7b6e22 100644 --- a/tests/baselines/reference/generatorTypeCheck12.symbols +++ b/tests/baselines/reference/generatorTypeCheck12.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck12.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck12.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) return ""; } diff --git a/tests/baselines/reference/generatorTypeCheck13.symbols b/tests/baselines/reference/generatorTypeCheck13.symbols index 84e42a06cfd..bc43ea8c8f9 100644 --- a/tests/baselines/reference/generatorTypeCheck13.symbols +++ b/tests/baselines/reference/generatorTypeCheck13.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck13.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck13.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) yield 0; return ""; diff --git a/tests/baselines/reference/generatorTypeCheck17.symbols b/tests/baselines/reference/generatorTypeCheck17.symbols index 9e689d9df42..789eb22347c 100644 --- a/tests/baselines/reference/generatorTypeCheck17.symbols +++ b/tests/baselines/reference/generatorTypeCheck17.symbols @@ -10,7 +10,7 @@ class Bar extends Foo { y: string } function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck17.ts, 1, 35)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >Foo : Symbol(Foo, Decl(generatorTypeCheck17.ts, 0, 0)) yield; diff --git a/tests/baselines/reference/generatorTypeCheck19.symbols b/tests/baselines/reference/generatorTypeCheck19.symbols index 2edec8fd21a..e7a5898099f 100644 --- a/tests/baselines/reference/generatorTypeCheck19.symbols +++ b/tests/baselines/reference/generatorTypeCheck19.symbols @@ -10,7 +10,7 @@ class Bar extends Foo { y: string } function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck19.ts, 1, 35)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >Foo : Symbol(Foo, Decl(generatorTypeCheck19.ts, 0, 0)) yield; diff --git a/tests/baselines/reference/generatorTypeCheck2.symbols b/tests/baselines/reference/generatorTypeCheck2.symbols index e0668786598..5a0aec4d592 100644 --- a/tests/baselines/reference/generatorTypeCheck2.symbols +++ b/tests/baselines/reference/generatorTypeCheck2.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck2.ts === function* g1(): Iterable { } >g1 : Symbol(g1, Decl(generatorTypeCheck2.ts, 0, 0)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck26.symbols b/tests/baselines/reference/generatorTypeCheck26.symbols index 4d3ad862565..08cc7289ef8 100644 --- a/tests/baselines/reference/generatorTypeCheck26.symbols +++ b/tests/baselines/reference/generatorTypeCheck26.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck26.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck26.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >x : Symbol(x, Decl(generatorTypeCheck26.ts, 0, 33)) yield x => x.length; diff --git a/tests/baselines/reference/generatorTypeCheck27.symbols b/tests/baselines/reference/generatorTypeCheck27.symbols index bfff5f9e10a..fcee922d1e9 100644 --- a/tests/baselines/reference/generatorTypeCheck27.symbols +++ b/tests/baselines/reference/generatorTypeCheck27.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck27.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck27.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >x : Symbol(x, Decl(generatorTypeCheck27.ts, 0, 33)) yield * function* () { diff --git a/tests/baselines/reference/generatorTypeCheck28.symbols b/tests/baselines/reference/generatorTypeCheck28.symbols index e1bbbd96b40..27b246515f6 100644 --- a/tests/baselines/reference/generatorTypeCheck28.symbols +++ b/tests/baselines/reference/generatorTypeCheck28.symbols @@ -1,14 +1,14 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck28.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck28.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >x : Symbol(x, Decl(generatorTypeCheck28.ts, 0, 33)) yield * { *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) yield x => x.length; >x : Symbol(x, Decl(generatorTypeCheck28.ts, 3, 17)) diff --git a/tests/baselines/reference/generatorTypeCheck29.symbols b/tests/baselines/reference/generatorTypeCheck29.symbols index 57790d5b700..260137dd1cf 100644 --- a/tests/baselines/reference/generatorTypeCheck29.symbols +++ b/tests/baselines/reference/generatorTypeCheck29.symbols @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck29.ts === function* g2(): Iterator number>> { >g2 : Symbol(g2, Decl(generatorTypeCheck29.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1662, 1)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) >x : Symbol(x, Decl(generatorTypeCheck29.ts, 0, 35)) yield function* () { diff --git a/tests/baselines/reference/generatorTypeCheck3.symbols b/tests/baselines/reference/generatorTypeCheck3.symbols index 2f5d2405507..a149a592e3d 100644 --- a/tests/baselines/reference/generatorTypeCheck3.symbols +++ b/tests/baselines/reference/generatorTypeCheck3.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck3.ts === function* g1(): IterableIterator { } >g1 : Symbol(g1, Decl(generatorTypeCheck3.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck30.symbols b/tests/baselines/reference/generatorTypeCheck30.symbols index 49c43ce135f..086c65685a8 100644 --- a/tests/baselines/reference/generatorTypeCheck30.symbols +++ b/tests/baselines/reference/generatorTypeCheck30.symbols @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck30.ts === function* g2(): Iterator number>> { >g2 : Symbol(g2, Decl(generatorTypeCheck30.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1662, 1)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) >x : Symbol(x, Decl(generatorTypeCheck30.ts, 0, 35)) yield function* () { diff --git a/tests/baselines/reference/generatorTypeCheck45.symbols b/tests/baselines/reference/generatorTypeCheck45.symbols index 06340925fec..89c01ff0203 100644 --- a/tests/baselines/reference/generatorTypeCheck45.symbols +++ b/tests/baselines/reference/generatorTypeCheck45.symbols @@ -6,7 +6,7 @@ declare function foo(x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) >x : Symbol(x, Decl(generatorTypeCheck45.ts, 0, 27)) >T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) >fun : Symbol(fun, Decl(generatorTypeCheck45.ts, 0, 32)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1662, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) >x : Symbol(x, Decl(generatorTypeCheck45.ts, 0, 54)) >T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) >U : Symbol(U, Decl(generatorTypeCheck45.ts, 0, 23)) diff --git a/tests/baselines/reference/generatorTypeCheck46.symbols b/tests/baselines/reference/generatorTypeCheck46.symbols index aa0b237d1f2..72d8ebf57a1 100644 --- a/tests/baselines/reference/generatorTypeCheck46.symbols +++ b/tests/baselines/reference/generatorTypeCheck46.symbols @@ -6,7 +6,7 @@ declare function foo(x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) >x : Symbol(x, Decl(generatorTypeCheck46.ts, 0, 27)) >T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) >fun : Symbol(fun, Decl(generatorTypeCheck46.ts, 0, 32)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) >x : Symbol(x, Decl(generatorTypeCheck46.ts, 0, 54)) >T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) >U : Symbol(U, Decl(generatorTypeCheck46.ts, 0, 23)) @@ -21,9 +21,9 @@ foo("", function* () { yield* { *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) yield x => x.length >x : Symbol(x, Decl(generatorTypeCheck46.ts, 5, 17)) diff --git a/tests/baselines/reference/genericCallWithTupleType.errors.txt b/tests/baselines/reference/genericCallWithTupleType.errors.txt index bcf580320e5..d03f8d5e68a 100644 --- a/tests/baselines/reference/genericCallWithTupleType.errors.txt +++ b/tests/baselines/reference/genericCallWithTupleType.errors.txt @@ -9,9 +9,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,1): error TS2322: Type '[number, string]' is not assignable to type '[string, number]'. Types of property '0' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,1): error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,1): error TS2322: Type '[{ [x: number]: undefined; }, {}]' is not assignable to type '[string, number]'. Types of property '0' are incompatible. - Type '{}' is not assignable to type 'string'. + Type '{ [x: number]: undefined; }' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(24,1): error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'. Property '1' is missing in type '[{}]'. @@ -55,9 +55,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup !!! error TS2322: Type 'number' is not assignable to type 'string'. i1.tuple1 = [{}, {}]; ~~~~~~~~~ -!!! error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'. +!!! error TS2322: Type '[{ [x: number]: undefined; }, {}]' is not assignable to type '[string, number]'. !!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type '{}' is not assignable to type 'string'. +!!! error TS2322: Type '{ [x: number]: undefined; }' is not assignable to type 'string'. i2.tuple1 = [{}]; ~~~~~~~~~ !!! error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'. diff --git a/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt b/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt index a07fbea75d8..1d3d2e7c275 100644 --- a/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt +++ b/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(6,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/compiler/illegalSuperCallsInConstructor.ts(7,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/illegalSuperCallsInConstructor.ts(8,26): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/illegalSuperCallsInConstructor.ts(9,32): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/illegalSuperCallsInConstructor.ts(7,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/illegalSuperCallsInConstructor.ts(8,26): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/illegalSuperCallsInConstructor.ts(9,32): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/compiler/illegalSuperCallsInConstructor.ts(11,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/illegalSuperCallsInConstructor.ts(12,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/illegalSuperCallsInConstructor.ts(12,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/compiler/illegalSuperCallsInConstructor.ts(15,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/compiler/illegalSuperCallsInConstructor.ts (8 errors) ==== @@ -19,15 +19,15 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Sup var r2 = () => super(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. var r3 = () => { super(); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. var r4 = function () { super(); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. var r5 = { ~~~~~~~~~~~~~~~~~~ get foo() { @@ -37,7 +37,7 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Sup super(); ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; ~~~~~~~~~~~~~~~~~~~~~~~~~ }, @@ -49,7 +49,7 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Sup super(); ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } ~~~~~~~~~~~~~ } diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType1.js b/tests/baselines/reference/inferentialTypingUsingApparentType1.js new file mode 100644 index 00000000000..02161a98695 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType1.js @@ -0,0 +1,12 @@ +//// [inferentialTypingUsingApparentType1.ts] +function foo number>(x: T): T { + return undefined; +} + +foo(x => x.length); + +//// [inferentialTypingUsingApparentType1.js] +function foo(x) { + return undefined; +} +foo(function (x) { return x.length; }); diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType1.symbols b/tests/baselines/reference/inferentialTypingUsingApparentType1.symbols new file mode 100644 index 00000000000..4babc614183 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType1.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType1.ts === +function foo number>(x: T): T { +>foo : Symbol(foo, Decl(inferentialTypingUsingApparentType1.ts, 0, 0)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType1.ts, 0, 13)) +>p : Symbol(p, Decl(inferentialTypingUsingApparentType1.ts, 0, 24)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType1.ts, 0, 46)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType1.ts, 0, 13)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType1.ts, 0, 13)) + + return undefined; +>undefined : Symbol(undefined) +} + +foo(x => x.length); +>foo : Symbol(foo, Decl(inferentialTypingUsingApparentType1.ts, 0, 0)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType1.ts, 4, 4)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType1.ts, 4, 4)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType1.types b/tests/baselines/reference/inferentialTypingUsingApparentType1.types new file mode 100644 index 00000000000..b56f3670ddc --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType1.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType1.ts === +function foo number>(x: T): T { +>foo : number>(x: T) => T +>T : T +>p : string +>x : T +>T : T +>T : T + + return undefined; +>undefined : undefined +} + +foo(x => x.length); +>foo(x => x.length) : (x: string) => number +>foo : number>(x: T) => T +>x => x.length : (x: string) => number +>x : string +>x.length : number +>x : string +>length : number + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType2.js b/tests/baselines/reference/inferentialTypingUsingApparentType2.js new file mode 100644 index 00000000000..7cb7e49cd62 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType2.js @@ -0,0 +1,12 @@ +//// [inferentialTypingUsingApparentType2.ts] +function foo(x: T): T { + return undefined; +} + +foo({ m(x) { return x.length } }); + +//// [inferentialTypingUsingApparentType2.js] +function foo(x) { + return undefined; +} +foo({ m: function (x) { return x.length; } }); diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType2.symbols b/tests/baselines/reference/inferentialTypingUsingApparentType2.symbols new file mode 100644 index 00000000000..3c47eb4c697 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType2.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType2.ts === +function foo(x: T): T { +>foo : Symbol(foo, Decl(inferentialTypingUsingApparentType2.ts, 0, 0)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType2.ts, 0, 13)) +>m : Symbol(m, Decl(inferentialTypingUsingApparentType2.ts, 0, 24)) +>p : Symbol(p, Decl(inferentialTypingUsingApparentType2.ts, 0, 27)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType2.ts, 0, 49)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType2.ts, 0, 13)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType2.ts, 0, 13)) + + return undefined; +>undefined : Symbol(undefined) +} + +foo({ m(x) { return x.length } }); +>foo : Symbol(foo, Decl(inferentialTypingUsingApparentType2.ts, 0, 0)) +>m : Symbol(m, Decl(inferentialTypingUsingApparentType2.ts, 4, 5)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType2.ts, 4, 8)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType2.ts, 4, 8)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType2.types b/tests/baselines/reference/inferentialTypingUsingApparentType2.types new file mode 100644 index 00000000000..597f5885f5a --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType2.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType2.ts === +function foo(x: T): T { +>foo : (x: T) => T +>T : T +>m : (p: string) => number +>p : string +>x : T +>T : T +>T : T + + return undefined; +>undefined : undefined +} + +foo({ m(x) { return x.length } }); +>foo({ m(x) { return x.length } }) : { } +>foo : (x: T) => T +>{ m(x) { return x.length } } : { m(x: string): number; } +>m : (x: string) => number +>x : string +>x.length : number +>x : string +>length : number + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType3.js b/tests/baselines/reference/inferentialTypingUsingApparentType3.js new file mode 100644 index 00000000000..819ca05098d --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType3.js @@ -0,0 +1,56 @@ +//// [inferentialTypingUsingApparentType3.ts] +interface Field { + clean(input: T): T +} + +class CharField implements Field { + clean(input: string) { + return "Yup"; + } +} + +class NumberField implements Field { + clean(input: number) { + return 123; + } +} + +class ObjectField }> { + constructor(public fields: T) { } +} + +var person = new ObjectField({ + id: new NumberField(), + name: new CharField() +}); + +person.fields.id; + +//// [inferentialTypingUsingApparentType3.js] +var CharField = (function () { + function CharField() { + } + CharField.prototype.clean = function (input) { + return "Yup"; + }; + return CharField; +})(); +var NumberField = (function () { + function NumberField() { + } + NumberField.prototype.clean = function (input) { + return 123; + }; + return NumberField; +})(); +var ObjectField = (function () { + function ObjectField(fields) { + this.fields = fields; + } + return ObjectField; +})(); +var person = new ObjectField({ + id: new NumberField(), + name: new CharField() +}); +person.fields.id; diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType3.symbols b/tests/baselines/reference/inferentialTypingUsingApparentType3.symbols new file mode 100644 index 00000000000..ac3058e8649 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType3.symbols @@ -0,0 +1,69 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType3.ts === +interface Field { +>Field : Symbol(Field, Decl(inferentialTypingUsingApparentType3.ts, 0, 0)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 0, 16)) + + clean(input: T): T +>clean : Symbol(clean, Decl(inferentialTypingUsingApparentType3.ts, 0, 20)) +>input : Symbol(input, Decl(inferentialTypingUsingApparentType3.ts, 1, 10)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 0, 16)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 0, 16)) +} + +class CharField implements Field { +>CharField : Symbol(CharField, Decl(inferentialTypingUsingApparentType3.ts, 2, 1)) +>Field : Symbol(Field, Decl(inferentialTypingUsingApparentType3.ts, 0, 0)) + + clean(input: string) { +>clean : Symbol(clean, Decl(inferentialTypingUsingApparentType3.ts, 4, 42)) +>input : Symbol(input, Decl(inferentialTypingUsingApparentType3.ts, 5, 10)) + + return "Yup"; + } +} + +class NumberField implements Field { +>NumberField : Symbol(NumberField, Decl(inferentialTypingUsingApparentType3.ts, 8, 1)) +>Field : Symbol(Field, Decl(inferentialTypingUsingApparentType3.ts, 0, 0)) + + clean(input: number) { +>clean : Symbol(clean, Decl(inferentialTypingUsingApparentType3.ts, 10, 44)) +>input : Symbol(input, Decl(inferentialTypingUsingApparentType3.ts, 11, 10)) + + return 123; + } +} + +class ObjectField }> { +>ObjectField : Symbol(ObjectField, Decl(inferentialTypingUsingApparentType3.ts, 14, 1)) +>A : Symbol(A, Decl(inferentialTypingUsingApparentType3.ts, 16, 18)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 16, 20)) +>name : Symbol(name, Decl(inferentialTypingUsingApparentType3.ts, 16, 34)) +>Field : Symbol(Field, Decl(inferentialTypingUsingApparentType3.ts, 0, 0)) + + constructor(public fields: T) { } +>fields : Symbol(fields, Decl(inferentialTypingUsingApparentType3.ts, 17, 16)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 16, 20)) +} + +var person = new ObjectField({ +>person : Symbol(person, Decl(inferentialTypingUsingApparentType3.ts, 20, 3)) +>ObjectField : Symbol(ObjectField, Decl(inferentialTypingUsingApparentType3.ts, 14, 1)) + + id: new NumberField(), +>id : Symbol(id, Decl(inferentialTypingUsingApparentType3.ts, 20, 30)) +>NumberField : Symbol(NumberField, Decl(inferentialTypingUsingApparentType3.ts, 8, 1)) + + name: new CharField() +>name : Symbol(name, Decl(inferentialTypingUsingApparentType3.ts, 21, 26)) +>CharField : Symbol(CharField, Decl(inferentialTypingUsingApparentType3.ts, 2, 1)) + +}); + +person.fields.id; +>person.fields.id : Symbol(id, Decl(inferentialTypingUsingApparentType3.ts, 20, 30)) +>person.fields : Symbol(ObjectField.fields, Decl(inferentialTypingUsingApparentType3.ts, 17, 16)) +>person : Symbol(person, Decl(inferentialTypingUsingApparentType3.ts, 20, 3)) +>fields : Symbol(ObjectField.fields, Decl(inferentialTypingUsingApparentType3.ts, 17, 16)) +>id : Symbol(id, Decl(inferentialTypingUsingApparentType3.ts, 20, 30)) + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType3.types b/tests/baselines/reference/inferentialTypingUsingApparentType3.types new file mode 100644 index 00000000000..7d0da8f4b06 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType3.types @@ -0,0 +1,75 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType3.ts === +interface Field { +>Field : Field +>T : T + + clean(input: T): T +>clean : (input: T) => T +>input : T +>T : T +>T : T +} + +class CharField implements Field { +>CharField : CharField +>Field : Field + + clean(input: string) { +>clean : (input: string) => string +>input : string + + return "Yup"; +>"Yup" : string + } +} + +class NumberField implements Field { +>NumberField : NumberField +>Field : Field + + clean(input: number) { +>clean : (input: number) => number +>input : number + + return 123; +>123 : number + } +} + +class ObjectField }> { +>ObjectField : ObjectField +>A : A +>T : T +>name : string +>Field : Field + + constructor(public fields: T) { } +>fields : T +>T : T +} + +var person = new ObjectField({ +>person : ObjectField<{}, { [x: string]: CharField | NumberField; id: NumberField; name: CharField; }> +>new ObjectField({ id: new NumberField(), name: new CharField()}) : ObjectField<{}, { [x: string]: CharField | NumberField; id: NumberField; name: CharField; }> +>ObjectField : typeof ObjectField +>{ id: new NumberField(), name: new CharField()} : { [x: string]: CharField | NumberField; id: NumberField; name: CharField; } + + id: new NumberField(), +>id : NumberField +>new NumberField() : NumberField +>NumberField : typeof NumberField + + name: new CharField() +>name : CharField +>new CharField() : CharField +>CharField : typeof CharField + +}); + +person.fields.id; +>person.fields.id : NumberField +>person.fields : { [x: string]: CharField | NumberField; id: NumberField; name: CharField; } +>person : ObjectField<{}, { [x: string]: CharField | NumberField; id: NumberField; name: CharField; }> +>fields : { [x: string]: CharField | NumberField; id: NumberField; name: CharField; } +>id : NumberField + diff --git a/tests/baselines/reference/interfaceDeclaration2.errors.txt b/tests/baselines/reference/interfaceDeclaration2.errors.txt index 9739d946bc5..db525e6f21f 100644 --- a/tests/baselines/reference/interfaceDeclaration2.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2300: Duplicate identifier 'I2'. -tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2300: Duplicate identifier 'I2'. +tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/interfaceDeclaration2.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2300: Duplicate iden interface I2 { } ~~ -!!! error TS2300: Duplicate identifier 'I2'. +!!! error TS2518: Only an ambient class can be merged with an interface. class I2 { } ~~ -!!! error TS2300: Duplicate identifier 'I2'. +!!! error TS2518: Only an ambient class can be merged with an interface. interface I3 { } function I3() { } diff --git a/tests/baselines/reference/intersectionAndUnionTypes.errors.txt b/tests/baselines/reference/intersectionAndUnionTypes.errors.txt new file mode 100644 index 00000000000..4f26cc63ba3 --- /dev/null +++ b/tests/baselines/reference/intersectionAndUnionTypes.errors.txt @@ -0,0 +1,162 @@ +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(19,1): error TS2322: Type 'A' is not assignable to type 'A & B'. + Type 'A' is not assignable to type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(20,1): error TS2322: Type 'B' is not assignable to type 'A & B'. + Type 'B' is not assignable to type 'A'. + Property 'a' is missing in type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(23,1): error TS2322: Type 'A | B' is not assignable to type '(A & B) | (C & D)'. + Type 'A' is not assignable to type '(A & B) | (C & D)'. + Type 'A' is not assignable to type 'C & D'. + Type 'A' is not assignable to type 'C'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(25,1): error TS2322: Type 'C | D' is not assignable to type '(A & B) | (C & D)'. + Type 'C' is not assignable to type '(A & B) | (C & D)'. + Type 'C' is not assignable to type 'C & D'. + Type 'C' is not assignable to type 'D'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(26,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A & B'. + Type 'C & D' is not assignable to type 'A & B'. + Type 'C & D' is not assignable to type 'A'. + Type 'D' is not assignable to type 'A'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(27,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A | B'. + Type 'C & D' is not assignable to type 'A | B'. + Type 'C & D' is not assignable to type 'B'. + Type 'D' is not assignable to type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(28,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C & D'. + Type 'A & B' is not assignable to type 'C & D'. + Type 'A & B' is not assignable to type 'C'. + Type 'B' is not assignable to type 'C'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(29,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C | D'. + Type 'A & B' is not assignable to type 'C | D'. + Type 'A & B' is not assignable to type 'D'. + Type 'B' is not assignable to type 'D'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(31,1): error TS2322: Type 'A & B' is not assignable to type '(A | B) & (C | D)'. + Type 'A & B' is not assignable to type 'C | D'. + Type 'A & B' is not assignable to type 'D'. + Type 'B' is not assignable to type 'D'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(32,1): error TS2322: Type 'A | B' is not assignable to type '(A | B) & (C | D)'. + Type 'A' is not assignable to type '(A | B) & (C | D)'. + Type 'A' is not assignable to type 'C | D'. + Type 'A' is not assignable to type 'D'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(33,1): error TS2322: Type 'C & D' is not assignable to type '(A | B) & (C | D)'. + Type 'C & D' is not assignable to type 'A | B'. + Type 'C & D' is not assignable to type 'B'. + Type 'D' is not assignable to type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(34,1): error TS2322: Type 'C | D' is not assignable to type '(A | B) & (C | D)'. + Type 'C' is not assignable to type '(A | B) & (C | D)'. + Type 'C' is not assignable to type 'A | B'. + Type 'C' is not assignable to type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(35,1): error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A & B'. + Type '(A | B) & (C | D)' is not assignable to type 'A'. + Type 'C | D' is not assignable to type 'A'. + Type 'C' is not assignable to type 'A'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C & D'. + Type '(A | B) & (C | D)' is not assignable to type 'C'. + Type 'C | D' is not assignable to type 'C'. + Type 'D' is not assignable to type 'C'. + + +==== tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts (14 errors) ==== + interface A { a: string } + interface B { b: string } + interface C { c: string } + interface D { d: string } + + var a: A; + var b: B; + var c: C; + var d: D; + var anb: A & B; + var aob: A | B; + var cnd: C & D; + var cod: C | D; + var x: A & B | C & D; + var y: (A | B) & (C | D); + + a = anb; // Ok + b = anb; // Ok + anb = a; + ~~~ +!!! error TS2322: Type 'A' is not assignable to type 'A & B'. +!!! error TS2322: Type 'A' is not assignable to type 'B'. + anb = b; + ~~~ +!!! error TS2322: Type 'B' is not assignable to type 'A & B'. +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Property 'a' is missing in type 'B'. + + x = anb; // Ok + x = aob; + ~ +!!! error TS2322: Type 'A | B' is not assignable to type '(A & B) | (C & D)'. +!!! error TS2322: Type 'A' is not assignable to type '(A & B) | (C & D)'. +!!! error TS2322: Type 'A' is not assignable to type 'C & D'. +!!! error TS2322: Type 'A' is not assignable to type 'C'. + x = cnd; // Ok + x = cod; + ~ +!!! error TS2322: Type 'C | D' is not assignable to type '(A & B) | (C & D)'. +!!! error TS2322: Type 'C' is not assignable to type '(A & B) | (C & D)'. +!!! error TS2322: Type 'C' is not assignable to type 'C & D'. +!!! error TS2322: Type 'C' is not assignable to type 'D'. + anb = x; + ~~~ +!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A & B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'A & B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'A'. +!!! error TS2322: Type 'D' is not assignable to type 'A'. + aob = x; + ~~~ +!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A | B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'A | B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'B'. +!!! error TS2322: Type 'D' is not assignable to type 'B'. + cnd = x; + ~~~ +!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C & D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'C & D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'C'. +!!! error TS2322: Type 'B' is not assignable to type 'C'. + cod = x; + ~~~ +!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C | D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'C | D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'D'. +!!! error TS2322: Type 'B' is not assignable to type 'D'. + + y = anb; + ~ +!!! error TS2322: Type 'A & B' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'A & B' is not assignable to type 'C | D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'D'. +!!! error TS2322: Type 'B' is not assignable to type 'D'. + y = aob; + ~ +!!! error TS2322: Type 'A | B' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'A' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'A' is not assignable to type 'C | D'. +!!! error TS2322: Type 'A' is not assignable to type 'D'. + y = cnd; + ~ +!!! error TS2322: Type 'C & D' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'C & D' is not assignable to type 'A | B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'B'. +!!! error TS2322: Type 'D' is not assignable to type 'B'. + y = cod; + ~ +!!! error TS2322: Type 'C | D' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'C' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'C' is not assignable to type 'A | B'. +!!! error TS2322: Type 'C' is not assignable to type 'B'. + anb = y; + ~~~ +!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A & B'. +!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A'. +!!! error TS2322: Type 'C | D' is not assignable to type 'A'. +!!! error TS2322: Type 'C' is not assignable to type 'A'. + aob = y; // Ok + cnd = y; + ~~~ +!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C & D'. +!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C'. +!!! error TS2322: Type 'C | D' is not assignable to type 'C'. +!!! error TS2322: Type 'D' is not assignable to type 'C'. + cod = y; // Ok + \ No newline at end of file diff --git a/tests/baselines/reference/intersectionAndUnionTypes.js b/tests/baselines/reference/intersectionAndUnionTypes.js new file mode 100644 index 00000000000..ec0adaab8b8 --- /dev/null +++ b/tests/baselines/reference/intersectionAndUnionTypes.js @@ -0,0 +1,72 @@ +//// [intersectionAndUnionTypes.ts] +interface A { a: string } +interface B { b: string } +interface C { c: string } +interface D { d: string } + +var a: A; +var b: B; +var c: C; +var d: D; +var anb: A & B; +var aob: A | B; +var cnd: C & D; +var cod: C | D; +var x: A & B | C & D; +var y: (A | B) & (C | D); + +a = anb; // Ok +b = anb; // Ok +anb = a; +anb = b; + +x = anb; // Ok +x = aob; +x = cnd; // Ok +x = cod; +anb = x; +aob = x; +cnd = x; +cod = x; + +y = anb; +y = aob; +y = cnd; +y = cod; +anb = y; +aob = y; // Ok +cnd = y; +cod = y; // Ok + + +//// [intersectionAndUnionTypes.js] +var a; +var b; +var c; +var d; +var anb; +var aob; +var cnd; +var cod; +var x; +var y; +a = anb; // Ok +b = anb; // Ok +anb = a; +anb = b; +x = anb; // Ok +x = aob; +x = cnd; // Ok +x = cod; +anb = x; +aob = x; +cnd = x; +cod = x; +y = anb; +y = aob; +y = cnd; +y = cod; +anb = y; +aob = y; // Ok +cnd = y; +cod = y; // Ok diff --git a/tests/baselines/reference/intersectionTypeAssignment.errors.txt b/tests/baselines/reference/intersectionTypeAssignment.errors.txt new file mode 100644 index 00000000000..11ea91d8f0e --- /dev/null +++ b/tests/baselines/reference/intersectionTypeAssignment.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(8,1): error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; b: string; }'. + Property 'b' is missing in type '{ a: string; }'. +tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(9,1): error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; } & { b: string; }'. + Type '{ a: string; }' is not assignable to type '{ b: string; }'. + Property 'b' is missing in type '{ a: string; }'. +tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(13,1): error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; b: string; }'. + Property 'a' is missing in type '{ b: string; }'. +tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(14,1): error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; } & { b: string; }'. + Type '{ b: string; }' is not assignable to type '{ a: string; }'. + Property 'a' is missing in type '{ b: string; }'. + + +==== tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts (4 errors) ==== + var a: { a: string }; + var b: { b: string }; + var x: { a: string, b: string }; + var y: { a: string } & { b: string }; + + a = x; + a = y; + x = a; // Error + ~ +!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Property 'b' is missing in type '{ a: string; }'. + y = a; // Error + ~ +!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; } & { b: string; }'. +!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ b: string; }'. +!!! error TS2322: Property 'b' is missing in type '{ a: string; }'. + + b = x; + b = y; + x = b; // Error + ~ +!!! error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Property 'a' is missing in type '{ b: string; }'. + y = b; // Error + ~ +!!! error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; } & { b: string; }'. +!!! error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; }'. +!!! error TS2322: Property 'a' is missing in type '{ b: string; }'. + + x = y; + y = x; + \ No newline at end of file diff --git a/tests/baselines/reference/intersectionTypeAssignment.js b/tests/baselines/reference/intersectionTypeAssignment.js new file mode 100644 index 00000000000..f1cddbf3b2a --- /dev/null +++ b/tests/baselines/reference/intersectionTypeAssignment.js @@ -0,0 +1,35 @@ +//// [intersectionTypeAssignment.ts] +var a: { a: string }; +var b: { b: string }; +var x: { a: string, b: string }; +var y: { a: string } & { b: string }; + +a = x; +a = y; +x = a; // Error +y = a; // Error + +b = x; +b = y; +x = b; // Error +y = b; // Error + +x = y; +y = x; + + +//// [intersectionTypeAssignment.js] +var a; +var b; +var x; +var y; +a = x; +a = y; +x = a; // Error +y = a; // Error +b = x; +b = y; +x = b; // Error +y = b; // Error +x = y; +y = x; diff --git a/tests/baselines/reference/intersectionTypeEquivalence.js b/tests/baselines/reference/intersectionTypeEquivalence.js new file mode 100644 index 00000000000..be04bfe7947 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeEquivalence.js @@ -0,0 +1,31 @@ +//// [intersectionTypeEquivalence.ts] +interface A { a: string } +interface B { b: string } +interface C { c: string } + +// A & B is equivalent to B & A. +var y: A & B; +var y : B & A; + +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z : A & B & C; +var z : (A & B) & C; +var z : A & (B & C); +var ab : A & B; +var bc : B & C; +var z1: typeof ab & C; +var z1: A & typeof bc; + + +//// [intersectionTypeEquivalence.js] +// A & B is equivalent to B & A. +var y; +var y; +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z; +var z; +var z; +var ab; +var bc; +var z1; +var z1; diff --git a/tests/baselines/reference/intersectionTypeEquivalence.symbols b/tests/baselines/reference/intersectionTypeEquivalence.symbols new file mode 100644 index 00000000000..2bec452c44e --- /dev/null +++ b/tests/baselines/reference/intersectionTypeEquivalence.symbols @@ -0,0 +1,63 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts === +interface A { a: string } +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>a : Symbol(a, Decl(intersectionTypeEquivalence.ts, 0, 13)) + +interface B { b: string } +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>b : Symbol(b, Decl(intersectionTypeEquivalence.ts, 1, 13)) + +interface C { c: string } +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) +>c : Symbol(c, Decl(intersectionTypeEquivalence.ts, 2, 13)) + +// A & B is equivalent to B & A. +var y: A & B; +>y : Symbol(y, Decl(intersectionTypeEquivalence.ts, 5, 3), Decl(intersectionTypeEquivalence.ts, 6, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) + +var y : B & A; +>y : Symbol(y, Decl(intersectionTypeEquivalence.ts, 5, 3), Decl(intersectionTypeEquivalence.ts, 6, 3)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) + +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z : A & B & C; +>z : Symbol(z, Decl(intersectionTypeEquivalence.ts, 9, 3), Decl(intersectionTypeEquivalence.ts, 10, 3), Decl(intersectionTypeEquivalence.ts, 11, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var z : (A & B) & C; +>z : Symbol(z, Decl(intersectionTypeEquivalence.ts, 9, 3), Decl(intersectionTypeEquivalence.ts, 10, 3), Decl(intersectionTypeEquivalence.ts, 11, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var z : A & (B & C); +>z : Symbol(z, Decl(intersectionTypeEquivalence.ts, 9, 3), Decl(intersectionTypeEquivalence.ts, 10, 3), Decl(intersectionTypeEquivalence.ts, 11, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var ab : A & B; +>ab : Symbol(ab, Decl(intersectionTypeEquivalence.ts, 12, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) + +var bc : B & C; +>bc : Symbol(bc, Decl(intersectionTypeEquivalence.ts, 13, 3)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var z1: typeof ab & C; +>z1 : Symbol(z1, Decl(intersectionTypeEquivalence.ts, 14, 3), Decl(intersectionTypeEquivalence.ts, 15, 3)) +>ab : Symbol(ab, Decl(intersectionTypeEquivalence.ts, 12, 3)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var z1: A & typeof bc; +>z1 : Symbol(z1, Decl(intersectionTypeEquivalence.ts, 14, 3), Decl(intersectionTypeEquivalence.ts, 15, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>bc : Symbol(bc, Decl(intersectionTypeEquivalence.ts, 13, 3)) + diff --git a/tests/baselines/reference/intersectionTypeEquivalence.types b/tests/baselines/reference/intersectionTypeEquivalence.types new file mode 100644 index 00000000000..25e175275d7 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeEquivalence.types @@ -0,0 +1,63 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts === +interface A { a: string } +>A : A +>a : string + +interface B { b: string } +>B : B +>b : string + +interface C { c: string } +>C : C +>c : string + +// A & B is equivalent to B & A. +var y: A & B; +>y : A & B +>A : A +>B : B + +var y : B & A; +>y : A & B +>B : B +>A : A + +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z : A & B & C; +>z : A & B & C +>A : A +>B : B +>C : C + +var z : (A & B) & C; +>z : A & B & C +>A : A +>B : B +>C : C + +var z : A & (B & C); +>z : A & B & C +>A : A +>B : B +>C : C + +var ab : A & B; +>ab : A & B +>A : A +>B : B + +var bc : B & C; +>bc : B & C +>B : B +>C : C + +var z1: typeof ab & C; +>z1 : A & B & C +>ab : A & B +>C : C + +var z1: A & typeof bc; +>z1 : A & B & C +>A : A +>bc : B & C + diff --git a/tests/baselines/reference/intersectionTypeInference.errors.txt b/tests/baselines/reference/intersectionTypeInference.errors.txt new file mode 100644 index 00000000000..af0b1b447bc --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference.errors.txt @@ -0,0 +1,41 @@ +tests/cases/conformance/types/intersection/intersectionTypeInference.ts(5,5): error TS2322: Type 'T' is not assignable to type 'T & U'. + Type 'T' is not assignable to type 'U'. +tests/cases/conformance/types/intersection/intersectionTypeInference.ts(6,5): error TS2322: Type 'U' is not assignable to type 'T & U'. + Type 'U' is not assignable to type 'T'. + + +==== tests/cases/conformance/types/intersection/intersectionTypeInference.ts (2 errors) ==== + function extend(obj1: T, obj2: U): T & U { + var result: T & U; + obj1 = result; + obj2 = result; + result = obj1; // Error + ~~~~~~ +!!! error TS2322: Type 'T' is not assignable to type 'T & U'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. + result = obj2; // Error + ~~~~~~ +!!! error TS2322: Type 'U' is not assignable to type 'T & U'. +!!! error TS2322: Type 'U' is not assignable to type 'T'. + return result; + } + + var x = extend({ a: "hello" }, { b: 42 }); + var s = x.a; + var n = x.b; + + interface A { + a: T; + } + + interface B { + b: U; + } + + function foo(obj: A & B): T | U { + return undefined; + } + + var z = foo({ a: "hello", b: 42 }); + var z: string | number; + \ No newline at end of file diff --git a/tests/baselines/reference/intersectionTypeInference.js b/tests/baselines/reference/intersectionTypeInference.js new file mode 100644 index 00000000000..8e7f1238c07 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference.js @@ -0,0 +1,47 @@ +//// [intersectionTypeInference.ts] +function extend(obj1: T, obj2: U): T & U { + var result: T & U; + obj1 = result; + obj2 = result; + result = obj1; // Error + result = obj2; // Error + return result; +} + +var x = extend({ a: "hello" }, { b: 42 }); +var s = x.a; +var n = x.b; + +interface A { + a: T; +} + +interface B { + b: U; +} + +function foo(obj: A & B): T | U { + return undefined; +} + +var z = foo({ a: "hello", b: 42 }); +var z: string | number; + + +//// [intersectionTypeInference.js] +function extend(obj1, obj2) { + var result; + obj1 = result; + obj2 = result; + result = obj1; // Error + result = obj2; // Error + return result; +} +var x = extend({ a: "hello" }, { b: 42 }); +var s = x.a; +var n = x.b; +function foo(obj) { + return undefined; +} +var z = foo({ a: "hello", b: 42 }); +var z; diff --git a/tests/baselines/reference/intersectionTypeMembers.js b/tests/baselines/reference/intersectionTypeMembers.js new file mode 100644 index 00000000000..9c1cd75d601 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeMembers.js @@ -0,0 +1,44 @@ +//// [intersectionTypeMembers.ts] +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types + +interface A { a: string } +interface B { b: string } +interface C { c: string } + +var abc: A & B & C; +abc.a = "hello"; +abc.b = "hello"; +abc.c = "hello"; + +interface X { x: A } +interface Y { x: B } +interface Z { x: C } + +var xyz: X & Y & Z; +xyz.x.a = "hello"; +xyz.x.b = "hello"; +xyz.x.c = "hello"; + +type F1 = (x: string) => string; +type F2 = (x: number) => number; + +var f: F1 & F2; +var s = f("hello"); +var n = f(42); + + +//// [intersectionTypeMembers.js] +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types +var abc; +abc.a = "hello"; +abc.b = "hello"; +abc.c = "hello"; +var xyz; +xyz.x.a = "hello"; +xyz.x.b = "hello"; +xyz.x.c = "hello"; +var f; +var s = f("hello"); +var n = f(42); diff --git a/tests/baselines/reference/intersectionTypeMembers.symbols b/tests/baselines/reference/intersectionTypeMembers.symbols new file mode 100644 index 00000000000..ebec69b4ebe --- /dev/null +++ b/tests/baselines/reference/intersectionTypeMembers.symbols @@ -0,0 +1,100 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeMembers.ts === +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types + +interface A { a: string } +>A : Symbol(A, Decl(intersectionTypeMembers.ts, 0, 0)) +>a : Symbol(a, Decl(intersectionTypeMembers.ts, 3, 13)) + +interface B { b: string } +>B : Symbol(B, Decl(intersectionTypeMembers.ts, 3, 25)) +>b : Symbol(b, Decl(intersectionTypeMembers.ts, 4, 13)) + +interface C { c: string } +>C : Symbol(C, Decl(intersectionTypeMembers.ts, 4, 25)) +>c : Symbol(c, Decl(intersectionTypeMembers.ts, 5, 13)) + +var abc: A & B & C; +>abc : Symbol(abc, Decl(intersectionTypeMembers.ts, 7, 3)) +>A : Symbol(A, Decl(intersectionTypeMembers.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeMembers.ts, 3, 25)) +>C : Symbol(C, Decl(intersectionTypeMembers.ts, 4, 25)) + +abc.a = "hello"; +>abc.a : Symbol(A.a, Decl(intersectionTypeMembers.ts, 3, 13)) +>abc : Symbol(abc, Decl(intersectionTypeMembers.ts, 7, 3)) +>a : Symbol(A.a, Decl(intersectionTypeMembers.ts, 3, 13)) + +abc.b = "hello"; +>abc.b : Symbol(B.b, Decl(intersectionTypeMembers.ts, 4, 13)) +>abc : Symbol(abc, Decl(intersectionTypeMembers.ts, 7, 3)) +>b : Symbol(B.b, Decl(intersectionTypeMembers.ts, 4, 13)) + +abc.c = "hello"; +>abc.c : Symbol(C.c, Decl(intersectionTypeMembers.ts, 5, 13)) +>abc : Symbol(abc, Decl(intersectionTypeMembers.ts, 7, 3)) +>c : Symbol(C.c, Decl(intersectionTypeMembers.ts, 5, 13)) + +interface X { x: A } +>X : Symbol(X, Decl(intersectionTypeMembers.ts, 10, 16)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13)) +>A : Symbol(A, Decl(intersectionTypeMembers.ts, 0, 0)) + +interface Y { x: B } +>Y : Symbol(Y, Decl(intersectionTypeMembers.ts, 12, 20)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 13, 13)) +>B : Symbol(B, Decl(intersectionTypeMembers.ts, 3, 25)) + +interface Z { x: C } +>Z : Symbol(Z, Decl(intersectionTypeMembers.ts, 13, 20)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 14, 13)) +>C : Symbol(C, Decl(intersectionTypeMembers.ts, 4, 25)) + +var xyz: X & Y & Z; +>xyz : Symbol(xyz, Decl(intersectionTypeMembers.ts, 16, 3)) +>X : Symbol(X, Decl(intersectionTypeMembers.ts, 10, 16)) +>Y : Symbol(Y, Decl(intersectionTypeMembers.ts, 12, 20)) +>Z : Symbol(Z, Decl(intersectionTypeMembers.ts, 13, 20)) + +xyz.x.a = "hello"; +>xyz.x.a : Symbol(A.a, Decl(intersectionTypeMembers.ts, 3, 13)) +>xyz.x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>xyz : Symbol(xyz, Decl(intersectionTypeMembers.ts, 16, 3)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>a : Symbol(A.a, Decl(intersectionTypeMembers.ts, 3, 13)) + +xyz.x.b = "hello"; +>xyz.x.b : Symbol(B.b, Decl(intersectionTypeMembers.ts, 4, 13)) +>xyz.x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>xyz : Symbol(xyz, Decl(intersectionTypeMembers.ts, 16, 3)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>b : Symbol(B.b, Decl(intersectionTypeMembers.ts, 4, 13)) + +xyz.x.c = "hello"; +>xyz.x.c : Symbol(C.c, Decl(intersectionTypeMembers.ts, 5, 13)) +>xyz.x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>xyz : Symbol(xyz, Decl(intersectionTypeMembers.ts, 16, 3)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>c : Symbol(C.c, Decl(intersectionTypeMembers.ts, 5, 13)) + +type F1 = (x: string) => string; +>F1 : Symbol(F1, Decl(intersectionTypeMembers.ts, 19, 18)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 21, 11)) + +type F2 = (x: number) => number; +>F2 : Symbol(F2, Decl(intersectionTypeMembers.ts, 21, 32)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 22, 11)) + +var f: F1 & F2; +>f : Symbol(f, Decl(intersectionTypeMembers.ts, 24, 3)) +>F1 : Symbol(F1, Decl(intersectionTypeMembers.ts, 19, 18)) +>F2 : Symbol(F2, Decl(intersectionTypeMembers.ts, 21, 32)) + +var s = f("hello"); +>s : Symbol(s, Decl(intersectionTypeMembers.ts, 25, 3)) +>f : Symbol(f, Decl(intersectionTypeMembers.ts, 24, 3)) + +var n = f(42); +>n : Symbol(n, Decl(intersectionTypeMembers.ts, 26, 3)) +>f : Symbol(f, Decl(intersectionTypeMembers.ts, 24, 3)) + diff --git a/tests/baselines/reference/intersectionTypeMembers.types b/tests/baselines/reference/intersectionTypeMembers.types new file mode 100644 index 00000000000..a97a54c7a81 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeMembers.types @@ -0,0 +1,116 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeMembers.ts === +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types + +interface A { a: string } +>A : A +>a : string + +interface B { b: string } +>B : B +>b : string + +interface C { c: string } +>C : C +>c : string + +var abc: A & B & C; +>abc : A & B & C +>A : A +>B : B +>C : C + +abc.a = "hello"; +>abc.a = "hello" : string +>abc.a : string +>abc : A & B & C +>a : string +>"hello" : string + +abc.b = "hello"; +>abc.b = "hello" : string +>abc.b : string +>abc : A & B & C +>b : string +>"hello" : string + +abc.c = "hello"; +>abc.c = "hello" : string +>abc.c : string +>abc : A & B & C +>c : string +>"hello" : string + +interface X { x: A } +>X : X +>x : A +>A : A + +interface Y { x: B } +>Y : Y +>x : B +>B : B + +interface Z { x: C } +>Z : Z +>x : C +>C : C + +var xyz: X & Y & Z; +>xyz : X & Y & Z +>X : X +>Y : Y +>Z : Z + +xyz.x.a = "hello"; +>xyz.x.a = "hello" : string +>xyz.x.a : string +>xyz.x : A & B & C +>xyz : X & Y & Z +>x : A & B & C +>a : string +>"hello" : string + +xyz.x.b = "hello"; +>xyz.x.b = "hello" : string +>xyz.x.b : string +>xyz.x : A & B & C +>xyz : X & Y & Z +>x : A & B & C +>b : string +>"hello" : string + +xyz.x.c = "hello"; +>xyz.x.c = "hello" : string +>xyz.x.c : string +>xyz.x : A & B & C +>xyz : X & Y & Z +>x : A & B & C +>c : string +>"hello" : string + +type F1 = (x: string) => string; +>F1 : (x: string) => string +>x : string + +type F2 = (x: number) => number; +>F2 : (x: number) => number +>x : number + +var f: F1 & F2; +>f : ((x: string) => string) & ((x: number) => number) +>F1 : (x: string) => string +>F2 : (x: number) => number + +var s = f("hello"); +>s : string +>f("hello") : string +>f : ((x: string) => string) & ((x: number) => number) +>"hello" : string + +var n = f(42); +>n : number +>f(42) : number +>f : ((x: string) => string) & ((x: number) => number) +>42 : number + diff --git a/tests/baselines/reference/intersectionTypeOverloading.js b/tests/baselines/reference/intersectionTypeOverloading.js new file mode 100644 index 00000000000..b7080e449b7 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeOverloading.js @@ -0,0 +1,26 @@ +//// [intersectionTypeOverloading.ts] +// Check that order is preserved in intersection types for purposes of +// overload resolution + +type F = (s: string) => string; +type G = (x: any) => any; + +var fg: F & G; +var gf: G & F; + +var x = fg("abc"); +var x: string; + +var y = gf("abc"); +var y: any; + + +//// [intersectionTypeOverloading.js] +// Check that order is preserved in intersection types for purposes of +// overload resolution +var fg; +var gf; +var x = fg("abc"); +var x; +var y = gf("abc"); +var y; diff --git a/tests/baselines/reference/intersectionTypeOverloading.symbols b/tests/baselines/reference/intersectionTypeOverloading.symbols new file mode 100644 index 00000000000..c8503345041 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeOverloading.symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts === +// Check that order is preserved in intersection types for purposes of +// overload resolution + +type F = (s: string) => string; +>F : Symbol(F, Decl(intersectionTypeOverloading.ts, 0, 0)) +>s : Symbol(s, Decl(intersectionTypeOverloading.ts, 3, 10)) + +type G = (x: any) => any; +>G : Symbol(G, Decl(intersectionTypeOverloading.ts, 3, 31)) +>x : Symbol(x, Decl(intersectionTypeOverloading.ts, 4, 10)) + +var fg: F & G; +>fg : Symbol(fg, Decl(intersectionTypeOverloading.ts, 6, 3)) +>F : Symbol(F, Decl(intersectionTypeOverloading.ts, 0, 0)) +>G : Symbol(G, Decl(intersectionTypeOverloading.ts, 3, 31)) + +var gf: G & F; +>gf : Symbol(gf, Decl(intersectionTypeOverloading.ts, 7, 3)) +>G : Symbol(G, Decl(intersectionTypeOverloading.ts, 3, 31)) +>F : Symbol(F, Decl(intersectionTypeOverloading.ts, 0, 0)) + +var x = fg("abc"); +>x : Symbol(x, Decl(intersectionTypeOverloading.ts, 9, 3), Decl(intersectionTypeOverloading.ts, 10, 3)) +>fg : Symbol(fg, Decl(intersectionTypeOverloading.ts, 6, 3)) + +var x: string; +>x : Symbol(x, Decl(intersectionTypeOverloading.ts, 9, 3), Decl(intersectionTypeOverloading.ts, 10, 3)) + +var y = gf("abc"); +>y : Symbol(y, Decl(intersectionTypeOverloading.ts, 12, 3), Decl(intersectionTypeOverloading.ts, 13, 3)) +>gf : Symbol(gf, Decl(intersectionTypeOverloading.ts, 7, 3)) + +var y: any; +>y : Symbol(y, Decl(intersectionTypeOverloading.ts, 12, 3), Decl(intersectionTypeOverloading.ts, 13, 3)) + diff --git a/tests/baselines/reference/intersectionTypeOverloading.types b/tests/baselines/reference/intersectionTypeOverloading.types new file mode 100644 index 00000000000..c478b6a08cb --- /dev/null +++ b/tests/baselines/reference/intersectionTypeOverloading.types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts === +// Check that order is preserved in intersection types for purposes of +// overload resolution + +type F = (s: string) => string; +>F : (s: string) => string +>s : string + +type G = (x: any) => any; +>G : (x: any) => any +>x : any + +var fg: F & G; +>fg : ((s: string) => string) & ((x: any) => any) +>F : (s: string) => string +>G : (x: any) => any + +var gf: G & F; +>gf : ((x: any) => any) & ((s: string) => string) +>G : (x: any) => any +>F : (s: string) => string + +var x = fg("abc"); +>x : string +>fg("abc") : string +>fg : ((s: string) => string) & ((x: any) => any) +>"abc" : string + +var x: string; +>x : string + +var y = gf("abc"); +>y : any +>gf("abc") : any +>gf : ((x: any) => any) & ((s: string) => string) +>"abc" : string + +var y: any; +>y : any + diff --git a/tests/baselines/reference/iterableArrayPattern1.symbols b/tests/baselines/reference/iterableArrayPattern1.symbols index c6025123179..3920dc1cef4 100644 --- a/tests/baselines/reference/iterableArrayPattern1.symbols +++ b/tests/baselines/reference/iterableArrayPattern1.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern1.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern1.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 32)) diff --git a/tests/baselines/reference/iterableArrayPattern11.symbols b/tests/baselines/reference/iterableArrayPattern11.symbols index 07b1fb52af8..06e38c57af4 100644 --- a/tests/baselines/reference/iterableArrayPattern11.symbols +++ b/tests/baselines/reference/iterableArrayPattern11.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern12.symbols b/tests/baselines/reference/iterableArrayPattern12.symbols index 001cb99b486..e16fe5255e4 100644 --- a/tests/baselines/reference/iterableArrayPattern12.symbols +++ b/tests/baselines/reference/iterableArrayPattern12.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern13.symbols b/tests/baselines/reference/iterableArrayPattern13.symbols index 7085fd224f4..b8709197829 100644 --- a/tests/baselines/reference/iterableArrayPattern13.symbols +++ b/tests/baselines/reference/iterableArrayPattern13.symbols @@ -35,9 +35,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern2.symbols b/tests/baselines/reference/iterableArrayPattern2.symbols index 09a6984cb3c..17ac6a1feac 100644 --- a/tests/baselines/reference/iterableArrayPattern2.symbols +++ b/tests/baselines/reference/iterableArrayPattern2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern2.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern2.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 35)) diff --git a/tests/baselines/reference/iterableArrayPattern3.symbols b/tests/baselines/reference/iterableArrayPattern3.symbols index 4ee65a10825..468866ca324 100644 --- a/tests/baselines/reference/iterableArrayPattern3.symbols +++ b/tests/baselines/reference/iterableArrayPattern3.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern30.symbols b/tests/baselines/reference/iterableArrayPattern30.symbols index 38dacc59cc2..6f0d347d9b4 100644 --- a/tests/baselines/reference/iterableArrayPattern30.symbols +++ b/tests/baselines/reference/iterableArrayPattern30.symbols @@ -4,5 +4,5 @@ const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]]) >v1 : Symbol(v1, Decl(iterableArrayPattern30.ts, 0, 11)) >k2 : Symbol(k2, Decl(iterableArrayPattern30.ts, 0, 18)) >v2 : Symbol(v2, Decl(iterableArrayPattern30.ts, 0, 21)) ->Map : Symbol(Map, Decl(lib.d.ts, 1864, 1), Decl(lib.d.ts, 1887, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) diff --git a/tests/baselines/reference/iterableArrayPattern4.symbols b/tests/baselines/reference/iterableArrayPattern4.symbols index aa5ce5783a0..10225e183e6 100644 --- a/tests/baselines/reference/iterableArrayPattern4.symbols +++ b/tests/baselines/reference/iterableArrayPattern4.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern9.symbols b/tests/baselines/reference/iterableArrayPattern9.symbols index 01cfba0f09e..86c46812688 100644 --- a/tests/baselines/reference/iterableArrayPattern9.symbols +++ b/tests/baselines/reference/iterableArrayPattern9.symbols @@ -32,9 +32,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern9.ts, 2, 27)) diff --git a/tests/baselines/reference/iterableContextualTyping1.symbols b/tests/baselines/reference/iterableContextualTyping1.symbols index a900c56ecab..ae99a4b5255 100644 --- a/tests/baselines/reference/iterableContextualTyping1.symbols +++ b/tests/baselines/reference/iterableContextualTyping1.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts === var iter: Iterable<(x: string) => number> = [s => s.length]; >iter : Symbol(iter, Decl(iterableContextualTyping1.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) >x : Symbol(x, Decl(iterableContextualTyping1.ts, 0, 20)) >s : Symbol(s, Decl(iterableContextualTyping1.ts, 0, 45)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) diff --git a/tests/baselines/reference/iteratorSpreadInArray.symbols b/tests/baselines/reference/iteratorSpreadInArray.symbols index f53e8266baa..c4a2459e262 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 36)) diff --git a/tests/baselines/reference/iteratorSpreadInArray11.symbols b/tests/baselines/reference/iteratorSpreadInArray11.symbols index 548e026744a..c2fce062fb0 100644 --- a/tests/baselines/reference/iteratorSpreadInArray11.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray11.ts === var iter: Iterable; >iter : Symbol(iter, Decl(iteratorSpreadInArray11.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) var array = [...iter]; >array : Symbol(array, Decl(iteratorSpreadInArray11.ts, 1, 3)) diff --git a/tests/baselines/reference/iteratorSpreadInArray2.symbols b/tests/baselines/reference/iteratorSpreadInArray2.symbols index db8da1bac9d..cdc7bb3e2bc 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 5, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 59)) @@ -48,9 +48,9 @@ class NumberIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 13, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInArray3.symbols b/tests/baselines/reference/iteratorSpreadInArray3.symbols index bdc200c25ec..e4d1b508bb5 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray3.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray3.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray3.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 47)) diff --git a/tests/baselines/reference/iteratorSpreadInArray4.symbols b/tests/baselines/reference/iteratorSpreadInArray4.symbols index c49ea74dc23..bd6760dd0aa 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray4.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray4.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray4.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInArray7.symbols b/tests/baselines/reference/iteratorSpreadInArray7.symbols index e7fbdac2264..d0bc9790752 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray7.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray7.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray7.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) diff --git a/tests/baselines/reference/iteratorSpreadInCall11.symbols b/tests/baselines/reference/iteratorSpreadInCall11.symbols index 54ac770c5df..a7e5d7b8919 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall11.symbols @@ -19,7 +19,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall11.ts, 6, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall11.ts, 7, 28)) @@ -28,9 +28,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 2, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInCall12.symbols b/tests/baselines/reference/iteratorSpreadInCall12.symbols index 8b24ba5d1b7..67b9e9e500d 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall12.symbols @@ -22,7 +22,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 8, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 9, 28)) @@ -31,9 +31,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 4, 1)) @@ -57,9 +57,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 17, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall3.symbols b/tests/baselines/reference/iteratorSpreadInCall3.symbols index d43a7f9b4fc..0c3c11c84f4 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall3.symbols @@ -16,7 +16,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall3.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall3.ts, 6, 28)) @@ -25,9 +25,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 2, 32)) diff --git a/tests/baselines/reference/iteratorSpreadInCall5.symbols b/tests/baselines/reference/iteratorSpreadInCall5.symbols index 9d86858eb8e..03faf4b593e 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall5.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 2, 43)) @@ -52,9 +52,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 14, 1)) diff --git a/tests/baselines/reference/jsxAndTypeAssertion.errors.txt b/tests/baselines/reference/jsxAndTypeAssertion.errors.txt new file mode 100644 index 00000000000..aebabf15133 --- /dev/null +++ b/tests/baselines/reference/jsxAndTypeAssertion.errors.txt @@ -0,0 +1,49 @@ +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(7,13): error TS2304: Cannot find name 'test'. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(7,17): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(11,32): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(13,36): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(15,45): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS1005: ':' expected. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS17002: Expected corresponding JSX closing tag for 'any'. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(22,1): error TS17002: Expected corresponding JSX closing tag for 'foo'. + + +==== tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx (8 errors) ==== + + declare var createElement: any; + + class foo {} + + var x: any; + x = { test: }; + ~~~~ +!!! error TS2304: Cannot find name 'test'. + ~ +!!! error TS1005: '}' expected. + + x = ; + + x = hello {{}} ; + ~ +!!! error TS1005: '}' expected. + + x = {}}>hello; + ~ +!!! error TS1005: '}' expected. + + x = {}}>hello{{}}; + ~ +!!! error TS1005: '}' expected. + + x = x, x = ; + + {{/foo/.test(x) ? : }} + + + + +!!! error TS1005: ':' expected. + +!!! error TS17002: Expected corresponding JSX closing tag for 'any'. + +!!! error TS17002: Expected corresponding JSX closing tag for 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/jsxAndTypeAssertion.js b/tests/baselines/reference/jsxAndTypeAssertion.js new file mode 100644 index 00000000000..0b402b43de2 --- /dev/null +++ b/tests/baselines/reference/jsxAndTypeAssertion.js @@ -0,0 +1,49 @@ +//// [jsxAndTypeAssertion.tsx] + +declare var createElement: any; + +class foo {} + +var x: any; +x = { test: }; + +x = ; + +x = hello {{}} ; + +x = {}}>hello; + +x = {}}>hello{{}}; + +x = x, x = ; + +{{/foo/.test(x) ? : }} + + + + +//// [jsxAndTypeAssertion.jsx] +var foo = (function () { + function foo() { + } + return foo; +})(); +var x; +x = {test}: }; + +x = ; + +x = hello {} }; + +x = }>hello}/>; + +x = }>hello{}}; + +x = x, x = ; + +{{/foo/.test(x) ? : }} + : +} + + +}}/>; diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt b/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt new file mode 100644 index 00000000000..5758db36960 --- /dev/null +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt @@ -0,0 +1,81 @@ +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,17): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,23): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,29): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,57): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(39,58): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(41,1): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(41,6): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(41,12): error TS1109: Expression expected. + + +==== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx (8 errors) ==== + declare var React: any; + declare var 日本語; + declare var AbC_def; + declare var LeftRight; + declare var x; + declare var a; + declare var props; + + ; + + //; Namespace unsuported + + // {value} ; Namespace unsuported + + ; + + ; + ; + + <日本語>; + + + bar + baz + ; + + : } />; + + {}; + + {/* this is a comment */}; + +
@test content
; + +

7x invalid-js-identifier
; + + right=monkeys /> gorillas />; + ~ +!!! error TS1005: '{' expected. + ~~~~~ +!!! error TS1005: '}' expected. + ~ +!!! error TS1005: '{' expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + + ; + ~ +!!! error TS1003: Identifier expected. + ~~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + + ; + + (
) < x; + +
; + +
; + +
; + + ; + \ No newline at end of file diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.js b/tests/baselines/reference/jsxEsprimaFbTestSuite.js new file mode 100644 index 00000000000..1e22826f440 --- /dev/null +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.js @@ -0,0 +1,82 @@ +//// [jsxEsprimaFbTestSuite.tsx] +declare var React: any; +declare var 日本語; +declare var AbC_def; +declare var LeftRight; +declare var x; +declare var a; +declare var props; + +; + +//; Namespace unsuported + +// {value} ; Namespace unsuported + +; + +; +; + +<日本語>; + + +bar +baz +; + + : } />; + +{}; + +{/* this is a comment */}; + +
@test content
; + +

7x invalid-js-identifier
; + + right=monkeys /> gorillas />; + +; + +; + +(
) < x; + +
; + +
; + +
; + + ; + + +//// [jsxEsprimaFbTestSuite.jsx] +; +//; Namespace unsuported +// {value} ; Namespace unsuported +; +; +; +<日本語>; + +bar +baz +; + : }/>; +; +; +
@test content
; +

7x invalid-js-identifier
; +} right={monkeys /> gorillas / > }/> + < a.b > ; +a.b > ; +; +(
) < x; +
; +
; +
; + ; diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt new file mode 100644 index 00000000000..3e2a10e9931 --- /dev/null +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt @@ -0,0 +1,251 @@ +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,3): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,4): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,1): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,2): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,3): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,6): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,7): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,6): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,6): error TS2304: Cannot find name 'd'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,9): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,10): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,1): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,4): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(8,4): error TS17002: Expected corresponding JSX closing tag for 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(9,13): error TS1002: Unterminated string literal. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,1): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,3): error TS1005: ';' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,4): error TS2304: Cannot find name 'b'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,6): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,8): error TS2304: Cannot find name 'b'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,10): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,5): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,11): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,12): error TS2304: Cannot find name 'b'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,16): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,5): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,13): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,14): error TS2304: Cannot find name 'c'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,16): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,8): error TS17002: Expected corresponding JSX closing tag for 'a.b.c'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,1): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,2): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,5): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,7): error TS1128: Declaration or statement expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,8): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,10): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,4): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,9): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,4): error TS2304: Cannot find name 'foo'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,9): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,11): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,13): error TS2304: Cannot find name 'foo'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,18): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,11): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,13): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,22): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(22,10): error TS1005: '}' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(23,20): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(24,15): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(25,7): error TS1005: '...' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(25,7): error TS2304: Cannot find name 'props'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(27,17): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(27,18): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,10): error TS2304: Cannot find name 'props'. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,28): error TS1005: '>' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,29): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(32,6): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,6): error TS1005: '{' expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,7): error TS1109: Expression expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,4): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002: Expected corresponding JSX closing tag for 'a'. + + +==== tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx (71 errors) ==== + declare var React: any; + + ; + ~~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + ; + ~ +!!! error TS1003: Identifier expected. + <:a />; + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + ; + ~ +!!! error TS1005: '{' expected. + ~ +!!! error TS2304: Cannot find name 'd'. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + ; + ~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1109: Expression expected. + ; + ~~~~ +!!! error TS17002: Expected corresponding JSX closing tag for 'a'. + ; + ~ +!!! error TS1005: '}' expected. + ; + ~ +!!! error TS1003: Identifier expected. +
; + ~~~~~ +!!! error TS1003: Identifier expected. +
; + ~~~~~ +!!! error TS1005: '...' expected. + ~~~~~ +!!! error TS2304: Cannot find name 'props'. + +
stuff
; + ~ +!!! error TS1005: '>' expected. + ~~~ +!!! error TS1109: Expression expected. +
stuff
; + ~~~~~ +!!! error TS2304: Cannot find name 'props'. + ~ +!!! error TS1005: '>' expected. + ~~~ +!!! error TS1109: Expression expected. + +
>; + >; + ; + ~ +!!! error TS1005: '{' expected. + ; + ~ +!!! error TS1005: '{' expected. + ~ +!!! error TS1109: Expression expected. + }; + ; + ~~~ +!!! error TS1003: Identifier expected. + +!!! error TS17002: Expected corresponding JSX closing tag for 'a'. \ No newline at end of file diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js new file mode 100644 index 00000000000..13808cc29e0 --- /dev/null +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js @@ -0,0 +1,81 @@ +//// [jsxInvalidEsprimaTestSuite.tsx] +declare var React: any; + +; +; +<:a />; +; +; +
; +; +; +
; +
; + +
stuff
; +
stuff
; + +
>; + >; +; +; +}; +; + +//// [jsxInvalidEsprimaTestSuite.jsx] + > ; +; + < ; +a / > ; + }/> + < a > ; +; +; +, id="b" />; +
"app">; +
; + +
stuff
{}...props}>; +
stuff
{}...props}>; + +
>; + >; +; +; +}; + .../*hai*/asdf/>;; diff --git a/tests/baselines/reference/jsxReactTestSuite.js b/tests/baselines/reference/jsxReactTestSuite.js new file mode 100644 index 00000000000..300274a1614 --- /dev/null +++ b/tests/baselines/reference/jsxReactTestSuite.js @@ -0,0 +1,171 @@ +//// [jsxReactTestSuite.tsx] + +declare var React: any; +declare var Component:any; +declare var Composite:any; +declare var Composite2:any; +declare var Child:any; +declare var Namespace:any; +declare var foo: any; +declare var bar: any; +declare var y:any; +declare var x:any; +declare var z:any; +declare var hasOwnProperty:any; + +
text
; + +
+ {this.props.children} +
; + +
+

+ {foo}
{bar}
+
+
; + + + + {this.props.children} +; + + + +; + +var x = +
+
; + +( +
+ {/* A comment at the beginning */} + {/* A second comment at the beginning */} + + {/* A nested comment */} + + {/* A sandwiched comment */} +
+ {/* A comment at the end */} + {/* A second comment at the end */} +
+); + +( +
+ +
+); + +
 
; + +
 
; + +testing; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + + +; + +Text; + + + + +//// [jsxReactTestSuite.jsx] +
text
; +
+ {this.props.children} +
; +
+

+ {foo}
{bar}
+
+
; + + {this.props.children} +; + + +; +var x =
+
; +(
+ + + + + + +
+ + +
); +(
+ +
); +
 
; +
 
; +testing; +; +; +; +; +; +; +; +; +; +; +; +; +; +Text; diff --git a/tests/baselines/reference/jsxReactTestSuite.symbols b/tests/baselines/reference/jsxReactTestSuite.symbols new file mode 100644 index 00000000000..9e382742f0d --- /dev/null +++ b/tests/baselines/reference/jsxReactTestSuite.symbols @@ -0,0 +1,194 @@ +=== tests/cases/conformance/jsx/jsxReactTestSuite.tsx === + +declare var React: any; +>React : Symbol(React, Decl(jsxReactTestSuite.tsx, 1, 11)) + +declare var Component:any; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) + +declare var Composite:any; +>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11)) + +declare var Composite2:any; +>Composite2 : Symbol(Composite2, Decl(jsxReactTestSuite.tsx, 4, 11)) + +declare var Child:any; +>Child : Symbol(Child, Decl(jsxReactTestSuite.tsx, 5, 11)) + +declare var Namespace:any; +>Namespace : Symbol(Namespace, Decl(jsxReactTestSuite.tsx, 6, 11)) + +declare var foo: any; +>foo : Symbol(foo, Decl(jsxReactTestSuite.tsx, 7, 11)) + +declare var bar: any; +>bar : Symbol(bar, Decl(jsxReactTestSuite.tsx, 8, 11)) + +declare var y:any; +>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 9, 11)) + +declare var x:any; +>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3)) + +declare var z:any; +>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) + +declare var hasOwnProperty:any; +>hasOwnProperty : Symbol(hasOwnProperty, Decl(jsxReactTestSuite.tsx, 12, 11)) + +
text
; + +
+ {this.props.children} +
; + +
+

+ {foo}
{bar}
+>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) + +
+
; + + + +>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11)) + + {this.props.children} +; + + +>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11)) + + +>Composite2 : Symbol(Composite2, Decl(jsxReactTestSuite.tsx, 4, 11)) + +; + +var x = +>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3)) + +
attr1 : Symbol(unknown) + + "foo" + "bar" + } + attr2={ +>attr2 : Symbol(unknown) + + "foo" + "bar" + + + "baz" + "bug" + } + attr3={ +>attr3 : Symbol(unknown) + + "foo" + "bar" + + "baz" + "bug" + // Extra line here. + } + attr4="baz"> +>attr4 : Symbol(unknown) + +
; + +( +
+ {/* A comment at the beginning */} + {/* A second comment at the beginning */} + + {/* A nested comment */} + + {/* A sandwiched comment */} +
+ {/* A comment at the end */} + {/* A second comment at the end */} +
+); + +( +
+>attr1 : Symbol(unknown) + + attr2 : Symbol(unknown) + + /> +
+); + +
 
; + +
 
; + +testing; + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>constructor : Symbol(unknown) + +; +>Component : Symbol(unknown) + +; +>Component : Symbol(unknown) + +Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>y : Symbol(unknown) + +={2 } z />; +>z : Symbol(unknown) + +Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) + + {...this.props} sound="moo" />; +>sound : Symbol(unknown) + +; + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(unknown) + +; + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>y : Symbol(unknown) + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>y : Symbol(unknown) +>z : Symbol(unknown) + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(unknown) + + +; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(unknown) +>y : Symbol(unknown) +>Child : Symbol(Child, Decl(jsxReactTestSuite.tsx, 5, 11)) + +Text; +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(unknown) +>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) +>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 113, 27)) +>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) +>z : Symbol(unknown) + + + diff --git a/tests/baselines/reference/jsxReactTestSuite.types b/tests/baselines/reference/jsxReactTestSuite.types new file mode 100644 index 00000000000..db7ebf8d912 --- /dev/null +++ b/tests/baselines/reference/jsxReactTestSuite.types @@ -0,0 +1,332 @@ +=== tests/cases/conformance/jsx/jsxReactTestSuite.tsx === + +declare var React: any; +>React : any + +declare var Component:any; +>Component : any + +declare var Composite:any; +>Composite : any + +declare var Composite2:any; +>Composite2 : any + +declare var Child:any; +>Child : any + +declare var Namespace:any; +>Namespace : any + +declare var foo: any; +>foo : any + +declare var bar: any; +>bar : any + +declare var y:any; +>y : any + +declare var x:any; +>x : any + +declare var z:any; +>z : any + +declare var hasOwnProperty:any; +>hasOwnProperty : any + +
text
; +>
text
: any +>div : any +>div : any + +
+>
{this.props.children}
: any +>div : any + + {this.props.children} +>this.props.children : any +>this.props : any +>this : any +>props : any +>children : any + +
; +>div : any + +
+>

{foo}
{bar}

: any +>div : any + +

+>

: any +>div : any +>
: any +>br : any +>div : any + + {foo}
{bar}
+>{foo}
{bar}
: any +>Component : any +>foo : any +>
: any +>br : any +>bar : any +>Component : any + +
+>
: any +>br : any + +
; +>div : any + + + +> {this.props.children} : any +>Composite : any + + {this.props.children} +>this.props.children : any +>this.props : any +>this : any +>props : any +>children : any + +; +>Composite : any + + +> : any +>Composite : any + + +> : any +>Composite2 : any + +; +>Composite : any + +var x = +>x : any + +
: any +>div : any + + attr1={ +>attr1 : any + + "foo" + "bar" +>"foo" + "bar" : string +>"foo" : string +>"bar" : string + } + attr2={ +>attr2 : any + + "foo" + "bar" + +>"foo" + "bar" + "baz" + "bug" : string +>"foo" + "bar" + "baz" : string +>"foo" + "bar" : string +>"foo" : string +>"bar" : string + + "baz" + "bug" +>"baz" : string +>"bug" : string + } + attr3={ +>attr3 : any + + "foo" + "bar" + +>"foo" + "bar" + "baz" + "bug" : string +>"foo" + "bar" + "baz" : string +>"foo" + "bar" : string +>"foo" : string +>"bar" : string + + "baz" + "bug" +>"baz" : string +>"bug" : string + + // Extra line here. + } + attr4="baz"> +>attr4 : any + +
; +>div : any + +( +>(
{/* A comment at the beginning */} {/* A second comment at the beginning */} {/* A nested comment */} {/* A sandwiched comment */}
{/* A comment at the end */} {/* A second comment at the end */}
) : any + +
+>
{/* A comment at the beginning */} {/* A second comment at the beginning */} {/* A nested comment */} {/* A sandwiched comment */}
{/* A comment at the end */} {/* A second comment at the end */}
: any +>div : any + + {/* A comment at the beginning */} + {/* A second comment at the beginning */} + +> {/* A nested comment */} : any +>span : any + + {/* A nested comment */} + +>span : any + + {/* A sandwiched comment */} +
+>
: any +>br : any + + {/* A comment at the end */} + {/* A second comment at the end */} +
+>div : any + +); + +( +>(
) : any + +
: any +>div : any + + /* a multi-line + comment */ + attr1="foo"> +>attr1 : any + + : any +>span : any + + attr2="bar" +>attr2 : any + + /> +
+>div : any + +); + +
 
; +>
 
: any +>div : any +>div : any + +
 
; +>
 
: any +>div : any +>div : any + +testing; +>testing : any +>hasOwnProperty : any +>hasOwnProperty : any + +; +> : any +>Component : any +>constructor : any + +; +> : any +>Namespace : any +>Component : any + +; +> : any +>Namespace : any +>DeepNamespace : any +>Component : any + + : any +>Component : any +>x : any +>y : any + +={2 } z />; +>z : any + + : any +>Component : any + + {...this.props} sound="moo" />; +>this.props : any +>this : any +>props : any +>sound : any + +; +> : any +>font-face : any + +; +> : any +>Component : any +>x : any +>y : any + +; +> : any +>x-component : any + +; +> : any +>Component : any +>x : any + +; +> : any +>Component : any +>x : any +>y : any + +; +> : any +>Component : any +>x : any +>y : any +>z : any + +; +> : any +>Component : any +>x : any +>y : any + + +; +> : any +>Component : any +>x : any +>y : any +>z : any +>z : any +> : any +>Child : any +>Component : any + +Text; +>Text : any +>Component : any +>x : any +>(z = { y: 2 }, z) : any +>z = { y: 2 }, z : any +>z = { y: 2 } : { y: number; } +>z : any +>{ y: 2 } : { y: number; } +>y : number +>2 : number +>z : any +>z : any +>Component : any + + + diff --git a/tests/baselines/reference/mergeClassInterfaceAndModule.js b/tests/baselines/reference/mergeClassInterfaceAndModule.js new file mode 100644 index 00000000000..5b7315031cd --- /dev/null +++ b/tests/baselines/reference/mergeClassInterfaceAndModule.js @@ -0,0 +1,19 @@ +//// [mergeClassInterfaceAndModule.ts] + +interface C1 {} +declare class C1 {} +module C1 {} + +declare class C2 {} +interface C2 {} +module C2 {} + +declare class C3 {} +module C3 {} +interface C3 {} + +module C4 {} +declare class C4 {} // error -- class declaration must preceed module declaration +interface C4 {} + +//// [mergeClassInterfaceAndModule.js] diff --git a/tests/baselines/reference/mergeClassInterfaceAndModule.symbols b/tests/baselines/reference/mergeClassInterfaceAndModule.symbols new file mode 100644 index 00000000000..a10227ed461 --- /dev/null +++ b/tests/baselines/reference/mergeClassInterfaceAndModule.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts === + +interface C1 {} +>C1 : Symbol(C1, Decl(mergeClassInterfaceAndModule.ts, 0, 0), Decl(mergeClassInterfaceAndModule.ts, 1, 15), Decl(mergeClassInterfaceAndModule.ts, 2, 19)) + +declare class C1 {} +>C1 : Symbol(C1, Decl(mergeClassInterfaceAndModule.ts, 0, 0), Decl(mergeClassInterfaceAndModule.ts, 1, 15), Decl(mergeClassInterfaceAndModule.ts, 2, 19)) + +module C1 {} +>C1 : Symbol(C1, Decl(mergeClassInterfaceAndModule.ts, 0, 0), Decl(mergeClassInterfaceAndModule.ts, 1, 15), Decl(mergeClassInterfaceAndModule.ts, 2, 19)) + +declare class C2 {} +>C2 : Symbol(C2, Decl(mergeClassInterfaceAndModule.ts, 3, 12), Decl(mergeClassInterfaceAndModule.ts, 5, 19), Decl(mergeClassInterfaceAndModule.ts, 6, 15)) + +interface C2 {} +>C2 : Symbol(C2, Decl(mergeClassInterfaceAndModule.ts, 3, 12), Decl(mergeClassInterfaceAndModule.ts, 5, 19), Decl(mergeClassInterfaceAndModule.ts, 6, 15)) + +module C2 {} +>C2 : Symbol(C2, Decl(mergeClassInterfaceAndModule.ts, 3, 12), Decl(mergeClassInterfaceAndModule.ts, 5, 19), Decl(mergeClassInterfaceAndModule.ts, 6, 15)) + +declare class C3 {} +>C3 : Symbol(C3, Decl(mergeClassInterfaceAndModule.ts, 7, 12), Decl(mergeClassInterfaceAndModule.ts, 9, 19), Decl(mergeClassInterfaceAndModule.ts, 10, 12)) + +module C3 {} +>C3 : Symbol(C3, Decl(mergeClassInterfaceAndModule.ts, 7, 12), Decl(mergeClassInterfaceAndModule.ts, 9, 19), Decl(mergeClassInterfaceAndModule.ts, 10, 12)) + +interface C3 {} +>C3 : Symbol(C3, Decl(mergeClassInterfaceAndModule.ts, 7, 12), Decl(mergeClassInterfaceAndModule.ts, 9, 19), Decl(mergeClassInterfaceAndModule.ts, 10, 12)) + +module C4 {} +>C4 : Symbol(C4, Decl(mergeClassInterfaceAndModule.ts, 11, 15), Decl(mergeClassInterfaceAndModule.ts, 13, 12), Decl(mergeClassInterfaceAndModule.ts, 14, 19)) + +declare class C4 {} // error -- class declaration must preceed module declaration +>C4 : Symbol(C4, Decl(mergeClassInterfaceAndModule.ts, 11, 15), Decl(mergeClassInterfaceAndModule.ts, 13, 12), Decl(mergeClassInterfaceAndModule.ts, 14, 19)) + +interface C4 {} +>C4 : Symbol(C4, Decl(mergeClassInterfaceAndModule.ts, 11, 15), Decl(mergeClassInterfaceAndModule.ts, 13, 12), Decl(mergeClassInterfaceAndModule.ts, 14, 19)) + diff --git a/tests/baselines/reference/mergeClassInterfaceAndModule.types b/tests/baselines/reference/mergeClassInterfaceAndModule.types new file mode 100644 index 00000000000..a91691e5bac --- /dev/null +++ b/tests/baselines/reference/mergeClassInterfaceAndModule.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts === + +interface C1 {} +>C1 : C1 + +declare class C1 {} +>C1 : C1 + +module C1 {} +>C1 : typeof C1 + +declare class C2 {} +>C2 : C2 + +interface C2 {} +>C2 : C2 + +module C2 {} +>C2 : typeof C2 + +declare class C3 {} +>C3 : C3 + +module C3 {} +>C3 : typeof C3 + +interface C3 {} +>C3 : C3 + +module C4 {} +>C4 : typeof C4 + +declare class C4 {} // error -- class declaration must preceed module declaration +>C4 : C4 + +interface C4 {} +>C4 : C4 + diff --git a/tests/baselines/reference/mergedClassInterface.errors.txt b/tests/baselines/reference/mergedClassInterface.errors.txt new file mode 100644 index 00000000000..5b23b046db7 --- /dev/null +++ b/tests/baselines/reference/mergedClassInterface.errors.txt @@ -0,0 +1,67 @@ +tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2518: Only an ambient class can be merged with an interface. + + +==== tests/cases/conformance/classes/classDeclarations/file1.ts (4 errors) ==== + + + declare class C1 { } + + interface C1 { } + + interface C2 { } + + declare class C2 { } + + class C3 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + + interface C3 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + + interface C4 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + + class C4 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + + interface C5 { + x1: number; + } + + declare class C5 { + x2: number; + } + + interface C5 { + x3: number; + } + + interface C5 { + x4: number; + } + + // checks if properties actually were merged + var c5 : C5; + c5.x1; + c5.x2; + c5.x3; + c5.x4; + +==== tests/cases/conformance/classes/classDeclarations/file2.ts (0 errors) ==== + + declare class C6 { } + + interface C7 { } + +==== tests/cases/conformance/classes/classDeclarations/file3.ts (0 errors) ==== + + interface C6 { } + + declare class C7 { } \ No newline at end of file diff --git a/tests/baselines/reference/mergedClassInterface.js b/tests/baselines/reference/mergedClassInterface.js new file mode 100644 index 00000000000..7176255655d --- /dev/null +++ b/tests/baselines/reference/mergedClassInterface.js @@ -0,0 +1,117 @@ +//// [tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts] //// + +//// [file1.ts] + + +declare class C1 { } + +interface C1 { } + +interface C2 { } + +declare class C2 { } + +class C3 { } // error -- cannot merge non-ambient class and interface + +interface C3 { } // error -- cannot merge non-ambient class and interface + +interface C4 { } // error -- cannot merge non-ambient class and interface + +class C4 { } // error -- cannot merge non-ambient class and interface + +interface C5 { + x1: number; +} + +declare class C5 { + x2: number; +} + +interface C5 { + x3: number; +} + +interface C5 { + x4: number; +} + +// checks if properties actually were merged +var c5 : C5; +c5.x1; +c5.x2; +c5.x3; +c5.x4; + +//// [file2.ts] + +declare class C6 { } + +interface C7 { } + +//// [file3.ts] + +interface C6 { } + +declare class C7 { } + +//// [file1.js] +var C3 = (function () { + function C3() { + } + return C3; +})(); // error -- cannot merge non-ambient class and interface +var C4 = (function () { + function C4() { + } + return C4; +})(); // error -- cannot merge non-ambient class and interface +// checks if properties actually were merged +var c5; +c5.x1; +c5.x2; +c5.x3; +c5.x4; +//// [file2.js] +//// [file3.js] + + +//// [file1.d.ts] +declare class C1 { +} +interface C1 { +} +interface C2 { +} +declare class C2 { +} +declare class C3 { +} +interface C3 { +} +interface C4 { +} +declare class C4 { +} +interface C5 { + x1: number; +} +declare class C5 { + x2: number; +} +interface C5 { + x3: number; +} +interface C5 { + x4: number; +} +declare var c5: C5; +//// [file2.d.ts] +declare class C6 { +} +interface C7 { +} +//// [file3.d.ts] +interface C6 { +} +declare class C7 { +} diff --git a/tests/baselines/reference/nameCollisions.errors.txt b/tests/baselines/reference/nameCollisions.errors.txt index 5eb7ea2cf80..5c32d464070 100644 --- a/tests/baselines/reference/nameCollisions.errors.txt +++ b/tests/baselines/reference/nameCollisions.errors.txt @@ -11,10 +11,10 @@ tests/cases/compiler/nameCollisions.ts(33,11): error TS2300: Duplicate identifie tests/cases/compiler/nameCollisions.ts(34,14): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/nameCollisions.ts(36,14): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/nameCollisions.ts(37,11): error TS2300: Duplicate identifier 'C2'. -tests/cases/compiler/nameCollisions.ts(42,11): error TS2300: Duplicate identifier 'cli'. -tests/cases/compiler/nameCollisions.ts(43,15): error TS2300: Duplicate identifier 'cli'. -tests/cases/compiler/nameCollisions.ts(45,15): error TS2300: Duplicate identifier 'cli2'. -tests/cases/compiler/nameCollisions.ts(46,11): error TS2300: Duplicate identifier 'cli2'. +tests/cases/compiler/nameCollisions.ts(42,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(43,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(45,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(46,11): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/nameCollisions.ts (17 errors) ==== @@ -87,15 +87,15 @@ tests/cases/compiler/nameCollisions.ts(46,11): error TS2300: Duplicate identifie class cli { } ~~~ -!!! error TS2300: Duplicate identifier 'cli'. +!!! error TS2518: Only an ambient class can be merged with an interface. interface cli { } // error ~~~ -!!! error TS2300: Duplicate identifier 'cli'. +!!! error TS2518: Only an ambient class can be merged with an interface. interface cli2 { } ~~~~ -!!! error TS2300: Duplicate identifier 'cli2'. +!!! error TS2518: Only an ambient class can be merged with an interface. class cli2 { } // error ~~~~ -!!! error TS2300: Duplicate identifier 'cli2'. +!!! error TS2518: Only an ambient class can be merged with an interface. } \ No newline at end of file diff --git a/tests/baselines/reference/noErrorsInCallback.errors.txt b/tests/baselines/reference/noErrorsInCallback.errors.txt index f0bfe00199e..90fdbbd77a5 100644 --- a/tests/baselines/reference/noErrorsInCallback.errors.txt +++ b/tests/baselines/reference/noErrorsInCallback.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/noErrorsInCallback.ts(4,19): error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. -tests/cases/compiler/noErrorsInCallback.ts(6,23): error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. +tests/cases/compiler/noErrorsInCallback.ts(4,19): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. +tests/cases/compiler/noErrorsInCallback.ts(6,23): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/noErrorsInCallback.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/noErrorsInCallback.ts(6,23): error TS2345: Argument of type } var one = new Bar({}); // Error ~~ -!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. [].forEach(() => { var two = new Bar({}); // No error? ~~ -!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. }); \ No newline at end of file diff --git a/tests/baselines/reference/parserAstSpans1.errors.txt b/tests/baselines/reference/parserAstSpans1.errors.txt index 9697dcbc128..648929e974e 100644 --- a/tests/baselines/reference/parserAstSpans1.errors.txt +++ b/tests/baselines/reference/parserAstSpans1.errors.txt @@ -2,10 +2,10 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(79,16): error TS10 tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(85,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(94,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(100,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(111,25): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(111,25): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(119,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(125,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts (8 errors) ==== @@ -129,7 +129,7 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2 super(10); this.p1 = super.c2_p1; ~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } /** c3 p1*/ public p1: number; @@ -241,6 +241,6 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2 super(); this.d = super.b; ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolProperty1.symbols b/tests/baselines/reference/parserSymbolProperty1.symbols index 54d674ea0a8..5d97b2d7a01 100644 --- a/tests/baselines/reference/parserSymbolProperty1.symbols +++ b/tests/baselines/reference/parserSymbolProperty1.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty1.ts, 0, 0)) [Symbol.iterator]: string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } diff --git a/tests/baselines/reference/parserSymbolProperty2.symbols b/tests/baselines/reference/parserSymbolProperty2.symbols index 51fdb40efd4..69764d70b45 100644 --- a/tests/baselines/reference/parserSymbolProperty2.symbols +++ b/tests/baselines/reference/parserSymbolProperty2.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty2.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty3.symbols b/tests/baselines/reference/parserSymbolProperty3.symbols index 11b6d8de94f..c42bb3abb83 100644 --- a/tests/baselines/reference/parserSymbolProperty3.symbols +++ b/tests/baselines/reference/parserSymbolProperty3.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty3.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty4.symbols b/tests/baselines/reference/parserSymbolProperty4.symbols index b2ffc2c89d2..ba93afde837 100644 --- a/tests/baselines/reference/parserSymbolProperty4.symbols +++ b/tests/baselines/reference/parserSymbolProperty4.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty4.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty5.symbols b/tests/baselines/reference/parserSymbolProperty5.symbols index e896ebbd2a2..4829677f516 100644 --- a/tests/baselines/reference/parserSymbolProperty5.symbols +++ b/tests/baselines/reference/parserSymbolProperty5.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty5.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty6.symbols b/tests/baselines/reference/parserSymbolProperty6.symbols index 1859c954ba4..793b925b382 100644 --- a/tests/baselines/reference/parserSymbolProperty6.symbols +++ b/tests/baselines/reference/parserSymbolProperty6.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty6.ts, 0, 0)) [Symbol.toStringTag]: string = ""; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty7.symbols b/tests/baselines/reference/parserSymbolProperty7.symbols index a91a8227ae4..e1b85f2a3b9 100644 --- a/tests/baselines/reference/parserSymbolProperty7.symbols +++ b/tests/baselines/reference/parserSymbolProperty7.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty7.ts, 0, 0)) [Symbol.toStringTag](): void { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty8.symbols b/tests/baselines/reference/parserSymbolProperty8.symbols index dee98ed1e77..05b002eb569 100644 --- a/tests/baselines/reference/parserSymbolProperty8.symbols +++ b/tests/baselines/reference/parserSymbolProperty8.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty8.ts, 0, 3)) [Symbol.toPrimitive](): string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty9.symbols b/tests/baselines/reference/parserSymbolProperty9.symbols index cffbded17e6..774eb2dcc4b 100644 --- a/tests/baselines/reference/parserSymbolProperty9.symbols +++ b/tests/baselines/reference/parserSymbolProperty9.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty9.ts, 0, 3)) [Symbol.toPrimitive]: string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } diff --git a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt index f29ee917ea7..7893100b5a5 100644 --- a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt +++ b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(6,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(8,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(6,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(8,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,15): error TS1003: Identifier expected. -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,21): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,21): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,8): error TS1110: Type expected. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,8): error TS2341: Property 'foo' is private and only accessible within class 'Base'. @@ -14,17 +14,17 @@ tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAcces class Derived extends Base { x = super.foo; // error ~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. y() { return super.foo; // error ~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } z: typeof super.foo; // error ~~~~~ !!! error TS1003: Identifier expected. ~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. a: this.foo; // error ~~~~ diff --git a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt index 656b6e1f2a2..bafcc39f48d 100644 --- a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt +++ b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt @@ -1,6 +1,6 @@ error TS6053: File 'a.ts' not found. -error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. +error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. !!! error TS6053: File 'a.ts' not found. -!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. \ No newline at end of file +!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. \ No newline at end of file diff --git a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt index 656b6e1f2a2..bafcc39f48d 100644 --- a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt +++ b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt @@ -1,6 +1,6 @@ error TS6053: File 'a.ts' not found. -error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. +error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. !!! error TS6053: File 'a.ts' not found. -!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.d.ts'. \ No newline at end of file +!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. \ No newline at end of file diff --git a/tests/baselines/reference/promiseVoidErrorCallback.symbols b/tests/baselines/reference/promiseVoidErrorCallback.symbols index d9e329885aa..27e7df62ab1 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.symbols +++ b/tests/baselines/reference/promiseVoidErrorCallback.symbols @@ -22,13 +22,13 @@ interface T3 { function f1(): Promise { >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0)) return Promise.resolve({ __t1: "foo_t1" }); ->Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4837, 39), Decl(lib.d.ts, 4844, 54)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) ->resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4837, 39), Decl(lib.d.ts, 4844, 54)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4840, 39), Decl(lib.d.ts, 4847, 54)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4840, 39), Decl(lib.d.ts, 4847, 54)) >__t1 : Symbol(__t1, Decl(promiseVoidErrorCallback.ts, 13, 28)) } @@ -47,12 +47,12 @@ function f2(x: T1): T2 { var x3 = f1() >x3 : Symbol(x3, Decl(promiseVoidErrorCallback.ts, 20, 3)) ->f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4775, 22), Decl(lib.d.ts, 4782, 158)) ->f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4775, 22), Decl(lib.d.ts, 4782, 158)) +>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) +>f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) .then(f2, (e: Error) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4775, 22), Decl(lib.d.ts, 4782, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) >f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1)) >e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15)) >Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11)) @@ -62,7 +62,7 @@ var x3 = f1() }) .then((x: T2) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4775, 22), Decl(lib.d.ts, 4782, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) >x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11)) >T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1)) diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt index f2b19d043c2..897636b6d90 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass3.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass3.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass3.ts (1 errors) ==== @@ -14,6 +14,6 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce this.x; // OK, accessed within a subclass of the declaring class super.x; // Error, x is not public ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt b/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt index 03671925feb..4b950c70019 100644 --- a/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt +++ b/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(14,23): error TS2339: Property 'z' does not exist on type 'B'. -tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(16,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(16,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(18,24): error TS2339: Property 'y' does not exist on type 'A'. tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(19,24): error TS2339: Property 'z' does not exist on type 'A'. tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(22,18): error TS2446: Property 'x' is protected and only accessible through an instance of class 'B'. @@ -33,7 +33,7 @@ tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAcc var s1 = super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var s2 = super.f(); var s3 = super.y; // error ~ diff --git a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt index 1f1bd72617c..b6fa239f291 100644 --- a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt +++ b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts (2 errors) ==== @@ -15,7 +15,7 @@ tests/cases/conformance/classes/members/accessibility/protectedStaticClassProper this.x; // OK, accessed within a class derived from their declaring class super.x; // Error, x is not public ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } @@ -25,6 +25,6 @@ tests/cases/conformance/classes/members/accessibility/protectedStaticClassProper this.x; // OK, accessed within a class derived from their declaring class super.x; // Error, x is not public ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/recursiveIntersectionTypes.errors.txt b/tests/baselines/reference/recursiveIntersectionTypes.errors.txt new file mode 100644 index 00000000000..bac97470e55 --- /dev/null +++ b/tests/baselines/reference/recursiveIntersectionTypes.errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts(19,1): error TS2322: Type 'Entity & { next: Entity & any; }' is not assignable to type 'Product & { next: Product & any; }'. + Type 'Entity & { next: Entity & any; }' is not assignable to type 'Product'. + Type '{ next: Entity & any; }' is not assignable to type 'Product'. + Property 'price' is missing in type '{ next: Entity & any; }'. + + +==== tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts (1 errors) ==== + type LinkedList = T & { next: LinkedList }; + + interface Entity { + name: string; + } + + interface Product extends Entity { + price: number; + } + + var entityList: LinkedList; + var s = entityList.name; + var s = entityList.next.name; + var s = entityList.next.next.name; + var s = entityList.next.next.next.name; + + var productList: LinkedList; + entityList = productList; + productList = entityList; // Error + ~~~~~~~~~~~ +!!! error TS2322: Type 'Entity & { next: Entity & any; }' is not assignable to type 'Product & { next: Product & any; }'. +!!! error TS2322: Type 'Entity & { next: Entity & any; }' is not assignable to type 'Product'. +!!! error TS2322: Type '{ next: Entity & any; }' is not assignable to type 'Product'. +!!! error TS2322: Property 'price' is missing in type '{ next: Entity & any; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/recursiveIntersectionTypes.js b/tests/baselines/reference/recursiveIntersectionTypes.js new file mode 100644 index 00000000000..88b7e6f831b --- /dev/null +++ b/tests/baselines/reference/recursiveIntersectionTypes.js @@ -0,0 +1,31 @@ +//// [recursiveIntersectionTypes.ts] +type LinkedList = T & { next: LinkedList }; + +interface Entity { + name: string; +} + +interface Product extends Entity { + price: number; +} + +var entityList: LinkedList; +var s = entityList.name; +var s = entityList.next.name; +var s = entityList.next.next.name; +var s = entityList.next.next.next.name; + +var productList: LinkedList; +entityList = productList; +productList = entityList; // Error + + +//// [recursiveIntersectionTypes.js] +var entityList; +var s = entityList.name; +var s = entityList.next.name; +var s = entityList.next.next.name; +var s = entityList.next.next.next.name; +var productList; +entityList = productList; +productList = entityList; // Error diff --git a/tests/baselines/reference/restParamModifier.errors.txt b/tests/baselines/reference/restParamModifier.errors.txt new file mode 100644 index 00000000000..87c73fcdc71 --- /dev/null +++ b/tests/baselines/reference/restParamModifier.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/restParamModifier.ts(2,17): error TS2370: A rest parameter must be of an array type. +tests/cases/compiler/restParamModifier.ts(2,27): error TS1005: '=' expected. +tests/cases/compiler/restParamModifier.ts(2,27): error TS2304: Cannot find name 'rest'. +tests/cases/compiler/restParamModifier.ts(2,31): error TS1005: ',' expected. +tests/cases/compiler/restParamModifier.ts(2,39): error TS1005: '=' expected. + + +==== tests/cases/compiler/restParamModifier.ts (5 errors) ==== + class C { + constructor(...public rest: string[]) {} + ~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. + ~~~~ +!!! error TS1005: '=' expected. + ~~~~ +!!! error TS2304: Cannot find name 'rest'. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1005: '=' expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/restParamModifier.js b/tests/baselines/reference/restParamModifier.js new file mode 100644 index 00000000000..9a780321dc9 --- /dev/null +++ b/tests/baselines/reference/restParamModifier.js @@ -0,0 +1,12 @@ +//// [restParamModifier.ts] +class C { + constructor(...public rest: string[]) {} +} + +//// [restParamModifier.js] +var C = (function () { + function C(public, string) { + if (string === void 0) { string = []; } + } + return C; +})(); diff --git a/tests/baselines/reference/restParamModifier2.errors.txt b/tests/baselines/reference/restParamModifier2.errors.txt new file mode 100644 index 00000000000..773592fa9bf --- /dev/null +++ b/tests/baselines/reference/restParamModifier2.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/restParamModifier2.ts(2,24): error TS1005: ',' expected. + + +==== tests/cases/compiler/restParamModifier2.ts (1 errors) ==== + class C { + constructor(public ...rest: string[]) {} + ~~~ +!!! error TS1005: ',' expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/restParamModifier2.js b/tests/baselines/reference/restParamModifier2.js new file mode 100644 index 00000000000..c588c945ce4 --- /dev/null +++ b/tests/baselines/reference/restParamModifier2.js @@ -0,0 +1,15 @@ +//// [restParamModifier2.ts] +class C { + constructor(public ...rest: string[]) {} +} + +//// [restParamModifier2.js] +var C = (function () { + function C(public) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + } + return C; +})(); diff --git a/tests/baselines/reference/superAccess.errors.txt b/tests/baselines/reference/superAccess.errors.txt index 64c921e0e7f..f506bb9f136 100644 --- a/tests/baselines/reference/superAccess.errors.txt +++ b/tests/baselines/reference/superAccess.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/superAccess.ts(9,24): error TS2339: Property 'S1' does not exist on type 'MyBase'. -tests/cases/compiler/superAccess.ts(10,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superAccess.ts(11,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superAccess.ts(10,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superAccess.ts(11,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/compiler/superAccess.ts (3 errors) ==== @@ -17,9 +17,9 @@ tests/cases/compiler/superAccess.ts(11,24): error TS2340: Only public and protec !!! error TS2339: Property 'S1' does not exist on type 'MyBase'. var l4 = super.S2; // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var l5 = super.f(); // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/superAccess2.errors.txt b/tests/baselines/reference/superAccess2.errors.txt index eda3e29bb0a..d8b39284f65 100644 --- a/tests/baselines/reference/superAccess2.errors.txt +++ b/tests/baselines/reference/superAccess2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/superAccess2.ts(7,15): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/compiler/superAccess2.ts(8,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/superAccess2.ts(8,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. tests/cases/compiler/superAccess2.ts(8,22): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superAccess2.ts(11,28): error TS2336: 'super' cannot be referenced in constructor arguments. tests/cases/compiler/superAccess2.ts(11,33): error TS1034: 'super' must be followed by an argument list or member access. @@ -25,7 +25,7 @@ tests/cases/compiler/superAccess2.ts(21,15): error TS2339: Property 'x' does not !!! error TS1034: 'super' must be followed by an argument list or member access. static yy = super; // error for static initializer accessing super ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. diff --git a/tests/baselines/reference/superCallOutsideConstructor.errors.txt b/tests/baselines/reference/superCallOutsideConstructor.errors.txt index 2cdcaad1891..c22c4d33b5d 100644 --- a/tests/baselines/reference/superCallOutsideConstructor.errors.txt +++ b/tests/baselines/reference/superCallOutsideConstructor.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/superCallOutsideConstructor.ts(6,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/superCallOutsideConstructor.ts(12,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/superCallOutsideConstructor.ts(6,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/superCallOutsideConstructor.ts(12,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/compiler/superCallOutsideConstructor.ts (3 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super class D extends C { x = super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. constructor() { super(); @@ -19,13 +19,13 @@ tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super var y = () => { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } var y2 = function() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } } } diff --git a/tests/baselines/reference/superErrors.errors.txt b/tests/baselines/reference/superErrors.errors.txt index fad592b490c..26e0ba3a6c4 100644 --- a/tests/baselines/reference/superErrors.errors.txt +++ b/tests/baselines/reference/superErrors.errors.txt @@ -4,12 +4,12 @@ tests/cases/compiler/superErrors.ts(4,19): error TS2335: 'super' can only be ref tests/cases/compiler/superErrors.ts(4,24): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superErrors.ts(5,31): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/superErrors.ts(5,36): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/compiler/superErrors.ts(22,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/superErrors.ts(27,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/superErrors.ts(31,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/superErrors.ts(22,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/superErrors.ts(27,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/superErrors.ts(31,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. tests/cases/compiler/superErrors.ts(31,41): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/compiler/superErrors.ts(39,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/superErrors.ts(43,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/superErrors.ts(39,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/superErrors.ts(43,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. tests/cases/compiler/superErrors.ts(43,41): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superErrors.ts(47,22): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superErrors.ts(48,28): error TS1034: 'super' must be followed by an argument list or member access. @@ -52,20 +52,20 @@ tests/cases/compiler/superErrors.ts(49,40): error TS1034: 'super' must be follow function inner() { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } // super call in a lambda in an inner function in a constructor function inner2() { var x = () => super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } // super call in a lambda in a function expression in a constructor (function() { return () => super; })(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. } @@ -77,13 +77,13 @@ tests/cases/compiler/superErrors.ts(49,40): error TS1034: 'super' must be follow function inner() { var x = () => super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } // super call in a lambda in a function expression in a constructor (function() { return () => super; })(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. } diff --git a/tests/baselines/reference/superInLambdas.errors.txt b/tests/baselines/reference/superInLambdas.errors.txt index 7587ed82ef1..a3863d00c02 100644 --- a/tests/baselines/reference/superInLambdas.errors.txt +++ b/tests/baselines/reference/superInLambdas.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/superInLambdas.ts(47,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superInLambdas.ts(51,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superInLambdas.ts(47,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superInLambdas.ts(51,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superInLambdas.ts(61,34): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superInLambdas.ts(65,34): error TS1034: 'super' must be followed by an argument list or member access. @@ -53,13 +53,13 @@ tests/cases/compiler/superInLambdas.ts(65,34): error TS1034: 'super' must be fol // super property in a nested lambda in a constructor var superName = () => () => () => super.name; ~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } sayHello(): void { // super property in a nested lambda in a method var superName = () => () => () => super.name; ~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } diff --git a/tests/baselines/reference/superPropertyAccess.errors.txt b/tests/baselines/reference/superPropertyAccess.errors.txt index 4880bf66f17..41e0a0adac5 100644 --- a/tests/baselines/reference/superPropertyAccess.errors.txt +++ b/tests/baselines/reference/superPropertyAccess.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/superPropertyAccess.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess.ts(9,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess.ts(22,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess.ts(22,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superPropertyAccess.ts(24,9): error TS2341: Property 'p1' is private and only accessible within class 'MyBase'. -tests/cases/compiler/superPropertyAccess.ts(26,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(28,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(32,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess.ts(26,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess.ts(28,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess.ts(32,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/compiler/superPropertyAccess.ts (8 errors) ==== @@ -36,7 +36,7 @@ tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public an super.m2.bind(this); // Should error, instance property, not a public instance member function ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.p1(); // Should error, private not public instance member function ~~~~~~~~ @@ -44,20 +44,20 @@ tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public an var l1 = super.d1; // Should error, instance data property not a public instance member function ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var l1 = super.d2; // Should error, instance data property not a public instance member function ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.m1 = function (a: string) { return ""; }; // Should be allowed, we will not restrict assignment super.value = 0; // Should error, instance data property not a public instance member function ~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var z = super.value; // Should error, instance data property not a public instance member function ~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/superPropertyAccess1.errors.txt b/tests/baselines/reference/superPropertyAccess1.errors.txt index b256860ec72..aed25fd6a92 100644 --- a/tests/baselines/reference/superPropertyAccess1.errors.txt +++ b/tests/baselines/reference/superPropertyAccess1.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/superPropertyAccess1.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess1.ts(13,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess1.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess1.ts(13,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess1.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superPropertyAccess1.ts(22,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/compiler/superPropertyAccess1.ts (5 errors) ==== @@ -22,7 +22,7 @@ tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public a super.bar(); super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } constructor() { @@ -30,7 +30,7 @@ tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public a super.bar(); super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } public get y() { @@ -39,7 +39,7 @@ tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public a super.bar(); super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. return 1; } } \ No newline at end of file diff --git a/tests/baselines/reference/superPropertyAccess2.errors.txt b/tests/baselines/reference/superPropertyAccess2.errors.txt index 475705f1506..2512ad91fae 100644 --- a/tests/baselines/reference/superPropertyAccess2.errors.txt +++ b/tests/baselines/reference/superPropertyAccess2.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/superPropertyAccess2.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess2.ts(13,15): error TS2339: Property 'x' does not exist on type 'typeof C'. tests/cases/compiler/superPropertyAccess2.ts(18,15): error TS2339: Property 'bar' does not exist on type 'C'. -tests/cases/compiler/superPropertyAccess2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superPropertyAccess2.ts(22,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess2.ts(24,15): error TS2339: Property 'x' does not exist on type 'typeof C'. @@ -33,7 +33,7 @@ tests/cases/compiler/superPropertyAccess2.ts(24,15): error TS2339: Property 'x' !!! error TS2339: Property 'bar' does not exist on type 'C'. super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } public static get y() { diff --git a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt index 44332e6e567..4f1faf78a78 100644 --- a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt +++ b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(7,13): e tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(8,13): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(11,20): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(20,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ==== tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts (7 errors) ==== @@ -42,7 +42,7 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return super.test(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } }; } diff --git a/tests/baselines/reference/symbolDeclarationEmit1.symbols b/tests/baselines/reference/symbolDeclarationEmit1.symbols index f24cfe2b783..9fae9d57c4f 100644 --- a/tests/baselines/reference/symbolDeclarationEmit1.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit1.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit1.ts, 0, 0)) [Symbol.toPrimitive]: number; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit10.symbols b/tests/baselines/reference/symbolDeclarationEmit10.symbols index 375bcf2174a..5dba2268d26 100644 --- a/tests/baselines/reference/symbolDeclarationEmit10.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit10.symbols @@ -3,13 +3,13 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit10.ts, 0, 3)) get [Symbol.isConcatSpreadable]() { return '' }, ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) set [Symbol.isConcatSpreadable](x) { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit10.ts, 2, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit11.symbols b/tests/baselines/reference/symbolDeclarationEmit11.symbols index 90290569e07..a6019a364e4 100644 --- a/tests/baselines/reference/symbolDeclarationEmit11.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit11.symbols @@ -3,23 +3,23 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit11.ts, 0, 0)) static [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) static [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) static get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) static set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit11.ts, 4, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit13.symbols b/tests/baselines/reference/symbolDeclarationEmit13.symbols index 66f540a8cae..e16ec738489 100644 --- a/tests/baselines/reference/symbolDeclarationEmit13.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit13.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit13.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) set [Symbol.toStringTag](x) { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit13.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit14.symbols b/tests/baselines/reference/symbolDeclarationEmit14.symbols index 5927b8a6a29..b2f520351f2 100644 --- a/tests/baselines/reference/symbolDeclarationEmit14.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit14.symbols @@ -3,12 +3,12 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit14.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) get [Symbol.toStringTag]() { return ""; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit2.symbols b/tests/baselines/reference/symbolDeclarationEmit2.symbols index 3c214bd9c25..7e9d06cd332 100644 --- a/tests/baselines/reference/symbolDeclarationEmit2.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit2.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit2.ts, 0, 0)) [Symbol.toPrimitive] = ""; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit3.symbols b/tests/baselines/reference/symbolDeclarationEmit3.symbols index d3a3a313223..177180b5bca 100644 --- a/tests/baselines/reference/symbolDeclarationEmit3.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit3.symbols @@ -3,20 +3,20 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit3.ts, 0, 0)) [Symbol.toPrimitive](x: number); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 1, 25)) [Symbol.toPrimitive](x: string); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 2, 25)) [Symbol.toPrimitive](x: any) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 3, 25)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit4.symbols b/tests/baselines/reference/symbolDeclarationEmit4.symbols index d552300b70e..98cb277ad47 100644 --- a/tests/baselines/reference/symbolDeclarationEmit4.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit4.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit4.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit4.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit5.symbols b/tests/baselines/reference/symbolDeclarationEmit5.symbols index 7f5fc3cf51b..17bda345253 100644 --- a/tests/baselines/reference/symbolDeclarationEmit5.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit5.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit5.ts, 0, 0)) [Symbol.isConcatSpreadable](): string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit6.symbols b/tests/baselines/reference/symbolDeclarationEmit6.symbols index fe60e2ecc31..c4b046cc146 100644 --- a/tests/baselines/reference/symbolDeclarationEmit6.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit6.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit6.ts, 0, 0)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit7.symbols b/tests/baselines/reference/symbolDeclarationEmit7.symbols index b044c5264d8..58a661412da 100644 --- a/tests/baselines/reference/symbolDeclarationEmit7.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit7.symbols @@ -3,7 +3,7 @@ var obj: { >obj : Symbol(obj, Decl(symbolDeclarationEmit7.ts, 0, 3)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit8.symbols b/tests/baselines/reference/symbolDeclarationEmit8.symbols index 797b422c7fc..7879d28b02f 100644 --- a/tests/baselines/reference/symbolDeclarationEmit8.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit8.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit8.ts, 0, 3)) [Symbol.isConcatSpreadable]: 0 ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit9.symbols b/tests/baselines/reference/symbolDeclarationEmit9.symbols index deaf1c1bb62..17901fb713a 100644 --- a/tests/baselines/reference/symbolDeclarationEmit9.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit9.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit9.ts, 0, 3)) [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) } diff --git a/tests/baselines/reference/symbolProperty11.symbols b/tests/baselines/reference/symbolProperty11.symbols index f8b758cbf68..4028da455a6 100644 --- a/tests/baselines/reference/symbolProperty11.symbols +++ b/tests/baselines/reference/symbolProperty11.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty11.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty11.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty13.symbols b/tests/baselines/reference/symbolProperty13.symbols index 246ca2f0851..07e9b6bae26 100644 --- a/tests/baselines/reference/symbolProperty13.symbols +++ b/tests/baselines/reference/symbolProperty13.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty13.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty13.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty13.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty14.symbols b/tests/baselines/reference/symbolProperty14.symbols index 4531b13dca1..d4e79a064a9 100644 --- a/tests/baselines/reference/symbolProperty14.symbols +++ b/tests/baselines/reference/symbolProperty14.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty14.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty14.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty14.ts, 2, 1)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 4, 25)) } diff --git a/tests/baselines/reference/symbolProperty15.symbols b/tests/baselines/reference/symbolProperty15.symbols index 6027f5e797e..2a83145da03 100644 --- a/tests/baselines/reference/symbolProperty15.symbols +++ b/tests/baselines/reference/symbolProperty15.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty15.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty15.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty16.symbols b/tests/baselines/reference/symbolProperty16.symbols index f7700e3b777..1b4b23e9511 100644 --- a/tests/baselines/reference/symbolProperty16.symbols +++ b/tests/baselines/reference/symbolProperty16.symbols @@ -3,18 +3,18 @@ class C { >C : Symbol(C, Decl(symbolProperty16.ts, 0, 0)) private [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 1, 32)) } interface I { >I : Symbol(I, Decl(symbolProperty16.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty18.symbols b/tests/baselines/reference/symbolProperty18.symbols index bc23c468a22..89df72d6543 100644 --- a/tests/baselines/reference/symbolProperty18.symbols +++ b/tests/baselines/reference/symbolProperty18.symbols @@ -3,39 +3,39 @@ var i = { >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) [Symbol.toStringTag]() { return "" }, ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) set [Symbol.toPrimitive](p: boolean) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) >p : Symbol(p, Decl(symbolProperty18.ts, 3, 29)) } var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty18.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty18.ts, 7, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) i[Symbol.toPrimitive] = false; >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) diff --git a/tests/baselines/reference/symbolProperty19.symbols b/tests/baselines/reference/symbolProperty19.symbols index a0274f2c762..3ee9ed595c2 100644 --- a/tests/baselines/reference/symbolProperty19.symbols +++ b/tests/baselines/reference/symbolProperty19.symbols @@ -3,15 +3,15 @@ var i = { >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) [Symbol.iterator]: { p: null }, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >p : Symbol(p, Decl(symbolProperty19.ts, 1, 24)) [Symbol.toStringTag]() { return { p: undefined }; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >p : Symbol(p, Decl(symbolProperty19.ts, 2, 37)) >undefined : Symbol(undefined) } @@ -19,14 +19,14 @@ var i = { var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty19.ts, 5, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty19.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) diff --git a/tests/baselines/reference/symbolProperty2.symbols b/tests/baselines/reference/symbolProperty2.symbols index c6bb74bef31..b52c4087d71 100644 --- a/tests/baselines/reference/symbolProperty2.symbols +++ b/tests/baselines/reference/symbolProperty2.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/Symbols/symbolProperty2.ts === var s = Symbol(); >s : Symbol(s, Decl(symbolProperty2.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) var x = { >x : Symbol(x, Decl(symbolProperty2.ts, 1, 3)) diff --git a/tests/baselines/reference/symbolProperty20.symbols b/tests/baselines/reference/symbolProperty20.symbols index 04c76275b55..ad4f0c79523 100644 --- a/tests/baselines/reference/symbolProperty20.symbols +++ b/tests/baselines/reference/symbolProperty20.symbols @@ -3,15 +3,15 @@ interface I { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: (s: string) => string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 1, 24)) [Symbol.toStringTag](s: number): number; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >s : Symbol(s, Decl(symbolProperty20.ts, 2, 25)) } @@ -20,16 +20,16 @@ var i: I = { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: s => s, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) [Symbol.toStringTag](n) { return n; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) } diff --git a/tests/baselines/reference/symbolProperty21.symbols b/tests/baselines/reference/symbolProperty21.symbols index 544813c3056..09997f687d5 100644 --- a/tests/baselines/reference/symbolProperty21.symbols +++ b/tests/baselines/reference/symbolProperty21.symbols @@ -5,15 +5,15 @@ interface I { >U : Symbol(U, Decl(symbolProperty21.ts, 0, 14)) [Symbol.unscopables]: T; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) >T : Symbol(T, Decl(symbolProperty21.ts, 0, 12)) [Symbol.isConcatSpreadable]: U; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) >U : Symbol(U, Decl(symbolProperty21.ts, 0, 14)) } @@ -34,18 +34,18 @@ foo({ >foo : Symbol(foo, Decl(symbolProperty21.ts, 3, 1)) [Symbol.isConcatSpreadable]: "", ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) [Symbol.toPrimitive]: 0, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) [Symbol.unscopables]: true ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) }); diff --git a/tests/baselines/reference/symbolProperty22.symbols b/tests/baselines/reference/symbolProperty22.symbols index e9f6761e121..b62037e32a5 100644 --- a/tests/baselines/reference/symbolProperty22.symbols +++ b/tests/baselines/reference/symbolProperty22.symbols @@ -5,9 +5,9 @@ interface I { >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) [Symbol.unscopables](x: T): U; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) >x : Symbol(x, Decl(symbolProperty22.ts, 1, 25)) >T : Symbol(T, Decl(symbolProperty22.ts, 0, 12)) >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) @@ -27,9 +27,9 @@ declare function foo(p1: T, p2: I): U; foo("", { [Symbol.unscopables]: s => s.length }); >foo : Symbol(foo, Decl(symbolProperty22.ts, 2, 1)) ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) diff --git a/tests/baselines/reference/symbolProperty23.symbols b/tests/baselines/reference/symbolProperty23.symbols index d220f80c0f7..da9d07ffeed 100644 --- a/tests/baselines/reference/symbolProperty23.symbols +++ b/tests/baselines/reference/symbolProperty23.symbols @@ -3,9 +3,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]: () => boolean; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } class C implements I { @@ -13,9 +13,9 @@ class C implements I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) return true; } diff --git a/tests/baselines/reference/symbolProperty26.symbols b/tests/baselines/reference/symbolProperty26.symbols index 819b93e6147..46babb69a87 100644 --- a/tests/baselines/reference/symbolProperty26.symbols +++ b/tests/baselines/reference/symbolProperty26.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return ""; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty27.symbols b/tests/baselines/reference/symbolProperty27.symbols index 7ead7b14b34..69fe473e17c 100644 --- a/tests/baselines/reference/symbolProperty27.symbols +++ b/tests/baselines/reference/symbolProperty27.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return {}; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty28.symbols b/tests/baselines/reference/symbolProperty28.symbols index 9f57cd1e2e3..cf6ab1f5edb 100644 --- a/tests/baselines/reference/symbolProperty28.symbols +++ b/tests/baselines/reference/symbolProperty28.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty28.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return { x: "" }; >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) @@ -24,8 +24,8 @@ var obj = c[Symbol.toStringTag]().x; >obj : Symbol(obj, Decl(symbolProperty28.ts, 9, 3)) >c[Symbol.toStringTag]().x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) >c : Symbol(c, Decl(symbolProperty28.ts, 8, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) diff --git a/tests/baselines/reference/symbolProperty4.symbols b/tests/baselines/reference/symbolProperty4.symbols index a6594f5146b..4e17e561bce 100644 --- a/tests/baselines/reference/symbolProperty4.symbols +++ b/tests/baselines/reference/symbolProperty4.symbols @@ -3,13 +3,13 @@ var x = { >x : Symbol(x, Decl(symbolProperty4.ts, 0, 3)) [Symbol()]: 0, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) [Symbol()]() { }, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) get [Symbol()]() { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) return 0; } diff --git a/tests/baselines/reference/symbolProperty40.symbols b/tests/baselines/reference/symbolProperty40.symbols index 1f0fdaf91a7..e3e469764a8 100644 --- a/tests/baselines/reference/symbolProperty40.symbols +++ b/tests/baselines/reference/symbolProperty40.symbols @@ -3,21 +3,21 @@ class C { >C : Symbol(C, Decl(symbolProperty40.ts, 0, 0)) [Symbol.iterator](x: string): string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 1, 22)) [Symbol.iterator](x: number): number; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 2, 22)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 3, 22)) return undefined; @@ -31,13 +31,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) c[Symbol.iterator](0); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) diff --git a/tests/baselines/reference/symbolProperty41.symbols b/tests/baselines/reference/symbolProperty41.symbols index d50401a637a..622d1b693e8 100644 --- a/tests/baselines/reference/symbolProperty41.symbols +++ b/tests/baselines/reference/symbolProperty41.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty41.ts, 0, 0)) [Symbol.iterator](x: string): { x: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 35)) [Symbol.iterator](x: "hello"): { x: string; hello: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 36)) >hello : Symbol(hello, Decl(symbolProperty41.ts, 2, 47)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 3, 22)) return undefined; @@ -34,13 +34,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) c[Symbol.iterator]("hello"); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) diff --git a/tests/baselines/reference/symbolProperty45.symbols b/tests/baselines/reference/symbolProperty45.symbols index 4c3d2595c13..5aba3b8c104 100644 --- a/tests/baselines/reference/symbolProperty45.symbols +++ b/tests/baselines/reference/symbolProperty45.symbols @@ -3,16 +3,16 @@ class C { >C : Symbol(C, Decl(symbolProperty45.ts, 0, 0)) get [Symbol.hasInstance]() { ->Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1222, 32)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1222, 32)) +>Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1235, 32)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1235, 32)) return ""; } get [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) return ""; } diff --git a/tests/baselines/reference/symbolProperty5.symbols b/tests/baselines/reference/symbolProperty5.symbols index a759e09588e..7b57003e607 100644 --- a/tests/baselines/reference/symbolProperty5.symbols +++ b/tests/baselines/reference/symbolProperty5.symbols @@ -3,19 +3,19 @@ var x = { >x : Symbol(x, Decl(symbolProperty5.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) [Symbol.toPrimitive]() { }, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty50.symbols b/tests/baselines/reference/symbolProperty50.symbols index ee785ae606d..4beb1f6d9e2 100644 --- a/tests/baselines/reference/symbolProperty50.symbols +++ b/tests/baselines/reference/symbolProperty50.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty50.ts, 1, 24)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } } diff --git a/tests/baselines/reference/symbolProperty51.symbols b/tests/baselines/reference/symbolProperty51.symbols index 825f73ebcd1..32240efd986 100644 --- a/tests/baselines/reference/symbolProperty51.symbols +++ b/tests/baselines/reference/symbolProperty51.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty51.ts, 1, 21)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } } diff --git a/tests/baselines/reference/symbolProperty55.symbols b/tests/baselines/reference/symbolProperty55.symbols index e76ad43f43d..05eeace3b86 100644 --- a/tests/baselines/reference/symbolProperty55.symbols +++ b/tests/baselines/reference/symbolProperty55.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) }; @@ -14,13 +14,13 @@ module M { var Symbol: SymbolConstructor; >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 1196, 1)) +>SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 1209, 1)) // The following should be of type 'any'. This is because even though obj has a property keyed by Symbol.iterator, // the key passed in here is the *wrong* Symbol.iterator. It is not the iterator property of the global Symbol. obj[Symbol.iterator]; >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } diff --git a/tests/baselines/reference/symbolProperty56.symbols b/tests/baselines/reference/symbolProperty56.symbols index caca4686bbf..a4e335cc7d7 100644 --- a/tests/baselines/reference/symbolProperty56.symbols +++ b/tests/baselines/reference/symbolProperty56.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty56.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) }; diff --git a/tests/baselines/reference/symbolProperty57.symbols b/tests/baselines/reference/symbolProperty57.symbols index 4e0ce420388..249545872b1 100644 --- a/tests/baselines/reference/symbolProperty57.symbols +++ b/tests/baselines/reference/symbolProperty57.symbols @@ -3,14 +3,14 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) }; // Should give type 'any'. obj[Symbol["nonsense"]]; >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) diff --git a/tests/baselines/reference/symbolProperty6.symbols b/tests/baselines/reference/symbolProperty6.symbols index cedcfe69a9f..78be14d0862 100644 --- a/tests/baselines/reference/symbolProperty6.symbols +++ b/tests/baselines/reference/symbolProperty6.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty6.ts, 0, 0)) [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) [Symbol.toPrimitive]() { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty8.symbols b/tests/baselines/reference/symbolProperty8.symbols index 269a8412d95..64452f49c9c 100644 --- a/tests/baselines/reference/symbolProperty8.symbols +++ b/tests/baselines/reference/symbolProperty8.symbols @@ -3,12 +3,12 @@ interface I { >I : Symbol(I, Decl(symbolProperty8.ts, 0, 0)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) [Symbol.toPrimitive](); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) } diff --git a/tests/baselines/reference/symbolType11.symbols b/tests/baselines/reference/symbolType11.symbols index 4bf91a6112e..d40e0e72724 100644 --- a/tests/baselines/reference/symbolType11.symbols +++ b/tests/baselines/reference/symbolType11.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/Symbols/symbolType11.ts === var s = Symbol.for("logical"); >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) ->Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1208, 42)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1208, 42)) +>Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) s && s; >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) diff --git a/tests/baselines/reference/symbolType16.symbols b/tests/baselines/reference/symbolType16.symbols index 1d87ae6a1a4..4b61749b898 100644 --- a/tests/baselines/reference/symbolType16.symbols +++ b/tests/baselines/reference/symbolType16.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/Symbols/symbolType16.ts === interface Symbol { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11), Decl(symbolType16.ts, 0, 0)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11), Decl(symbolType16.ts, 0, 0)) newSymbolProp: number; >newSymbolProp : Symbol(newSymbolProp, Decl(symbolType16.ts, 0, 18)) diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols index 4d7c4d6ac4e..baa4613d26b 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperatorES6.ts === var x = `abc${ new String("Hi") }def`; >x : Symbol(x, Decl(templateStringWithEmbeddedNewOperatorES6.ts, 0, 3)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt index 7c796d47398..69d686c3156 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt @@ -1,14 +1,13 @@ -lib.d.ts(521,11): error TS2300: Duplicate identifier 'TemplateStringsArray'. -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'. -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. - Property 'raw' is missing in type '{ [x: number]: undefined; }'. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. + Property 'raw' is missing in type '{}'. ==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (2 errors) ==== class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'TemplateStringsArray'. +!!! error TS2518: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { @@ -16,7 +15,7 @@ tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2 f({}, 10, 10); ~~ -!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. -!!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'. +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. +!!! error TS2345: Property 'raw' is missing in type '{}'. f `abcdef${ 1234 }${ 5678 }ghijkl`; \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt index 4b9cb63d9aa..02ccd7f2413 100644 --- a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt @@ -1,14 +1,13 @@ -lib.d.ts(521,11): error TS2300: Duplicate identifier 'TemplateStringsArray'. -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'. -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. - Property 'raw' is missing in type '{ [x: number]: undefined; }'. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. + Property 'raw' is missing in type '{}'. ==== tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts (2 errors) ==== class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'TemplateStringsArray'. +!!! error TS2518: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { @@ -16,7 +15,7 @@ tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error T f({}, 10, 10); ~~ -!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. -!!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'. +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. +!!! error TS2345: Property 'raw' is missing in type '{}'. f `abcdef${ 1234 }${ 5678 }ghijkl`; \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeErrors.errors.txt b/tests/baselines/reference/tsxAttributeErrors.errors.txt new file mode 100644 index 00000000000..30a897c5163 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeErrors.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/jsx/tsxAttributeErrors.tsx(15,6): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeErrors.tsx(18,6): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeErrors.tsx(22,6): error TS2606: Property 'text' of JSX spread attribute is not assignable to target property. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeErrors.tsx (3 errors) ==== + + declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + width?: number; + } + + span: any; + } + } + + // Error, number is not assignable to string +
; + ~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + // Error, string is not assignable to number +
; + ~~~~~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + + // Error, number is not assignable to string + var attribs = { text: 100 }; +
; + ~~~~~~~~~~~~ +!!! error TS2606: Property 'text' of JSX spread attribute is not assignable to target property. +!!! error TS2606: Type 'number' is not assignable to type 'string'. + + // No errors here + ; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeErrors.js b/tests/baselines/reference/tsxAttributeErrors.js new file mode 100644 index 00000000000..2ab862e0efe --- /dev/null +++ b/tests/baselines/reference/tsxAttributeErrors.js @@ -0,0 +1,38 @@ +//// [tsxAttributeErrors.tsx] + +declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + width?: number; + } + + span: any; + } +} + +// Error, number is not assignable to string +
; + +// Error, string is not assignable to number +
; + +// Error, number is not assignable to string +var attribs = { text: 100 }; +
; + +// No errors here +; + + +//// [tsxAttributeErrors.jsx] +// Error, number is not assignable to string +
; +// Error, string is not assignable to number +
; +// Error, number is not assignable to string +var attribs = { text: 100 }; +
; +// No errors here +; diff --git a/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt b/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt new file mode 100644 index 00000000000..90d0d003c28 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt @@ -0,0 +1,50 @@ +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,8): error TS1003: Identifier expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,10): error TS1005: ';' expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,10): error TS2304: Cannot find name 'data'. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,15): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,18): error TS1005: ':' expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,21): error TS1109: Expression expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(10,22): error TS1109: Expression expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(11,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(11,8): error TS1003: Identifier expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(11,9): error TS2304: Cannot find name 'data'. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(11,13): error TS1005: ';' expected. +tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx(11,20): error TS1161: Unterminated regular expression literal. + + +==== tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx (12 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + test2: { "data-foo"?: string }; + } + } + + // Invalid names + ; + ~~ +!!! error TS1003: Identifier expected. + ~~~~ +!!! error TS1005: ';' expected. + ~~~~ +!!! error TS2304: Cannot find name 'data'. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~ +!!! error TS1005: ':' expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + ; + ~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~ +!!! error TS1003: Identifier expected. + ~~~~ +!!! error TS2304: Cannot find name 'data'. + ~ +!!! error TS1005: ';' expected. + +!!! error TS1161: Unterminated regular expression literal. \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeInvalidNames.js b/tests/baselines/reference/tsxAttributeInvalidNames.js new file mode 100644 index 00000000000..af1de76995c --- /dev/null +++ b/tests/baselines/reference/tsxAttributeInvalidNames.js @@ -0,0 +1,23 @@ +//// [tsxAttributeInvalidNames.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + test2: { "data-foo"?: string }; + } +} + +// Invalid names +; +; + +//// [tsxAttributeInvalidNames.jsx] +// Invalid names +; +32; +data = { 32: } / > ; + - data; +{ + 32; +} +/>;; diff --git a/tests/baselines/reference/tsxAttributeResolution.js b/tests/baselines/reference/tsxAttributeResolution.js new file mode 100644 index 00000000000..ed3915b7ff2 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution.js @@ -0,0 +1,12 @@ +//// [tsxAttributeResolution.tsx] + +declare namespace JSX { + interface IntrinsicElements { + x: { y: number; z: string; }; + } +} + + + + +//// [tsxAttributeResolution.jsx] diff --git a/tests/baselines/reference/tsxAttributeResolution.symbols b/tests/baselines/reference/tsxAttributeResolution.symbols new file mode 100644 index 00000000000..a40be3861b3 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution.symbols @@ -0,0 +1,17 @@ +=== tests/cases/conformance/jsx/tsxAttributeResolution.tsx === + +declare namespace JSX { +>JSX : Symbol(JSX, Decl(tsxAttributeResolution.tsx, 0, 0)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxAttributeResolution.tsx, 1, 23)) + + x: { y: number; z: string; }; +>x : Symbol(x, Decl(tsxAttributeResolution.tsx, 2, 30)) +>y : Symbol(y, Decl(tsxAttributeResolution.tsx, 3, 6)) +>z : Symbol(z, Decl(tsxAttributeResolution.tsx, 3, 17)) + } +} + + + diff --git a/tests/baselines/reference/tsxAttributeResolution.types b/tests/baselines/reference/tsxAttributeResolution.types new file mode 100644 index 00000000000..f0adc582944 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/jsx/tsxAttributeResolution.tsx === + +declare namespace JSX { +>JSX : any + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + x: { y: number; z: string; }; +>x : { y: number; z: string; } +>y : number +>z : string + } +} + + + diff --git a/tests/baselines/reference/tsxAttributeResolution1.errors.txt b/tests/baselines/reference/tsxAttributeResolution1.errors.txt new file mode 100644 index 00000000000..7503c5f5969 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution1.errors.txt @@ -0,0 +1,58 @@ +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(23,8): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(24,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(25,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(26,8): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(27,8): error TS2339: Property 'var' does not exist on type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(29,1): error TS2324: Property 'reqd' is missing in type '{ reqd: string; }'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(30,8): error TS2322: Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution1.tsx (7 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: { reqd: string }; + var: { var: string }; + } + } + interface Attribs1 { + x?: number; + s?: string; + } + + // OK + ; // OK + ; // OK + ; // OK + + ; // OK + ; // OK + + // Errors + ; // Error, '0' is not number + ~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + ; // Error, no property "y" + ~ +!!! error TS2339: Property 'y' does not exist on type 'Attribs1'. + ; // Error, no property "y" + ~ +!!! error TS2339: Property 'y' does not exist on type 'Attribs1'. + ; // Error, "32" is not number + ~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + ; // Error, no 'var' property + ~~~ +!!! error TS2339: Property 'var' does not exist on type 'Attribs1'. + + ; // Error, missing reqd + ~~~~~~~~~ +!!! error TS2324: Property 'reqd' is missing in type '{ reqd: string; }'. + ; // Error, reqd is not string + ~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + // Should be OK + ; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution1.js b/tests/baselines/reference/tsxAttributeResolution1.js new file mode 100644 index 00000000000..1e1efb7ea22 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution1.js @@ -0,0 +1,53 @@ +//// [tsxAttributeResolution1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: { reqd: string }; + var: { var: string }; + } +} +interface Attribs1 { + x?: number; + s?: string; +} + +// OK +; // OK +; // OK +; // OK + +; // OK +; // OK + +// Errors +; // Error, '0' is not number +; // Error, no property "y" +; // Error, no property "y" +; // Error, "32" is not number +; // Error, no 'var' property + +; // Error, missing reqd +; // Error, reqd is not string + +// Should be OK +; + + +//// [tsxAttributeResolution1.jsx] +// OK +; // OK +; // OK +; // OK +; // OK +; // OK +// Errors +; // Error, '0' is not number +; // Error, no property "y" +; // Error, no property "y" +; // Error, "32" is not number +; // Error, no 'var' property +; // Error, missing reqd +; // Error, reqd is not string +// Should be OK +; diff --git a/tests/baselines/reference/tsxAttributeResolution2.errors.txt b/tests/baselines/reference/tsxAttributeResolution2.errors.txt new file mode 100644 index 00000000000..d213ccaf54e --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution2.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/jsx/tsxAttributeResolution2.tsx(17,21): error TS2339: Property 'leng' does not exist on type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution2.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } + } + interface Attribs1 { + c1?: (x: string) => void; + } + + // OK + x.length} />; // OK + x.leng} />; // OK + + + // Errors + x.leng} />; // Error, no leng on 'string' + ~~~~ +!!! error TS2339: Property 'leng' does not exist on type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution2.js b/tests/baselines/reference/tsxAttributeResolution2.js new file mode 100644 index 00000000000..564767e6169 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution2.js @@ -0,0 +1,26 @@ +//// [tsxAttributeResolution2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + c1?: (x: string) => void; +} + +// OK + x.length} />; // OK + x.leng} />; // OK + + +// Errors + x.leng} />; // Error, no leng on 'string' + + +//// [tsxAttributeResolution2.jsx] +// OK +; // OK +; // OK +// Errors +; // Error, no leng on 'string' diff --git a/tests/baselines/reference/tsxAttributeResolution3.errors.txt b/tests/baselines/reference/tsxAttributeResolution3.errors.txt new file mode 100644 index 00000000000..c797362e8d7 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution3.errors.txt @@ -0,0 +1,59 @@ +tests/cases/conformance/jsx/tsxAttributeResolution3.tsx(19,8): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeResolution3.tsx(23,1): error TS2324: Property 'x' is missing in type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution3.tsx(31,15): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeResolution3.tsx(39,8): error TS2322: Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution3.tsx (4 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } + } + interface Attribs1 { + x: string; + y?: number; + z?: string; + } + + // OK + var obj1 = { x: 'foo' }; + + + // Error, x is not string + var obj2 = { x: 32 }; + + ~~~~~~~~~ +!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. +!!! error TS2606: Type 'number' is not assignable to type 'string'. + + // Error, x is missing + var obj3 = { y: 32 }; + + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2324: Property 'x' is missing in type 'Attribs1'. + + // OK + var obj4 = { x: 32, y: 32 }; + + + // Error + var obj5 = { x: 32, y: 32 }; + + ~~~~~~~~~ +!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. +!!! error TS2606: Type 'number' is not assignable to type 'string'. + + // OK + var obj6 = { x: 'ok', y: 32, extra: 100 }; + + + // Error + var obj7 = { x: 'foo' }; + + ~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution3.js b/tests/baselines/reference/tsxAttributeResolution3.js new file mode 100644 index 00000000000..8cf853820e1 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution3.js @@ -0,0 +1,64 @@ +//// [tsxAttributeResolution3.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + x: string; + y?: number; + z?: string; +} + +// OK +var obj1 = { x: 'foo' }; + + +// Error, x is not string +var obj2 = { x: 32 }; + + +// Error, x is missing +var obj3 = { y: 32 }; + + +// OK +var obj4 = { x: 32, y: 32 }; + + +// Error +var obj5 = { x: 32, y: 32 }; + + +// OK +var obj6 = { x: 'ok', y: 32, extra: 100 }; + + +// Error +var obj7 = { x: 'foo' }; + + + +//// [tsxAttributeResolution3.jsx] +// OK +var obj1 = { x: 'foo' }; +; +// Error, x is not string +var obj2 = { x: 32 }; +; +// Error, x is missing +var obj3 = { y: 32 }; +; +// OK +var obj4 = { x: 32, y: 32 }; +; +// Error +var obj5 = { x: 32, y: 32 }; +; +// OK +var obj6 = { x: 'ok', y: 32, extra: 100 }; +; +// Error +var obj7 = { x: 'foo' }; +; diff --git a/tests/baselines/reference/tsxAttributeResolution4.errors.txt b/tests/baselines/reference/tsxAttributeResolution4.errors.txt new file mode 100644 index 00000000000..211a349b304 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution4.errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/jsx/tsxAttributeResolution4.tsx(15,26): error TS2339: Property 'len' does not exist on type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution4.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } + } + interface Attribs1 { + x(n: string): void; + } + + // OK + 0} } />; + + // Error, no member 'len' on 'string' + n.len} } />; + ~~~ +!!! error TS2339: Property 'len' does not exist on type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution4.js b/tests/baselines/reference/tsxAttributeResolution4.js new file mode 100644 index 00000000000..d56cb4cc2e8 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution4.js @@ -0,0 +1,23 @@ +//// [tsxAttributeResolution4.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + x(n: string): void; +} + +// OK + 0} } />; + +// Error, no member 'len' on 'string' + n.len} } />; + + +//// [tsxAttributeResolution4.jsx] +// OK +; +// Error, no member 'len' on 'string' +; diff --git a/tests/baselines/reference/tsxAttributeResolution5.errors.txt b/tests/baselines/reference/tsxAttributeResolution5.errors.txt new file mode 100644 index 00000000000..1b42dd01465 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution5.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/jsx/tsxAttributeResolution5.tsx(21,16): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeResolution5.tsx(25,9): error TS2324: Property 'x' is missing in type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution5.tsx(29,1): error TS2324: Property 'x' is missing in type 'Attribs1'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution5.tsx (3 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: Attribs2; + } + } + interface Attribs1 { + x: string; + } + + interface Attribs2 { + toString(): string; + } + + function make1 (obj: T) { + return ; // OK + } + + function make2 (obj: T) { + return ; // Error (x is number, not string) + ~~~~~~~~ +!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. +!!! error TS2606: Type 'number' is not assignable to type 'string'. + } + + function make3 (obj: T) { + return ; // Error, missing x + ~~~~~~~~~~~~~~~~~~ +!!! error TS2324: Property 'x' is missing in type 'Attribs1'. + } + + + ; // Error, missing x + ~~~~~~~~~~~~~~~~~ +!!! error TS2324: Property 'x' is missing in type 'Attribs1'. + ; // OK + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution5.js b/tests/baselines/reference/tsxAttributeResolution5.js new file mode 100644 index 00000000000..34fe9a3bfb6 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution5.js @@ -0,0 +1,45 @@ +//// [tsxAttributeResolution5.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: Attribs2; + } +} +interface Attribs1 { + x: string; +} + +interface Attribs2 { + toString(): string; +} + +function make1 (obj: T) { + return ; // OK +} + +function make2 (obj: T) { + return ; // Error (x is number, not string) +} + +function make3 (obj: T) { + return ; // Error, missing x +} + + +; // Error, missing x +; // OK + + +//// [tsxAttributeResolution5.jsx] +function make1(obj) { + return ; // OK +} +function make2(obj) { + return ; // Error (x is number, not string) +} +function make3(obj) { + return ; // Error, missing x +} +; // Error, missing x +; // OK diff --git a/tests/baselines/reference/tsxAttributeResolution6.errors.txt b/tests/baselines/reference/tsxAttributeResolution6.errors.txt new file mode 100644 index 00000000000..4f1960358a5 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution6.errors.txt @@ -0,0 +1,30 @@ +tests/cases/conformance/jsx/tsxAttributeResolution6.tsx(10,8): error TS2322: Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeResolution6.tsx(11,8): error TS2322: Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/jsx/tsxAttributeResolution6.tsx(12,1): error TS2324: Property 'n' is missing in type '{ n: boolean; }'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution6.tsx (3 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { n?: boolean; s?: string}; + test2: { n: boolean; }; + } + } + + // Error + ; + ~ +!!! error TS2322: Type 'boolean' is not assignable to type 'string'. + ; + ~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. + ; + ~~~~~~~~~ +!!! error TS2324: Property 'n' is missing in type '{ n: boolean; }'. + + // OK + ; + ; + ; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution6.js b/tests/baselines/reference/tsxAttributeResolution6.js new file mode 100644 index 00000000000..f4af0ba875a --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution6.js @@ -0,0 +1,29 @@ +//// [tsxAttributeResolution6.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { n?: boolean; s?: string}; + test2: { n: boolean; }; + } +} + +// Error +; +; +; + +// OK +; +; +; + + +//// [tsxAttributeResolution6.jsx] +// Error +; +; +; +// OK +; +; +; diff --git a/tests/baselines/reference/tsxAttributeResolution7.errors.txt b/tests/baselines/reference/tsxAttributeResolution7.errors.txt new file mode 100644 index 00000000000..4d05254ace8 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution7.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/jsx/tsxAttributeResolution7.tsx(9,8): error TS2322: Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/jsx/tsxAttributeResolution7.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + } + } + + // Error + ; + ~~~~~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + // OK + ; + ; + ; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution7.js b/tests/baselines/reference/tsxAttributeResolution7.js new file mode 100644 index 00000000000..7ebd2e8f4db --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution7.js @@ -0,0 +1,24 @@ +//// [tsxAttributeResolution7.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + } +} + +// Error +; + +// OK +; +; +; + + +//// [tsxAttributeResolution7.jsx] +// Error +; +// OK +; +; +; diff --git a/tests/baselines/reference/tsxAttributeResolution8.js b/tests/baselines/reference/tsxAttributeResolution8.js new file mode 100644 index 00000000000..50fff6c80fd --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution8.js @@ -0,0 +1,16 @@ +//// [tsxAttributeResolution8.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: {x: string}; + } +} + +var x: any; +// Should be OK + + +//// [tsxAttributeResolution8.jsx] +var x; +// Should be OK +; diff --git a/tests/baselines/reference/tsxAttributeResolution8.symbols b/tests/baselines/reference/tsxAttributeResolution8.symbols new file mode 100644 index 00000000000..9bb09c6cd85 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution8.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/jsx/tsxAttributeResolution8.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxAttributeResolution8.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxAttributeResolution8.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxAttributeResolution8.tsx, 1, 22)) + + test1: {x: string}; +>test1 : Symbol(test1, Decl(tsxAttributeResolution8.tsx, 2, 30)) +>x : Symbol(x, Decl(tsxAttributeResolution8.tsx, 3, 10)) + } +} + +var x: any; +>x : Symbol(x, Decl(tsxAttributeResolution8.tsx, 7, 3)) + +// Should be OK + +>test1 : Symbol(JSX.IntrinsicElements.test1, Decl(tsxAttributeResolution8.tsx, 2, 30)) + diff --git a/tests/baselines/reference/tsxAttributeResolution8.types b/tests/baselines/reference/tsxAttributeResolution8.types new file mode 100644 index 00000000000..db89d6678b6 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution8.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsx/tsxAttributeResolution8.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + test1: {x: string}; +>test1 : { x: string; } +>x : string + } +} + +var x: any; +>x : any + +// Should be OK + +> : JSX.Element +>test1 : any +>x : any + diff --git a/tests/baselines/reference/tsxElementResolution.js b/tests/baselines/reference/tsxElementResolution.js new file mode 100644 index 00000000000..e7a4ae95e94 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution.js @@ -0,0 +1,55 @@ +//// [tsxElementResolution.tsx] + +declare namespace JSX { + interface IntrinsicElements { + foundFirst: { x: string }; + 'string_named'; + 'var'; + } +} + +class foundFirst { } +class Other {} + +module Dotted { + export class Name { } +} + +// Should find the intrinsic element, not the class element +var a = ; +var b = ; +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +var e = ; + + +//// [tsxElementResolution.jsx] +var foundFirst = (function () { + function foundFirst() { + } + return foundFirst; +})(); +var Other = (function () { + function Other() { + } + return Other; +})(); +var Dotted; +(function (Dotted) { + var Name = (function () { + function Name() { + } + return Name; + })(); + Dotted.Name = Name; +})(Dotted || (Dotted = {})); +// Should find the intrinsic element, not the class element +var a = ; +var b = ; +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +var e = ; diff --git a/tests/baselines/reference/tsxElementResolution.symbols b/tests/baselines/reference/tsxElementResolution.symbols new file mode 100644 index 00000000000..4cdd0c23cf1 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/jsx/tsxElementResolution.tsx === + +declare namespace JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution.tsx, 0, 0)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxElementResolution.tsx, 1, 23)) + + foundFirst: { x: string }; +>foundFirst : Symbol(foundFirst, Decl(tsxElementResolution.tsx, 2, 30)) +>x : Symbol(x, Decl(tsxElementResolution.tsx, 3, 15)) + + 'string_named'; + 'var'; + } +} + +class foundFirst { } +>foundFirst : Symbol(foundFirst, Decl(tsxElementResolution.tsx, 7, 1)) + +class Other {} +>Other : Symbol(Other, Decl(tsxElementResolution.tsx, 9, 20)) + +module Dotted { +>Dotted : Symbol(Dotted, Decl(tsxElementResolution.tsx, 10, 14)) + + export class Name { } +>Name : Symbol(Name, Decl(tsxElementResolution.tsx, 12, 15)) +} + +// Should find the intrinsic element, not the class element +var a = ; +>a : Symbol(a, Decl(tsxElementResolution.tsx, 17, 3)) +>foundFirst : Symbol(JSX.IntrinsicElements.foundFirst, Decl(tsxElementResolution.tsx, 2, 30)) +>x : Symbol(x, Decl(tsxElementResolution.tsx, 3, 15)) + +var b = ; +>b : Symbol(b, Decl(tsxElementResolution.tsx, 18, 3)) +>string_named : Symbol(JSX.IntrinsicElements.'string_named', Decl(tsxElementResolution.tsx, 3, 28)) + +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +>d : Symbol(d, Decl(tsxElementResolution.tsx, 22, 3)) +>Other : Symbol(Other, Decl(tsxElementResolution.tsx, 9, 20)) + +var e = ; +>e : Symbol(e, Decl(tsxElementResolution.tsx, 23, 3)) +>Name : Symbol(Dotted.Name, Decl(tsxElementResolution.tsx, 12, 15)) + diff --git a/tests/baselines/reference/tsxElementResolution.types b/tests/baselines/reference/tsxElementResolution.types new file mode 100644 index 00000000000..89600bbbc2f --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/jsx/tsxElementResolution.tsx === + +declare namespace JSX { +>JSX : any + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + foundFirst: { x: string }; +>foundFirst : { x: string; } +>x : string + + 'string_named'; + 'var'; + } +} + +class foundFirst { } +>foundFirst : foundFirst + +class Other {} +>Other : Other + +module Dotted { +>Dotted : typeof Dotted + + export class Name { } +>Name : Name +} + +// Should find the intrinsic element, not the class element +var a = ; +>a : any +> : any +>foundFirst : typeof foundFirst +>x : any + +var b = ; +>b : any +> : any +>string_named : any + +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +>d : any +> : any +>Other : typeof Other + +var e = ; +>e : any +> : any +>Dotted : any +>Name : any + diff --git a/tests/baselines/reference/tsxElementResolution1.errors.txt b/tests/baselines/reference/tsxElementResolution1.errors.txt new file mode 100644 index 00000000000..b54430bd106 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution1.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/jsx/tsxElementResolution1.tsx(12,1): error TS2339: Property 'span' does not exist on type 'JSX.IntrinsicElements'. + + +==== tests/cases/conformance/jsx/tsxElementResolution1.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } + } + + // OK +
; + + // Fail + ; + ~~~~~~~~ +!!! error TS2339: Property 'span' does not exist on type 'JSX.IntrinsicElements'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution1.js b/tests/baselines/reference/tsxElementResolution1.js new file mode 100644 index 00000000000..c7e0536bde2 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution1.js @@ -0,0 +1,19 @@ +//// [tsxElementResolution1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } +} + +// OK +
; + +// Fail +; + +//// [tsxElementResolution1.jsx] +// OK +
; +// Fail +; diff --git a/tests/baselines/reference/tsxElementResolution10.errors.txt b/tests/baselines/reference/tsxElementResolution10.errors.txt new file mode 100644 index 00000000000..6dcee7d18fa --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution10.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/jsx/tsxElementResolution10.tsx(13,1): error TS2605: JSX element type '{ x: number; }' is not a constructor function for JSX elements. + Property 'render' is missing in type '{ x: number; }'. + + +==== tests/cases/conformance/jsx/tsxElementResolution10.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface ElementClass { + render: any; + } + interface IntrinsicElements { } + } + + interface Obj1type { + new(n: string): { x: number }; + } + var Obj1: Obj1type; + ; // Error, no render member + ~~~~~~~~~~~~~~~ +!!! error TS2605: JSX element type '{ x: number; }' is not a constructor function for JSX elements. +!!! error TS2605: Property 'render' is missing in type '{ x: number; }'. + + interface Obj2type { + (n: string): { x: number; render: any; }; + } + var Obj2: Obj2type; + ; // OK + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution10.js b/tests/baselines/reference/tsxElementResolution10.js new file mode 100644 index 00000000000..84c8619ab96 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution10.js @@ -0,0 +1,27 @@ +//// [tsxElementResolution10.tsx] +declare module JSX { + interface Element { } + interface ElementClass { + render: any; + } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): { x: number }; +} +var Obj1: Obj1type; +; // Error, no render member + +interface Obj2type { + (n: string): { x: number; render: any; }; +} +var Obj2: Obj2type; +; // OK + + +//// [tsxElementResolution10.jsx] +var Obj1; +; // Error, no render member +var Obj2; +; // OK diff --git a/tests/baselines/reference/tsxElementResolution11.errors.txt b/tests/baselines/reference/tsxElementResolution11.errors.txt new file mode 100644 index 00000000000..4f3ee00d82f --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution11.errors.txt @@ -0,0 +1,30 @@ +tests/cases/conformance/jsx/tsxElementResolution11.tsx(17,7): error TS2339: Property 'x' does not exist on type '{ q?: number; }'. + + +==== tests/cases/conformance/jsx/tsxElementResolution11.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface ElementAttributesProperty { } + interface IntrinsicElements { } + } + + interface Obj1type { + new(n: string): any; + } + var Obj1: Obj1type; + ; // OK + + interface Obj2type { + new(n: string): { q?: number }; + } + var Obj2: Obj2type; + ; // Error + ~ +!!! error TS2339: Property 'x' does not exist on type '{ q?: number; }'. + + interface Obj3type { + new(n: string): { x: number; }; + } + var Obj3: Obj3type; + ; // OK + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution11.js b/tests/baselines/reference/tsxElementResolution11.js new file mode 100644 index 00000000000..fb8572116b1 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution11.js @@ -0,0 +1,33 @@ +//// [tsxElementResolution11.tsx] +declare module JSX { + interface Element { } + interface ElementAttributesProperty { } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): any; +} +var Obj1: Obj1type; +; // OK + +interface Obj2type { + new(n: string): { q?: number }; +} +var Obj2: Obj2type; +; // Error + +interface Obj3type { + new(n: string): { x: number; }; +} +var Obj3: Obj3type; +; // OK + + +//// [tsxElementResolution11.jsx] +var Obj1; +; // OK +var Obj2; +; // Error +var Obj3; +; // OK diff --git a/tests/baselines/reference/tsxElementResolution12.errors.txt b/tests/baselines/reference/tsxElementResolution12.errors.txt new file mode 100644 index 00000000000..71a22b502aa --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution12.errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/jsx/tsxElementResolution12.tsx(17,2): error TS2304: Cannot find name 'Obj2'. +tests/cases/conformance/jsx/tsxElementResolution12.tsx(23,1): error TS2607: JSX element class does not support attributes because it does not have a 'pr' property +tests/cases/conformance/jsx/tsxElementResolution12.tsx(30,7): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== tests/cases/conformance/jsx/tsxElementResolution12.tsx (3 errors) ==== + declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr: any; } + interface IntrinsicElements { } + } + + interface Obj1type { + new(n: string): any; + } + var Obj1: Obj1type; + ; // OK + + interface Obj2type { + new(n: string): { q?: number; pr: any }; + } + var obj2: Obj2type; + ; // OK + ~~~~ +!!! error TS2304: Cannot find name 'Obj2'. + + interface Obj3type { + new(n: string): { x: number; }; + } + var Obj3: Obj3type; + ; // Error + ~~~~~~~~~~~~~~~ +!!! error TS2607: JSX element class does not support attributes because it does not have a 'pr' property + + interface Obj4type { + new(n: string): { x: number; pr: { x: number; } }; + } + var Obj4: Obj4type; + ; // OK + ; // Error + ~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution12.js b/tests/baselines/reference/tsxElementResolution12.js new file mode 100644 index 00000000000..12973efdda7 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution12.js @@ -0,0 +1,43 @@ +//// [tsxElementResolution12.tsx] +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr: any; } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): any; +} +var Obj1: Obj1type; +; // OK + +interface Obj2type { + new(n: string): { q?: number; pr: any }; +} +var obj2: Obj2type; +; // OK + +interface Obj3type { + new(n: string): { x: number; }; +} +var Obj3: Obj3type; +; // Error + +interface Obj4type { + new(n: string): { x: number; pr: { x: number; } }; +} +var Obj4: Obj4type; +; // OK +; // Error + + +//// [tsxElementResolution12.jsx] +var Obj1; +; // OK +var obj2; +; // OK +var Obj3; +; // Error +var Obj4; +; // OK +; // Error diff --git a/tests/baselines/reference/tsxElementResolution13.js b/tests/baselines/reference/tsxElementResolution13.js new file mode 100644 index 00000000000..f8631bdec0c --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution13.js @@ -0,0 +1,16 @@ +//// [tsxElementResolution13.tsx] +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } +} + +interface Obj1 { + new(n: string): any; +} +var obj1: Obj1; +; // Error + + +//// [tsxElementResolution13.jsx] +var obj1; +; // Error diff --git a/tests/baselines/reference/tsxElementResolution13.symbols b/tests/baselines/reference/tsxElementResolution13.symbols new file mode 100644 index 00000000000..4022602e53a --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution13.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/jsx/tsxElementResolution13.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution13.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxElementResolution13.tsx, 0, 20)) + + interface ElementAttributesProperty { pr1: any; pr2: any; } +>ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(tsxElementResolution13.tsx, 1, 22)) +>pr1 : Symbol(pr1, Decl(tsxElementResolution13.tsx, 2, 38)) +>pr2 : Symbol(pr2, Decl(tsxElementResolution13.tsx, 2, 48)) +} + +interface Obj1 { +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution13.tsx, 3, 1)) + + new(n: string): any; +>n : Symbol(n, Decl(tsxElementResolution13.tsx, 6, 5)) +} +var obj1: Obj1; +>obj1 : Symbol(obj1, Decl(tsxElementResolution13.tsx, 8, 3)) +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution13.tsx, 3, 1)) + +; // Error +>x : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxElementResolution13.types b/tests/baselines/reference/tsxElementResolution13.types new file mode 100644 index 00000000000..cd6265de091 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution13.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/tsxElementResolution13.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface ElementAttributesProperty { pr1: any; pr2: any; } +>ElementAttributesProperty : ElementAttributesProperty +>pr1 : any +>pr2 : any +} + +interface Obj1 { +>Obj1 : Obj1 + + new(n: string): any; +>n : string +} +var obj1: Obj1; +>obj1 : Obj1 +>Obj1 : Obj1 + +; // Error +> : JSX.Element +>obj1 : Obj1 +>x : any + diff --git a/tests/baselines/reference/tsxElementResolution14.js b/tests/baselines/reference/tsxElementResolution14.js new file mode 100644 index 00000000000..e1e440db5f3 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution14.js @@ -0,0 +1,15 @@ +//// [tsxElementResolution14.tsx] +declare module JSX { + interface Element { } +} + +interface Obj1 { + new(n: string): {}; +} +var obj1: Obj1; +; // OK + + +//// [tsxElementResolution14.jsx] +var obj1; +; // OK diff --git a/tests/baselines/reference/tsxElementResolution14.symbols b/tests/baselines/reference/tsxElementResolution14.symbols new file mode 100644 index 00000000000..58236a4e462 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution14.symbols @@ -0,0 +1,21 @@ +=== tests/cases/conformance/jsx/tsxElementResolution14.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution14.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxElementResolution14.tsx, 0, 20)) +} + +interface Obj1 { +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution14.tsx, 2, 1)) + + new(n: string): {}; +>n : Symbol(n, Decl(tsxElementResolution14.tsx, 5, 5)) +} +var obj1: Obj1; +>obj1 : Symbol(obj1, Decl(tsxElementResolution14.tsx, 7, 3)) +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution14.tsx, 2, 1)) + +; // OK +>x : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxElementResolution14.types b/tests/baselines/reference/tsxElementResolution14.types new file mode 100644 index 00000000000..ef03187d28e --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution14.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/jsx/tsxElementResolution14.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element +} + +interface Obj1 { +>Obj1 : Obj1 + + new(n: string): {}; +>n : string +} +var obj1: Obj1; +>obj1 : Obj1 +>Obj1 : Obj1 + +; // OK +> : JSX.Element +>obj1 : Obj1 +>x : any + diff --git a/tests/baselines/reference/tsxElementResolution15.errors.txt b/tests/baselines/reference/tsxElementResolution15.errors.txt new file mode 100644 index 00000000000..24480ab7f2b --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution15.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/jsx/tsxElementResolution15.tsx(3,12): error TS2608: The global type 'JSX.ElementAttributesProperty' may not have more than one property + + +==== tests/cases/conformance/jsx/tsxElementResolution15.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2608: The global type 'JSX.ElementAttributesProperty' may not have more than one property + interface IntrinsicElements { } + } + + interface Obj1type { + new(n: string): {}; + } + var Obj1: Obj1type; + ; // Error + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution15.js b/tests/baselines/reference/tsxElementResolution15.js new file mode 100644 index 00000000000..831b3a54b41 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution15.js @@ -0,0 +1,17 @@ +//// [tsxElementResolution15.tsx] +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): {}; +} +var Obj1: Obj1type; +; // Error + + +//// [tsxElementResolution15.jsx] +var Obj1; +; // Error diff --git a/tests/baselines/reference/tsxElementResolution16.errors.txt b/tests/baselines/reference/tsxElementResolution16.errors.txt new file mode 100644 index 00000000000..0e30cad9673 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution16.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/jsx/tsxElementResolution16.tsx(8,1): error TS2602: JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist. +tests/cases/conformance/jsx/tsxElementResolution16.tsx(8,1): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists + + +==== tests/cases/conformance/jsx/tsxElementResolution16.tsx (2 errors) ==== + declare module JSX { + } + + interface Obj1 { + new(n: string): {}; + } + var obj1: Obj1; + ; // Error (JSX.Element is implicit any) + ~~~~~~~~~~~~~~~ +!!! error TS2602: JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist. + ~~~~~~~~~~~~~~~ +!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution16.js b/tests/baselines/reference/tsxElementResolution16.js new file mode 100644 index 00000000000..1961215fa05 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution16.js @@ -0,0 +1,14 @@ +//// [tsxElementResolution16.tsx] +declare module JSX { +} + +interface Obj1 { + new(n: string): {}; +} +var obj1: Obj1; +; // Error (JSX.Element is implicit any) + + +//// [tsxElementResolution16.jsx] +var obj1; +; // Error (JSX.Element is implicit any) diff --git a/tests/baselines/reference/tsxElementResolution17.js b/tests/baselines/reference/tsxElementResolution17.js new file mode 100644 index 00000000000..cd8d7e13beb --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution17.js @@ -0,0 +1,34 @@ +//// [tests/cases/conformance/jsx/tsxElementResolution17.tsx] //// + +//// [file.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +declare module 'elements1' { + class MyElement { + + } +} + +declare module 'elements2' { + class MyElement { + + } +} + +//// [consumer.tsx] +/// +// Should keep s1 and elide s2 +import s1 = require('elements1'); +import s2 = require('elements2'); +; + + +//// [file.jsx] +//// [consumer.jsx] +define(["require", "exports", 'elements1'], function (require, exports, s1) { + ; +}); diff --git a/tests/baselines/reference/tsxElementResolution17.symbols b/tests/baselines/reference/tsxElementResolution17.symbols new file mode 100644 index 00000000000..0b4459552de --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution17.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/jsx/consumer.tsx === +/// +// Should keep s1 and elide s2 +import s1 = require('elements1'); +>s1 : Symbol(s1, Decl(consumer.tsx, 0, 0)) + +import s2 = require('elements2'); +>s2 : Symbol(s2, Decl(consumer.tsx, 2, 33)) + +; +>MyElement : Symbol(s1.MyElement, Decl(file.tsx, 6, 28)) + +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : Symbol(JSX, Decl(file.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file.tsx, 1, 20)) + + interface IntrinsicElements { } +>IntrinsicElements : Symbol(IntrinsicElements, Decl(file.tsx, 2, 22)) +} + +declare module 'elements1' { + class MyElement { +>MyElement : Symbol(MyElement, Decl(file.tsx, 6, 28)) + + } +} + +declare module 'elements2' { + class MyElement { +>MyElement : Symbol(MyElement, Decl(file.tsx, 12, 28)) + + } +} + diff --git a/tests/baselines/reference/tsxElementResolution17.types b/tests/baselines/reference/tsxElementResolution17.types new file mode 100644 index 00000000000..e6396a9a60b --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution17.types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/jsx/consumer.tsx === +/// +// Should keep s1 and elide s2 +import s1 = require('elements1'); +>s1 : typeof s1 + +import s2 = require('elements2'); +>s2 : typeof s2 + +; +> : JSX.Element +>s1 : any +>MyElement : any + +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { } +>IntrinsicElements : IntrinsicElements +} + +declare module 'elements1' { + class MyElement { +>MyElement : MyElement + + } +} + +declare module 'elements2' { + class MyElement { +>MyElement : MyElement + + } +} + diff --git a/tests/baselines/reference/tsxElementResolution18.errors.txt b/tests/baselines/reference/tsxElementResolution18.errors.txt new file mode 100644 index 00000000000..a4728b2f749 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution18.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/jsx/tsxElementResolution18.tsx(6,1): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists + + +==== tests/cases/conformance/jsx/tsxElementResolution18.tsx (1 errors) ==== + declare module JSX { + interface Element { } + } + + // Error under implicit any +
; + ~~~~~~~~~~~~~ +!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution18.js b/tests/baselines/reference/tsxElementResolution18.js new file mode 100644 index 00000000000..0b5138b7b49 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution18.js @@ -0,0 +1,12 @@ +//// [tsxElementResolution18.tsx] +declare module JSX { + interface Element { } +} + +// Error under implicit any +
; + + +//// [tsxElementResolution18.jsx] +// Error under implicit any +
; diff --git a/tests/baselines/reference/tsxElementResolution19.js b/tests/baselines/reference/tsxElementResolution19.js new file mode 100644 index 00000000000..72612e8ce54 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution19.js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/jsx/tsxElementResolution19.tsx] //// + +//// [react.d.ts] + +declare module "react" { + +} + +//// [file1.tsx] +declare module JSX { + interface Element { } +} +export class MyClass { } + +//// [file2.tsx] + +// Should not elide React import +import * as React from 'react'; +import {MyClass} from './file1'; + +; + + +//// [file1.js] +define(["require", "exports"], function (require, exports) { + var MyClass = (function () { + function MyClass() { + } + return MyClass; + })(); + exports.MyClass = MyClass; +}); +//// [file2.js] +define(["require", "exports", 'react', './file1'], function (require, exports, React, file1_1) { + React.createElement(file1_1.MyClass, null); +}); diff --git a/tests/baselines/reference/tsxElementResolution19.symbols b/tests/baselines/reference/tsxElementResolution19.symbols new file mode 100644 index 00000000000..48aa4f962b6 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution19.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +No type information for this code.declare module "react" { +No type information for this code. +No type information for this code.} +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsx/file1.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(file1.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file1.tsx, 0, 20)) +} +export class MyClass { } +>MyClass : Symbol(MyClass, Decl(file1.tsx, 2, 1)) + +=== tests/cases/conformance/jsx/file2.tsx === + +// Should not elide React import +import * as React from 'react'; +>React : Symbol(React, Decl(file2.tsx, 2, 6)) + +import {MyClass} from './file1'; +>MyClass : Symbol(MyClass, Decl(file2.tsx, 3, 8)) + +; +>MyClass : Symbol(MyClass, Decl(file2.tsx, 3, 8)) + diff --git a/tests/baselines/reference/tsxElementResolution19.types b/tests/baselines/reference/tsxElementResolution19.types new file mode 100644 index 00000000000..0fa1eefe5f6 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution19.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +No type information for this code.declare module "react" { +No type information for this code. +No type information for this code.} +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsx/file1.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element +} +export class MyClass { } +>MyClass : MyClass + +=== tests/cases/conformance/jsx/file2.tsx === + +// Should not elide React import +import * as React from 'react'; +>React : typeof React + +import {MyClass} from './file1'; +>MyClass : typeof MyClass + +; +> : any +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/tsxElementResolution2.js b/tests/baselines/reference/tsxElementResolution2.js new file mode 100644 index 00000000000..1d06656d529 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution2.js @@ -0,0 +1,19 @@ +//// [tsxElementResolution2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: any; + } +} + +// OK +
; + +// OK +; + +//// [tsxElementResolution2.jsx] +// OK +
; +// OK +; diff --git a/tests/baselines/reference/tsxElementResolution2.symbols b/tests/baselines/reference/tsxElementResolution2.symbols new file mode 100644 index 00000000000..2935bcd4f63 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution2.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/jsx/tsxElementResolution2.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution2.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxElementResolution2.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxElementResolution2.tsx, 1, 22)) + + [x: string]: any; +>x : Symbol(x, Decl(tsxElementResolution2.tsx, 3, 6)) + } +} + +// OK +
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxElementResolution2.tsx, 1, 22)) + +// OK +; +>span : Symbol(JSX.IntrinsicElements, Decl(tsxElementResolution2.tsx, 1, 22)) + diff --git a/tests/baselines/reference/tsxElementResolution2.types b/tests/baselines/reference/tsxElementResolution2.types new file mode 100644 index 00000000000..56ea5158253 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution2.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsx/tsxElementResolution2.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [x: string]: any; +>x : string + } +} + +// OK +
; +>
: JSX.Element +>div : any + +// OK +; +> : JSX.Element +>span : any + diff --git a/tests/baselines/reference/tsxElementResolution3.errors.txt b/tests/baselines/reference/tsxElementResolution3.errors.txt new file mode 100644 index 00000000000..bc3c7c5ebfc --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution3.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/jsx/tsxElementResolution3.tsx(12,1): error TS2324: Property 'n' is missing in type '{ n: string; }'. +tests/cases/conformance/jsx/tsxElementResolution3.tsx(12,7): error TS2339: Property 'w' does not exist on type '{ n: string; }'. + + +==== tests/cases/conformance/jsx/tsxElementResolution3.tsx (2 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: { n: string; }; + } + } + + // OK +
; + + // Error + ; + ~~~~~~~~~~~~~~~~ +!!! error TS2324: Property 'n' is missing in type '{ n: string; }'. + ~ +!!! error TS2339: Property 'w' does not exist on type '{ n: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution3.js b/tests/baselines/reference/tsxElementResolution3.js new file mode 100644 index 00000000000..607d1c5ec66 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution3.js @@ -0,0 +1,19 @@ +//// [tsxElementResolution3.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: { n: string; }; + } +} + +// OK +
; + +// Error +; + +//// [tsxElementResolution3.jsx] +// OK +
; +// Error +; diff --git a/tests/baselines/reference/tsxElementResolution4.errors.txt b/tests/baselines/reference/tsxElementResolution4.errors.txt new file mode 100644 index 00000000000..0e383af5e7b --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution4.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/jsx/tsxElementResolution4.tsx(16,1): error TS2324: Property 'm' is missing in type '{ m: string; }'. +tests/cases/conformance/jsx/tsxElementResolution4.tsx(16,7): error TS2339: Property 'q' does not exist on type '{ m: string; }'. + + +==== tests/cases/conformance/jsx/tsxElementResolution4.tsx (2 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + div: { n: string; }; + span: { m: string; }; + } + } + + // OK +
; + + // OK + ; + + // Error + ; + ~~~~~~~~~~~~~ +!!! error TS2324: Property 'm' is missing in type '{ m: string; }'. + ~ +!!! error TS2339: Property 'q' does not exist on type '{ m: string; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution4.js b/tests/baselines/reference/tsxElementResolution4.js new file mode 100644 index 00000000000..ea395cb5077 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution4.js @@ -0,0 +1,26 @@ +//// [tsxElementResolution4.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: { n: string; }; + span: { m: string; }; + } +} + +// OK +
; + +// OK +; + +// Error +; + + +//// [tsxElementResolution4.jsx] +// OK +
; +// OK +; +// Error +; diff --git a/tests/baselines/reference/tsxElementResolution5.js b/tests/baselines/reference/tsxElementResolution5.js new file mode 100644 index 00000000000..8aadfec0f78 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution5.js @@ -0,0 +1,12 @@ +//// [tsxElementResolution5.tsx] +declare module JSX { + interface Element { } +} + +// OK, but implicit any +
; + + +//// [tsxElementResolution5.jsx] +// OK, but implicit any +
; diff --git a/tests/baselines/reference/tsxElementResolution5.symbols b/tests/baselines/reference/tsxElementResolution5.symbols new file mode 100644 index 00000000000..8bbbfaaeb68 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution5.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/jsx/tsxElementResolution5.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution5.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxElementResolution5.tsx, 0, 20)) +} + +// OK, but implicit any +
; +>n : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxElementResolution5.types b/tests/baselines/reference/tsxElementResolution5.types new file mode 100644 index 00000000000..ba3509f4fa1 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution5.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/jsx/tsxElementResolution5.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element +} + +// OK, but implicit any +
; +>
: JSX.Element +>div : any +>n : any + diff --git a/tests/baselines/reference/tsxElementResolution6.errors.txt b/tests/baselines/reference/tsxElementResolution6.errors.txt new file mode 100644 index 00000000000..1336cc6df0c --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution6.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/jsx/tsxElementResolution6.tsx(8,1): error TS2339: Property 'div' does not exist on type 'JSX.IntrinsicElements'. + + +==== tests/cases/conformance/jsx/tsxElementResolution6.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { } + } + + var div: any; + // Still an error +
; + ~~~~~~~~~~~~~ +!!! error TS2339: Property 'div' does not exist on type 'JSX.IntrinsicElements'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution6.js b/tests/baselines/reference/tsxElementResolution6.js new file mode 100644 index 00000000000..1b6d174fea8 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution6.js @@ -0,0 +1,15 @@ +//// [tsxElementResolution6.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +var div: any; +// Still an error +
; + + +//// [tsxElementResolution6.jsx] +var div; +// Still an error +
; diff --git a/tests/baselines/reference/tsxElementResolution7.errors.txt b/tests/baselines/reference/tsxElementResolution7.errors.txt new file mode 100644 index 00000000000..b8549e19535 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution7.errors.txt @@ -0,0 +1,30 @@ +tests/cases/conformance/jsx/tsxElementResolution7.tsx(12,5): error TS2339: Property 'other' does not exist on type 'typeof my'. +tests/cases/conformance/jsx/tsxElementResolution7.tsx(19,11): error TS2339: Property 'non' does not exist on type 'typeof my'. + + +==== tests/cases/conformance/jsx/tsxElementResolution7.tsx (2 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { } + } + + module my { + export var div: any; + } + // OK + ; + // Error + ; + ~~~~~ +!!! error TS2339: Property 'other' does not exist on type 'typeof my'. + + module q { + import mine = my; + // OK + ; + // Error + ; + ~~~ +!!! error TS2339: Property 'non' does not exist on type 'typeof my'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution7.js b/tests/baselines/reference/tsxElementResolution7.js new file mode 100644 index 00000000000..7df44b052a2 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution7.js @@ -0,0 +1,39 @@ +//// [tsxElementResolution7.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +module my { + export var div: any; +} +// OK +; +// Error +; + +module q { + import mine = my; + // OK + ; + // Error + ; +} + + +//// [tsxElementResolution7.jsx] +var my; +(function (my) { +})(my || (my = {})); +// OK +; +// Error +; +var q; +(function (q) { + var mine = my; + // OK + ; + // Error + ; +})(q || (q = {})); diff --git a/tests/baselines/reference/tsxElementResolution8.errors.txt b/tests/baselines/reference/tsxElementResolution8.errors.txt new file mode 100644 index 00000000000..5710c4e177d --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution8.errors.txt @@ -0,0 +1,50 @@ +tests/cases/conformance/jsx/tsxElementResolution8.tsx(8,2): error TS2604: JSX element type 'Div' does not have any construct or call signatures. +tests/cases/conformance/jsx/tsxElementResolution8.tsx(16,2): error TS2601: The return type of a JSX element constructor must return an object type. +tests/cases/conformance/jsx/tsxElementResolution8.tsx(29,2): error TS2601: The return type of a JSX element constructor must return an object type. +tests/cases/conformance/jsx/tsxElementResolution8.tsx(34,2): error TS2604: JSX element type 'Obj3' does not have any construct or call signatures. + + +==== tests/cases/conformance/jsx/tsxElementResolution8.tsx (4 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { } + } + + // Error + var Div = 3; +
; + ~~~ +!!! error TS2604: JSX element type 'Div' does not have any construct or call signatures. + + // OK + function Fact(): any { return null; } + + + // Error + function Fnum(): number{ return 42; } + + ~~~~ +!!! error TS2601: The return type of a JSX element constructor must return an object type. + + interface Obj1 { + new(): {}; + (): number; + } + var Obj1: Obj1; + ; // OK, prefer construct signatures + + interface Obj2 { + (): number; + } + var Obj2: Obj2; + ; // Error + ~~~~ +!!! error TS2601: The return type of a JSX element constructor must return an object type. + + interface Obj3 { + } + var Obj3: Obj3; + ; // Error + ~~~~ +!!! error TS2604: JSX element type 'Obj3' does not have any construct or call signatures. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution8.js b/tests/baselines/reference/tsxElementResolution8.js new file mode 100644 index 00000000000..4217761c402 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution8.js @@ -0,0 +1,53 @@ +//// [tsxElementResolution8.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +// Error +var Div = 3; +
; + +// OK +function Fact(): any { return null; } + + +// Error +function Fnum(): number{ return 42; } + + +interface Obj1 { + new(): {}; + (): number; +} +var Obj1: Obj1; +; // OK, prefer construct signatures + +interface Obj2 { + (): number; +} +var Obj2: Obj2; +; // Error + +interface Obj3 { +} +var Obj3: Obj3; +; // Error + + +//// [tsxElementResolution8.jsx] +// Error +var Div = 3; +
; +// OK +function Fact() { return null; } +; +// Error +function Fnum() { return 42; } +; +var Obj1; +; // OK, prefer construct signatures +var Obj2; +; // Error +var Obj3; +; // Error diff --git a/tests/baselines/reference/tsxElementResolution9.errors.txt b/tests/baselines/reference/tsxElementResolution9.errors.txt new file mode 100644 index 00000000000..f4412719b33 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution9.errors.txt @@ -0,0 +1,35 @@ +tests/cases/conformance/jsx/tsxElementResolution9.tsx(11,2): error TS2601: The return type of a JSX element constructor must return an object type. +tests/cases/conformance/jsx/tsxElementResolution9.tsx(18,2): error TS2601: The return type of a JSX element constructor must return an object type. + + +==== tests/cases/conformance/jsx/tsxElementResolution9.tsx (2 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { } + } + + interface Obj1 { + new(n: string): { x: number }; + new(n: number): { y: string }; + } + var Obj1: Obj1; + ; // Error, return type is not an object type + ~~~~ +!!! error TS2601: The return type of a JSX element constructor must return an object type. + + interface Obj2 { + (n: string): { x: number }; + (n: number): { y: string }; + } + var Obj2: Obj2; + ; // Error, return type is not an object type + ~~~~ +!!! error TS2601: The return type of a JSX element constructor must return an object type. + + interface Obj3 { + (n: string): { x: number }; + (n: number): { x: number; y: string }; + } + var Obj3: Obj3; + ; // OK + \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution9.js b/tests/baselines/reference/tsxElementResolution9.js new file mode 100644 index 00000000000..c897a51eaeb --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution9.js @@ -0,0 +1,35 @@ +//// [tsxElementResolution9.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +interface Obj1 { + new(n: string): { x: number }; + new(n: number): { y: string }; +} +var Obj1: Obj1; +; // Error, return type is not an object type + +interface Obj2 { + (n: string): { x: number }; + (n: number): { y: string }; +} +var Obj2: Obj2; +; // Error, return type is not an object type + +interface Obj3 { + (n: string): { x: number }; + (n: number): { x: number; y: string }; +} +var Obj3: Obj3; +; // OK + + +//// [tsxElementResolution9.jsx] +var Obj1; +; // Error, return type is not an object type +var Obj2; +; // Error, return type is not an object type +var Obj3; +; // OK diff --git a/tests/baselines/reference/tsxEmit1.js b/tests/baselines/reference/tsxEmit1.js new file mode 100644 index 00000000000..baa75526dd7 --- /dev/null +++ b/tests/baselines/reference/tsxEmit1.js @@ -0,0 +1,75 @@ +//// [tsxEmit1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; + +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; + +class SomeClass { + f() { + var rewrites1 =
{() => this}
; + var rewrites2 =
{[p, ...p, p]}
; + var rewrites3 =
{{p}}
; + + var rewrites4 =
this}>
; + var rewrites5 =
; + var rewrites6 =
; + } +} + +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; + + +//// [tsxEmit1.jsx] +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; +var SomeClass = (function () { + function SomeClass() { + } + SomeClass.prototype.f = function () { + var _this = this; + var rewrites1 =
{function () { return _this; }}
; + var rewrites2 =
{[p].concat(p, [p])}
; + var rewrites3 =
{{ p: p }}
; + var rewrites4 =
; + var rewrites5 =
; + var rewrites6 =
; + }; + return SomeClass; +})(); +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; diff --git a/tests/baselines/reference/tsxEmit1.symbols b/tests/baselines/reference/tsxEmit1.symbols new file mode 100644 index 00000000000..284f6cd9ce7 --- /dev/null +++ b/tests/baselines/reference/tsxEmit1.symbols @@ -0,0 +1,144 @@ +=== tests/cases/conformance/jsx/tsxEmit1.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxEmit1.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxEmit1.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxEmit1.tsx, 3, 3)) + } +} + +var p; +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + +var selfClosed1 =
; +>selfClosed1 : Symbol(selfClosed1, Decl(tsxEmit1.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + +var selfClosed2 =
; +>selfClosed2 : Symbol(selfClosed2, Decl(tsxEmit1.tsx, 9, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) + +var selfClosed3 =
; +>selfClosed3 : Symbol(selfClosed3, Decl(tsxEmit1.tsx, 10, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) + +var selfClosed4 =
; +>selfClosed4 : Symbol(selfClosed4, Decl(tsxEmit1.tsx, 11, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed5 =
; +>selfClosed5 : Symbol(selfClosed5, Decl(tsxEmit1.tsx, 12, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed6 =
; +>selfClosed6 : Symbol(selfClosed6, Decl(tsxEmit1.tsx, 13, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed7 =
; +>selfClosed7 : Symbol(selfClosed7, Decl(tsxEmit1.tsx, 14, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var openClosed1 =
; +>openClosed1 : Symbol(openClosed1, Decl(tsxEmit1.tsx, 16, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + +var openClosed2 =
foo
; +>openClosed2 : Symbol(openClosed2, Decl(tsxEmit1.tsx, 17, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>n : Symbol(unknown) + +var openClosed3 =
{p}
; +>openClosed3 : Symbol(openClosed3, Decl(tsxEmit1.tsx, 18, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>n : Symbol(unknown) + +var openClosed4 =
{p < p}
; +>openClosed4 : Symbol(openClosed4, Decl(tsxEmit1.tsx, 19, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>n : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + +var openClosed5 =
{p > p}
; +>openClosed5 : Symbol(openClosed5, Decl(tsxEmit1.tsx, 20, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>n : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + +class SomeClass { +>SomeClass : Symbol(SomeClass, Decl(tsxEmit1.tsx, 20, 43)) + + f() { +>f : Symbol(f, Decl(tsxEmit1.tsx, 22, 17)) + + var rewrites1 =
{() => this}
; +>rewrites1 : Symbol(rewrites1, Decl(tsxEmit1.tsx, 24, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>this : Symbol(SomeClass, Decl(tsxEmit1.tsx, 20, 43)) + + var rewrites2 =
{[p, ...p, p]}
; +>rewrites2 : Symbol(rewrites2, Decl(tsxEmit1.tsx, 25, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + + var rewrites3 =
{{p}}
; +>rewrites3 : Symbol(rewrites3, Decl(tsxEmit1.tsx, 26, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 26, 25)) + + var rewrites4 =
this}>
; +>rewrites4 : Symbol(rewrites4, Decl(tsxEmit1.tsx, 28, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>this : Symbol(SomeClass, Decl(tsxEmit1.tsx, 20, 43)) + + var rewrites5 =
; +>rewrites5 : Symbol(rewrites5, Decl(tsxEmit1.tsx, 29, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + + var rewrites6 =
; +>rewrites6 : Symbol(rewrites6, Decl(tsxEmit1.tsx, 30, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 30, 27)) + } +} + +var whitespace1 =
; +>whitespace1 : Symbol(whitespace1, Decl(tsxEmit1.tsx, 34, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + +var whitespace2 =
{p}
; +>whitespace2 : Symbol(whitespace2, Decl(tsxEmit1.tsx, 35, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + +var whitespace3 =
+>whitespace3 : Symbol(whitespace3, Decl(tsxEmit1.tsx, 36, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) + + {p} +
; + diff --git a/tests/baselines/reference/tsxEmit1.types b/tests/baselines/reference/tsxEmit1.types new file mode 100644 index 00000000000..667ec113337 --- /dev/null +++ b/tests/baselines/reference/tsxEmit1.types @@ -0,0 +1,194 @@ +=== tests/cases/conformance/jsx/tsxEmit1.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +var p; +>p : any + +var selfClosed1 =
; +>selfClosed1 : JSX.Element +>
: JSX.Element +>div : any + +var selfClosed2 =
; +>selfClosed2 : JSX.Element +>
: JSX.Element +>div : any +>x : any + +var selfClosed3 =
; +>selfClosed3 : JSX.Element +>
: JSX.Element +>div : any +>x : any + +var selfClosed4 =
; +>selfClosed4 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed5 =
; +>selfClosed5 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed6 =
; +>selfClosed6 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed7 =
; +>selfClosed7 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>p : any +>y : any + +var openClosed1 =
; +>openClosed1 : JSX.Element +>
: JSX.Element +>div : any +>div : any + +var openClosed2 =
foo
; +>openClosed2 : JSX.Element +>
foo
: JSX.Element +>div : any +>n : any +>div : any + +var openClosed3 =
{p}
; +>openClosed3 : JSX.Element +>
{p}
: JSX.Element +>div : any +>n : any +>p : any +>div : any + +var openClosed4 =
{p < p}
; +>openClosed4 : JSX.Element +>
{p < p}
: JSX.Element +>div : any +>n : any +>p < p : boolean +>p : any +>p : any +>div : any + +var openClosed5 =
{p > p}
; +>openClosed5 : JSX.Element +>
{p > p}
: JSX.Element +>div : any +>n : any +>p > p : boolean +>p : any +>p : any +>div : any + +class SomeClass { +>SomeClass : SomeClass + + f() { +>f : () => void + + var rewrites1 =
{() => this}
; +>rewrites1 : JSX.Element +>
{() => this}
: JSX.Element +>div : any +>() => this : () => SomeClass +>this : SomeClass +>div : any + + var rewrites2 =
{[p, ...p, p]}
; +>rewrites2 : JSX.Element +>
{[p, ...p, p]}
: JSX.Element +>div : any +>[p, ...p, p] : any[] +>p : any +>...p : any +>p : any +>p : any +>div : any + + var rewrites3 =
{{p}}
; +>rewrites3 : JSX.Element +>
{{p}}
: JSX.Element +>div : any +>{p} : { p: any; } +>p : any +>div : any + + var rewrites4 =
this}>
; +>rewrites4 : JSX.Element +>
this}>
: JSX.Element +>div : any +>a : any +>() => this : () => SomeClass +>this : SomeClass +>div : any + + var rewrites5 =
; +>rewrites5 : JSX.Element +>
: JSX.Element +>div : any +>a : any +>[p, ...p, p] : any[] +>p : any +>...p : any +>p : any +>p : any +>div : any + + var rewrites6 =
; +>rewrites6 : JSX.Element +>
: JSX.Element +>div : any +>a : any +>{p} : { p: any; } +>p : any +>div : any + } +} + +var whitespace1 =
; +>whitespace1 : JSX.Element +>
: JSX.Element +>div : any +>div : any + +var whitespace2 =
{p}
; +>whitespace2 : JSX.Element +>
{p}
: JSX.Element +>div : any +>p : any +>div : any + +var whitespace3 =
+>whitespace3 : JSX.Element +>
{p}
: JSX.Element +>div : any + + {p} +>p : any + +
; +>div : any + diff --git a/tests/baselines/reference/tsxEmit2.js b/tests/baselines/reference/tsxEmit2.js new file mode 100644 index 00000000000..1101df49a1c --- /dev/null +++ b/tests/baselines/reference/tsxEmit2.js @@ -0,0 +1,23 @@ +//// [tsxEmit2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; + + +//// [tsxEmit2.jsx] +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; diff --git a/tests/baselines/reference/tsxEmit2.symbols b/tests/baselines/reference/tsxEmit2.symbols new file mode 100644 index 00000000000..28f6a9f5026 --- /dev/null +++ b/tests/baselines/reference/tsxEmit2.symbols @@ -0,0 +1,44 @@ +=== tests/cases/conformance/jsx/tsxEmit2.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxEmit2.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxEmit2.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxEmit2.tsx, 3, 3)) + } +} + +var p1, p2, p3; +>p1 : Symbol(p1, Decl(tsxEmit2.tsx, 7, 3)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) +>p3 : Symbol(p3, Decl(tsxEmit2.tsx, 7, 11)) + +var spreads1 =
{p2}
; +>spreads1 : Symbol(spreads1, Decl(tsxEmit2.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) + +var spreads2 =
{p2}
; +>spreads2 : Symbol(spreads2, Decl(tsxEmit2.tsx, 9, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) + +var spreads3 =
{p2}
; +>spreads3 : Symbol(spreads3, Decl(tsxEmit2.tsx, 10, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>x : Symbol(unknown) + +var spreads4 =
{p2}
; +>spreads4 : Symbol(spreads4, Decl(tsxEmit2.tsx, 11, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>x : Symbol(unknown) + +var spreads5 =
{p2}
; +>spreads5 : Symbol(spreads5, Decl(tsxEmit2.tsx, 12, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxEmit2.types b/tests/baselines/reference/tsxEmit2.types new file mode 100644 index 00000000000..f5633b739e3 --- /dev/null +++ b/tests/baselines/reference/tsxEmit2.types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/jsx/tsxEmit2.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +var p1, p2, p3; +>p1 : any +>p2 : any +>p3 : any + +var spreads1 =
{p2}
; +>spreads1 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>p2 : any +>div : any + +var spreads2 =
{p2}
; +>spreads2 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>p2 : any +>div : any + +var spreads3 =
{p2}
; +>spreads3 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>x : any +>p3 : any +>p1 : any +>p2 : any +>div : any + +var spreads4 =
{p2}
; +>spreads4 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>x : any +>p3 : any +>p2 : any +>div : any + +var spreads5 =
{p2}
; +>spreads5 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>x : any +>p2 : any +>p1 : any +>y : any +>p3 : any +>p2 : any +>div : any + diff --git a/tests/baselines/reference/tsxEmit3.js b/tests/baselines/reference/tsxEmit3.js new file mode 100644 index 00000000000..beae73e2bf1 --- /dev/null +++ b/tests/baselines/reference/tsxEmit3.js @@ -0,0 +1,84 @@ +//// [tsxEmit3.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +module M { + export class Foo { constructor() { } } + export module S { + export class Bar { } + + // Emit Foo + // Foo, ; + } +} + +module M { + // Emit M.Foo + Foo, ; + + export module S { + // Emit M.Foo + Foo, ; + + // Emit S.Bar + Bar, ; + } + +} + +module M { + // Emit M.S.Bar + S.Bar, ; +} + +module M { + var M = 100; + // Emit M_1.Foo + Foo, ; +} + + +//// [tsxEmit3.jsx] +var M; +(function (M) { + var Foo = (function () { + function Foo() { + } + return Foo; + })(); + M.Foo = Foo; + var S; + (function (S) { + var Bar = (function () { + function Bar() { + } + return Bar; + })(); + S.Bar = Bar; + })(S = M.S || (M.S = {})); +})(M || (M = {})); +var M; +(function (M) { + // Emit M.Foo + M.Foo, ; + var S; + (function (S) { + // Emit M.Foo + M.Foo, ; + // Emit S.Bar + S.Bar, ; + })(S = M.S || (M.S = {})); +})(M || (M = {})); +var M; +(function (M) { + // Emit M.S.Bar + M.S.Bar, ; +})(M || (M = {})); +var M; +(function (M_1) { + var M = 100; + // Emit M_1.Foo + M_1.Foo, ; +})(M || (M = {})); diff --git a/tests/baselines/reference/tsxEmit3.symbols b/tests/baselines/reference/tsxEmit3.symbols new file mode 100644 index 00000000000..4ceed0b9b1e --- /dev/null +++ b/tests/baselines/reference/tsxEmit3.symbols @@ -0,0 +1,75 @@ +=== tests/cases/conformance/jsx/tsxEmit3.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxEmit3.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxEmit3.tsx, 0, 20)) + + interface IntrinsicElements { } +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxEmit3.tsx, 1, 22)) +} + +module M { +>M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) + + export class Foo { constructor() { } } +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) + + export module S { +>S : Symbol(S, Decl(tsxEmit3.tsx, 6, 39), Decl(tsxEmit3.tsx, 17, 14)) + + export class Bar { } +>Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 7, 18)) + + // Emit Foo + // Foo, ; + } +} + +module M { +>M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) + + // Emit M.Foo + Foo, ; +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) + + export module S { +>S : Symbol(S, Decl(tsxEmit3.tsx, 6, 39), Decl(tsxEmit3.tsx, 17, 14)) + + // Emit M.Foo + Foo, ; +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) + + // Emit S.Bar + Bar, ; +>Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 7, 18)) +>Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 7, 18)) + } + +} + +module M { +>M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) + + // Emit M.S.Bar + S.Bar, ; +>S.Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 7, 18)) +>S : Symbol(S, Decl(tsxEmit3.tsx, 6, 39), Decl(tsxEmit3.tsx, 17, 14)) +>Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 7, 18)) +>Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 7, 18)) +} + +module M { +>M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) + + var M = 100; +>M : Symbol(M, Decl(tsxEmit3.tsx, 35, 4)) + + // Emit M_1.Foo + Foo, ; +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +} + diff --git a/tests/baselines/reference/tsxEmit3.types b/tests/baselines/reference/tsxEmit3.types new file mode 100644 index 00000000000..4bb92d9aea5 --- /dev/null +++ b/tests/baselines/reference/tsxEmit3.types @@ -0,0 +1,87 @@ +=== tests/cases/conformance/jsx/tsxEmit3.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { } +>IntrinsicElements : IntrinsicElements +} + +module M { +>M : typeof M + + export class Foo { constructor() { } } +>Foo : Foo + + export module S { +>S : typeof S + + export class Bar { } +>Bar : Bar + + // Emit Foo + // Foo, ; + } +} + +module M { +>M : typeof M + + // Emit M.Foo + Foo, ; +>Foo, : JSX.Element +>Foo : typeof Foo +> : JSX.Element +>Foo : typeof Foo + + export module S { +>S : typeof S + + // Emit M.Foo + Foo, ; +>Foo, : JSX.Element +>Foo : typeof Foo +> : JSX.Element +>Foo : typeof Foo + + // Emit S.Bar + Bar, ; +>Bar, : JSX.Element +>Bar : typeof Bar +> : JSX.Element +>Bar : typeof Bar + } + +} + +module M { +>M : typeof M + + // Emit M.S.Bar + S.Bar, ; +>S.Bar, : JSX.Element +>S.Bar : typeof S.Bar +>S : typeof S +>Bar : typeof S.Bar +> : JSX.Element +>S : any +>Bar : any +} + +module M { +>M : typeof M + + var M = 100; +>M : number +>100 : number + + // Emit M_1.Foo + Foo, ; +>Foo, : JSX.Element +>Foo : typeof Foo +> : JSX.Element +>Foo : typeof Foo +} + diff --git a/tests/baselines/reference/tsxErrorRecovery1.errors.txt b/tests/baselines/reference/tsxErrorRecovery1.errors.txt new file mode 100644 index 00000000000..dc4f4d51afe --- /dev/null +++ b/tests/baselines/reference/tsxErrorRecovery1.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/jsx/tsxErrorRecovery1.tsx(5,19): error TS1109: Expression expected. + + +==== tests/cases/conformance/jsx/tsxErrorRecovery1.tsx (1 errors) ==== + + declare namespace JSX { interface Element { } } + + function foo() { + var x =
{
+ ~~ +!!! error TS1109: Expression expected. + } + // Shouldn't see any errors down here + var y = { a: 1 }; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxErrorRecovery1.js b/tests/baselines/reference/tsxErrorRecovery1.js new file mode 100644 index 00000000000..8d20951f6ed --- /dev/null +++ b/tests/baselines/reference/tsxErrorRecovery1.js @@ -0,0 +1,17 @@ +//// [tsxErrorRecovery1.tsx] + +declare namespace JSX { interface Element { } } + +function foo() { + var x =
{
+} +// Shouldn't see any errors down here +var y = { a: 1 }; + + +//// [tsxErrorRecovery1.jsx] +function foo() { + var x =
{}
; +} +// Shouldn't see any errors down here +var y = { a: 1 }; diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.js b/tests/baselines/reference/tsxExternalModuleEmit1.js new file mode 100644 index 00000000000..3e486eacef8 --- /dev/null +++ b/tests/baselines/reference/tsxExternalModuleEmit1.js @@ -0,0 +1,71 @@ +//// [tests/cases/conformance/jsx/tsxExternalModuleEmit1.tsx] //// + +//// [react.d.ts] + +declare module 'react' { + class Component { } +} + +//// [app.tsx] +import * as React from 'react'; + +// Should see var button_1 = require('./button') here +import { Button } from './button'; + +export class App extends React.Component { + + render() { + return ; + } + +} + +//// [button.jsx] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var React = require('react'); +var Button = (function (_super) { + __extends(Button, _super); + function Button() { + _super.apply(this, arguments); + } + Button.prototype.render = function () { + return ; + }; + return Button; +})(React.Component); +exports.Button = Button; +//// [app.jsx] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var React = require('react'); +// Should see var button_1 = require('./button') here +var button_1 = require('./button'); +var App = (function (_super) { + __extends(App, _super); + function App() { + _super.apply(this, arguments); + } + App.prototype.render = function () { + return ; + }; + return App; +})(React.Component); +exports.App = App; diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.symbols b/tests/baselines/reference/tsxExternalModuleEmit1.symbols new file mode 100644 index 00000000000..5e8eb2fed4e --- /dev/null +++ b/tests/baselines/reference/tsxExternalModuleEmit1.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +declare module 'react' { + class Component { } +>Component : Symbol(Component, Decl(react.d.ts, 1, 24)) +>T : Symbol(T, Decl(react.d.ts, 2, 17)) +>U : Symbol(U, Decl(react.d.ts, 2, 19)) +} + +=== tests/cases/conformance/jsx/app.tsx === +import * as React from 'react'; +>React : Symbol(React, Decl(app.tsx, 0, 6)) + +// Should see var button_1 = require('./button') here +import { Button } from './button'; +>Button : Symbol(Button, Decl(app.tsx, 3, 8)) + +export class App extends React.Component { +>App : Symbol(App, Decl(app.tsx, 3, 34)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 1, 24)) +>React : Symbol(React, Decl(app.tsx, 0, 6)) +>Component : Symbol(React.Component, Decl(react.d.ts, 1, 24)) + + render() { +>render : Symbol(render, Decl(app.tsx, 5, 52)) + + return ; + } + +} diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.types b/tests/baselines/reference/tsxExternalModuleEmit1.types new file mode 100644 index 00000000000..7e28c35dd13 --- /dev/null +++ b/tests/baselines/reference/tsxExternalModuleEmit1.types @@ -0,0 +1,53 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +declare module 'react' { + class Component { } +>Component : Component +>T : T +>U : U +} + +=== tests/cases/conformance/jsx/app.tsx === +import * as React from 'react'; +>React : typeof React + +// Should see var button_1 = require('./button') here +import { Button } from './button'; +>Button : typeof Button + +export class App extends React.Component { +>App : App +>React.Component : React.Component +>React : typeof React +>Component : typeof React.Component + + render() { +>render : () => any + + return ; +> : any +>button : any +>button : any + } + +} diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.js b/tests/baselines/reference/tsxGenericArrowFunctionParsing.js new file mode 100644 index 00000000000..f493347ca9c --- /dev/null +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.js @@ -0,0 +1,46 @@ +//// [tsxGenericArrowFunctionParsing.tsx] +declare module JSX { + interface Element { isElement; } +} + +var T, T1, T2; + +// This is an element +var x1 = () => {}; +x1.isElement; + +// This is a generic function +var x2 = () => {}; +x2(); + +// This is a generic function +var x3 = () => {}; +x3(); + +// This is an element +var x4 = () => {}; +x4.isElement; + +// This is an element +var x5 = () => {}; +x5.isElement; + + + +//// [tsxGenericArrowFunctionParsing.jsx] +var T, T1, T2; +// This is an element +var x1 = () => ; +x1.isElement; +// This is a generic function +var x2 = function () { }; +x2(); +// This is a generic function +var x3 = function () { }; +x3(); +// This is an element +var x4 = () => ; +x4.isElement; +// This is an element +var x5 = () => ; +x5.isElement; diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols b/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols new file mode 100644 index 00000000000..8bd68b2e8e7 --- /dev/null +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols @@ -0,0 +1,64 @@ +=== tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxGenericArrowFunctionParsing.tsx, 0, 0)) + + interface Element { isElement; } +>Element : Symbol(Element, Decl(tsxGenericArrowFunctionParsing.tsx, 0, 20)) +>isElement : Symbol(isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) +} + +var T, T1, T2; +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) +>T1 : Symbol(T1, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 6)) +>T2 : Symbol(T2, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 10)) + +// This is an element +var x1 = () => {}; +>x1 : Symbol(x1, Decl(tsxGenericArrowFunctionParsing.tsx, 7, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) + +x1.isElement; +>x1.isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) +>x1 : Symbol(x1, Decl(tsxGenericArrowFunctionParsing.tsx, 7, 3)) +>isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) + +// This is a generic function +var x2 = () => {}; +>x2 : Symbol(x2, Decl(tsxGenericArrowFunctionParsing.tsx, 11, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 11, 10)) + +x2(); +>x2 : Symbol(x2, Decl(tsxGenericArrowFunctionParsing.tsx, 11, 3)) + +// This is a generic function +var x3 = () => {}; +>x3 : Symbol(x3, Decl(tsxGenericArrowFunctionParsing.tsx, 15, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 15, 10)) +>T1 : Symbol(T1, Decl(tsxGenericArrowFunctionParsing.tsx, 15, 12)) + +x3(); +>x3 : Symbol(x3, Decl(tsxGenericArrowFunctionParsing.tsx, 15, 3)) + +// This is an element +var x4 = () => {}; +>x4 : Symbol(x4, Decl(tsxGenericArrowFunctionParsing.tsx, 19, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) +>extends : Symbol(unknown) + +x4.isElement; +>x4.isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) +>x4 : Symbol(x4, Decl(tsxGenericArrowFunctionParsing.tsx, 19, 3)) +>isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) + +// This is an element +var x5 = () => {}; +>x5 : Symbol(x5, Decl(tsxGenericArrowFunctionParsing.tsx, 23, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) +>extends : Symbol(unknown) + +x5.isElement; +>x5.isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) +>x5 : Symbol(x5, Decl(tsxGenericArrowFunctionParsing.tsx, 23, 3)) +>isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) + + diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.types b/tests/baselines/reference/tsxGenericArrowFunctionParsing.types new file mode 100644 index 00000000000..a7d98d35b64 --- /dev/null +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.types @@ -0,0 +1,75 @@ +=== tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx === +declare module JSX { +>JSX : any + + interface Element { isElement; } +>Element : Element +>isElement : any +} + +var T, T1, T2; +>T : any +>T1 : any +>T2 : any + +// This is an element +var x1 = () => {}; +>x1 : JSX.Element +>() => {} : JSX.Element +>T : any +>T : any + +x1.isElement; +>x1.isElement : any +>x1 : JSX.Element +>isElement : any + +// This is a generic function +var x2 = () => {}; +>x2 : () => void +>() => {} : () => void +>T : T + +x2(); +>x2() : void +>x2 : () => void + +// This is a generic function +var x3 = () => {}; +>x3 : () => void +>() => {} : () => void +>T : T +>T1 : T1 + +x3(); +>x3() : void +>x3 : () => void + +// This is an element +var x4 = () => {}; +>x4 : JSX.Element +>() => {} : JSX.Element +>T : any +>extends : any +>true : boolean +>T : any + +x4.isElement; +>x4.isElement : any +>x4 : JSX.Element +>isElement : any + +// This is an element +var x5 = () => {}; +>x5 : JSX.Element +>() => {} : JSX.Element +>T : any +>extends : any +>T : any + +x5.isElement; +>x5.isElement : any +>x5 : JSX.Element +>isElement : any + + diff --git a/tests/baselines/reference/tsxInArrowFunction.js b/tests/baselines/reference/tsxInArrowFunction.js new file mode 100644 index 00000000000..ba4a0dd1d14 --- /dev/null +++ b/tests/baselines/reference/tsxInArrowFunction.js @@ -0,0 +1,34 @@ +//// [tsxInArrowFunction.tsx] + +declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + } + } +} + + +// didn't work +
{() =>
}
; + +// didn't work +
{x =>
}
; + +// worked +
{() => (
)}
; + +// worked (!) +
{() =>
}
; + + +//// [tsxInArrowFunction.jsx] +// didn't work +
{function () { return
; }}
; +// didn't work +
{function (x) { return
; }}
; +// worked +
{function () { return (
); }}
; +// worked (!) +
{function () { return
; }}
; diff --git a/tests/baselines/reference/tsxInArrowFunction.symbols b/tests/baselines/reference/tsxInArrowFunction.symbols new file mode 100644 index 00000000000..814f2577bf0 --- /dev/null +++ b/tests/baselines/reference/tsxInArrowFunction.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/jsx/tsxInArrowFunction.tsx === + +declare namespace JSX { +>JSX : Symbol(JSX, Decl(tsxInArrowFunction.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxInArrowFunction.tsx, 1, 23)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxInArrowFunction.tsx, 2, 25)) + + div: { +>div : Symbol(div, Decl(tsxInArrowFunction.tsx, 3, 33)) + + text?: string; +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + } + } +} + + +// didn't work +
{() =>
}
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + +// didn't work +
{x =>
}
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>x : Symbol(x, Decl(tsxInArrowFunction.tsx, 15, 6)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + +// worked +
{() => (
)}
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + +// worked (!) +
{() =>
}
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) + diff --git a/tests/baselines/reference/tsxInArrowFunction.types b/tests/baselines/reference/tsxInArrowFunction.types new file mode 100644 index 00000000000..e4b2aeb50fe --- /dev/null +++ b/tests/baselines/reference/tsxInArrowFunction.types @@ -0,0 +1,64 @@ +=== tests/cases/conformance/jsx/tsxInArrowFunction.tsx === + +declare namespace JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + div: { +>div : { text?: string; } + + text?: string; +>text : string + } + } +} + + +// didn't work +
{() =>
}
; +>
{() =>
}
: JSX.Element +>div : any +>() =>
: () => JSX.Element +>
: JSX.Element +>div : any +>text : any +>div : any + +// didn't work +
{x =>
}
; +>
{x =>
}
: JSX.Element +>div : any +>x =>
: (x: any) => JSX.Element +>x : any +>
: JSX.Element +>div : any +>text : any +>div : any + +// worked +
{() => (
)}
; +>
{() => (
)}
: JSX.Element +>div : any +>() => (
) : () => JSX.Element +>(
) : JSX.Element +>
: JSX.Element +>div : any +>text : any +>div : any + +// worked (!) +
{() =>
}
; +>
{() =>
}
: JSX.Element +>div : any +>() =>
: () => JSX.Element +>
: JSX.Element +>div : any +>text : any +>div : any +>div : any + diff --git a/tests/baselines/reference/tsxNoJsx.js b/tests/baselines/reference/tsxNoJsx.js new file mode 100644 index 00000000000..37663adf2a7 --- /dev/null +++ b/tests/baselines/reference/tsxNoJsx.js @@ -0,0 +1,7 @@ +//// [tsxNoJsx.tsx] + +; + + +//// [tsxNoJsx.jsx] +; diff --git a/tests/baselines/reference/tsxNoJsx.symbols b/tests/baselines/reference/tsxNoJsx.symbols new file mode 100644 index 00000000000..6744c2edb10 --- /dev/null +++ b/tests/baselines/reference/tsxNoJsx.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/jsx/tsxNoJsx.tsx === + +No type information for this code.; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/tsxNoJsx.types b/tests/baselines/reference/tsxNoJsx.types new file mode 100644 index 00000000000..52e6769795e --- /dev/null +++ b/tests/baselines/reference/tsxNoJsx.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/jsx/tsxNoJsx.tsx === + +; +> : any +>nope : any + diff --git a/tests/baselines/reference/tsxOpeningClosingNames.js b/tests/baselines/reference/tsxOpeningClosingNames.js new file mode 100644 index 00000000000..80adad0f406 --- /dev/null +++ b/tests/baselines/reference/tsxOpeningClosingNames.js @@ -0,0 +1,14 @@ +//// [tsxOpeningClosingNames.tsx] +declare module JSX { + interface Element { } +} + +declare module A.B.C { + var D: any; +} + +foo + + +//// [tsxOpeningClosingNames.jsx] +foo; diff --git a/tests/baselines/reference/tsxOpeningClosingNames.symbols b/tests/baselines/reference/tsxOpeningClosingNames.symbols new file mode 100644 index 00000000000..3ff2a3ff68d --- /dev/null +++ b/tests/baselines/reference/tsxOpeningClosingNames.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxOpeningClosingNames.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxOpeningClosingNames.tsx, 0, 20)) +} + +declare module A.B.C { +>A : Symbol(A, Decl(tsxOpeningClosingNames.tsx, 2, 1)) +>B : Symbol(B, Decl(tsxOpeningClosingNames.tsx, 4, 17)) +>C : Symbol(C, Decl(tsxOpeningClosingNames.tsx, 4, 19)) + + var D: any; +>D : Symbol(D, Decl(tsxOpeningClosingNames.tsx, 5, 5)) +} + +foo +>D : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxOpeningClosingNames.types b/tests/baselines/reference/tsxOpeningClosingNames.types new file mode 100644 index 00000000000..b02564ae104 --- /dev/null +++ b/tests/baselines/reference/tsxOpeningClosingNames.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element +} + +declare module A.B.C { +>A : typeof A +>B : typeof B +>C : typeof C + + var D: any; +>D : any +} + +foo +>foo : JSX.Element +>A : any +>B : any +>C : any +>D : any +>A : any +>B : any +>C : any +>D : any + diff --git a/tests/baselines/reference/tsxParseTests1.js b/tests/baselines/reference/tsxParseTests1.js new file mode 100644 index 00000000000..7ab98cab314 --- /dev/null +++ b/tests/baselines/reference/tsxParseTests1.js @@ -0,0 +1,11 @@ +//// [tsxParseTests1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { div; span; } +} + +var x =
; + + +//// [tsxParseTests1.jsx] +var x =
; diff --git a/tests/baselines/reference/tsxParseTests1.symbols b/tests/baselines/reference/tsxParseTests1.symbols new file mode 100644 index 00000000000..dbe11dbcbba --- /dev/null +++ b/tests/baselines/reference/tsxParseTests1.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/jsx/tsxParseTests1.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxParseTests1.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxParseTests1.tsx, 0, 20)) + + interface IntrinsicElements { div; span; } +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxParseTests1.tsx, 1, 22)) +>div : Symbol(div, Decl(tsxParseTests1.tsx, 2, 30)) +>span : Symbol(span, Decl(tsxParseTests1.tsx, 2, 35)) +} + +var x =
; +>x : Symbol(x, Decl(tsxParseTests1.tsx, 5, 3)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests1.tsx, 2, 30)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests1.tsx, 2, 30)) +>span : Symbol(JSX.IntrinsicElements.span, Decl(tsxParseTests1.tsx, 2, 35)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests1.tsx, 2, 30)) + diff --git a/tests/baselines/reference/tsxParseTests1.types b/tests/baselines/reference/tsxParseTests1.types new file mode 100644 index 00000000000..78e49a227e2 --- /dev/null +++ b/tests/baselines/reference/tsxParseTests1.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/tsxParseTests1.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { div; span; } +>IntrinsicElements : IntrinsicElements +>div : any +>span : any +} + +var x =
; +>x : JSX.Element +>
: JSX.Element +>div : any +>
: JSX.Element +>div : any +>
: JSX.Element +>span : any +>
: JSX.Element +>div : any +>div : any +>span : any +>div : any +>div : any + diff --git a/tests/baselines/reference/tsxReactEmit1.js b/tests/baselines/reference/tsxReactEmit1.js new file mode 100644 index 00000000000..f1799e5bb77 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit1.js @@ -0,0 +1,74 @@ +//// [tsxReactEmit1.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; + +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; + +class SomeClass { + f() { + var rewrites1 =
{() => this}
; + var rewrites2 =
{[p, ...p, p]}
; + var rewrites3 =
{{p}}
; + + var rewrites4 =
this}>
; + var rewrites5 =
; + var rewrites6 =
; + } +} + +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; + + +//// [tsxReactEmit1.js] +var p; +var selfClosed1 = React.createElement("div", null); +var selfClosed2 = React.createElement("div", {x: "1"}); +var selfClosed3 = React.createElement("div", {x: '1'}); +var selfClosed4 = React.createElement("div", {x: "1", y: '0'}); +var selfClosed5 = React.createElement("div", {x: 0, y: '0'}); +var selfClosed6 = React.createElement("div", {x: "1", y: '0'}); +var selfClosed7 = React.createElement("div", {x: p, y: 'p', b: true}); +var openClosed1 = React.createElement("div", null); +var openClosed2 = React.createElement("div", {n: 'm'}, "foo"); +var openClosed3 = React.createElement("div", {n: 'm'}, p); +var openClosed4 = React.createElement("div", {n: 'm'}, p < p); +var openClosed5 = React.createElement("div", {n: 'm', b: true}, p > p); +var SomeClass = (function () { + function SomeClass() { + } + SomeClass.prototype.f = function () { + var _this = this; + var rewrites1 = React.createElement("div", null, function () { return _this; }); + var rewrites2 = React.createElement("div", null, [p].concat(p, [p])); + var rewrites3 = React.createElement("div", null, { p: p }); + var rewrites4 = React.createElement("div", {a: function () { return _this; }}); + var rewrites5 = React.createElement("div", {a: [p].concat(p, [p])}); + var rewrites6 = React.createElement("div", {a: { p: p }}); + }; + return SomeClass; +})(); +var whitespace1 = React.createElement("div", null); +var whitespace2 = React.createElement("div", null, p); +var whitespace3 = React.createElement("div", null, p); diff --git a/tests/baselines/reference/tsxReactEmit1.symbols b/tests/baselines/reference/tsxReactEmit1.symbols new file mode 100644 index 00000000000..c9e819c82d3 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit1.symbols @@ -0,0 +1,148 @@ +=== tests/cases/conformance/jsx/tsxReactEmit1.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmit1.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmit1.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmit1.tsx, 3, 3)) + } +} +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmit1.tsx, 6, 11)) + +var p; +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) + +var selfClosed1 =
; +>selfClosed1 : Symbol(selfClosed1, Decl(tsxReactEmit1.tsx, 9, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + +var selfClosed2 =
; +>selfClosed2 : Symbol(selfClosed2, Decl(tsxReactEmit1.tsx, 10, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) + +var selfClosed3 =
; +>selfClosed3 : Symbol(selfClosed3, Decl(tsxReactEmit1.tsx, 11, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) + +var selfClosed4 =
; +>selfClosed4 : Symbol(selfClosed4, Decl(tsxReactEmit1.tsx, 12, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed5 =
; +>selfClosed5 : Symbol(selfClosed5, Decl(tsxReactEmit1.tsx, 13, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed6 =
; +>selfClosed6 : Symbol(selfClosed6, Decl(tsxReactEmit1.tsx, 14, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + +var selfClosed7 =
; +>selfClosed7 : Symbol(selfClosed7, Decl(tsxReactEmit1.tsx, 15, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) +>b : Symbol(unknown) + +var openClosed1 =
; +>openClosed1 : Symbol(openClosed1, Decl(tsxReactEmit1.tsx, 17, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + +var openClosed2 =
foo
; +>openClosed2 : Symbol(openClosed2, Decl(tsxReactEmit1.tsx, 18, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>n : Symbol(unknown) + +var openClosed3 =
{p}
; +>openClosed3 : Symbol(openClosed3, Decl(tsxReactEmit1.tsx, 19, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>n : Symbol(unknown) + +var openClosed4 =
{p < p}
; +>openClosed4 : Symbol(openClosed4, Decl(tsxReactEmit1.tsx, 20, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>n : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) + +var openClosed5 =
{p > p}
; +>openClosed5 : Symbol(openClosed5, Decl(tsxReactEmit1.tsx, 21, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>n : Symbol(unknown) +>b : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) + +class SomeClass { +>SomeClass : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) + + f() { +>f : Symbol(f, Decl(tsxReactEmit1.tsx, 23, 17)) + + var rewrites1 =
{() => this}
; +>rewrites1 : Symbol(rewrites1, Decl(tsxReactEmit1.tsx, 25, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) + + var rewrites2 =
{[p, ...p, p]}
; +>rewrites2 : Symbol(rewrites2, Decl(tsxReactEmit1.tsx, 26, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) + + var rewrites3 =
{{p}}
; +>rewrites3 : Symbol(rewrites3, Decl(tsxReactEmit1.tsx, 27, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 27, 25)) + + var rewrites4 =
this}>
; +>rewrites4 : Symbol(rewrites4, Decl(tsxReactEmit1.tsx, 29, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) + + var rewrites5 =
; +>rewrites5 : Symbol(rewrites5, Decl(tsxReactEmit1.tsx, 30, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) + + var rewrites6 =
; +>rewrites6 : Symbol(rewrites6, Decl(tsxReactEmit1.tsx, 31, 5)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>a : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 31, 27)) + } +} + +var whitespace1 =
; +>whitespace1 : Symbol(whitespace1, Decl(tsxReactEmit1.tsx, 35, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + +var whitespace2 =
{p}
; +>whitespace2 : Symbol(whitespace2, Decl(tsxReactEmit1.tsx, 36, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + +var whitespace3 =
+>whitespace3 : Symbol(whitespace3, Decl(tsxReactEmit1.tsx, 37, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) + + {p} +
; + diff --git a/tests/baselines/reference/tsxReactEmit1.types b/tests/baselines/reference/tsxReactEmit1.types new file mode 100644 index 00000000000..0b6e03c5742 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit1.types @@ -0,0 +1,198 @@ +=== tests/cases/conformance/jsx/tsxReactEmit1.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} +declare var React: any; +>React : any + +var p; +>p : any + +var selfClosed1 =
; +>selfClosed1 : JSX.Element +>
: JSX.Element +>div : any + +var selfClosed2 =
; +>selfClosed2 : JSX.Element +>
: JSX.Element +>div : any +>x : any + +var selfClosed3 =
; +>selfClosed3 : JSX.Element +>
: JSX.Element +>div : any +>x : any + +var selfClosed4 =
; +>selfClosed4 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed5 =
; +>selfClosed5 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed6 =
; +>selfClosed6 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>y : any + +var selfClosed7 =
; +>selfClosed7 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>p : any +>y : any +>b : any + +var openClosed1 =
; +>openClosed1 : JSX.Element +>
: JSX.Element +>div : any +>div : any + +var openClosed2 =
foo
; +>openClosed2 : JSX.Element +>
foo
: JSX.Element +>div : any +>n : any +>div : any + +var openClosed3 =
{p}
; +>openClosed3 : JSX.Element +>
{p}
: JSX.Element +>div : any +>n : any +>p : any +>div : any + +var openClosed4 =
{p < p}
; +>openClosed4 : JSX.Element +>
{p < p}
: JSX.Element +>div : any +>n : any +>p < p : boolean +>p : any +>p : any +>div : any + +var openClosed5 =
{p > p}
; +>openClosed5 : JSX.Element +>
{p > p}
: JSX.Element +>div : any +>n : any +>b : any +>p > p : boolean +>p : any +>p : any +>div : any + +class SomeClass { +>SomeClass : SomeClass + + f() { +>f : () => void + + var rewrites1 =
{() => this}
; +>rewrites1 : JSX.Element +>
{() => this}
: JSX.Element +>div : any +>() => this : () => SomeClass +>this : SomeClass +>div : any + + var rewrites2 =
{[p, ...p, p]}
; +>rewrites2 : JSX.Element +>
{[p, ...p, p]}
: JSX.Element +>div : any +>[p, ...p, p] : any[] +>p : any +>...p : any +>p : any +>p : any +>div : any + + var rewrites3 =
{{p}}
; +>rewrites3 : JSX.Element +>
{{p}}
: JSX.Element +>div : any +>{p} : { p: any; } +>p : any +>div : any + + var rewrites4 =
this}>
; +>rewrites4 : JSX.Element +>
this}>
: JSX.Element +>div : any +>a : any +>() => this : () => SomeClass +>this : SomeClass +>div : any + + var rewrites5 =
; +>rewrites5 : JSX.Element +>
: JSX.Element +>div : any +>a : any +>[p, ...p, p] : any[] +>p : any +>...p : any +>p : any +>p : any +>div : any + + var rewrites6 =
; +>rewrites6 : JSX.Element +>
: JSX.Element +>div : any +>a : any +>{p} : { p: any; } +>p : any +>div : any + } +} + +var whitespace1 =
; +>whitespace1 : JSX.Element +>
: JSX.Element +>div : any +>div : any + +var whitespace2 =
{p}
; +>whitespace2 : JSX.Element +>
{p}
: JSX.Element +>div : any +>p : any +>div : any + +var whitespace3 =
+>whitespace3 : JSX.Element +>
{p}
: JSX.Element +>div : any + + {p} +>p : any + +
; +>div : any + diff --git a/tests/baselines/reference/tsxReactEmit2.js b/tests/baselines/reference/tsxReactEmit2.js new file mode 100644 index 00000000000..4b2b4695561 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit2.js @@ -0,0 +1,24 @@ +//// [tsxReactEmit2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; + + +//// [tsxReactEmit2.js] +var p1, p2, p3; +var spreads1 = React.createElement("div", React.__spread({}, p1), p2); +var spreads2 = React.createElement("div", React.__spread({}, p1), p2); +var spreads3 = React.createElement("div", React.__spread({x: p3}, p1), p2); +var spreads4 = React.createElement("div", React.__spread({}, p1, {x: p3}), p2); +var spreads5 = React.createElement("div", React.__spread({x: p2}, p1, {y: p3}), p2); diff --git a/tests/baselines/reference/tsxReactEmit2.symbols b/tests/baselines/reference/tsxReactEmit2.symbols new file mode 100644 index 00000000000..9cf739c960c --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit2.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/jsx/tsxReactEmit2.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmit2.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmit2.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmit2.tsx, 3, 3)) + } +} +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmit2.tsx, 6, 11)) + +var p1, p2, p3; +>p1 : Symbol(p1, Decl(tsxReactEmit2.tsx, 8, 3)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 8, 11)) + +var spreads1 =
{p2}
; +>spreads1 : Symbol(spreads1, Decl(tsxReactEmit2.tsx, 9, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) + +var spreads2 =
{p2}
; +>spreads2 : Symbol(spreads2, Decl(tsxReactEmit2.tsx, 10, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) + +var spreads3 =
{p2}
; +>spreads3 : Symbol(spreads3, Decl(tsxReactEmit2.tsx, 11, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>x : Symbol(unknown) + +var spreads4 =
{p2}
; +>spreads4 : Symbol(spreads4, Decl(tsxReactEmit2.tsx, 12, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>x : Symbol(unknown) + +var spreads5 =
{p2}
; +>spreads5 : Symbol(spreads5, Decl(tsxReactEmit2.tsx, 13, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxReactEmit2.types b/tests/baselines/reference/tsxReactEmit2.types new file mode 100644 index 00000000000..e28910b62c7 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit2.types @@ -0,0 +1,70 @@ +=== tests/cases/conformance/jsx/tsxReactEmit2.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} +declare var React: any; +>React : any + +var p1, p2, p3; +>p1 : any +>p2 : any +>p3 : any + +var spreads1 =
{p2}
; +>spreads1 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>p2 : any +>div : any + +var spreads2 =
{p2}
; +>spreads2 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>p2 : any +>div : any + +var spreads3 =
{p2}
; +>spreads3 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>x : any +>p3 : any +>p1 : any +>p2 : any +>div : any + +var spreads4 =
{p2}
; +>spreads4 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>p1 : any +>x : any +>p3 : any +>p2 : any +>div : any + +var spreads5 =
{p2}
; +>spreads5 : JSX.Element +>
{p2}
: JSX.Element +>div : any +>x : any +>p2 : any +>p1 : any +>y : any +>p3 : any +>p2 : any +>div : any + diff --git a/tests/baselines/reference/tsxReactEmit3.js b/tests/baselines/reference/tsxReactEmit3.js new file mode 100644 index 00000000000..1a6ba037230 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit3.js @@ -0,0 +1,11 @@ +//// [tsxReactEmit3.tsx] + +declare module JSX { interface Element { } } +declare var React: any; + +declare var Foo, Bar, baz; + + q s ; + +//// [tsxReactEmit3.js] +React.createElement(Foo, null, React.createElement(Bar, null, "q "), React.createElement(Bar, null), "s ", React.createElement(Bar, null), React.createElement(Bar, null)); diff --git a/tests/baselines/reference/tsxReactEmit3.symbols b/tests/baselines/reference/tsxReactEmit3.symbols new file mode 100644 index 00000000000..857647400a9 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit3.symbols @@ -0,0 +1,21 @@ +=== tests/cases/conformance/jsx/tsxReactEmit3.tsx === + +declare module JSX { interface Element { } } +>JSX : Symbol(JSX, Decl(tsxReactEmit3.tsx, 0, 0)) +>Element : Symbol(Element, Decl(tsxReactEmit3.tsx, 1, 20)) + +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmit3.tsx, 2, 11)) + +declare var Foo, Bar, baz; +>Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 4, 11)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>baz : Symbol(baz, Decl(tsxReactEmit3.tsx, 4, 21)) + + q s ; +>Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 4, 11)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) + diff --git a/tests/baselines/reference/tsxReactEmit3.types b/tests/baselines/reference/tsxReactEmit3.types new file mode 100644 index 00000000000..8babe724fa1 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit3.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/tsxReactEmit3.tsx === + +declare module JSX { interface Element { } } +>JSX : any +>Element : Element + +declare var React: any; +>React : any + +declare var Foo, Bar, baz; +>Foo : any +>Bar : any +>baz : any + + q s ; +> q s : JSX.Element +>Foo : any +> q : JSX.Element +>Bar : any +>Bar : any +> : JSX.Element +>Bar : any +> : JSX.Element +>Bar : any +> : JSX.Element +>Bar : any +>Foo : any + diff --git a/tests/baselines/reference/tsxReactEmit4.errors.txt b/tests/baselines/reference/tsxReactEmit4.errors.txt new file mode 100644 index 00000000000..fca2b028237 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit4.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/jsx/tsxReactEmit4.tsx(12,5): error TS2304: Cannot find name 'blah'. + + +==== tests/cases/conformance/jsx/tsxReactEmit4.tsx (1 errors) ==== + declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } + } + declare var React: any; + + var p; + var openClosed1 =
+ + {blah} + ~~~~ +!!! error TS2304: Cannot find name 'blah'. + +
; + + // Should emit React.__spread({}, p, {x: 0}) + var spread1 =
; \ No newline at end of file diff --git a/tests/baselines/reference/tsxReactEmit4.js b/tests/baselines/reference/tsxReactEmit4.js new file mode 100644 index 00000000000..dcbfafcef2f --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit4.js @@ -0,0 +1,24 @@ +//// [tsxReactEmit4.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +var p; +var openClosed1 =
+ + {blah} + +
; + +// Should emit React.__spread({}, p, {x: 0}) +var spread1 =
; + +//// [tsxReactEmit4.js] +var p; +var openClosed1 = React.createElement("div", null, blah); +// Should emit React.__spread({}, p, {x: 0}) +var spread1 = React.createElement("div", React.__spread({}, p, {x: 0})); diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.js b/tests/baselines/reference/tsxReactEmitWhitespace.js new file mode 100644 index 00000000000..a124ce73312 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace.js @@ -0,0 +1,76 @@ +//// [tsxReactEmitWhitespace.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT + +var p = 0; +// Emit " " +
; +// Emit " ", p, " " +
{p}
; +// Emit only p +
+ {p} +
; + +// Emit only p +
+ {p} +
; + +// Emit " 3" +
3 +
; + +// Emit " 3 " +
3
; + +// Emit "3" +
+ 3 +
; + +// Emit no args +
+
; + +// Emit "foo" + ' ' + "bar" +
+ + foo + + bar + +
; + + + +//// [tsxReactEmitWhitespace.js] +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT +var p = 0; +// Emit " " +React.createElement("div", null); +// Emit " ", p, " " +React.createElement("div", null, p); +// Emit only p +React.createElement("div", null, p); +// Emit only p +React.createElement("div", null, p); +// Emit " 3" +React.createElement("div", null, "3"); +// Emit " 3 " +React.createElement("div", null, "3 "); +// Emit "3" +React.createElement("div", null, "3"); +// Emit no args +React.createElement("div", null); +// Emit "foo" + ' ' + "bar" +React.createElement("div", null, "foo" + ' ' + "bar"); diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.symbols b/tests/baselines/reference/tsxReactEmitWhitespace.symbols new file mode 100644 index 00000000000..06c8258a2c2 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace.symbols @@ -0,0 +1,79 @@ +=== tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmitWhitespace.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmitWhitespace.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmitWhitespace.tsx, 3, 3)) + } +} +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmitWhitespace.tsx, 6, 11)) + +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT + +var p = 0; +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 11, 3)) + +// Emit " " +
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +// Emit " ", p, " " +
{p}
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +// Emit only p +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + {p} +
; + +// Emit only p +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + {p} +
; + +// Emit " 3" +
3 +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +
; + +// Emit " 3 " +
3
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +// Emit "3" +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + 3 +
; + +// Emit no args +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + +
; + +// Emit "foo" + ' ' + "bar" +
+>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) + + foo + + bar + +
; + + diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.types b/tests/baselines/reference/tsxReactEmitWhitespace.types new file mode 100644 index 00000000000..603dc4ca6c1 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace.types @@ -0,0 +1,103 @@ +=== tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} +declare var React: any; +>React : any + +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT + +var p = 0; +>p : number +>0 : number + +// Emit " " +
; +>
: JSX.Element +>div : any +>div : any + +// Emit " ", p, " " +
{p}
; +>
{p}
: JSX.Element +>div : any +>p : any +>div : any + +// Emit only p +
+>
{p}
: JSX.Element +>div : any + + {p} +>p : any + +
; +>div : any + +// Emit only p +
+>
{p}
: JSX.Element +>div : any + + {p} +>p : any + +
; +>div : any + +// Emit " 3" +
3 +>
3
: JSX.Element +>div : any + +
; +>div : any + +// Emit " 3 " +
3
; +>
3
: JSX.Element +>div : any +>div : any + +// Emit "3" +
+>
3
: JSX.Element +>div : any + + 3 +
; +>div : any + +// Emit no args +
+>
: JSX.Element +>div : any + +
; +>div : any + +// Emit "foo" + ' ' + "bar" +
+>
foo bar
: JSX.Element +>div : any + + foo + + bar + +
; +>div : any + + diff --git a/tests/baselines/reference/tsxTypeErrors.js b/tests/baselines/reference/tsxTypeErrors.js new file mode 100644 index 00000000000..f195a459747 --- /dev/null +++ b/tests/baselines/reference/tsxTypeErrors.js @@ -0,0 +1,60 @@ +//// [tsxTypeErrors.tsx] + +// A built-in element (OK) +var a1 =
; + +// A built-in element with a mistyped property (error) +var a2 = + +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +var a3 =
+ +// Mistyped html name (error) +var e1 = + +// A custom type +class MyClass { + props: { + pt?: { x: number; y: number; }; + name?: string; + reqd: boolean; + } +} + +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; + +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; + + + +//// [tsxTypeErrors.jsx] +// A built-in element (OK) +var a1 =
; +// A built-in element with a mistyped property (error) +var a2 = ; +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +var a3 =
; +// Mistyped html name (error) +var e1 = ; +// A custom type +var MyClass = (function () { + function MyClass() { + } + return MyClass; +})(); +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; diff --git a/tests/baselines/reference/tsxTypeErrors.symbols b/tests/baselines/reference/tsxTypeErrors.symbols new file mode 100644 index 00000000000..bfe0c568640 --- /dev/null +++ b/tests/baselines/reference/tsxTypeErrors.symbols @@ -0,0 +1,65 @@ +=== tests/cases/conformance/jsx/tsxTypeErrors.tsx === + +// A built-in element (OK) +var a1 =
; +>a1 : Symbol(a1, Decl(tsxTypeErrors.tsx, 2, 3)) +>id : Symbol(unknown) + +// A built-in element with a mistyped property (error) +var a2 = +>a2 : Symbol(a2, Decl(tsxTypeErrors.tsx, 5, 3)) +>srce : Symbol(unknown) + +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +>thing : Symbol(thing, Decl(tsxTypeErrors.tsx, 8, 3)) +>oops : Symbol(oops, Decl(tsxTypeErrors.tsx, 8, 13)) + +var a3 =
+>a3 : Symbol(a3, Decl(tsxTypeErrors.tsx, 9, 3)) +>id : Symbol(unknown) + +// Mistyped html name (error) +var e1 = +>e1 : Symbol(e1, Decl(tsxTypeErrors.tsx, 12, 3)) +>src : Symbol(unknown) + +// A custom type +class MyClass { +>MyClass : Symbol(MyClass, Decl(tsxTypeErrors.tsx, 12, 31)) + + props: { +>props : Symbol(props, Decl(tsxTypeErrors.tsx, 15, 15)) + + pt?: { x: number; y: number; }; +>pt : Symbol(pt, Decl(tsxTypeErrors.tsx, 16, 10)) +>x : Symbol(x, Decl(tsxTypeErrors.tsx, 17, 10)) +>y : Symbol(y, Decl(tsxTypeErrors.tsx, 17, 21)) + + name?: string; +>name : Symbol(name, Decl(tsxTypeErrors.tsx, 17, 35)) + + reqd: boolean; +>reqd : Symbol(reqd, Decl(tsxTypeErrors.tsx, 18, 15)) + } +} + +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; +>b1 : Symbol(b1, Decl(tsxTypeErrors.tsx, 25, 3)) +>MyClass : Symbol(MyClass, Decl(tsxTypeErrors.tsx, 12, 31)) +>reqd : Symbol(unknown) + +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; +>b2 : Symbol(b2, Decl(tsxTypeErrors.tsx, 31, 3)) +>MyClass : Symbol(MyClass, Decl(tsxTypeErrors.tsx, 12, 31)) +>pt : Symbol(unknown) +>x : Symbol(x, Decl(tsxTypeErrors.tsx, 31, 23)) +>y : Symbol(y, Decl(tsxTypeErrors.tsx, 31, 28)) + + diff --git a/tests/baselines/reference/tsxTypeErrors.types b/tests/baselines/reference/tsxTypeErrors.types new file mode 100644 index 00000000000..92c7148b314 --- /dev/null +++ b/tests/baselines/reference/tsxTypeErrors.types @@ -0,0 +1,82 @@ +=== tests/cases/conformance/jsx/tsxTypeErrors.tsx === + +// A built-in element (OK) +var a1 =
; +>a1 : any +>
: any +>div : any +>id : any + +// A built-in element with a mistyped property (error) +var a2 = +>a2 : any +> : any +>img : any +>srce : any + +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +>thing : { oops: number; } +>{ oops: 100 } : { oops: number; } +>oops : number +>100 : number + +var a3 =
+>a3 : any +>
: any +>div : any +>id : any +>thing : any + +// Mistyped html name (error) +var e1 = +>e1 : any +> : any +>imag : any +>src : any + +// A custom type +class MyClass { +>MyClass : MyClass + + props: { +>props : { pt?: { x: number; y: number; }; name?: string; reqd: boolean; } + + pt?: { x: number; y: number; }; +>pt : { x: number; y: number; } +>x : number +>y : number + + name?: string; +>name : string + + reqd: boolean; +>reqd : boolean + } +} + +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; +>b1 : any +> : any +>MyClass : typeof MyClass +>reqd : any +>true : boolean + +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; +>b2 : any +> : any +>MyClass : typeof MyClass +>pt : any +>{x: 4, y: 'oops'} : { x: number; y: string; } +>x : number +>4 : number +>y : string +>'oops' : string + + diff --git a/tests/baselines/reference/typeParameterExtendingUnion1.symbols b/tests/baselines/reference/typeParameterExtendingUnion1.symbols index 39b67e6428c..97d900b5d5e 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion1.symbols +++ b/tests/baselines/reference/typeParameterExtendingUnion1.symbols @@ -33,9 +33,9 @@ function f(a: T) { >T : Symbol(T, Decl(typeParameterExtendingUnion1.ts, 8, 11)) a.run(); ->a.run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion1.ts, 8, 32)) ->run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14)) run(a); >run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 2, 33)) diff --git a/tests/baselines/reference/typeParameterExtendingUnion2.symbols b/tests/baselines/reference/typeParameterExtendingUnion2.symbols index 44d47692a82..21866b3df92 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion2.symbols +++ b/tests/baselines/reference/typeParameterExtendingUnion2.symbols @@ -20,9 +20,9 @@ function run(a: Cat | Dog) { >Dog : Symbol(Dog, Decl(typeParameterExtendingUnion2.ts, 1, 33)) a.run(); ->a.run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion2.ts, 4, 13)) ->run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) } function f(a: T) { @@ -34,9 +34,9 @@ function f(a: T) { >T : Symbol(T, Decl(typeParameterExtendingUnion2.ts, 8, 11)) a.run(); ->a.run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion2.ts, 8, 32)) ->run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) run(a); >run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 2, 33)) diff --git a/tests/baselines/reference/typeParameterFixingWithConstraints.types b/tests/baselines/reference/typeParameterFixingWithConstraints.types index 64876952852..22d294f9d2e 100644 --- a/tests/baselines/reference/typeParameterFixingWithConstraints.types +++ b/tests/baselines/reference/typeParameterFixingWithConstraints.types @@ -31,17 +31,17 @@ var foo: IFoo; >IFoo : IFoo foo.foo({ bar: null }, bar => null, bar => null); ->foo.foo({ bar: null }, bar => null, bar => null) : IBar +>foo.foo({ bar: null }, bar => null, bar => null) : { [x: string]: any; bar: any; } >foo.foo : (bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar) => TBar >foo : IFoo >foo : (bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar) => TBar >{ bar: null } : { [x: string]: null; bar: null; } >bar : null >null : null ->bar => null : (bar: IBar) => any ->bar : IBar +>bar => null : (bar: { [x: string]: any; bar: any; }) => any +>bar : { [x: string]: any; bar: any; } >null : null ->bar => null : (bar: IBar) => any ->bar : IBar +>bar => null : (bar: { [x: string]: any; bar: any; }) => any +>bar : { [x: string]: any; bar: any; } >null : null diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index a6b8cb52a86..6b9842f6c81 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -8,39 +8,39 @@ function CreateTypedArrayTypes() { typedArrays[0] = Int8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) typedArrays[1] = Uint8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) typedArrays[2] = Int16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) typedArrays[3] = Uint16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) typedArrays[4] = Int32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) typedArrays[5] = Uint32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) typedArrays[6] = Float32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) typedArrays[7] = Float64Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) typedArrays[8] = Uint8ClampedArray; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) @@ -55,47 +55,47 @@ function CreateTypedArrayInstancesFromLength(obj: number) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) return typedArrays; @@ -111,47 +111,47 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) return typedArrays; @@ -167,65 +167,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) return typedArrays; @@ -235,72 +235,72 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >CreateIntegerTypedArraysFromArrayLike : Symbol(CreateIntegerTypedArraysFromArrayLike, Decl(typedArrays.ts, 59, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1434, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) var typedArrays = []; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) return typedArrays; @@ -332,57 +332,57 @@ function CreateTypedArraysOf2() { typedArrays[0] = Int8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2382, 30)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) ->of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2382, 30)) +>Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2395, 30)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2395, 30)) typedArrays[1] = Uint8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2672, 30)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) ->of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2672, 30)) +>Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2685, 30)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2685, 30)) typedArrays[2] = Int16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3252, 30)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) ->of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3252, 30)) +>Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3265, 30)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3265, 30)) typedArrays[3] = Uint16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3542, 30)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) ->of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3542, 30)) +>Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3555, 30)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3555, 30)) typedArrays[4] = Int32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3832, 30)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) ->of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3832, 30)) +>Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3845, 30)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3845, 30)) typedArrays[5] = Uint32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4122, 30)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) ->of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4122, 30)) +>Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4135, 30)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4135, 30)) typedArrays[6] = Float32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4412, 30)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) ->of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4412, 30)) +>Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4425, 30)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4425, 30)) typedArrays[7] = Float64Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4702, 30)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) ->of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4702, 30)) +>Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4715, 30)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4715, 30)) typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2962, 30)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) ->of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2962, 30)) +>Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2975, 30)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2975, 30)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) @@ -391,7 +391,7 @@ function CreateTypedArraysOf2() { function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { >CreateTypedArraysFromMapFn : Symbol(CreateTypedArraysFromMapFn, Decl(typedArrays.ts, 106, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1434, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) >n : Symbol(n, Decl(typedArrays.ts, 108, 67)) >v : Symbol(v, Decl(typedArrays.ts, 108, 76)) @@ -401,73 +401,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) @@ -478,7 +478,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { >CreateTypedArraysFromThisObj : Symbol(CreateTypedArraysFromThisObj, Decl(typedArrays.ts, 121, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1434, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >n : Symbol(n, Decl(typedArrays.ts, 123, 69)) >v : Symbol(v, Decl(typedArrays.ts, 123, 78)) @@ -489,81 +489,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) diff --git a/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt b/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt index 47e8e6ff4f2..60602351b46 100644 --- a/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt +++ b/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts(13,12): error TS2345: Argument of type '{ length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts(13,12): error TS2345: Argument of type '{ [x: number]: undefined; length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. ==== tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts (1 errors) ==== @@ -16,4 +16,4 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursi var r = c.foo(''); var r2 = r({ length: 3, charAt: (x: number) => { '' } }); // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. \ No newline at end of file +!!! error TS2345: Argument of type '{ [x: number]: undefined; length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. \ No newline at end of file diff --git a/tests/cases/compiler/abstractIdentifierNameStrict.ts b/tests/cases/compiler/abstractIdentifierNameStrict.ts new file mode 100644 index 00000000000..c75fbf43043 --- /dev/null +++ b/tests/cases/compiler/abstractIdentifierNameStrict.ts @@ -0,0 +1,6 @@ +var abstract = true; + +function foo() { + "use strict"; + var abstract = true; +} \ No newline at end of file diff --git a/tests/cases/compiler/abstractInterfaceIdentifierName.ts b/tests/cases/compiler/abstractInterfaceIdentifierName.ts new file mode 100644 index 00000000000..c7bdc100ccf --- /dev/null +++ b/tests/cases/compiler/abstractInterfaceIdentifierName.ts @@ -0,0 +1,4 @@ + +interface abstract { + abstract(): void; +} diff --git a/tests/cases/compiler/class1.ts b/tests/cases/compiler/class1.ts deleted file mode 100644 index c7b2115b88b..00000000000 --- a/tests/cases/compiler/class1.ts +++ /dev/null @@ -1,2 +0,0 @@ -interface foo{ } // error -class foo{ } // error \ No newline at end of file diff --git a/tests/cases/compiler/classAndInterface1.ts b/tests/cases/compiler/classAndInterface1.ts deleted file mode 100644 index 79b02915857..00000000000 --- a/tests/cases/compiler/classAndInterface1.ts +++ /dev/null @@ -1,2 +0,0 @@ - class cli { } // error -interface cli { } // error \ No newline at end of file diff --git a/tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts b/tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts new file mode 100644 index 00000000000..94e5cd94ab1 --- /dev/null +++ b/tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts @@ -0,0 +1,33 @@ +// @declaration: true + +// @Filename: file1.ts +interface I { } +class C1 { } +class C2 { } +function f() { } +var v = 3; + +class Foo { + static x: number; +} + +module N { + export module F { + var t; + } +} + +// @Filename: file2.ts +class I { } // error -- cannot merge interface with non-ambient class +interface C1 { } // error -- cannot merge interface with non-ambient class +function C2() { } // error -- cannot merge function with non-ambient class +class f { } // error -- cannot merge function with non-ambient class +var v = 3; + +module Foo { + export var x: number; // error for redeclaring var in a different parent +} + +declare module N { + export function F(); // no error because function is ambient +} diff --git a/tests/cases/compiler/exportSpecifierForAGlobal.ts b/tests/cases/compiler/exportSpecifierForAGlobal.ts new file mode 100644 index 00000000000..c24ec0b086f --- /dev/null +++ b/tests/cases/compiler/exportSpecifierForAGlobal.ts @@ -0,0 +1,12 @@ +// @declaration: true +// @module: commonjs + +// @filename: a.d.ts +declare class X { } + +// @filename: b.ts +export {X}; +export function f() { + var x: X; + return x; +} diff --git a/tests/cases/compiler/inferentialTypingUsingApparentType1.ts b/tests/cases/compiler/inferentialTypingUsingApparentType1.ts new file mode 100644 index 00000000000..98920cf693f --- /dev/null +++ b/tests/cases/compiler/inferentialTypingUsingApparentType1.ts @@ -0,0 +1,5 @@ +function foo number>(x: T): T { + return undefined; +} + +foo(x => x.length); \ No newline at end of file diff --git a/tests/cases/compiler/inferentialTypingUsingApparentType2.ts b/tests/cases/compiler/inferentialTypingUsingApparentType2.ts new file mode 100644 index 00000000000..8290b14927d --- /dev/null +++ b/tests/cases/compiler/inferentialTypingUsingApparentType2.ts @@ -0,0 +1,5 @@ +function foo(x: T): T { + return undefined; +} + +foo({ m(x) { return x.length } }); \ No newline at end of file diff --git a/tests/cases/compiler/inferentialTypingUsingApparentType3.ts b/tests/cases/compiler/inferentialTypingUsingApparentType3.ts new file mode 100644 index 00000000000..d1734b0d100 --- /dev/null +++ b/tests/cases/compiler/inferentialTypingUsingApparentType3.ts @@ -0,0 +1,26 @@ +interface Field { + clean(input: T): T +} + +class CharField implements Field { + clean(input: string) { + return "Yup"; + } +} + +class NumberField implements Field { + clean(input: number) { + return 123; + } +} + +class ObjectField }> { + constructor(public fields: T) { } +} + +var person = new ObjectField({ + id: new NumberField(), + name: new CharField() +}); + +person.fields.id; \ No newline at end of file diff --git a/tests/cases/compiler/restParamModifier.ts b/tests/cases/compiler/restParamModifier.ts new file mode 100644 index 00000000000..220b7d36d5e --- /dev/null +++ b/tests/cases/compiler/restParamModifier.ts @@ -0,0 +1,3 @@ +class C { + constructor(...public rest: string[]) {} +} \ No newline at end of file diff --git a/tests/cases/compiler/restParamModifier2.ts b/tests/cases/compiler/restParamModifier2.ts new file mode 100644 index 00000000000..e007bc56d7c --- /dev/null +++ b/tests/cases/compiler/restParamModifier2.ts @@ -0,0 +1,3 @@ +class C { + constructor(public ...rest: string[]) {} +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts new file mode 100644 index 00000000000..bb9f8a54e44 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts @@ -0,0 +1,8 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true + +var foo = async foo(): Promise => { + // Legal to use 'await' in a type context. + var v: await; +} diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts new file mode 100644 index 00000000000..45e686fd280 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true + +var foo = async (): Promise => { +}; \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts new file mode 100644 index 00000000000..8d792fdff9c --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +var f = (await) => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts new file mode 100644 index 00000000000..9ca200f8d76 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +function f(await = await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts new file mode 100644 index 00000000000..4946592c45b --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +var await = () => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts new file mode 100644 index 00000000000..53052368b31 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true + +var foo = async (await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts new file mode 100644 index 00000000000..69768429ecf --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true + +var foo = async (a = await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts new file mode 100644 index 00000000000..a034381ba57 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts @@ -0,0 +1,9 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true + +var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts new file mode 100644 index 00000000000..397e06f703d --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true + +var foo = async (): Promise => { + var v = { [await]: foo } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts new file mode 100644 index 00000000000..3f961c9d595 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +var foo = async (a = await => await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts new file mode 100644 index 00000000000..f00d0d16545 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts @@ -0,0 +1,9 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +class C { + method() { + function other() {} + var fn = async () => await other.apply(this, arguments); + } +} diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts new file mode 100644 index 00000000000..a90f08cb9f7 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts @@ -0,0 +1,8 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +class C { + method() { + var fn = async () => await this; + } +} diff --git a/tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts b/tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts new file mode 100644 index 00000000000..52694f24118 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts @@ -0,0 +1,42 @@ +// @target: ES6 +// @isolatedModules: true +// @experimentalAsyncFunctions: true +import { MyPromise } from "missing"; + +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncAwait_es6.ts b/tests/cases/conformance/async/es6/asyncAwait_es6.ts new file mode 100644 index 00000000000..eee2e73d023 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncAwait_es6.ts @@ -0,0 +1,41 @@ +// @target: ES6 +// @experimentalAsyncFunctions: true +type MyPromise = Promise; +declare var MyPromise: typeof Promise; +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncClass_es6.ts b/tests/cases/conformance/async/es6/asyncClass_es6.ts new file mode 100644 index 00000000000..c4a444ca909 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncClass_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async class C { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncConstructor_es6.ts b/tests/cases/conformance/async/es6/asyncConstructor_es6.ts new file mode 100644 index 00000000000..998156f19f4 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncConstructor_es6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +class C { + async constructor() { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncDeclare_es6.ts b/tests/cases/conformance/async/es6/asyncDeclare_es6.ts new file mode 100644 index 00000000000..d83c25a421a --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncDeclare_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare async function foo(): Promise; \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncEnum_es6.ts b/tests/cases/conformance/async/es6/asyncEnum_es6.ts new file mode 100644 index 00000000000..d9569bef9d1 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncEnum_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async enum E { + Value +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncGetter_es6.ts b/tests/cases/conformance/async/es6/asyncGetter_es6.ts new file mode 100644 index 00000000000..fe5751ece0b --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncGetter_es6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +class C { + async get foo() { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncInterface_es6.ts b/tests/cases/conformance/async/es6/asyncInterface_es6.ts new file mode 100644 index 00000000000..c7bb460ea2b --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncInterface_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async interface I { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncModule_es6.ts b/tests/cases/conformance/async/es6/asyncModule_es6.ts new file mode 100644 index 00000000000..cf660d25d1f --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncModule_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async module M { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncSetter_es6.ts b/tests/cases/conformance/async/es6/asyncSetter_es6.ts new file mode 100644 index 00000000000..2ca1c805a45 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncSetter_es6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +class C { + async set foo(value) { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts new file mode 100644 index 00000000000..df0d0e459d4 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts @@ -0,0 +1,10 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p || a; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts new file mode 100644 index 00000000000..7678c4b17ab --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts @@ -0,0 +1,10 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p && a; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts new file mode 100644 index 00000000000..0b441f063dd --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts @@ -0,0 +1,10 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: number; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p + a; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts new file mode 100644 index 00000000000..a0bdf58710f --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts @@ -0,0 +1,10 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p, a; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts new file mode 100644 index 00000000000..3276d24ee4b --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts @@ -0,0 +1,11 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var o: { a: boolean; }; + o.a = await p; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts new file mode 100644 index 00000000000..02de646112c --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(a, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts new file mode 100644 index 00000000000..5d2e4046349 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(await p, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts new file mode 100644 index 00000000000..702e1f4cbcc --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(a, await p, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts new file mode 100644 index 00000000000..aeeb192b4ba --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = (await pfn)(a, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts new file mode 100644 index 00000000000..82bb1f88ad2 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(a, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts new file mode 100644 index 00000000000..d5778df71ba --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(await p, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts new file mode 100644 index 00000000000..db01f34c825 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(a, await p, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts new file mode 100644 index 00000000000..b0b10a02a6f --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = (await po).fn(a, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitUnion_es6.ts b/tests/cases/conformance/async/es6/awaitUnion_es6.ts new file mode 100644 index 00000000000..59c5285556c --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitUnion_es6.ts @@ -0,0 +1,15 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare let a: number | string; +declare let b: PromiseLike | PromiseLike; +declare let c: PromiseLike; +declare let d: number | PromiseLike; +declare let e: number | PromiseLike; +async function f() { + let await_a = await a; + let await_b = await b; + let await_c = await c; + let await_d = await d; + let await_e = await e; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts new file mode 100644 index 00000000000..d543e424a38 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function foo(a = await => await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts new file mode 100644 index 00000000000..23e40a0e5ba --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function await(): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts new file mode 100644 index 00000000000..a457d27073f --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +var v = async function await(): Promise { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts new file mode 100644 index 00000000000..83b6a99579c --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; +} diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts new file mode 100644 index 00000000000..b837e6618d1 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function foo(): Promise { + return; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts new file mode 100644 index 00000000000..3a792140011 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function foo(): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts new file mode 100644 index 00000000000..e75ef1d36a3 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +function f(await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts new file mode 100644 index 00000000000..9ca200f8d76 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +function f(await = await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts new file mode 100644 index 00000000000..ac4447a0e4d --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +function await() { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts new file mode 100644 index 00000000000..60a0a8f4b74 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function foo(await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts new file mode 100644 index 00000000000..a3ab64b9d29 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function foo(a = await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts new file mode 100644 index 00000000000..cde12c7dbe3 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts @@ -0,0 +1,8 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts new file mode 100644 index 00000000000..52b6dba2792 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +var v = { [await]: foo } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts new file mode 100644 index 00000000000..662fa017606 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function foo(): Promise { + var v = { [await]: foo } +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts new file mode 100644 index 00000000000..4c251a03c36 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts @@ -0,0 +1,5 @@ +class abstract { + foo() { return 1; } +} + +new abstract; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts new file mode 100644 index 00000000000..f53b1a3a937 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts @@ -0,0 +1,3 @@ +abstract class A { + abstract constructor() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts new file mode 100644 index 00000000000..747b8dafe6e --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts @@ -0,0 +1,10 @@ +abstract class foo { + protected abstract test(); +} + +class bar extends foo { + test() { + this. + } +} +var x = new bar(); \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts new file mode 100644 index 00000000000..14dfd1d86d8 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts @@ -0,0 +1,25 @@ +declare abstract class A { + abstract constructor() {} +} + +declare abstract class AA { + abstract foo(); +} + +declare abstract class BB extends AA {} + +declare class CC extends AA {} + +declare class DD extends BB {} + +declare abstract class EE extends BB {} + +declare class FF extends CC {} + +declare abstract class GG extends CC {} + +declare abstract class AAA {} + +declare abstract class BBB extends AAA {} + +declare class CCC extends AAA {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts new file mode 100644 index 00000000000..f69ea30d0d6 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts @@ -0,0 +1,25 @@ +abstract class A { + t: T; + + abstract foo(): T; + abstract bar(t: T); +} + +abstract class B extends A {} + +class C extends A {} // error -- inherits abstract methods + +class D extends A {} // error -- inherits abstract methods + +class E extends A { // error -- doesn't implement bar + foo() { return this.t; } +} + +class F extends A { // error -- doesn't implement foo + bar(t : T) {} +} + +class G extends A { + foo() { return this.t; } + bar(t: T) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts new file mode 100644 index 00000000000..165a3d7a2e6 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts @@ -0,0 +1,9 @@ +module M { + export abstract class A {} + + new A; +} + +import myA = M.A; + +new myA; diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts new file mode 100644 index 00000000000..f31dd41436e --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts @@ -0,0 +1,7 @@ +module M { + export abstract class A {} + export class B extends A {} +} + +new M.A; +new M.B; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts new file mode 100644 index 00000000000..ced15607f84 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts @@ -0,0 +1,21 @@ +abstract class A {} + +abstract class B extends A {} + +class C extends A {} + +abstract class AA { + abstract foo(); +} + +abstract class BB extends AA {} + +class CC extends AA {} + +class DD extends BB {} + +abstract class EE extends BB {} + +class FF extends CC {} + +abstract class GG extends CC {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts new file mode 100644 index 00000000000..4daf27b53e4 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts @@ -0,0 +1,19 @@ + +abstract class A {} + +class B extends A {} + +abstract class C extends B {} + +new A; +new A(1); // should report 1 error +new B; +new C; + +var a : A; +var b : B; +var c : C; + +a = new B; +b = new B; +c = new B; diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts new file mode 100644 index 00000000000..3b68b898b94 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts @@ -0,0 +1,51 @@ +class A { + // ... +} + +abstract class B { + foo(): number { return this.bar(); } + abstract bar() : number; +} + +new B; // error + +var BB: typeof B = B; +var AA: typeof A = BB; // error, AA is not of abstract type. +new AA; + +function constructB(Factory : typeof B) { + new Factory; // error -- Factory is of type typeof B. +} + +var BB = B; +new BB; // error -- BB is of type typeof B. + +var x : any = C; +new x; // okay -- undefined behavior at runtime + +class C extends B { } // error -- not declared abstract + +abstract class D extends B { } // okay + +class E extends B { // okay -- implements abstract method + bar() { return 1; } +} + +abstract class F extends B { + abstract foo() : number; + bar() { return 2; } +} + +abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent + + abstract nom(): boolean; + nom(x : number): boolean; // error -- use of modifier abstract must match on all overloads. +} + +class H { // error -- not declared abstract + abstract baz() : number; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts new file mode 100644 index 00000000000..2a6fd46a08d --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts @@ -0,0 +1,4 @@ +export default abstract class A {} +export abstract class B {} +default abstract class C {} +import abstract class D {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts new file mode 100644 index 00000000000..6e5686feb25 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts @@ -0,0 +1,40 @@ +abstract class CM {} +module CM {} + +module MC {} +abstract class MC {} + +abstract class CI {} +interface CI {} + +interface IC {} +abstract class IC {} + +abstract class CC1 {} +class CC1 {} + +class CC2 {} +abstract class CC2 {} + +declare abstract class DCI {} +interface DCI {} + +interface DIC {} +declare abstract class DIC {} + +declare abstract class DCC1 {} +declare class DCC1 {} + +declare class DCC2 {} +declare abstract class DCC2 {} + +new CM; +new MC; +new CI; +new IC; +new CC1; +new CC2; +new DCI; +new DIC; +new DCC1; +new DCC2; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts new file mode 100644 index 00000000000..432613ca04b --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts @@ -0,0 +1,3 @@ +abstract class A { + abstract foo() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts new file mode 100644 index 00000000000..d3c2546ac90 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts @@ -0,0 +1,15 @@ +abstract class A { + abstract foo_a(); + + public abstract foo_b(); + protected abstract foo_c(); + private abstract foo_d(); + + abstract public foo_bb(); + abstract protected foo_cc(); + abstract private foo_dd(); + + abstract static foo_d(); + + static abstract foo_e(); +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts new file mode 100644 index 00000000000..374a3c089ef --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts @@ -0,0 +1,12 @@ +abstract class A {} + +abstract +class B {} + +abstract + +class C {} + +new A; +new B; +new C; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts new file mode 100644 index 00000000000..c30a03f8217 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts @@ -0,0 +1,24 @@ +abstract class A { + abstract foo(); + abstract foo() : number; + abstract foo(); + + abstract bar(); + bar(); + abstract bar(); + + abstract baz(); + baz(); + abstract baz(); + baz() {} + + qux(); +} + +abstract class B { + abstract foo() : number; + abstract foo(); + x : number; + abstract foo(); + abstract foo(); +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts new file mode 100644 index 00000000000..e6dc355adb9 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts @@ -0,0 +1,13 @@ +abstract class A { + abstract x : number; + public abstract y : number; + protected abstract z : number; + private abstract w : number; + + abstract m: () => void; + + abstract foo_x() : number; + public abstract foo_y() : number; + protected abstract foo_z() : number; + private abstract foo_w() : number; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts new file mode 100644 index 00000000000..e93a670b55f --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts @@ -0,0 +1,26 @@ + +class A { + foo() { return 1; } +} + +abstract class B extends A { + abstract foo(); + bar() { super.foo(); } + baz() { return this.foo; } +} + +class C extends B { + foo() { return 2; } + qux() { return super.foo() || super.foo; } // 2 errors, foo is abstract + norf() { return super.bar(); } +} + +class AA { + foo() { return 1; } + bar() { return this.foo(); } +} + +abstract class BB extends AA { + abstract foo(); + // inherits bar. But BB is abstract, so this is OK. +} diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts new file mode 100644 index 00000000000..8561fa2ce15 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts @@ -0,0 +1,17 @@ +abstract class A { + abstract foo() : number; +} + +class B extends A { + foo() { return 1; } +} + +abstract class C extends A { + abstract foo() : number; +} + +var a = new B; +a.foo(); + +a = new C; // error, cannot instantiate abstract class. +a.foo(); \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts new file mode 100644 index 00000000000..e333811c67f --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts @@ -0,0 +1,27 @@ +class A { + abstract foo(); +} + +class B extends A {} + +abstract class C extends A {} + +class D extends A { + foo() {} +} + +abstract class E extends A { + foo() {} +} + +abstract class AA { + abstract foo(); +} + +class BB extends AA {} + +abstract class CC extends AA {} + +class DD extends AA { + foo() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts new file mode 100644 index 00000000000..17b89868943 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts @@ -0,0 +1 @@ +abstract interface I {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts new file mode 100644 index 00000000000..1ef7724f81d --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts @@ -0,0 +1,25 @@ + +interface C { } + +declare class C { } + +interface C { } + +interface C { } + +declare module M { + + interface C1 { } + + class C1 { } + + interface C1 { } + + interface C1 { } + + export class C2 { } +} + +declare module M { + export interface C2 { } +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts new file mode 100644 index 00000000000..d11d67c3fea --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts @@ -0,0 +1,23 @@ +declare class C1 { + public x : number; +} + +interface C1 { + x : number; +} + +declare class C2 { + protected x : number; +} + +interface C2 { + x : number; +} + +declare class C3 { + private x : number; +} + +interface C3 { + x : number; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts b/tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts new file mode 100644 index 00000000000..d5ac1b005bf --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts @@ -0,0 +1,23 @@ +declare class C1 { + x : number; +} + +interface C1 { + y : number; +} + +class C2 implements C1 { // error -- missing x +} + +class C3 implements C1 { // error -- missing y + x : number; +} + +class C4 implements C1 { // error -- missing x + y : number; +} + +class C5 implements C1 { // okay + x : number; + y : number; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts b/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts new file mode 100644 index 00000000000..7445104e228 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts @@ -0,0 +1,20 @@ + +// @Filename: file1.ts + +declare class C1 {} + +declare class C1 {} + +declare class C2 {} + +interface C2 {} + +declare class C2 {} + +// @Filename: file2.ts + +declare class C3 { } + +// @Filename: file3.ts + +declare class C3 { } \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts b/tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts new file mode 100644 index 00000000000..4dc733d28c0 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts @@ -0,0 +1,16 @@ + +interface C1 {} +declare class C1 {} +module C1 {} + +declare class C2 {} +interface C2 {} +module C2 {} + +declare class C3 {} +module C3 {} +interface C3 {} + +module C4 {} +declare class C4 {} // error -- class declaration must preceed module declaration +interface C4 {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts b/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts new file mode 100644 index 00000000000..29400c63808 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts @@ -0,0 +1,54 @@ +// @declaration: true + +// @Filename: file1.ts + +declare class C1 { } + +interface C1 { } + +interface C2 { } + +declare class C2 { } + +class C3 { } // error -- cannot merge non-ambient class and interface + +interface C3 { } // error -- cannot merge non-ambient class and interface + +interface C4 { } // error -- cannot merge non-ambient class and interface + +class C4 { } // error -- cannot merge non-ambient class and interface + +interface C5 { + x1: number; +} + +declare class C5 { + x2: number; +} + +interface C5 { + x3: number; +} + +interface C5 { + x4: number; +} + +// checks if properties actually were merged +var c5 : C5; +c5.x1; +c5.x2; +c5.x3; +c5.x4; + +// @Filename: file2.ts + +declare class C6 { } + +interface C7 { } + +// @Filename: file3.ts + +interface C6 { } + +declare class C7 { } \ No newline at end of file diff --git a/tests/cases/conformance/expressions/asOperator/asOperator1.ts b/tests/cases/conformance/expressions/asOperator/asOperator1.ts new file mode 100644 index 00000000000..cf953d75ab4 --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperator1.ts @@ -0,0 +1,8 @@ +var as = 43; +var x = undefined as number; +var y = (null as string).length; +var z = Date as any as string; + +// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' +var j = 32 as number|string; +j = ''; diff --git a/tests/cases/conformance/expressions/asOperator/asOperator2.ts b/tests/cases/conformance/expressions/asOperator/asOperator2.ts new file mode 100644 index 00000000000..1fa5f2c938d --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperator2.ts @@ -0,0 +1 @@ +var x = 23 as string; diff --git a/tests/cases/conformance/expressions/asOperator/asOperator3.ts b/tests/cases/conformance/expressions/asOperator/asOperator3.ts new file mode 100644 index 00000000000..4c136247e00 --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperator3.ts @@ -0,0 +1,10 @@ +declare function tag(...x: any[]): any; + +var a = `${123 + 456 as number}`; +var b = `leading ${123 + 456 as number}`; +var c = `${123 + 456 as number} trailing`; +var d = `Hello ${123} World` as string; +var e = `Hello` as string; +var f = 1 + `${1} end of string` as string; +var g = tag `Hello ${123} World` as string; +var h = tag `Hello` as string; \ No newline at end of file diff --git a/tests/cases/conformance/expressions/asOperator/asOperatorASI.ts b/tests/cases/conformance/expressions/asOperator/asOperatorASI.ts new file mode 100644 index 00000000000..a4dd44a15ad --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperatorASI.ts @@ -0,0 +1,10 @@ +class Foo { } +declare function as(...args: any[]); + +// Example 1 +var x = 10 +as `Hello world`; // should not error + +// Example 2 +var y = 20 +as(Foo); // should emit diff --git a/tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts b/tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts new file mode 100644 index 00000000000..e4921314ba7 --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts @@ -0,0 +1,8 @@ +interface A { x: T; } +interface B { m: string; } + +// Make sure this is a type assertion to an array type, and not nested comparison operators. +var x: any; +var y = x as A[]; +var z = y[0].m; // z should be string + diff --git a/tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts b/tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts new file mode 100644 index 00000000000..d3a23e224ba --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts @@ -0,0 +1,2 @@ +// should error +var x = (v => v) as (x: number) => string; \ No newline at end of file diff --git a/tests/cases/conformance/expressions/asOperator/asOperatorNames.ts b/tests/cases/conformance/expressions/asOperator/asOperatorNames.ts new file mode 100644 index 00000000000..a0b54d43e84 --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperatorNames.ts @@ -0,0 +1,4 @@ +var a = 20; +var b = a as string; +var as = "hello"; +var as1 = as as string; diff --git a/tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx b/tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx new file mode 100644 index 00000000000..b20dea210a9 --- /dev/null +++ b/tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx @@ -0,0 +1,22 @@ +// @jsx: preserve + +declare var createElement: any; + +class foo {} + +var x: any; +x = { test: }; + +x = ; + +x = hello {{}} ; + +x = {}}>hello; + +x = {}}>hello{{}}; + +x = x, x = ; + +{{/foo/.test(x) ? : }} + + diff --git a/tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx b/tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx new file mode 100644 index 00000000000..163357454aa --- /dev/null +++ b/tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx @@ -0,0 +1,54 @@ +// @jsx: preserve +declare var React: any; +declare var 日本語; +declare var AbC_def; +declare var LeftRight; +declare var x; +declare var a; +declare var props; + +; + +//; Namespace unsuported + +// {value} ; Namespace unsuported + +; + +; +; + +<日本語>; + + +bar +baz +; + + : } />; + +{}; + +{/* this is a comment */}; + +
@test content
; + +

7x invalid-js-identifier
; + + right=monkeys /> gorillas />; + +; + +; + +(
) < x; + +
; + +
; + +
; + + ; diff --git a/tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx b/tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx new file mode 100644 index 00000000000..815cd4abb21 --- /dev/null +++ b/tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx @@ -0,0 +1,36 @@ +// @jsx: preserve +declare var React: any; + +; +; +<:a />; +; +; +
; +; +; +
; +
; + +
stuff
; +
stuff
; + +
>; + >; +; +; +}; +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/jsxReactTestSuite.tsx b/tests/cases/conformance/jsx/jsxReactTestSuite.tsx new file mode 100644 index 00000000000..96b91987cbc --- /dev/null +++ b/tests/cases/conformance/jsx/jsxReactTestSuite.tsx @@ -0,0 +1,117 @@ +// @jsx: preserve + +declare var React: any; +declare var Component:any; +declare var Composite:any; +declare var Composite2:any; +declare var Child:any; +declare var Namespace:any; +declare var foo: any; +declare var bar: any; +declare var y:any; +declare var x:any; +declare var z:any; +declare var hasOwnProperty:any; + +
text
; + +
+ {this.props.children} +
; + +
+

+ {foo}
{bar}
+
+
; + + + + {this.props.children} +; + + + +; + +var x = +
+
; + +( +
+ {/* A comment at the beginning */} + {/* A second comment at the beginning */} + + {/* A nested comment */} + + {/* A sandwiched comment */} +
+ {/* A comment at the end */} + {/* A second comment at the end */} +
+); + +( +
+ +
+); + +
 
; + +
 
; + +testing; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + +; + + +; + +Text; + + diff --git a/tests/cases/conformance/jsx/tsxAttributeErrors.tsx b/tests/cases/conformance/jsx/tsxAttributeErrors.tsx new file mode 100644 index 00000000000..477135e1544 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeErrors.tsx @@ -0,0 +1,26 @@ +// @jsx: preserve + +declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + width?: number; + } + + span: any; + } +} + +// Error, number is not assignable to string +
; + +// Error, string is not assignable to number +
; + +// Error, number is not assignable to string +var attribs = { text: 100 }; +
; + +// No errors here +; diff --git a/tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx b/tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx new file mode 100644 index 00000000000..4471c5a9c92 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeInvalidNames.tsx @@ -0,0 +1,13 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + test2: { "data-foo"?: string }; + } +} + +// Invalid names +; +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution.tsx new file mode 100644 index 00000000000..3e5d8e3a7c8 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution.tsx @@ -0,0 +1,9 @@ +//@jsx: preserve + +declare namespace JSX { + interface IntrinsicElements { + x: { y: number; z: string; }; + } +} + + diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx new file mode 100644 index 00000000000..eff3f3a8f43 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx @@ -0,0 +1,35 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: { reqd: string }; + var: { var: string }; + } +} +interface Attribs1 { + x?: number; + s?: string; +} + +// OK +; // OK +; // OK +; // OK + +; // OK +; // OK + +// Errors +; // Error, '0' is not number +; // Error, no property "y" +; // Error, no property "y" +; // Error, "32" is not number +; // Error, no 'var' property + +; // Error, missing reqd +; // Error, reqd is not string + +// Should be OK +; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution2.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution2.tsx new file mode 100644 index 00000000000..c9bc2de978a --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution2.tsx @@ -0,0 +1,19 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + c1?: (x: string) => void; +} + +// OK + x.length} />; // OK + x.leng} />; // OK + + +// Errors + x.leng} />; // Error, no leng on 'string' diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution3.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution3.tsx new file mode 100644 index 00000000000..dc0c2fed8d6 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution3.tsx @@ -0,0 +1,41 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + x: string; + y?: number; + z?: string; +} + +// OK +var obj1 = { x: 'foo' }; + + +// Error, x is not string +var obj2 = { x: 32 }; + + +// Error, x is missing +var obj3 = { y: 32 }; + + +// OK +var obj4 = { x: 32, y: 32 }; + + +// Error +var obj5 = { x: 32, y: 32 }; + + +// OK +var obj6 = { x: 'ok', y: 32, extra: 100 }; + + +// Error +var obj7 = { x: 'foo' }; + diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution4.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution4.tsx new file mode 100644 index 00000000000..caaad3559c3 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution4.tsx @@ -0,0 +1,17 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + } +} +interface Attribs1 { + x(n: string): void; +} + +// OK + 0} } />; + +// Error, no member 'len' on 'string' + n.len} } />; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx new file mode 100644 index 00000000000..dd16ade10e3 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx @@ -0,0 +1,32 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: Attribs1; + test2: Attribs2; + } +} +interface Attribs1 { + x: string; +} + +interface Attribs2 { + toString(): string; +} + +function make1 (obj: T) { + return ; // OK +} + +function make2 (obj: T) { + return ; // Error (x is number, not string) +} + +function make3 (obj: T) { + return ; // Error, missing x +} + + +; // Error, missing x +; // OK diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution6.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution6.tsx new file mode 100644 index 00000000000..b083247ba7a --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution6.tsx @@ -0,0 +1,19 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { n?: boolean; s?: string}; + test2: { n: boolean; }; + } +} + +// Error +; +; +; + +// OK +; +; +; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution7.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution7.tsx new file mode 100644 index 00000000000..1fc6a873187 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution7.tsx @@ -0,0 +1,16 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: { "data-foo"?: string }; + } +} + +// Error +; + +// OK +; +; +; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution8.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution8.tsx new file mode 100644 index 00000000000..ac99cd15593 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution8.tsx @@ -0,0 +1,12 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + test1: {x: string}; + } +} + +var x: any; +// Should be OK + \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxElementResolution.tsx b/tests/cases/conformance/jsx/tsxElementResolution.tsx new file mode 100644 index 00000000000..e5c3c191f05 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution.tsx @@ -0,0 +1,25 @@ +//@jsx: preserve + +declare namespace JSX { + interface IntrinsicElements { + foundFirst: { x: string }; + 'string_named'; + 'var'; + } +} + +class foundFirst { } +class Other {} + +module Dotted { + export class Name { } +} + +// Should find the intrinsic element, not the class element +var a = ; +var b = ; +// TODO: This should not be a parse error (should +// parse a property name here, not identifier) +// var c = ; +var d = ; +var e = ; diff --git a/tests/cases/conformance/jsx/tsxElementResolution1.tsx b/tests/cases/conformance/jsx/tsxElementResolution1.tsx new file mode 100644 index 00000000000..b9c1b91d05e --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution1.tsx @@ -0,0 +1,14 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } +} + +// OK +
; + +// Fail +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxElementResolution10.tsx b/tests/cases/conformance/jsx/tsxElementResolution10.tsx new file mode 100644 index 00000000000..526c0529e1b --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution10.tsx @@ -0,0 +1,21 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementClass { + render: any; + } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): { x: number }; +} +var Obj1: Obj1type; +; // Error, no render member + +interface Obj2type { + (n: string): { x: number; render: any; }; +} +var Obj2: Obj2type; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution11.tsx b/tests/cases/conformance/jsx/tsxElementResolution11.tsx new file mode 100644 index 00000000000..0fc74335500 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution11.tsx @@ -0,0 +1,25 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementAttributesProperty { } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): any; +} +var Obj1: Obj1type; +; // OK + +interface Obj2type { + new(n: string): { q?: number }; +} +var Obj2: Obj2type; +; // Error + +interface Obj3type { + new(n: string): { x: number; }; +} +var Obj3: Obj3type; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution12.tsx b/tests/cases/conformance/jsx/tsxElementResolution12.tsx new file mode 100644 index 00000000000..a5d8f2d812b --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution12.tsx @@ -0,0 +1,32 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr: any; } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): any; +} +var Obj1: Obj1type; +; // OK + +interface Obj2type { + new(n: string): { q?: number; pr: any }; +} +var obj2: Obj2type; +; // OK + +interface Obj3type { + new(n: string): { x: number; }; +} +var Obj3: Obj3type; +; // Error + +interface Obj4type { + new(n: string): { x: number; pr: { x: number; } }; +} +var Obj4: Obj4type; +; // OK +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution13.tsx b/tests/cases/conformance/jsx/tsxElementResolution13.tsx new file mode 100644 index 00000000000..32ee20afbfe --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution13.tsx @@ -0,0 +1,12 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } +} + +interface Obj1 { + new(n: string): any; +} +var obj1: Obj1; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution14.tsx b/tests/cases/conformance/jsx/tsxElementResolution14.tsx new file mode 100644 index 00000000000..f76af00bbeb --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution14.tsx @@ -0,0 +1,11 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } +} + +interface Obj1 { + new(n: string): {}; +} +var obj1: Obj1; +; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution15.tsx b/tests/cases/conformance/jsx/tsxElementResolution15.tsx new file mode 100644 index 00000000000..61cea63ce76 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution15.tsx @@ -0,0 +1,13 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface ElementAttributesProperty { pr1: any; pr2: any; } + interface IntrinsicElements { } +} + +interface Obj1type { + new(n: string): {}; +} +var Obj1: Obj1type; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution16.tsx b/tests/cases/conformance/jsx/tsxElementResolution16.tsx new file mode 100644 index 00000000000..3b5b23d77f5 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution16.tsx @@ -0,0 +1,11 @@ +//@filename: file.tsx +//@jsx: preserve +//@noImplicitAny: true +declare module JSX { +} + +interface Obj1 { + new(n: string): {}; +} +var obj1: Obj1; +; // Error (JSX.Element is implicit any) diff --git a/tests/cases/conformance/jsx/tsxElementResolution17.tsx b/tests/cases/conformance/jsx/tsxElementResolution17.tsx new file mode 100644 index 00000000000..97777d76a58 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution17.tsx @@ -0,0 +1,27 @@ +//@jsx: preserve +//@module: amd + +//@filename: file.tsx +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +declare module 'elements1' { + class MyElement { + + } +} + +declare module 'elements2' { + class MyElement { + + } +} + +//@filename: consumer.tsx +/// +// Should keep s1 and elide s2 +import s1 = require('elements1'); +import s2 = require('elements2'); +; diff --git a/tests/cases/conformance/jsx/tsxElementResolution18.tsx b/tests/cases/conformance/jsx/tsxElementResolution18.tsx new file mode 100644 index 00000000000..89081d7629f --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution18.tsx @@ -0,0 +1,9 @@ +//@jsx: preserve +//@filename: file1.tsx +//@noimplicitany: true +declare module JSX { + interface Element { } +} + +// Error under implicit any +
; diff --git a/tests/cases/conformance/jsx/tsxElementResolution19.tsx b/tests/cases/conformance/jsx/tsxElementResolution19.tsx new file mode 100644 index 00000000000..23e503ae962 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution19.tsx @@ -0,0 +1,21 @@ +//@jsx: react +//@module: amd + +//@filename: react.d.ts +declare module "react" { + +} + +//@filename: file1.tsx +declare module JSX { + interface Element { } +} +export class MyClass { } + +//@filename: file2.tsx + +// Should not elide React import +import * as React from 'react'; +import {MyClass} from './file1'; + +; diff --git a/tests/cases/conformance/jsx/tsxElementResolution2.tsx b/tests/cases/conformance/jsx/tsxElementResolution2.tsx new file mode 100644 index 00000000000..75e4956e728 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution2.tsx @@ -0,0 +1,14 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: any; + } +} + +// OK +
; + +// OK +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxElementResolution3.tsx b/tests/cases/conformance/jsx/tsxElementResolution3.tsx new file mode 100644 index 00000000000..c3f057c4ff5 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution3.tsx @@ -0,0 +1,14 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + [x: string]: { n: string; }; + } +} + +// OK +
; + +// Error +; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxElementResolution4.tsx b/tests/cases/conformance/jsx/tsxElementResolution4.tsx new file mode 100644 index 00000000000..413ae6d5ed9 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution4.tsx @@ -0,0 +1,18 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: { n: string; }; + span: { m: string; }; + } +} + +// OK +
; + +// OK +; + +// Error +; diff --git a/tests/cases/conformance/jsx/tsxElementResolution5.tsx b/tests/cases/conformance/jsx/tsxElementResolution5.tsx new file mode 100644 index 00000000000..c12c07d3e60 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution5.tsx @@ -0,0 +1,8 @@ +//@jsx: preserve +//@filename: file1.tsx +declare module JSX { + interface Element { } +} + +// OK, but implicit any +
; diff --git a/tests/cases/conformance/jsx/tsxElementResolution6.tsx b/tests/cases/conformance/jsx/tsxElementResolution6.tsx new file mode 100644 index 00000000000..74d3324ea0f --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution6.tsx @@ -0,0 +1,10 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +var div: any; +// Still an error +
; diff --git a/tests/cases/conformance/jsx/tsxElementResolution7.tsx b/tests/cases/conformance/jsx/tsxElementResolution7.tsx new file mode 100644 index 00000000000..c7ab23e76ea --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution7.tsx @@ -0,0 +1,22 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +module my { + export var div: any; +} +// OK +; +// Error +; + +module q { + import mine = my; + // OK + ; + // Error + ; +} diff --git a/tests/cases/conformance/jsx/tsxElementResolution8.tsx b/tests/cases/conformance/jsx/tsxElementResolution8.tsx new file mode 100644 index 00000000000..624302da062 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution8.tsx @@ -0,0 +1,36 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +// Error +var Div = 3; +
; + +// OK +function Fact(): any { return null; } + + +// Error +function Fnum(): number{ return 42; } + + +interface Obj1 { + new(): {}; + (): number; +} +var Obj1: Obj1; +; // OK, prefer construct signatures + +interface Obj2 { + (): number; +} +var Obj2: Obj2; +; // Error + +interface Obj3 { +} +var Obj3: Obj3; +; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution9.tsx b/tests/cases/conformance/jsx/tsxElementResolution9.tsx new file mode 100644 index 00000000000..7165f8277b3 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution9.tsx @@ -0,0 +1,27 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +interface Obj1 { + new(n: string): { x: number }; + new(n: number): { y: string }; +} +var Obj1: Obj1; +; // Error, return type is not an object type + +interface Obj2 { + (n: string): { x: number }; + (n: number): { y: string }; +} +var Obj2: Obj2; +; // Error, return type is not an object type + +interface Obj3 { + (n: string): { x: number }; + (n: number): { x: number; y: string }; +} +var Obj3: Obj3; +; // OK diff --git a/tests/cases/conformance/jsx/tsxEmit1.tsx b/tests/cases/conformance/jsx/tsxEmit1.tsx new file mode 100644 index 00000000000..9f3d9ca3a5e --- /dev/null +++ b/tests/cases/conformance/jsx/tsxEmit1.tsx @@ -0,0 +1,41 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; + +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; + +class SomeClass { + f() { + var rewrites1 =
{() => this}
; + var rewrites2 =
{[p, ...p, p]}
; + var rewrites3 =
{{p}}
; + + var rewrites4 =
this}>
; + var rewrites5 =
; + var rewrites6 =
; + } +} + +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; diff --git a/tests/cases/conformance/jsx/tsxEmit2.tsx b/tests/cases/conformance/jsx/tsxEmit2.tsx new file mode 100644 index 00000000000..24f51a4583d --- /dev/null +++ b/tests/cases/conformance/jsx/tsxEmit2.tsx @@ -0,0 +1,15 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; diff --git a/tests/cases/conformance/jsx/tsxEmit3.tsx b/tests/cases/conformance/jsx/tsxEmit3.tsx new file mode 100644 index 00000000000..b3c3350dd11 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxEmit3.tsx @@ -0,0 +1,41 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { } +} + +module M { + export class Foo { constructor() { } } + export module S { + export class Bar { } + + // Emit Foo + // Foo, ; + } +} + +module M { + // Emit M.Foo + Foo, ; + + export module S { + // Emit M.Foo + Foo, ; + + // Emit S.Bar + Bar, ; + } + +} + +module M { + // Emit M.S.Bar + S.Bar, ; +} + +module M { + var M = 100; + // Emit M_1.Foo + Foo, ; +} diff --git a/tests/cases/conformance/jsx/tsxErrorRecovery1.tsx b/tests/cases/conformance/jsx/tsxErrorRecovery1.tsx new file mode 100644 index 00000000000..881b3c95376 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxErrorRecovery1.tsx @@ -0,0 +1,10 @@ +//@filename: file.tsx +//@jsx: preserve + +declare namespace JSX { interface Element { } } + +function foo() { + var x =
{
+} +// Shouldn't see any errors down here +var y = { a: 1 }; diff --git a/tests/cases/conformance/jsx/tsxExternalModuleEmit1.tsx b/tests/cases/conformance/jsx/tsxExternalModuleEmit1.tsx new file mode 100644 index 00000000000..bb7f5c3f361 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxExternalModuleEmit1.tsx @@ -0,0 +1,32 @@ +//@jsx: preserve +//@module: commonjs + +//@filename: react.d.ts +declare module 'react' { + class Component { } +} + +//@filename: app.tsx +import * as React from 'react'; + +// Should see var button_1 = require('./button') here +import { Button } from './button'; + +export class App extends React.Component { + + render() { + return ; + } + +} \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx b/tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx new file mode 100644 index 00000000000..b3d3d34020a --- /dev/null +++ b/tests/cases/conformance/jsx/tsxGenericArrowFunctionParsing.tsx @@ -0,0 +1,28 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { isElement; } +} + +var T, T1, T2; + +// This is an element +var x1 = () => {}; +x1.isElement; + +// This is a generic function +var x2 = () => {}; +x2(); + +// This is a generic function +var x3 = () => {}; +x3(); + +// This is an element +var x4 = () => {}; +x4.isElement; + +// This is an element +var x5 = () => {}; +x5.isElement; + diff --git a/tests/cases/conformance/jsx/tsxInArrowFunction.tsx b/tests/cases/conformance/jsx/tsxInArrowFunction.tsx new file mode 100644 index 00000000000..36951e0d092 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxInArrowFunction.tsx @@ -0,0 +1,23 @@ +// @jsx: preserve + +declare namespace JSX { + interface Element { } + interface IntrinsicElements { + div: { + text?: string; + } + } +} + + +// didn't work +
{() =>
}
; + +// didn't work +
{x =>
}
; + +// worked +
{() => (
)}
; + +// worked (!) +
{() =>
}
; diff --git a/tests/cases/conformance/jsx/tsxNoJsx.tsx b/tests/cases/conformance/jsx/tsxNoJsx.tsx new file mode 100644 index 00000000000..03b827b7e61 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxNoJsx.tsx @@ -0,0 +1,3 @@ +//@jsx: preserve + +; diff --git a/tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx b/tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx new file mode 100644 index 00000000000..8f21517474f --- /dev/null +++ b/tests/cases/conformance/jsx/tsxOpeningClosingNames.tsx @@ -0,0 +1,11 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } +} + +declare module A.B.C { + var D: any; +} + +foo diff --git a/tests/cases/conformance/jsx/tsxParseTests1.tsx b/tests/cases/conformance/jsx/tsxParseTests1.tsx new file mode 100644 index 00000000000..7675aee7962 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxParseTests1.tsx @@ -0,0 +1,8 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { div; span; } +} + +var x =
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit1.tsx b/tests/cases/conformance/jsx/tsxReactEmit1.tsx new file mode 100644 index 00000000000..15ece4153a8 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit1.tsx @@ -0,0 +1,42 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +var p; +var selfClosed1 =
; +var selfClosed2 =
; +var selfClosed3 =
; +var selfClosed4 =
; +var selfClosed5 =
; +var selfClosed6 =
; +var selfClosed7 =
; + +var openClosed1 =
; +var openClosed2 =
foo
; +var openClosed3 =
{p}
; +var openClosed4 =
{p < p}
; +var openClosed5 =
{p > p}
; + +class SomeClass { + f() { + var rewrites1 =
{() => this}
; + var rewrites2 =
{[p, ...p, p]}
; + var rewrites3 =
{{p}}
; + + var rewrites4 =
this}>
; + var rewrites5 =
; + var rewrites6 =
; + } +} + +var whitespace1 =
; +var whitespace2 =
{p}
; +var whitespace3 =
+ {p} +
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit2.tsx b/tests/cases/conformance/jsx/tsxReactEmit2.tsx new file mode 100644 index 00000000000..96ab8c6046b --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit2.tsx @@ -0,0 +1,16 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +var p1, p2, p3; +var spreads1 =
{p2}
; +var spreads2 =
{p2}
; +var spreads3 =
{p2}
; +var spreads4 =
{p2}
; +var spreads5 =
{p2}
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit3.tsx b/tests/cases/conformance/jsx/tsxReactEmit3.tsx new file mode 100644 index 00000000000..12adcd3c2b6 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit3.tsx @@ -0,0 +1,9 @@ +//@jsx: react +//@filename: test.tsx + +declare module JSX { interface Element { } } +declare var React: any; + +declare var Foo, Bar, baz; + + q s ; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxReactEmit4.tsx b/tests/cases/conformance/jsx/tsxReactEmit4.tsx new file mode 100644 index 00000000000..a032a5a3985 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit4.tsx @@ -0,0 +1,19 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +var p; +var openClosed1 =
+ + {blah} + +
; + +// Should emit React.__spread({}, p, {x: 0}) +var spread1 =
; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx new file mode 100644 index 00000000000..34fd158eab1 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx @@ -0,0 +1,53 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +// THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING +// WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT + +var p = 0; +// Emit " " +
; +// Emit " ", p, " " +
{p}
; +// Emit only p +
+ {p} +
; + +// Emit only p +
+ {p} +
; + +// Emit " 3" +
3 +
; + +// Emit " 3 " +
3
; + +// Emit "3" +
+ 3 +
; + +// Emit no args +
+
; + +// Emit "foo" + ' ' + "bar" +
+ + foo + + bar + +
; + diff --git a/tests/cases/conformance/jsx/tsxTypeErrors.tsx b/tests/cases/conformance/jsx/tsxTypeErrors.tsx new file mode 100644 index 00000000000..f8288b68ce3 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxTypeErrors.tsx @@ -0,0 +1,34 @@ +//@jsx: preserve + +// A built-in element (OK) +var a1 =
; + +// A built-in element with a mistyped property (error) +var a2 = + +// A built-in element with a badly-typed attribute value (error) +var thing = { oops: 100 }; +var a3 =
+ +// Mistyped html name (error) +var e1 = + +// A custom type +class MyClass { + props: { + pt?: { x: number; y: number; }; + name?: string; + reqd: boolean; + } +} + +// Let's use it +// TODO: Error on missing 'reqd' +var b1 = ; + +// Mistyped attribute member +// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. +// Types of property 'y' are incompatible. +// Type 'string' is not assignable to type 'number'. +var b2 = ; + diff --git a/tests/cases/conformance/types/intersection/contextualIntersectionType.ts b/tests/cases/conformance/types/intersection/contextualIntersectionType.ts new file mode 100644 index 00000000000..580827992ac --- /dev/null +++ b/tests/cases/conformance/types/intersection/contextualIntersectionType.ts @@ -0,0 +1,5 @@ +var x: { a: (s: string) => string } & { b: (n: number) => number }; +x = { + a: s => s, + b: n => n +}; diff --git a/tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts b/tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts new file mode 100644 index 00000000000..e6bd671c6b2 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts @@ -0,0 +1,38 @@ +interface A { a: string } +interface B { b: string } +interface C { c: string } +interface D { d: string } + +var a: A; +var b: B; +var c: C; +var d: D; +var anb: A & B; +var aob: A | B; +var cnd: C & D; +var cod: C | D; +var x: A & B | C & D; +var y: (A | B) & (C | D); + +a = anb; // Ok +b = anb; // Ok +anb = a; +anb = b; + +x = anb; // Ok +x = aob; +x = cnd; // Ok +x = cod; +anb = x; +aob = x; +cnd = x; +cod = x; + +y = anb; +y = aob; +y = cnd; +y = cod; +anb = y; +aob = y; // Ok +cnd = y; +cod = y; // Ok diff --git a/tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts b/tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts new file mode 100644 index 00000000000..00a299ea244 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts @@ -0,0 +1,17 @@ +var a: { a: string }; +var b: { b: string }; +var x: { a: string, b: string }; +var y: { a: string } & { b: string }; + +a = x; +a = y; +x = a; // Error +y = a; // Error + +b = x; +b = y; +x = b; // Error +y = b; // Error + +x = y; +y = x; diff --git a/tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts b/tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts new file mode 100644 index 00000000000..fce399eff94 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts @@ -0,0 +1,16 @@ +interface A { a: string } +interface B { b: string } +interface C { c: string } + +// A & B is equivalent to B & A. +var y: A & B; +var y : B & A; + +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z : A & B & C; +var z : (A & B) & C; +var z : A & (B & C); +var ab : A & B; +var bc : B & C; +var z1: typeof ab & C; +var z1: A & typeof bc; diff --git a/tests/cases/conformance/types/intersection/intersectionTypeInference.ts b/tests/cases/conformance/types/intersection/intersectionTypeInference.ts new file mode 100644 index 00000000000..32a419ff03a --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeInference.ts @@ -0,0 +1,27 @@ +function extend(obj1: T, obj2: U): T & U { + var result: T & U; + obj1 = result; + obj2 = result; + result = obj1; // Error + result = obj2; // Error + return result; +} + +var x = extend({ a: "hello" }, { b: 42 }); +var s = x.a; +var n = x.b; + +interface A { + a: T; +} + +interface B { + b: U; +} + +function foo(obj: A & B): T | U { + return undefined; +} + +var z = foo({ a: "hello", b: 42 }); +var z: string | number; diff --git a/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts b/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts new file mode 100644 index 00000000000..a8c92647f47 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts @@ -0,0 +1,27 @@ +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types + +interface A { a: string } +interface B { b: string } +interface C { c: string } + +var abc: A & B & C; +abc.a = "hello"; +abc.b = "hello"; +abc.c = "hello"; + +interface X { x: A } +interface Y { x: B } +interface Z { x: C } + +var xyz: X & Y & Z; +xyz.x.a = "hello"; +xyz.x.b = "hello"; +xyz.x.c = "hello"; + +type F1 = (x: string) => string; +type F2 = (x: number) => number; + +var f: F1 & F2; +var s = f("hello"); +var n = f(42); diff --git a/tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts b/tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts new file mode 100644 index 00000000000..0a0d30d8dbb --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts @@ -0,0 +1,14 @@ +// Check that order is preserved in intersection types for purposes of +// overload resolution + +type F = (s: string) => string; +type G = (x: any) => any; + +var fg: F & G; +var gf: G & F; + +var x = fg("abc"); +var x: string; + +var y = gf("abc"); +var y: any; diff --git a/tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts b/tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts new file mode 100644 index 00000000000..d741d30ac1f --- /dev/null +++ b/tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts @@ -0,0 +1,19 @@ +type LinkedList = T & { next: LinkedList }; + +interface Entity { + name: string; +} + +interface Product extends Entity { + price: number; +} + +var entityList: LinkedList; +var s = entityList.name; +var s = entityList.next.name; +var s = entityList.next.next.name; +var s = entityList.next.next.next.name; + +var productList: LinkedList; +entityList = productList; +productList = entityList; // Error diff --git a/tests/cases/fourslash/asOperatorFormatting.ts b/tests/cases/fourslash/asOperatorFormatting.ts new file mode 100644 index 00000000000..f697ffd8bb6 --- /dev/null +++ b/tests/cases/fourslash/asOperatorFormatting.ts @@ -0,0 +1,7 @@ +/// + +//// /**/var x = 3 as number; + +goTo.marker(); +format.document(); +verify.currentLineContentIs("var x = 3 as number;"); diff --git a/tests/cases/fourslash/completionForExports.ts b/tests/cases/fourslash/completionForExports.ts deleted file mode 100644 index 57c0f75efc1..00000000000 --- a/tests/cases/fourslash/completionForExports.ts +++ /dev/null @@ -1,32 +0,0 @@ -/// - -// @Filename: m1.ts -////export var foo: number = 1; -////export function bar() { return 10; } -////export function baz() { return 10; } - -// @Filename: m2.ts -////import {/*1*/, /*2*/ from "m1" -////import {/*3*/} from "m1" -////import {foo,/*4*/ from "m1" -////import {bar as /*5*/, /*6*/ from "m1" -////import {foo, bar, baz as b,/*7*/} from "m1" -function verifyCompletionAtMarker(marker: string, ...completions: string[]) { - goTo.marker(marker); - if (completions.length) { - for (var i = 0; i < completions.length; ++i) { - verify.completionListContains(completions[i]); - } - } - else { - verify.completionListIsEmpty(); - } -} - -verifyCompletionAtMarker("1", "foo", "bar", "baz"); -verifyCompletionAtMarker("2", "foo", "bar", "baz"); -verifyCompletionAtMarker("3", "foo", "bar", "baz"); -verifyCompletionAtMarker("4", "bar", "baz"); -verifyCompletionAtMarker("5"); -verifyCompletionAtMarker("6", "foo", "baz"); -verifyCompletionAtMarker("7"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListAfterSpreadOperator01.ts b/tests/cases/fourslash/completionListAfterSpreadOperator01.ts new file mode 100644 index 00000000000..48a50124daf --- /dev/null +++ b/tests/cases/fourslash/completionListAfterSpreadOperator01.ts @@ -0,0 +1,7 @@ +/// + +////let v = [1,2,3,4]; +////let x = [.../**/ + +goTo.marker(); +verify.completionListContains("v"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListBuilderLocations_Modules.ts b/tests/cases/fourslash/completionListBuilderLocations_Modules.ts index eac7085ab66..0552e540a7e 100644 --- a/tests/cases/fourslash/completionListBuilderLocations_Modules.ts +++ b/tests/cases/fourslash/completionListBuilderLocations_Modules.ts @@ -5,9 +5,8 @@ ////module A./*moduleName2*/ +goTo.marker("moduleName1"); +verify.not.completionListIsEmpty(); -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.not.completionListIsEmpty(); - verify.completionListAllowsNewIdentifier(); -}); \ No newline at end of file +goTo.marker("moduleName2"); +verify.completionListIsEmpty(); diff --git a/tests/cases/fourslash/completionListInImportClause01.ts b/tests/cases/fourslash/completionListInImportClause01.ts new file mode 100644 index 00000000000..1191216baf1 --- /dev/null +++ b/tests/cases/fourslash/completionListInImportClause01.ts @@ -0,0 +1,39 @@ +/// + +// @Filename: m1.ts +////export var foo: number = 1; +////export function bar() { return 10; } +////export function baz() { return 10; } + +// @Filename: m2.ts +////import {/*1*/, /*2*/ from "m1" +////import {/*3*/} from "m1" +////import {foo,/*4*/ from "m1" +////import {bar as /*5*/, /*6*/ from "m1" +////import {foo, bar, baz as b,/*7*/} from "m1" +function verifyCompletionAtMarker(marker: string, showBuilder: boolean, ...completions: string[]) { + goTo.marker(marker); + if (completions.length) { + for (let completion of completions) { + verify.completionListContains(completion); + } + } + else { + verify.completionListIsEmpty(); + } + + if (showBuilder) { + verify.completionListAllowsNewIdentifier(); + } + else { + verify.not.completionListAllowsNewIdentifier(); + } +} + +verifyCompletionAtMarker("1", /*showBuilder*/ false, "foo", "bar", "baz"); +verifyCompletionAtMarker("2", /*showBuilder*/ false, "foo", "bar", "baz"); +verifyCompletionAtMarker("3", /*showBuilder*/ false, "foo", "bar", "baz"); +verifyCompletionAtMarker("4", /*showBuilder*/ false, "bar", "baz"); +verifyCompletionAtMarker("5", /*showBuilder*/ true); +verifyCompletionAtMarker("6", /*showBuilder*/ false, "foo", "baz"); +verifyCompletionAtMarker("7", /*showBuilder*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInImportClause02.ts b/tests/cases/fourslash/completionListInImportClause02.ts new file mode 100644 index 00000000000..9cf216f4578 --- /dev/null +++ b/tests/cases/fourslash/completionListInImportClause02.ts @@ -0,0 +1,13 @@ +/// + +////declare module "M1" { +//// export var V; +////} +//// +////declare module "M2" { +//// import { /**/ } from "M1" +////} + +goTo.marker(); +verify.completionListContains("V"); +verify.not.completionListAllowsNewIdentifier(); diff --git a/tests/cases/fourslash/completionListInIndexSignature01.ts b/tests/cases/fourslash/completionListInIndexSignature01.ts new file mode 100644 index 00000000000..2db28505b3e --- /dev/null +++ b/tests/cases/fourslash/completionListInIndexSignature01.ts @@ -0,0 +1,20 @@ +/// + +////interface I { +//// [/*1*/]: T; +//// [/*2*/]: T; +////} +//// +////class C { +//// [/*3*/]: string; +//// [str/*4*/: string]: number; +////} +//// +////type T = { +//// [x/*5*/yz: number]: boolean; +//// [/*6*/ + +for (let marker of test.markers()) { + goTo.position(marker.position); + verify.completionListAllowsNewIdentifier(); +} \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInIndexSignature02.ts b/tests/cases/fourslash/completionListInIndexSignature02.ts new file mode 100644 index 00000000000..d3b65dc7759 --- /dev/null +++ b/tests/cases/fourslash/completionListInIndexSignature02.ts @@ -0,0 +1,19 @@ +/// + +////interface I { +//// [x: /*1*/]: T; +//// [: /*2*/]: T +////} +//// +////class C { +//// [a: /*3*/]: string; +//// [str: string/*4*/]: number; +////} +//// +////type T = { +//// [xyz: /*5*/ + +for (let marker of test.markers()) { + goTo.position(marker.position); + verify.not.completionListAllowsNewIdentifier(); +} \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern01.ts b/tests/cases/fourslash/completionListInObjectBindingPattern01.ts index 128e95b8ed3..99188457e6f 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern01.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern01.ts @@ -10,4 +10,5 @@ goTo.marker(); verify.completionListContains("property1"); -verify.completionListContains("property2"); \ No newline at end of file +verify.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern02.ts b/tests/cases/fourslash/completionListInObjectBindingPattern02.ts index 6d2b7a6b516..0cd86c8d1a6 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern02.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern02.ts @@ -10,4 +10,5 @@ goTo.marker(); verify.completionListContains("property2"); -verify.not.completionListContains("property1"); \ No newline at end of file +verify.not.completionListContains("property1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern04.ts b/tests/cases/fourslash/completionListInObjectBindingPattern04.ts index 92b202a1b37..e6057ec0fae 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern04.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern04.ts @@ -10,4 +10,5 @@ goTo.marker(); verify.completionListContains("property1"); -verify.completionListContains("property2"); \ No newline at end of file +verify.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern05.ts b/tests/cases/fourslash/completionListInObjectBindingPattern05.ts index d17e11810df..d0876ed6a34 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern05.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern05.ts @@ -9,4 +9,5 @@ ////var { property1/**/ } = foo; goTo.marker(); -verify.completionListContains("property1"); \ No newline at end of file +verify.completionListContains("property1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern07.ts b/tests/cases/fourslash/completionListInObjectBindingPattern07.ts index a3015346aa3..4db3fc383d4 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern07.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern07.ts @@ -15,4 +15,5 @@ goTo.marker(); verify.completionListContains("propertyOfI_1"); verify.completionListContains("propertyOfI_2"); -verify.not.completionListContains("property2"); \ No newline at end of file +verify.not.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern08.ts b/tests/cases/fourslash/completionListInObjectBindingPattern08.ts index 6d6be330b83..b062ca702a2 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern08.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern08.ts @@ -15,4 +15,5 @@ goTo.marker(); verify.completionListContains("propertyOfI_2"); verify.not.completionListContains("propertyOfI_1"); -verify.not.completionListContains("property2"); \ No newline at end of file +verify.not.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern09.ts b/tests/cases/fourslash/completionListInObjectBindingPattern09.ts index 2698e78667b..61b31385b35 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern09.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern09.ts @@ -16,4 +16,5 @@ goTo.marker(); verify.completionListContains("property2"); verify.not.completionListContains("property1"); verify.not.completionListContains("propertyOfI_2"); -verify.not.completionListContains("propertyOfI_1"); \ No newline at end of file +verify.not.completionListContains("propertyOfI_1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern10.ts b/tests/cases/fourslash/completionListInObjectBindingPattern10.ts index fcc09d1ead4..836e12fd8a3 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern10.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern10.ts @@ -17,7 +17,9 @@ verify.completionListContains("property2"); verify.not.completionListContains("property1"); verify.not.completionListContains("propertyOfI_2"); verify.not.completionListContains("propertyOfI_1"); +verify.not.completionListAllowsNewIdentifier(); goTo.marker("2"); verify.completionListContains("property1"); -verify.completionListContains("property2"); \ No newline at end of file +verify.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern11.ts b/tests/cases/fourslash/completionListInObjectBindingPattern11.ts index 25d6651a038..57a32578026 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern11.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern11.ts @@ -10,4 +10,5 @@ goTo.marker(""); verify.completionListContains("property2"); verify.not.completionListContains("property1"); -verify.not.completionListContains("prop1"); \ No newline at end of file +verify.not.completionListContains("prop1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern12.ts b/tests/cases/fourslash/completionListInObjectBindingPattern12.ts index f31206a21b6..59af2da38d2 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern12.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern12.ts @@ -10,4 +10,5 @@ goTo.marker(""); verify.completionListContains("property2"); -verify.not.completionListContains("property1"); \ No newline at end of file +verify.not.completionListContains("property1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern13.ts b/tests/cases/fourslash/completionListInObjectBindingPattern13.ts new file mode 100644 index 00000000000..8081d2ee23b --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern13.ts @@ -0,0 +1,20 @@ +/// + +////interface I { +//// x: number; +//// y: string; +//// z: boolean; +////} +//// +////interface J { +//// x: string; +//// y: string; +////} +//// +////let { /**/ }: I | J = { x: 10 }; + +goTo.marker(); +verify.completionListContains("x"); +verify.completionListContains("y"); +verify.not.completionListContains("z"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport01.ts b/tests/cases/fourslash/findAllRefsForDefaultExport01.ts new file mode 100644 index 00000000000..2f40af93c02 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport01.ts @@ -0,0 +1,18 @@ +/// + +////export default class [|DefaultExportedClass|] { +////} +//// +////var x: [|DefaultExportedClass|]; +//// +////var y = new [|DefaultExportedClass|]; + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport02.ts b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts new file mode 100644 index 00000000000..db773c74e3c --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts @@ -0,0 +1,19 @@ +/// + +////export default function [|DefaultExportedFunction|]() { +//// return [|DefaultExportedFunction|] +////} +//// +////var x: typeof [|DefaultExportedFunction|]; +//// +////var y = [|DefaultExportedFunction|](); + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport03.ts b/tests/cases/fourslash/findAllRefsForDefaultExport03.ts new file mode 100644 index 00000000000..f753d17de49 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport03.ts @@ -0,0 +1,25 @@ +/// + +////function [|f|]() { +//// return 100; +////} +//// +////export default [|f|]; +//// +////var x: typeof [|f|]; +//// +////var y = [|f|](); +//// +////namespace [|f|] { +//// var local = 100; +////} + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport04.ts b/tests/cases/fourslash/findAllRefsForDefaultExport04.ts new file mode 100644 index 00000000000..45b008b55fe --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport04.ts @@ -0,0 +1,28 @@ +/// + +////function f() { +//// return 100; +////} +//// +////export default [|f|]; +//// +////var x: typeof f; +//// +////var y = f(); +//// +////namespace /**/[|f|] { +////} + +// The function 'f' and the namespace 'f' don't get merged, +// but the 'export default' site, includes both meanings. + +// Here we are testing whether the 'export default' +// site is included in the references to the namespace. + +goTo.marker(); +let ranges = test.ranges(); +verify.referencesCountIs(ranges.length); + +for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); +} diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport05.ts b/tests/cases/fourslash/findAllRefsForDefaultExport05.ts new file mode 100644 index 00000000000..6655138da3b --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport05.ts @@ -0,0 +1,28 @@ +/// + +////function /**/[|f|]() { +//// return 100; +////} +//// +////export default [|f|]; +//// +////var x: typeof [|f|]; +//// +////var y = [|f|](); +//// +////namespace f { +////} + +// The function 'f' and the namespace 'f' don't get merged, +// but the 'export default' site, includes both meanings. + +// Here we are testing whether the 'export default' site +// and all value-uses of 'f' are included in the references to the function. + +goTo.marker(); +let ranges = test.ranges(); +verify.referencesCountIs(ranges.length); + +for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); +} diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport06.ts b/tests/cases/fourslash/findAllRefsForDefaultExport06.ts new file mode 100644 index 00000000000..12c187b4b0c --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport06.ts @@ -0,0 +1,28 @@ +/// + +////function [|f|]() { +//// return 100; +////} +//// +////export default /**/[|f|]; +//// +////var x: typeof [|f|]; +//// +////var y = [|f|](); +//// +////namespace [|f|] { +////} + +// The function 'f' and the namespace 'f' don't get merged, +// but the 'export default' site, includes both meanings. + +// Here we are testing whether the 'export default' site +// and all value-uses of 'f' are included in the references to the function. + +goTo.marker(); +let ranges = test.ranges(); +verify.referencesCountIs(ranges.length); + +for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); +} diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport07.ts b/tests/cases/fourslash/findAllRefsForDefaultExport07.ts new file mode 100644 index 00000000000..9534a671316 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport07.ts @@ -0,0 +1,18 @@ +/// + +////export default function DefaultExportedFunction() { +//// return DefaultExportedFunction +////} +//// +////var x: typeof DefaultExportedFunction; +//// +////var y = DefaultExportedFunction(); +//// +////namespace /**/DefaultExportedFunction { +////} + +// The namespace and function do not merge, +// so the namespace should be all alone. + +goTo.marker(); +verify.referencesCountIs(1); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport08.ts b/tests/cases/fourslash/findAllRefsForDefaultExport08.ts new file mode 100644 index 00000000000..80eabbe53f4 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport08.ts @@ -0,0 +1,17 @@ +/// + +////export default class DefaultExportedClass { +////} +//// +////var x: DefaultExportedClass; +//// +////var y = new DefaultExportedClass; +//// +////namespace /**/DefaultExportedClass { +////} + +// The namespace and class do not merge, +// so the namespace should be all alone. + +goTo.marker(); +verify.referencesCountIs(1); diff --git a/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts b/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts new file mode 100644 index 00000000000..a312a277ebb --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts @@ -0,0 +1,21 @@ +/// + +// @Filename: file1.ts +////var foo = function [|foo|](a = [|foo|](), b = () => [|foo|]) { +//// [|foo|]([|foo|], [|foo|]); +////} + +// @Filename: file2.ts +/////// +////foo(); + + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/incrementalParsingInsertIntoMethod1.ts b/tests/cases/fourslash/incrementalParsingInsertIntoMethod1.ts index 930c0511ffb..b5deb361056 100644 --- a/tests/cases/fourslash/incrementalParsingInsertIntoMethod1.ts +++ b/tests/cases/fourslash/incrementalParsingInsertIntoMethod1.ts @@ -8,6 +8,5 @@ //// public foo3() { } ////} -debugger; goTo.marker("1"); edit.insert(" + 1"); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListAfterDoubleDot.ts b/tests/cases/fourslash/memberListAfterDoubleDot.ts new file mode 100644 index 00000000000..21a1ad913ea --- /dev/null +++ b/tests/cases/fourslash/memberListAfterDoubleDot.ts @@ -0,0 +1,6 @@ +/// + +////../**/ + +goTo.marker(); +verify.memberListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListAfterSingleDot.ts b/tests/cases/fourslash/memberListAfterSingleDot.ts index 0bc5107f2c1..62edf3b8c9e 100644 --- a/tests/cases/fourslash/memberListAfterSingleDot.ts +++ b/tests/cases/fourslash/memberListAfterSingleDot.ts @@ -3,4 +3,4 @@ ////./**/ goTo.marker(); -verify.not.memberListIsEmpty(); \ No newline at end of file +verify.memberListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport01.ts b/tests/cases/fourslash/renameForDefaultExport01.ts new file mode 100644 index 00000000000..809c127a727 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport01.ts @@ -0,0 +1,18 @@ +/// + +////export default class /*1*/[|DefaultExportedClass|] { +////} +/////* +//// * Commenting [|DefaultExportedClass|] +//// */ +//// +////var x: /*2*/[|DefaultExportedClass|]; +//// +////var y = new /*3*/[|DefaultExportedClass|]; + +let markers = test.markers() +for (let marker of markers) { + goTo.position(marker.position); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); +} \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport02.ts b/tests/cases/fourslash/renameForDefaultExport02.ts new file mode 100644 index 00000000000..ddf4b224023 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport02.ts @@ -0,0 +1,19 @@ +/// + +////export default function /*1*/[|DefaultExportedFunction|]() { +//// return /*2*/[|DefaultExportedFunction|] +////} +/////** +//// * Commenting [|DefaultExportedFunction|] +//// */ +//// +////var x: typeof /*3*/[|DefaultExportedFunction|]; +//// +////var y = /*4*/[|DefaultExportedFunction|](); + +let markers = test.markers() +for (let marker of markers) { + goTo.position(marker.position); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); +} \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport03.ts b/tests/cases/fourslash/renameForDefaultExport03.ts new file mode 100644 index 00000000000..6f82d96fe5e --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport03.ts @@ -0,0 +1,25 @@ +/// + +////function /*1*/[|f|]() { +//// return 100; +////} +//// +////export default /*2*/[|f|]; +//// +////var x: typeof /*3*/[|f|]; +//// +////var y = /*4*/[|f|](); +//// +/////** +//// * Commenting [|f|] +//// */ +////namespace /*5*/[|f|] { +//// var local = 100; +////} + +let markers = test.markers() +for (let marker of markers) { + goTo.position(marker.position); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); +} \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport04.ts b/tests/cases/fourslash/renameForDefaultExport04.ts new file mode 100644 index 00000000000..ba40374e262 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport04.ts @@ -0,0 +1,15 @@ +/// + +// @Filename: foo.ts +////export default class /**/[|DefaultExportedClass|] { +////} +/////* +//// * Commenting DefaultExportedClass +//// */ +//// +////var x: DefaultExportedClass; +//// +////var y = new DefaultExportedClass; + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport05.ts b/tests/cases/fourslash/renameForDefaultExport05.ts new file mode 100644 index 00000000000..099f878bda1 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport05.ts @@ -0,0 +1,15 @@ +/// + +// @Filename: foo.ts +////export default class DefaultExportedClass { +////} +/////* +//// * Commenting DefaultExportedClass +//// */ +//// +////var x: /**/[|DefaultExportedClass|]; +//// +////var y = new DefaultExportedClass; + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport06.ts b/tests/cases/fourslash/renameForDefaultExport06.ts new file mode 100644 index 00000000000..3ec067b7029 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport06.ts @@ -0,0 +1,15 @@ +/// + +// @Filename: foo.ts +////export default class DefaultExportedClass { +////} +/////* +//// * Commenting DefaultExportedClass +//// */ +//// +////var x: DefaultExportedClass; +//// +////var y = new /**/[|DefaultExportedClass|]; + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport07.ts b/tests/cases/fourslash/renameForDefaultExport07.ts new file mode 100644 index 00000000000..b65f348f2a0 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport07.ts @@ -0,0 +1,16 @@ +/// + +// @Filename: foo.ts +////export default function /**/[|DefaultExportedFunction|]() { +//// return DefaultExportedFunction +////} +/////** +//// * Commenting DefaultExportedFunction +//// */ +//// +////var x: typeof DefaultExportedFunction; +//// +////var y = DefaultExportedFunction(); + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedFunction", '"tests/cases/fourslash/foo".DefaultExportedFunction'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport08.ts b/tests/cases/fourslash/renameForDefaultExport08.ts new file mode 100644 index 00000000000..9b3f23db2c1 --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport08.ts @@ -0,0 +1,16 @@ +/// + +// @Filename: foo.ts +////export default function DefaultExportedFunction() { +//// return /**/[|DefaultExportedFunction|] +////} +/////** +//// * Commenting DefaultExportedFunction +//// */ +//// +////var x: typeof DefaultExportedFunction; +//// +////var y = DefaultExportedFunction(); + +goTo.marker(); +verify.renameInfoSucceeded("DefaultExportedFunction", '"tests/cases/fourslash/foo".DefaultExportedFunction'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport09.ts b/tests/cases/fourslash/renameForDefaultExport09.ts new file mode 100644 index 00000000000..bba2e57f49e --- /dev/null +++ b/tests/cases/fourslash/renameForDefaultExport09.ts @@ -0,0 +1,22 @@ +/// + +// @Filename: foo.ts +////function /**/[|f|]() { +//// return 100; +////} +//// +////export default f; +//// +////var x: typeof f; +//// +////var y = f(); +//// +/////** +//// * Commenting f +//// */ +////namespace f { +//// var local = 100; +////} + +goTo.marker(); +verify.renameInfoSucceeded("f", "f"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameInfoForFunctionExpression01.ts b/tests/cases/fourslash/renameInfoForFunctionExpression01.ts new file mode 100644 index 00000000000..807c4541f3f --- /dev/null +++ b/tests/cases/fourslash/renameInfoForFunctionExpression01.ts @@ -0,0 +1,8 @@ +/// + +////var x = function /**/[|f|](g: any, h: any) { +//// f(f, g); +////} + +goTo.marker(); +verify.renameInfoSucceeded("f"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameLocationsForClassExpression01.ts b/tests/cases/fourslash/renameLocationsForClassExpression01.ts new file mode 100644 index 00000000000..e7247f8e4ee --- /dev/null +++ b/tests/cases/fourslash/renameLocationsForClassExpression01.ts @@ -0,0 +1,32 @@ +/// + +////class Foo { +////} +//// +////var x = class [|Foo|] { +//// doIt() { +//// return [|Foo|]; +//// } +//// +//// static doItStatically() { +//// return [|Foo|]; +//// } +////} +//// +////var y = class { +//// getSomeName() { +//// return Foo +//// } +////} + + +// TODO (yuit): Fix up this test when class expressions are supported. +// Just uncomment the below, remove the marker, and add the +// appropriate ranges in the test itself. + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} \ No newline at end of file diff --git a/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts b/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts new file mode 100644 index 00000000000..e884783d960 --- /dev/null +++ b/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts @@ -0,0 +1,12 @@ +/// + +////var x = function [|f|](g: any, h: any) { +//// [|f|]([|f|], g); +////} + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} \ No newline at end of file diff --git a/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts b/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts new file mode 100644 index 00000000000..8186611cb64 --- /dev/null +++ b/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts @@ -0,0 +1,18 @@ +/// + +////function f() { +//// +////} +////var x = function [|f|](g: any, h: any) { +//// +//// let helper = function f(): any { f(); } +//// +//// let foo = () => [|f|]([|f|], g); +////} + +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} \ No newline at end of file diff --git a/tests/cases/fourslash/semanticClassificationsCancellation1.ts b/tests/cases/fourslash/semanticClassificationsCancellation1.ts new file mode 100644 index 00000000000..9381bef5e86 --- /dev/null +++ b/tests/cases/fourslash/semanticClassificationsCancellation1.ts @@ -0,0 +1,15 @@ +/// + +////module M { +////} +////module N { +////} + +var c = classification; +cancellation.setCancelled(1); +verifyOperationIsCancelled(() => verify.semanticClassificationsAre()); +cancellation.resetCancelled(); + +verify.semanticClassificationsAre( + c.moduleName("M"), + c.moduleName("N")); diff --git a/tests/cases/fourslash/server/tsxIncrementalServer.ts b/tests/cases/fourslash/server/tsxIncrementalServer.ts new file mode 100644 index 00000000000..9ae51406c2f --- /dev/null +++ b/tests/cases/fourslash/server/tsxIncrementalServer.ts @@ -0,0 +1,13 @@ +/// + +//// /**/ + +goTo.marker(); +edit.insert("<"); +edit.insert("div"); +edit.insert(" "); +edit.insert(" id"); +edit.insert("="); +edit.insert("\"foo"); +edit.insert("\""); +edit.insert(">"); diff --git a/tests/cases/fourslash/shims/cancellationWhenfindingAllRefsOnDefinition.ts b/tests/cases/fourslash/shims/cancellationWhenfindingAllRefsOnDefinition.ts deleted file mode 100644 index 09f580bb965..00000000000 --- a/tests/cases/fourslash/shims/cancellationWhenfindingAllRefsOnDefinition.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// - -//@Filename: findAllRefsOnDefinition-import.ts -////export class Test{ -//// -//// constructor(){ -//// -//// } -//// -//// public /*1*/start(){ -//// return this; -//// } -//// -//// public stop(){ -//// return this; -//// } -////} - -//@Filename: findAllRefsOnDefinition.ts -////import Second = require("findAllRefsOnDefinition-import"); -//// -////var second = new Second.Test() -////second.start(); -////second.stop(); - -goTo.file("findAllRefsOnDefinition-import.ts"); -goTo.marker("1"); - -verify.referencesCountIs(2); - -cancellation.setCancelled(); -goTo.marker("1"); -verifyOperationIsCancelled(() => verify.referencesCountIs(0) ); - -// verify that internal state is still correct -cancellation.resetCancelled(); -goTo.marker("1"); -verify.referencesCountIs(2); diff --git a/tests/cases/fourslash/syntacticClassificationsCancellation1.ts b/tests/cases/fourslash/syntacticClassificationsCancellation1.ts new file mode 100644 index 00000000000..f15ce5f9984 --- /dev/null +++ b/tests/cases/fourslash/syntacticClassificationsCancellation1.ts @@ -0,0 +1,21 @@ +/// + +////module M { +////} +////module N { +////} + +var c = classification; +cancellation.setCancelled(1); +verifyOperationIsCancelled(() => verify.syntacticClassificationsAre()); +cancellation.resetCancelled(); + +verify.syntacticClassificationsAre( + c.keyword("module"), + c.moduleName("M"), + c.punctuation("{"), + c.punctuation("}"), + c.keyword("module"), + c.moduleName("N"), + c.punctuation("{"), + c.punctuation("}")); diff --git a/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts b/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts index e381856c41e..7f26038c33e 100644 --- a/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts +++ b/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts @@ -7,7 +7,7 @@ //// v = 2; ////>>>>>>> Branch - a ////} -debugger; + var c = classification; verify.syntacticClassificationsAre( c.keyword("class"), c.className("C"), c.punctuation("{"), diff --git a/tests/cases/fourslash/tsxCompletion1.ts b/tests/cases/fourslash/tsxCompletion1.ts new file mode 100644 index 00000000000..f638b0b6e4f --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion1.ts @@ -0,0 +1,14 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { ONE: string; TWO: number; } +//// } +//// } +//// var x =
; + +goTo.marker(); +verify.completionListContains('ONE'); +verify.completionListContains('TWO'); diff --git a/tests/cases/fourslash/tsxCompletion2.ts b/tests/cases/fourslash/tsxCompletion2.ts new file mode 100644 index 00000000000..d33f9106877 --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion2.ts @@ -0,0 +1,15 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// } +//// interface ElementAttributesProperty { props; } +//// } +//// class MyComp { props: { ONE: string; TWO: number } } +//// var x = ; + +goTo.marker(); +verify.completionListContains('ONE'); +verify.completionListContains('TWO'); diff --git a/tests/cases/fourslash/tsxCompletion3.ts b/tests/cases/fourslash/tsxCompletion3.ts new file mode 100644 index 00000000000..5ee712f7e96 --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion3.ts @@ -0,0 +1,14 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { one; two; } +//// } +//// } +////
; + +goTo.marker(); +verify.completionListContains('two'); +verify.not.completionListContains('one'); diff --git a/tests/cases/fourslash/tsxCompletion4.ts b/tests/cases/fourslash/tsxCompletion4.ts new file mode 100644 index 00000000000..6a66c4a898f --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion4.ts @@ -0,0 +1,14 @@ +/// + +//@Filename: file.tsx +//// declare namespace JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { one; two; } +//// } +//// } +//// let bag = { x: 100, y: 200 }; +////
+ +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { } +//// interface ElementAttributesProperty { props; } +//// } +//// /*ct*/class MyClass { +//// props: { +//// /*pt*/foo: string; +//// } +//// } +//// var x = ; +//// var y = ; + +goTo.marker('c'); +goTo.definition(); +verify.caretAtMarker('ct'); + +goTo.marker('p'); +goTo.definition(); +verify.caretAtMarker('pt'); diff --git a/tests/cases/fourslash/tsxGoToDefinitionIntrinsics.ts b/tests/cases/fourslash/tsxGoToDefinitionIntrinsics.ts new file mode 100644 index 00000000000..bbdf395e478 --- /dev/null +++ b/tests/cases/fourslash/tsxGoToDefinitionIntrinsics.ts @@ -0,0 +1,29 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// /*dt*/div: { +//// /*pt*/name?: string; +//// isOpen?: boolean; +//// }; +//// /*st*/span: { n: string; }; +//// } +//// } +//// var x = ; +//// var y = ; +//// var z =
; + +goTo.marker('ds'); +goTo.definition(); +verify.caretAtMarker('dt'); + +goTo.marker('ss'); +goTo.definition(); +verify.caretAtMarker('st'); + +goTo.marker('ps'); +goTo.definition(); +verify.caretAtMarker('pt'); + diff --git a/tests/cases/fourslash/tsxIncremental.ts b/tests/cases/fourslash/tsxIncremental.ts new file mode 100644 index 00000000000..c901401fff9 --- /dev/null +++ b/tests/cases/fourslash/tsxIncremental.ts @@ -0,0 +1,13 @@ +/// + +//// /**/ + +goTo.marker(); +edit.insert("<"); +edit.insert("div"); +edit.insert(" "); +edit.insert(" id"); +edit.insert("="); +edit.insert("\"foo"); +edit.insert("\""); +edit.insert(">"); diff --git a/tests/cases/fourslash/tsxParsing.ts b/tests/cases/fourslash/tsxParsing.ts new file mode 100644 index 00000000000..e5b2e7ea841 --- /dev/null +++ b/tests/cases/fourslash/tsxParsing.ts @@ -0,0 +1,5 @@ +//// var x =
; +//// var y = /**/x; + +goTo.marker(); +verify.quickInfoExists(); diff --git a/tests/cases/fourslash/tsxRename1.ts b/tests/cases/fourslash/tsxRename1.ts new file mode 100644 index 00000000000..3fb973ec996 --- /dev/null +++ b/tests/cases/fourslash/tsxRename1.ts @@ -0,0 +1,17 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// [|div|]: { +//// name?: string; +//// isOpen?: boolean; +//// }; +//// span: { n: string; }; +//// } +//// } +//// var x = <[|di/*ds*/v|] />; + +goTo.marker('ds'); +verify.renameLocations(false, false); diff --git a/tests/cases/fourslash/tsxRename2.ts b/tests/cases/fourslash/tsxRename2.ts new file mode 100644 index 00000000000..d0f5737214b --- /dev/null +++ b/tests/cases/fourslash/tsxRename2.ts @@ -0,0 +1,17 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { +//// [|name|]?: string; +//// isOpen?: boolean; +//// }; +//// span: { n: string; }; +//// } +//// } +//// var x =
; + +goTo.marker(); +verify.renameLocations(false, false); diff --git a/tests/cases/fourslash/tsxRename3.ts b/tests/cases/fourslash/tsxRename3.ts new file mode 100644 index 00000000000..1ab9c8a5915 --- /dev/null +++ b/tests/cases/fourslash/tsxRename3.ts @@ -0,0 +1,20 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// } +//// interface ElementAttributesProperty { props } +//// } +//// class MyClass { +//// props: { +//// [|name|]?: string; +//// size?: number; +//// } +//// +//// +//// var x = ; + +goTo.marker(); +verify.renameLocations(false, false);