From 7b0e74d91a02f0da8993f6dec401cf4cad6bc8bf Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 3 Oct 2017 12:41:33 -0700 Subject: [PATCH 01/26] Binding pattern contextual type checks spread type The spread type can contain properties that have been built up during the construction of the object literal. --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8c9b818cd79..6cdad32751c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13890,7 +13890,7 @@ namespace ts { // type with those properties for which the binding pattern specifies a default value. if (contextualTypeHasPattern) { for (const prop of getPropertiesOfType(contextualType)) { - if (!propertiesTable.get(prop.escapedName)) { + if (!propertiesTable.get(prop.escapedName) && !(spread && getPropertyOfType(spread, prop.escapedName))) { if (!(prop.flags & SymbolFlags.Optional)) { error(prop.valueDeclaration || (prop).bindingElement, Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); From 2c04b5510fcf735775a0891cab7283864e923ca1 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 3 Oct 2017 12:43:23 -0700 Subject: [PATCH 02/26] Test:spread contextually typed by binding pattern --- .../spreadContextualTypedBindingPattern.js | 25 +++++++++++++++++ ...preadContextualTypedBindingPattern.symbols | 27 ++++++++++++++++++ .../spreadContextualTypedBindingPattern.types | 28 +++++++++++++++++++ .../spreadContextualTypedBindingPattern.ts | 11 ++++++++ 4 files changed, 91 insertions(+) create mode 100644 tests/baselines/reference/spreadContextualTypedBindingPattern.js create mode 100644 tests/baselines/reference/spreadContextualTypedBindingPattern.symbols create mode 100644 tests/baselines/reference/spreadContextualTypedBindingPattern.types create mode 100644 tests/cases/conformance/types/spread/spreadContextualTypedBindingPattern.ts diff --git a/tests/baselines/reference/spreadContextualTypedBindingPattern.js b/tests/baselines/reference/spreadContextualTypedBindingPattern.js new file mode 100644 index 00000000000..a97a3124886 --- /dev/null +++ b/tests/baselines/reference/spreadContextualTypedBindingPattern.js @@ -0,0 +1,25 @@ +//// [spreadContextualTypedBindingPattern.ts] +// #18308 +interface Person { + naam: string, + age: number +} + +declare const bob: Person +declare const alice: Person + +// [ts] Initializer provides no value for this binding element and the binding element has no default value. +const { naam, age } = {...bob, ...alice} + + +//// [spreadContextualTypedBindingPattern.js] +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; +// [ts] Initializer provides no value for this binding element and the binding element has no default value. +var _a = __assign({}, bob, alice), naam = _a.naam, age = _a.age; diff --git a/tests/baselines/reference/spreadContextualTypedBindingPattern.symbols b/tests/baselines/reference/spreadContextualTypedBindingPattern.symbols new file mode 100644 index 00000000000..260ac282b07 --- /dev/null +++ b/tests/baselines/reference/spreadContextualTypedBindingPattern.symbols @@ -0,0 +1,27 @@ +=== tests/cases/conformance/types/spread/spreadContextualTypedBindingPattern.ts === +// #18308 +interface Person { +>Person : Symbol(Person, Decl(spreadContextualTypedBindingPattern.ts, 0, 0)) + + naam: string, +>naam : Symbol(Person.naam, Decl(spreadContextualTypedBindingPattern.ts, 1, 18)) + + age: number +>age : Symbol(Person.age, Decl(spreadContextualTypedBindingPattern.ts, 2, 15)) +} + +declare const bob: Person +>bob : Symbol(bob, Decl(spreadContextualTypedBindingPattern.ts, 6, 13)) +>Person : Symbol(Person, Decl(spreadContextualTypedBindingPattern.ts, 0, 0)) + +declare const alice: Person +>alice : Symbol(alice, Decl(spreadContextualTypedBindingPattern.ts, 7, 13)) +>Person : Symbol(Person, Decl(spreadContextualTypedBindingPattern.ts, 0, 0)) + +// [ts] Initializer provides no value for this binding element and the binding element has no default value. +const { naam, age } = {...bob, ...alice} +>naam : Symbol(naam, Decl(spreadContextualTypedBindingPattern.ts, 10, 7)) +>age : Symbol(age, Decl(spreadContextualTypedBindingPattern.ts, 10, 13)) +>bob : Symbol(bob, Decl(spreadContextualTypedBindingPattern.ts, 6, 13)) +>alice : Symbol(alice, Decl(spreadContextualTypedBindingPattern.ts, 7, 13)) + diff --git a/tests/baselines/reference/spreadContextualTypedBindingPattern.types b/tests/baselines/reference/spreadContextualTypedBindingPattern.types new file mode 100644 index 00000000000..c58fb9e357e --- /dev/null +++ b/tests/baselines/reference/spreadContextualTypedBindingPattern.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/types/spread/spreadContextualTypedBindingPattern.ts === +// #18308 +interface Person { +>Person : Person + + naam: string, +>naam : string + + age: number +>age : number +} + +declare const bob: Person +>bob : Person +>Person : Person + +declare const alice: Person +>alice : Person +>Person : Person + +// [ts] Initializer provides no value for this binding element and the binding element has no default value. +const { naam, age } = {...bob, ...alice} +>naam : string +>age : number +>{...bob, ...alice} : { naam: string; age: number; } +>bob : Person +>alice : Person + diff --git a/tests/cases/conformance/types/spread/spreadContextualTypedBindingPattern.ts b/tests/cases/conformance/types/spread/spreadContextualTypedBindingPattern.ts new file mode 100644 index 00000000000..1414c5f278b --- /dev/null +++ b/tests/cases/conformance/types/spread/spreadContextualTypedBindingPattern.ts @@ -0,0 +1,11 @@ +// #18308 +interface Person { + naam: string, + age: number +} + +declare const bob: Person +declare const alice: Person + +// [ts] Initializer provides no value for this binding element and the binding element has no default value. +const { naam, age } = {...bob, ...alice} From db88c8eac29aba048403e2a8a7ab868c79b99b00 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 1 Nov 2017 09:12:01 -0700 Subject: [PATCH 03/26] Check function type parameters for this references Previously, when checking for this references, the compiler did not check type parameters. This caused it to miss some instantiations that were necessary. Also some cleanup: 1. Rename isIndependent* to is*FreeOfThisReference. 'Independent' was a one-off concept that was unique to Typescript (and isn't referenced in the spec), so I think the new name is friendlier to new readers. 2. Use `Array.every` whenever possible, since Typescript added a dependency on ES5 since the code was first written. 3. Switch to JSDoc so that it shows up nicely in editors. --- src/compiler/checker.ts | 101 +++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 49 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 09354d957a3..ccb7c869137 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5108,10 +5108,14 @@ namespace ts { } } - // Returns true if the interface given by the symbol is free of "this" references. Specifically, the result is - // true if the interface itself contains no references to "this" in its body, if all base types are interfaces, - // and if none of the base interfaces have a "this" type. - function isIndependentInterface(symbol: Symbol): boolean { + /** + * Returns true if the interface given by the symbol is free of "this" references. + * + * Specifically, the result is true if the interface itself contains no references + * to "this" in its body, if all base types are interfaces, + * and if none of the base interfaces have a "this" type. + */ + function isInterfaceFreeOfThisReference(symbol: Symbol): boolean { for (const declaration of symbol.declarations) { if (declaration.kind === SyntaxKind.InterfaceDeclaration) { if (declaration.flags & NodeFlags.ContainsThis) { @@ -5145,7 +5149,7 @@ namespace ts { // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === ObjectFlags.Class || !isIndependentInterface(symbol)) { + if (outerTypeParameters || localTypeParameters || kind === ObjectFlags.Class || !isInterfaceFreeOfThisReference(symbol)) { type.objectFlags |= ObjectFlags.Reference; type.typeParameters = concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -5327,22 +5331,17 @@ namespace ts { return undefined; } - // A type reference is considered independent if each type argument is considered independent. - function isIndependentTypeReference(node: TypeReferenceNode): boolean { - if (node.typeArguments) { - for (const typeNode of node.typeArguments) { - if (!isIndependentType(typeNode)) { - return false; - } - } - } - return true; + /** A type reference is free of this references if each type argument is free of this references. */ + function isTypeReferenceFreeOfThisReference(node: TypeReferenceNode): boolean { + return !node.typeArguments || node.typeArguments.every(isTypeFreeOfThisReference); } - // A type is considered independent if it the any, string, number, boolean, symbol, or void keyword, a string - // literal type, an array with an element type that is considered independent, or a type reference that is - // considered independent. - function isIndependentType(node: TypeNode): boolean { + /** + * A type is free of this references if it's the any, string, number, boolean, symbol, or void keyword, a string + * literal type, an array with an element type that is free of this references, or a type reference that is + * free of this references. + */ + function isTypeFreeOfThisReference(node: TypeNode): boolean { switch (node.kind) { case SyntaxKind.AnyKeyword: case SyntaxKind.StringKeyword: @@ -5357,54 +5356,58 @@ namespace ts { case SyntaxKind.LiteralType: return true; case SyntaxKind.ArrayType: - return isIndependentType((node).elementType); + return isTypeFreeOfThisReference((node).elementType); case SyntaxKind.TypeReference: - return isIndependentTypeReference(node); + return isTypeReferenceFreeOfThisReference(node); } return false; } - // A variable-like declaration is considered independent (free of this references) if it has a type annotation - // that specifies an independent type, or if it has no type annotation and no initializer (and thus of type any). - function isIndependentVariableLikeDeclaration(node: VariableLikeDeclaration): boolean { + /** A type parameter is this-free if its contraint is this-free, or if it has no constraint. */ + function isTypeParameterFreeOfThisReference(node: TypeParameterDeclaration) { + return !node.constraint || isTypeFreeOfThisReference(node.constraint); + } + + /** + * A variable-like declaration is free of this references if it has a type annotation + * that is this-free, or if it has no type annotation and no initializer (and is thus of type any). + */ + function isVariableLikeDeclarationFreeOfThisReference(node: VariableLikeDeclaration): boolean { const typeNode = getEffectiveTypeAnnotationNode(node); - return typeNode ? isIndependentType(typeNode) : !node.initializer; + return typeNode ? isTypeFreeOfThisReference(typeNode) : !node.initializer; } - // A function-like declaration is considered independent (free of this references) if it has a return type - // annotation that is considered independent and if each parameter is considered independent. - function isIndependentFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { - if (node.kind !== SyntaxKind.Constructor) { - const typeNode = getEffectiveReturnTypeNode(node); - if (!typeNode || !isIndependentType(typeNode)) { - return false; - } - } - for (const parameter of node.parameters) { - if (!isIndependentVariableLikeDeclaration(parameter)) { - return false; - } - } - return true; + /** + * A function-like declaration is considered free of `this` references if it has a return type + * annotation that is free of this references and if each parameter is this-free and if + * each type parameter (if present) is this-free. + */ + function isFunctionLikeDeclarationFreeOfThisReference(node: FunctionLikeDeclaration): boolean { + const returnType = getEffectiveReturnTypeNode(node); + return (node.kind === SyntaxKind.Constructor || (returnType && isTypeFreeOfThisReference(returnType))) && + node.parameters.every(isVariableLikeDeclarationFreeOfThisReference) && + (!node.typeParameters || node.typeParameters.every(isTypeParameterFreeOfThisReference)); } - // Returns true if the class or interface member given by the symbol is free of "this" references. The - // function may return false for symbols that are actually free of "this" references because it is not - // feasible to perform a complete analysis in all cases. In particular, property members with types - // inferred from their initializers and function members with inferred return types are conservatively - // assumed not to be free of "this" references. - function isIndependentMember(symbol: Symbol): boolean { + /** + * Returns true if the class or interface member given by the symbol is free of "this" references. The + * function may return false for symbols that are actually free of "this" references because it is not + * feasible to perform a complete analysis in all cases. In particular, property members with types + * inferred from their initializers and function members with inferred return types are conservatively + * assumed not to be free of "this" references. + */ + function isFreeOfThisReference(symbol: Symbol): boolean { if (symbol.declarations && symbol.declarations.length === 1) { const declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: - return isIndependentVariableLikeDeclaration(declaration); + return isVariableLikeDeclarationFreeOfThisReference(declaration); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.Constructor: - return isIndependentFunctionLikeDeclaration(declaration); + return isFunctionLikeDeclarationFreeOfThisReference(declaration); } } } @@ -5416,7 +5419,7 @@ namespace ts { function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable { const result = createSymbolTable(); for (const symbol of symbols) { - result.set(symbol.escapedName, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); + result.set(symbol.escapedName, mappingThisOnly && isFreeOfThisReference(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } From e0e1a3b078723333ebdee629ebdea7ac9c9f4c1d Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 1 Nov 2017 09:17:52 -0700 Subject: [PATCH 04/26] Test:this instantiation in type parameters Make sure that `this` gets instantiated when it's used as a constraint of a type parameter, and nowhere else in a signature. --- .../reference/thisTypeInFunctions3.js | 33 +++++++++++++++++++ .../reference/thisTypeInFunctions3.symbols | 26 +++++++++++++++ .../reference/thisTypeInFunctions3.types | 27 +++++++++++++++ .../types/thisType/thisTypeInFunctions3.ts | 9 +++++ 4 files changed, 95 insertions(+) create mode 100644 tests/baselines/reference/thisTypeInFunctions3.js create mode 100644 tests/baselines/reference/thisTypeInFunctions3.symbols create mode 100644 tests/baselines/reference/thisTypeInFunctions3.types create mode 100644 tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts diff --git a/tests/baselines/reference/thisTypeInFunctions3.js b/tests/baselines/reference/thisTypeInFunctions3.js new file mode 100644 index 00000000000..68af387c251 --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions3.js @@ -0,0 +1,33 @@ +//// [thisTypeInFunctions3.ts] +declare class Base { + check(prop: TProp): boolean; +} + +class Test extends Base { + m() { + this.check(this); + } +} + + +//// [thisTypeInFunctions3.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var Test = /** @class */ (function (_super) { + __extends(Test, _super); + function Test() { + return _super !== null && _super.apply(this, arguments) || this; + } + Test.prototype.m = function () { + this.check(this); + }; + return Test; +}(Base)); diff --git a/tests/baselines/reference/thisTypeInFunctions3.symbols b/tests/baselines/reference/thisTypeInFunctions3.symbols new file mode 100644 index 00000000000..061a33fd63d --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions3.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts === +declare class Base { +>Base : Symbol(Base, Decl(thisTypeInFunctions3.ts, 0, 0)) + + check(prop: TProp): boolean; +>check : Symbol(Base.check, Decl(thisTypeInFunctions3.ts, 0, 20)) +>TProp : Symbol(TProp, Decl(thisTypeInFunctions3.ts, 1, 10)) +>prop : Symbol(prop, Decl(thisTypeInFunctions3.ts, 1, 30)) +>TProp : Symbol(TProp, Decl(thisTypeInFunctions3.ts, 1, 10)) +} + +class Test extends Base { +>Test : Symbol(Test, Decl(thisTypeInFunctions3.ts, 2, 1)) +>Base : Symbol(Base, Decl(thisTypeInFunctions3.ts, 0, 0)) + + m() { +>m : Symbol(Test.m, Decl(thisTypeInFunctions3.ts, 4, 25)) + + this.check(this); +>this.check : Symbol(Base.check, Decl(thisTypeInFunctions3.ts, 0, 20)) +>this : Symbol(Test, Decl(thisTypeInFunctions3.ts, 2, 1)) +>check : Symbol(Base.check, Decl(thisTypeInFunctions3.ts, 0, 20)) +>this : Symbol(Test, Decl(thisTypeInFunctions3.ts, 2, 1)) + } +} + diff --git a/tests/baselines/reference/thisTypeInFunctions3.types b/tests/baselines/reference/thisTypeInFunctions3.types new file mode 100644 index 00000000000..563d6488704 --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions3.types @@ -0,0 +1,27 @@ +=== tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts === +declare class Base { +>Base : Base + + check(prop: TProp): boolean; +>check : (prop: TProp) => boolean +>TProp : TProp +>prop : TProp +>TProp : TProp +} + +class Test extends Base { +>Test : Test +>Base : Base + + m() { +>m : () => void + + this.check(this); +>this.check(this) : boolean +>this.check : (prop: TProp) => boolean +>this : this +>check : (prop: TProp) => boolean +>this : this + } +} + diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts new file mode 100644 index 00000000000..01d7fd0430b --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts @@ -0,0 +1,9 @@ +declare class Base { + check(prop: TProp): boolean; +} + +class Test extends Base { + m() { + this.check(this); + } +} From 9d8a854ea295a470d7cc95921804f5f9d642facb Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 13 Nov 2017 13:22:09 -0800 Subject: [PATCH 05/26] Revert "Break out of speculative parsing on bad parameter initializer (#19158)" (#19975) This reverts commit e7df83263df9433d2b27a2b86e9d198fca68bd92. --- src/compiler/parser.ts | 180 +++++------------- .../parserArrowFunctionExpression7.js | 16 -- .../parserArrowFunctionExpression7.symbols | 10 - .../parserArrowFunctionExpression7.types | 13 -- .../parserArrowFunctionExpression7.ts | 7 - 5 files changed, 50 insertions(+), 176 deletions(-) delete mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.js delete mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.symbols delete mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.types delete mode 100644 tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 64cd8219a01..79b5eb30c49 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -531,18 +531,6 @@ namespace ts { let TokenConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node; let IdentifierConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node; let SourceFileConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node; - interface Fail extends Node { kind: SyntaxKind.Unknown; } - interface FailList extends NodeArray { pos: -1; } - let Fail: Fail; - let FailList: FailList; - function isFail(x: Node | undefined): x is Fail { - Debug.assert(Fail !== undefined); - return x === Fail; - } - function isFailList(x: NodeArray | undefined): x is FailList { - Debug.assert(Fail !== undefined); - return x === FailList; - } // tslint:enable variable-name let sourceFile: SourceFile; @@ -693,9 +681,6 @@ namespace ts { IdentifierConstructor = objectAllocator.getIdentifierConstructor(); SourceFileConstructor = objectAllocator.getSourceFileConstructor(); - Fail = createNode(SyntaxKind.Unknown) as Fail; - FailList = createNodeArray([], -1) as FailList; - sourceText = _sourceText; syntaxCursor = _syntaxCursor; @@ -751,7 +736,7 @@ namespace ts { processReferenceComments(sourceFile); sourceFile.statements = parseList(ParsingContext.SourceElements, parseStatement); - Debug.assertEqual(token(), SyntaxKind.EndOfFileToken); + Debug.assert(token() === SyntaxKind.EndOfFileToken); sourceFile.endOfFileToken = addJSDocComment(parseTokenNode() as EndOfFileToken); setExternalModuleIndicator(sourceFile); @@ -1018,7 +1003,7 @@ namespace ts { return currentToken = scanner.scanJsxAttributeValue(); } - function speculationHelper(callback: () => T, isLookAhead: boolean): T | undefined { + 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). const saveToken = currentToken; @@ -1030,7 +1015,6 @@ namespace ts { // descent nature of our parser. However, we still store this here just so we can // assert that invariant holds. const saveContextFlags = contextFlags; - const saveParsingContext = parsingContext; // If we're only looking ahead, then tell the scanner to only lookahead as well. // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the @@ -1039,8 +1023,7 @@ namespace ts { ? scanner.lookAhead(callback) : scanner.tryScan(callback); - Debug.assertEqual(saveContextFlags, contextFlags); - Debug.assertEqual(saveParsingContext, parsingContext); + Debug.assert(saveContextFlags === contextFlags); // If our callback returned something 'falsy' or we're just looking ahead, // then unconditionally restore us to where we were. @@ -1594,7 +1577,7 @@ namespace ts { return createNodeArray(list, listPos); } - function parseListElement(parsingContext: ParsingContext, parseElement: () => T): T { + function parseListElement(parsingContext: ParsingContext, parseElement: () => T): T { const node = currentNode(parsingContext); if (node) { return consumeNode(node); @@ -1918,24 +1901,17 @@ namespace ts { } // Parses a comma-delimited list of elements - function parseDelimitedList(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimiter?: boolean): NodeArray; - function parseDelimitedList(kind: ParsingContext, parseElement: () => T | Fail, considerSemicolonAsDelimiter?: boolean): NodeArray | FailList; - function parseDelimitedList(kind: ParsingContext, parseElement: () => T | Fail, considerSemicolonAsDelimiter?: boolean): NodeArray | FailList { + function parseDelimitedList(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimiter?: boolean): NodeArray { const saveParsingContext = parsingContext; parsingContext |= 1 << kind; - const list: T[] = []; + const list = []; const listPos = getNodePos(); let commaStart = -1; // Meaning the previous token was not a comma while (true) { if (isListElement(kind, /*inErrorRecovery*/ false)) { const startPos = scanner.getStartPos(); - const elem = parseListElement(kind, parseElement); - if (isFail(elem)) { - parsingContext = saveParsingContext; - return FailList; - } - list.push(elem); + list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); if (parseOptional(SyntaxKind.CommaToken)) { @@ -2295,13 +2271,7 @@ namespace ts { isStartOfType(/*inStartOfParameter*/ true); } - function tryParseParameter(): ParameterDeclaration | Fail { - return parseParameterWorker(/*inSpeculation*/ true); - } - function parseParameter(): ParameterDeclaration { - return parseParameterWorker(/*inSpeculation*/ false) as ParameterDeclaration; - } - function parseParameterWorker(inSpeculation: boolean): ParameterDeclaration | Fail { + function parseParameter(requireEqualsToken?: boolean): ParameterDeclaration { const node = createNode(SyntaxKind.Parameter); if (token() === SyntaxKind.ThisKeyword) { node.name = createIdentifier(/*isIdentifier*/ true); @@ -2315,11 +2285,7 @@ namespace ts { // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] - const name = parseIdentifierOrPattern(inSpeculation); - if (isFail(name)) { - return Fail; - } - node.name = name; + node.name = parseIdentifierOrPattern(); if (getFullWidth(node.name) === 0 && !hasModifiers(node) && isModifierKind(token())) { // in cases like // 'use strict' @@ -2334,27 +2300,20 @@ namespace ts { node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken); node.type = parseParameterType(); - const initializer = parseInitializer(/*inParameter*/ true, inSpeculation); - if (isFail(initializer)) { - return Fail; - } - node.initializer = initializer; + node.initializer = parseInitializer(/*inParameter*/ true, requireEqualsToken); return addJSDocComment(finishNode(node)); } - /** @return 'true' on success. */ - function fillSignature(returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, flags: SignatureFlags, signature: SignatureDeclaration, inSpeculation?: boolean): boolean { + function fillSignature( + returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, + flags: SignatureFlags, + signature: SignatureDeclaration): void { if (!(flags & SignatureFlags.JSDoc)) { signature.typeParameters = parseTypeParameters(); } - const parameters = parseParameterList(flags, inSpeculation); - if (isFailList(parameters)) { - return false; - } - signature.parameters = parameters; + signature.parameters = parseParameterList(flags); signature.type = parseReturnType(returnToken, !!(flags & SignatureFlags.Type)); - return true; } function parseReturnType(returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, isType: boolean): TypeNode | undefined { @@ -2377,7 +2336,7 @@ namespace ts { return false; } - function parseParameterList(flags: SignatureFlags, inSpeculation: boolean): NodeArray | FailList { + function parseParameterList(flags: SignatureFlags) { // FormalParameters [Yield,Await]: (modified) // [empty] // FormalParameterList[?Yield,Await] @@ -2398,9 +2357,9 @@ namespace ts { setYieldContext(!!(flags & SignatureFlags.Yield)); setAwaitContext(!!(flags & SignatureFlags.Await)); - const result = parseDelimitedList( - ParsingContext.Parameters, - flags & SignatureFlags.JSDoc ? parseJSDocParameter : inSpeculation ? tryParseParameter : parseParameter); + const result = parseDelimitedList(ParsingContext.Parameters, + flags & SignatureFlags.JSDoc ? parseJSDocParameter : () => parseParameter(!!(flags & SignatureFlags.RequireCompleteParameterList))); + setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); @@ -3073,16 +3032,14 @@ namespace ts { while ((operatorToken = parseOptionalToken(SyntaxKind.CommaToken))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } + if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } - return expr; } - function parseInitializer(inParameter: boolean): Expression | undefined; - function parseInitializer(inParameter: boolean, inSpeculation?: boolean): Expression | Fail | undefined; - function parseInitializer(inParameter: boolean, inSpeculation?: boolean): Expression | Fail | undefined { + function parseInitializer(inParameter: boolean, requireEqualsToken?: boolean): Expression { if (token() !== SyntaxKind.EqualsToken) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse @@ -3097,8 +3054,12 @@ namespace ts { // do not try to parse initializer return undefined; } - if (inSpeculation) { - return Fail; + if (inParameter && requireEqualsToken) { + // = is required when speculatively parsing arrow function parameters, + // so return a fake initializer as a signal that the equals token was missing + const result = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics._0_expected, "=") as Identifier; + result.escapedText = "= not found" as __String; + return result; } } @@ -3264,7 +3225,7 @@ namespace ts { // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. const arrowFunction = triState === Tristate.True - ? parseParenthesizedArrowFunctionExpressionHead(/*inSpeculation*/ false) + ? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); if (!arrowFunction) { @@ -3412,7 +3373,7 @@ namespace ts { } function parsePossibleParenthesizedArrowFunctionExpressionHead(): ArrowFunction { - return parseParenthesizedArrowFunctionExpressionHead(/*inSpeculation*/ true); + return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function tryParseAsyncSimpleArrowFunctionExpression(): ArrowFunction | undefined { @@ -3448,7 +3409,7 @@ namespace ts { return Tristate.False; } - function parseParenthesizedArrowFunctionExpressionHead(inSpeculation: boolean): ArrowFunction | undefined { + function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction { const node = createNode(SyntaxKind.ArrowFunction); node.modifiers = parseModifiersForArrowFunction(); const isAsync = hasModifier(node, ModifierFlags.Async) ? SignatureFlags.Await : SignatureFlags.None; @@ -3459,10 +3420,7 @@ namespace ts { // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - - if (!fillSignature(SyntaxKind.ColonToken, isAsync | (inSpeculation ? SignatureFlags.RequireCompleteParameterList : SignatureFlags.None), node, inSpeculation)) { - return undefined; - } + fillSignature(SyntaxKind.ColonToken, isAsync | (allowAmbiguity ? SignatureFlags.None : SignatureFlags.RequireCompleteParameterList), node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { @@ -3477,7 +3435,8 @@ namespace ts { // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (inSpeculation && token() !== SyntaxKind.EqualsGreaterThanToken && token() !== SyntaxKind.OpenBraceToken) { + if (!allowAmbiguity && ((token() !== SyntaxKind.EqualsGreaterThanToken && token() !== SyntaxKind.OpenBraceToken) || + find(node.parameters, p => p.initializer && ts.isIdentifier(p.initializer) && p.initializer.escapedText === "= not found"))) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -4615,6 +4574,7 @@ namespace ts { if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } + const node = createNode(SyntaxKind.FunctionExpression); node.modifiers = parseModifiers(); parseExpected(SyntaxKind.FunctionKeyword); @@ -4630,6 +4590,7 @@ namespace ts { fillSignature(SyntaxKind.ColonToken, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); + if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -4692,6 +4653,7 @@ namespace ts { } const block = parseBlock(!!(flags & SignatureFlags.IgnoreMissingOpenBrace), diagnosticMessage); + if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -5265,38 +5227,18 @@ namespace ts { // DECLARATIONS - function tryParseArrayBindingElement(): ArrayBindingElement | Fail { - return parseArrayBindingElementWorker(/*inSpeculation*/ true); - } function parseArrayBindingElement(): ArrayBindingElement { - return parseArrayBindingElementWorker(/*inSpeculation*/ false) as ArrayBindingElement; - } - function parseArrayBindingElementWorker(inSpeculation: boolean): ArrayBindingElement | Fail { if (token() === SyntaxKind.CommaToken) { return createNode(SyntaxKind.OmittedExpression); } const node = createNode(SyntaxKind.BindingElement); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); - const name = parseIdentifierOrPattern(inSpeculation); - if (isFail(name)) { - return Fail; - } - node.name = name; - const init = parseInitializer(/*inParameter*/ false, inSpeculation); - if (isFail(init)) { - return Fail; - } - node.initializer = init; + node.name = parseIdentifierOrPattern(); + node.initializer = parseInitializer(/*inParameter*/ false); return finishNode(node); } - function tryParseObjectBindingElement(): BindingElement | Fail { - return parseObjectBindingElementWorker(/*inSpeculation*/ true); - } function parseObjectBindingElement(): BindingElement { - return parseObjectBindingElementWorker(/*inSpeculation*/ false) as BindingElement; - } - function parseObjectBindingElementWorker(inSpeculation: boolean): BindingElement | Fail { const node = createNode(SyntaxKind.BindingElement); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); const tokenIsIdentifier = isIdentifier(); @@ -5307,46 +5249,24 @@ namespace ts { else { parseExpected(SyntaxKind.ColonToken); node.propertyName = propertyName; - const name = parseIdentifierOrPattern(inSpeculation); - if (isFail(name)) { - return Fail; - } - node.name = name; + node.name = parseIdentifierOrPattern(); } - const init = parseInitializer(/*inParameter*/ false, inSpeculation); - if (isFail(init)) { - return Fail; - } - node.initializer = init; + node.initializer = parseInitializer(/*inParameter*/ false); return finishNode(node); } - function parseObjectBindingPattern(inSpeculation: boolean): ObjectBindingPattern | Fail { + function parseObjectBindingPattern(): ObjectBindingPattern { const node = createNode(SyntaxKind.ObjectBindingPattern); parseExpected(SyntaxKind.OpenBraceToken); - const elements = parseDelimitedList( - ParsingContext.ObjectBindingElements, - inSpeculation ? tryParseObjectBindingElement : parseObjectBindingElement, - /*considerSemicolonAsDelimiter*/ undefined); - if (isFailList(elements)) { - return Fail; - } - node.elements = elements; + node.elements = parseDelimitedList(ParsingContext.ObjectBindingElements, parseObjectBindingElement); parseExpected(SyntaxKind.CloseBraceToken); return finishNode(node); } - function parseArrayBindingPattern(inSpeculation: boolean): ArrayBindingPattern | Fail { + function parseArrayBindingPattern(): ArrayBindingPattern { const node = createNode(SyntaxKind.ArrayBindingPattern); parseExpected(SyntaxKind.OpenBracketToken); - const elements = parseDelimitedList( - ParsingContext.ArrayBindingElements, - inSpeculation ? tryParseArrayBindingElement : parseArrayBindingElement, - /*considerSemicolonAsDelimiter*/ undefined); - if (isFailList(elements)) { - return Fail; - } - node.elements = elements; + node.elements = parseDelimitedList(ParsingContext.ArrayBindingElements, parseArrayBindingElement); parseExpected(SyntaxKind.CloseBracketToken); return finishNode(node); } @@ -5355,14 +5275,12 @@ namespace ts { return token() === SyntaxKind.OpenBraceToken || token() === SyntaxKind.OpenBracketToken || isIdentifier(); } - function parseIdentifierOrPattern(): Identifier | BindingPattern; - function parseIdentifierOrPattern(inSpeculation: boolean): Identifier | BindingPattern | Fail; - function parseIdentifierOrPattern(inSpeculation?: boolean): Identifier | BindingPattern | Fail { + function parseIdentifierOrPattern(): Identifier | BindingPattern { if (token() === SyntaxKind.OpenBracketToken) { - return parseArrayBindingPattern(inSpeculation); + return parseArrayBindingPattern(); } if (token() === SyntaxKind.OpenBraceToken) { - return parseObjectBindingPattern(inSpeculation); + return parseObjectBindingPattern(); } return parseIdentifier(); } @@ -5410,7 +5328,9 @@ namespace ts { else { const savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); + node.declarations = parseDelimitedList(ParsingContext.VariableDeclarations, parseVariableDeclaration); + setDisallowInContext(savedDisallowIn); } @@ -5508,7 +5428,7 @@ namespace ts { } } - function parseNonParameterInitializer(): Expression | undefined { + function parseNonParameterInitializer() { return parseInitializer(/*inParameter*/ false); } diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.js b/tests/baselines/reference/parserArrowFunctionExpression7.js deleted file mode 100644 index 0646a1bf438..00000000000 --- a/tests/baselines/reference/parserArrowFunctionExpression7.js +++ /dev/null @@ -1,16 +0,0 @@ -//// [parserArrowFunctionExpression7.ts] -({ - async m() { - for (;;) { - } - } -}); - - -//// [parserArrowFunctionExpression7.js] -({ - async m() { - for (;;) { - } - } -}); diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.symbols b/tests/baselines/reference/parserArrowFunctionExpression7.symbols deleted file mode 100644 index 0dbc2cf05a1..00000000000 --- a/tests/baselines/reference/parserArrowFunctionExpression7.symbols +++ /dev/null @@ -1,10 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts === -({ - async m() { ->m : Symbol(m, Decl(parserArrowFunctionExpression7.ts, 0, 2)) - - for (;;) { - } - } -}); - diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.types b/tests/baselines/reference/parserArrowFunctionExpression7.types deleted file mode 100644 index 072a1548bd2..00000000000 --- a/tests/baselines/reference/parserArrowFunctionExpression7.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts === -({ ->({ async m() { for (;;) { } }}) : { m(): Promise; } ->{ async m() { for (;;) { } }} : { m(): Promise; } - - async m() { ->m : () => Promise - - for (;;) { - } - } -}); - diff --git a/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts deleted file mode 100644 index 65911cf0fc6..00000000000 --- a/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts +++ /dev/null @@ -1,7 +0,0 @@ -// @target: esnext -({ - async m() { - for (;;) { - } - } -}); From ce29b4c36d04cc22b8b513b4ff1fc84e084f6628 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 13 Nov 2017 14:38:14 -0800 Subject: [PATCH 06/26] Use UTF8 BOM in emit --- src/compiler/sys.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 529ece36fa6..a6e5cd7a392 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -348,7 +348,7 @@ namespace ts { function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void { // If a BOM is required, emit one if (writeByteOrderMark) { - data = "\uFEFF" + data; + data = "\u00EF\u00BB\u00BF" + data; } let fd: number; @@ -549,7 +549,7 @@ namespace ts { writeFile(path: string, data: string, writeByteOrderMark?: boolean) { // If a BOM is required, emit one if (writeByteOrderMark) { - data = "\uFEFF" + data; + data = "\u00EF\u00BB\u00BF" + data; } ChakraHost.writeFile(path, data); From c8b77ae83a22f6a5f9d5fc911cb63fc0db7be5cf Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 13 Nov 2017 15:02:28 -0800 Subject: [PATCH 07/26] mark all submodule changes as ignored --- .gitmodules | 5 +++++ .../TypeScript-React-Native-Starter | 2 +- .../user/TypeScript-React-Starter/TypeScript-React-Starter | 2 +- .../user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index f83d0f77c9e..bd4620625cf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,15 +1,20 @@ [submodule "tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter"] path = tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter url = https://github.com/Microsoft/TypeScript-React-Starter + ignore = all [submodule "tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter"] path = tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter url = https://github.com/Microsoft/TypeScript-Node-Starter.git + ignore = all [submodule "tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter"] path = tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter url = https://github.com/Microsoft/TypeScript-React-Native-Starter.git + ignore = all [submodule "tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter"] path = tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter url = https://github.com/Microsoft/TypeScript-Vue-Starter.git + ignore = all [submodule "tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter"] path = tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter url = https://github.com/Microsoft/TypeScript-WeChat-Starter.git + ignore = all diff --git a/tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter b/tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter index 2c62f5a4ea5..59571c0d34a 160000 --- a/tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter +++ b/tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter @@ -1 +1 @@ -Subproject commit 2c62f5a4ea51978e3715b475e17962cdeca75e38 +Subproject commit 59571c0d34aa48820309291b966778795d1cbebf diff --git a/tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter b/tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter index 96fb6237a9d..68f60e1a4b9 160000 --- a/tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter +++ b/tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter @@ -1 +1 @@ -Subproject commit 96fb6237a9dda8d17059eea7fa7c22dd7db82c97 +Subproject commit 68f60e1a4b947df47418e1d420acc59dafdfef12 diff --git a/tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter b/tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter index 5fca1032eda..3fb8b460102 160000 --- a/tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter +++ b/tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter @@ -1 +1 @@ -Subproject commit 5fca1032edaab5414ec1c167f42d3dc59220d9aa +Subproject commit 3fb8b4601022f7e2df899eb0ac0178f531e6f027 From babd3e7f0e1e149f7d98789459b6053dba6f99ba Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 13 Nov 2017 15:04:11 -0800 Subject: [PATCH 08/26] Also make clones/updates shallow --- .gitmodules | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitmodules b/.gitmodules index bd4620625cf..e5cf4c016e9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,19 +2,24 @@ path = tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter url = https://github.com/Microsoft/TypeScript-React-Starter ignore = all + shallow = true [submodule "tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter"] path = tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter url = https://github.com/Microsoft/TypeScript-Node-Starter.git ignore = all + shallow = true [submodule "tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter"] path = tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter url = https://github.com/Microsoft/TypeScript-React-Native-Starter.git ignore = all + shallow = true [submodule "tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter"] path = tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter url = https://github.com/Microsoft/TypeScript-Vue-Starter.git ignore = all + shallow = true [submodule "tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter"] path = tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter url = https://github.com/Microsoft/TypeScript-WeChat-Starter.git ignore = all + shallow = true From b3d3b781ab9effea0bcbd0ba8689e4f8aee85669 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 13 Nov 2017 15:39:08 -0800 Subject: [PATCH 09/26] Treat `{}` in `T = {}` as `any` in JS files (#19977) --- src/compiler/checker.ts | 5 +- .../defaultPropsEmptyCurlyBecomesAnyForJs.js | 76 +++++++++++++++++ ...aultPropsEmptyCurlyBecomesAnyForJs.symbols | 70 ++++++++++++++++ ...efaultPropsEmptyCurlyBecomesAnyForJs.types | 81 +++++++++++++++++++ .../defaultPropsEmptyCurlyBecomesAnyForJs.ts | 26 ++++++ 5 files changed, 257 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.js create mode 100644 tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.symbols create mode 100644 tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.types create mode 100644 tests/cases/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 85033816766..f983abc9cfe 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6454,7 +6454,10 @@ namespace ts { } for (let i = numTypeArguments; i < numTypeParameters; i++) { const mapper = createTypeMapper(typeParameters, typeArguments); - const defaultType = getDefaultFromTypeParameter(typeParameters[i]); + let defaultType = getDefaultFromTypeParameter(typeParameters[i]); + if (defaultType && isTypeIdenticalTo(defaultType, emptyObjectType) && isJavaScriptImplicitAny) { + defaultType = anyType; + } typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : getDefaultTypeArgumentType(isJavaScriptImplicitAny); } } diff --git a/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.js b/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.js new file mode 100644 index 00000000000..63e45ff68b0 --- /dev/null +++ b/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.js @@ -0,0 +1,76 @@ +//// [tests/cases/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.ts] //// + +//// [library.d.ts] +export class Foo { + props: T; + state: U; + constructor(props: T, state: U); +} + +//// [component.js] +import { Foo } from "./library"; +export class MyFoo extends Foo { + member; +} + +//// [typed_component.ts] +import { MyFoo } from "./component"; +export class TypedFoo extends MyFoo { + constructor() { + super({x: "string", y: 42}, { value: undefined }); + this.props.x; + this.props.y; + this.state.value; + this.member; + } +} + +//// [component.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var library_1 = require("./library"); +var MyFoo = /** @class */ (function (_super) { + __extends(MyFoo, _super); + function MyFoo() { + return _super !== null && _super.apply(this, arguments) || this; + } + return MyFoo; +}(library_1.Foo)); +exports.MyFoo = MyFoo; +//// [typed_component.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var component_1 = require("./component"); +var TypedFoo = /** @class */ (function (_super) { + __extends(TypedFoo, _super); + function TypedFoo() { + var _this = _super.call(this, { x: "string", y: 42 }, { value: undefined }) || this; + _this.props.x; + _this.props.y; + _this.state.value; + _this.member; + return _this; + } + return TypedFoo; +}(component_1.MyFoo)); +exports.TypedFoo = TypedFoo; diff --git a/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.symbols b/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.symbols new file mode 100644 index 00000000000..ba18a4ecca9 --- /dev/null +++ b/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.symbols @@ -0,0 +1,70 @@ +=== tests/cases/compiler/library.d.ts === +export class Foo { +>Foo : Symbol(Foo, Decl(library.d.ts, --, --)) +>T : Symbol(T, Decl(library.d.ts, --, --)) +>U : Symbol(U, Decl(library.d.ts, --, --)) + + props: T; +>props : Symbol(Foo.props, Decl(library.d.ts, --, --)) +>T : Symbol(T, Decl(library.d.ts, --, --)) + + state: U; +>state : Symbol(Foo.state, Decl(library.d.ts, --, --)) +>U : Symbol(U, Decl(library.d.ts, --, --)) + + constructor(props: T, state: U); +>props : Symbol(props, Decl(library.d.ts, --, --)) +>T : Symbol(T, Decl(library.d.ts, --, --)) +>state : Symbol(state, Decl(library.d.ts, --, --)) +>U : Symbol(U, Decl(library.d.ts, --, --)) +} + +=== tests/cases/compiler/component.js === +import { Foo } from "./library"; +>Foo : Symbol(Foo, Decl(component.js, 0, 8)) + +export class MyFoo extends Foo { +>MyFoo : Symbol(MyFoo, Decl(component.js, 0, 32)) +>Foo : Symbol(Foo, Decl(component.js, 0, 8)) + + member; +>member : Symbol(MyFoo.member, Decl(component.js, 1, 32)) +} + +=== tests/cases/compiler/typed_component.ts === +import { MyFoo } from "./component"; +>MyFoo : Symbol(MyFoo, Decl(typed_component.ts, 0, 8)) + +export class TypedFoo extends MyFoo { +>TypedFoo : Symbol(TypedFoo, Decl(typed_component.ts, 0, 36)) +>MyFoo : Symbol(MyFoo, Decl(typed_component.ts, 0, 8)) + + constructor() { + super({x: "string", y: 42}, { value: undefined }); +>super : Symbol(MyFoo, Decl(component.js, 0, 32)) +>x : Symbol(x, Decl(typed_component.ts, 3, 15)) +>y : Symbol(y, Decl(typed_component.ts, 3, 27)) +>value : Symbol(value, Decl(typed_component.ts, 3, 37)) +>undefined : Symbol(undefined) + + this.props.x; +>this.props : Symbol(Foo.props, Decl(library.d.ts, --, --)) +>this : Symbol(TypedFoo, Decl(typed_component.ts, 0, 36)) +>props : Symbol(Foo.props, Decl(library.d.ts, --, --)) + + this.props.y; +>this.props : Symbol(Foo.props, Decl(library.d.ts, --, --)) +>this : Symbol(TypedFoo, Decl(typed_component.ts, 0, 36)) +>props : Symbol(Foo.props, Decl(library.d.ts, --, --)) + + this.state.value; +>this.state : Symbol(Foo.state, Decl(library.d.ts, --, --)) +>this : Symbol(TypedFoo, Decl(typed_component.ts, 0, 36)) +>state : Symbol(Foo.state, Decl(library.d.ts, --, --)) + + this.member; +>this.member : Symbol(MyFoo.member, Decl(component.js, 1, 32)) +>this : Symbol(TypedFoo, Decl(typed_component.ts, 0, 36)) +>member : Symbol(MyFoo.member, Decl(component.js, 1, 32)) + } +} diff --git a/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.types b/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.types new file mode 100644 index 00000000000..4e4bab57696 --- /dev/null +++ b/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.types @@ -0,0 +1,81 @@ +=== tests/cases/compiler/library.d.ts === +export class Foo { +>Foo : Foo +>T : T +>U : U + + props: T; +>props : T +>T : T + + state: U; +>state : U +>U : U + + constructor(props: T, state: U); +>props : T +>T : T +>state : U +>U : U +} + +=== tests/cases/compiler/component.js === +import { Foo } from "./library"; +>Foo : typeof Foo + +export class MyFoo extends Foo { +>MyFoo : MyFoo +>Foo : Foo + + member; +>member : any +} + +=== tests/cases/compiler/typed_component.ts === +import { MyFoo } from "./component"; +>MyFoo : typeof MyFoo + +export class TypedFoo extends MyFoo { +>TypedFoo : TypedFoo +>MyFoo : MyFoo + + constructor() { + super({x: "string", y: 42}, { value: undefined }); +>super({x: "string", y: 42}, { value: undefined }) : void +>super : typeof MyFoo +>{x: "string", y: 42} : { x: string; y: number; } +>x : string +>"string" : "string" +>y : number +>42 : 42 +>{ value: undefined } : { value: undefined; } +>value : undefined +>undefined : undefined + + this.props.x; +>this.props.x : any +>this.props : any +>this : this +>props : any +>x : any + + this.props.y; +>this.props.y : any +>this.props : any +>this : this +>props : any +>y : any + + this.state.value; +>this.state.value : any +>this.state : any +>this : this +>state : any +>value : any + + this.member; +>this.member : any +>this : this +>member : any + } +} diff --git a/tests/cases/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.ts b/tests/cases/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.ts new file mode 100644 index 00000000000..2375ed2a5ba --- /dev/null +++ b/tests/cases/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.ts @@ -0,0 +1,26 @@ +// @allowJs: true +// @outDir: ./built +// @filename: library.d.ts +export class Foo { + props: T; + state: U; + constructor(props: T, state: U); +} + +// @filename: component.js +import { Foo } from "./library"; +export class MyFoo extends Foo { + member; +} + +// @filename: typed_component.ts +import { MyFoo } from "./component"; +export class TypedFoo extends MyFoo { + constructor() { + super({x: "string", y: 42}, { value: undefined }); + this.props.x; + this.props.y; + this.state.value; + this.member; + } +} \ No newline at end of file From 2f941f33e238e5fb25e710cb74c35549cd694eb6 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 13 Nov 2017 16:36:13 -0800 Subject: [PATCH 10/26] Make BOM a constant --- src/compiler/sys.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index a6e5cd7a392..aa928cdaacd 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -125,6 +125,8 @@ namespace ts { }; export let sys: System = (() => { + const utf8ByteOrderMark = "\u00EF\u00BB\u00BF"; + function getNodeSystem(): System { const _fs = require("fs"); const _path = require("path"); @@ -348,7 +350,7 @@ namespace ts { function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void { // If a BOM is required, emit one if (writeByteOrderMark) { - data = "\u00EF\u00BB\u00BF" + data; + data = utf8ByteOrderMark + data; } let fd: number; @@ -549,7 +551,7 @@ namespace ts { writeFile(path: string, data: string, writeByteOrderMark?: boolean) { // If a BOM is required, emit one if (writeByteOrderMark) { - data = "\u00EF\u00BB\u00BF" + data; + data = utf8ByteOrderMark + data; } ChakraHost.writeFile(path, data); From 3d602936e01a9f19f0f4eba2141837c349aeafd5 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 13 Nov 2017 16:40:08 -0800 Subject: [PATCH 11/26] Handle binding elements while looking for invalid `await` and `yield` (#19972) * Handle omitting a node in addCustomPrologue, account for binding elemnts in isInParameterInitializerBeforeContainingFunction * Use append * Fix lint --- src/compiler/checker.ts | 6 +- src/compiler/factory.ts | 2 +- ...orbiddenInParameterInitializers.errors.txt | 15 ++++ ...essionsForbiddenInParameterInitializers.js | 76 +++++++++++++++++++ ...nsForbiddenInParameterInitializers.symbols | 12 +++ ...ionsForbiddenInParameterInitializers.types | 16 ++++ ...essionsForbiddenInParameterInitializers.ts | 7 ++ 7 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/expressionsForbiddenInParameterInitializers.errors.txt create mode 100644 tests/baselines/reference/expressionsForbiddenInParameterInitializers.js create mode 100644 tests/baselines/reference/expressionsForbiddenInParameterInitializers.symbols create mode 100644 tests/baselines/reference/expressionsForbiddenInParameterInitializers.types create mode 100644 tests/cases/compiler/expressionsForbiddenInParameterInitializers.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 37905e1047c..a8ba45b8825 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13472,10 +13472,14 @@ namespace ts { } function isInParameterInitializerBeforeContainingFunction(node: Node) { + let inBindingInitializer = false; while (node.parent && !isFunctionLike(node.parent)) { - if (node.parent.kind === SyntaxKind.Parameter && (node.parent).initializer === node) { + if (isParameter(node.parent) && (inBindingInitializer || node.parent.initializer === node)) { return true; } + if (isBindingElement(node.parent) && node.parent.initializer === node) { + inBindingInitializer = true; + } node = node.parent; } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index e8dfcbc1e94..35d35b40826 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -3709,7 +3709,7 @@ namespace ts { while (statementOffset < numStatements) { const statement = source[statementOffset]; if (getEmitFlags(statement) & EmitFlags.CustomPrologue) { - target.push(visitor ? visitNode(statement, visitor, isStatement) : statement); + append(target, visitor ? visitNode(statement, visitor, isStatement) : statement); } else { break; diff --git a/tests/baselines/reference/expressionsForbiddenInParameterInitializers.errors.txt b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.errors.txt new file mode 100644 index 00000000000..605b6d78ea3 --- /dev/null +++ b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/bar.ts(1,35): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/compiler/bar.ts(4,31): error TS2523: 'yield' expressions cannot be used in a parameter initializer. + + +==== tests/cases/compiler/bar.ts (2 errors) ==== + export async function foo({ foo = await import("./bar") }) { + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + } + + export function* foo2({ foo = yield "a" }) { + ~~~~~~~~~ +!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. + } + \ No newline at end of file diff --git a/tests/baselines/reference/expressionsForbiddenInParameterInitializers.js b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.js new file mode 100644 index 00000000000..d66b3c8e06d --- /dev/null +++ b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.js @@ -0,0 +1,76 @@ +//// [bar.ts] +export async function foo({ foo = await import("./bar") }) { +} + +export function* foo2({ foo = yield "a" }) { +} + + +//// [bar.js] +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +function foo(_a) { + var _b = _a.foo, foo = _b === void 0 ? yield Promise.resolve().then(function () { return require("./bar"); }) : _b; + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_c) { + return [2 /*return*/]; + }); + }); +} +exports.foo = foo; +function foo2(_a) { + var _b, foo, _c; + return __generator(this, function (_d) { + switch (_d.label) { + case 0: + _b = _a.foo; + if (!(_b === void 0)) return [3 /*break*/, 2]; + return [4 /*yield*/, "a"]; + case 1: + _c = _d.sent(); + return [3 /*break*/, 3]; + case 2: + _c = _b; + _d.label = 3; + case 3: + foo = _c; + return [2 /*return*/]; + } + }); +} +exports.foo2 = foo2; diff --git a/tests/baselines/reference/expressionsForbiddenInParameterInitializers.symbols b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.symbols new file mode 100644 index 00000000000..6ad101f3c17 --- /dev/null +++ b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/bar.ts === +export async function foo({ foo = await import("./bar") }) { +>foo : Symbol(foo, Decl(bar.ts, 0, 0)) +>foo : Symbol(foo, Decl(bar.ts, 0, 27)) +>"./bar" : Symbol("tests/cases/compiler/bar", Decl(bar.ts, 0, 0)) +} + +export function* foo2({ foo = yield "a" }) { +>foo2 : Symbol(foo2, Decl(bar.ts, 1, 1)) +>foo : Symbol(foo, Decl(bar.ts, 3, 23)) +} + diff --git a/tests/baselines/reference/expressionsForbiddenInParameterInitializers.types b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.types new file mode 100644 index 00000000000..1fd11b0513b --- /dev/null +++ b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/bar.ts === +export async function foo({ foo = await import("./bar") }) { +>foo : ({ foo }: { foo?: typeof "tests/cases/compiler/bar"; }) => Promise +>foo : typeof "tests/cases/compiler/bar" +>await import("./bar") : typeof "tests/cases/compiler/bar" +>import("./bar") : Promise +>"./bar" : "./bar" +} + +export function* foo2({ foo = yield "a" }) { +>foo2 : ({ foo }: { foo?: any; }) => IterableIterator +>foo : any +>yield "a" : any +>"a" : "a" +} + diff --git a/tests/cases/compiler/expressionsForbiddenInParameterInitializers.ts b/tests/cases/compiler/expressionsForbiddenInParameterInitializers.ts new file mode 100644 index 00000000000..ea4dce15408 --- /dev/null +++ b/tests/cases/compiler/expressionsForbiddenInParameterInitializers.ts @@ -0,0 +1,7 @@ +// @lib: es6 +// @filename: bar.ts +export async function foo({ foo = await import("./bar") }) { +} + +export function* foo2({ foo = yield "a" }) { +} From 7d93434f2cbf2e246a48398423059d7d7fffe07b Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 13 Nov 2017 16:41:29 -0800 Subject: [PATCH 12/26] Fix crash on non-dts-require (#19980) --- src/compiler/checker.ts | 2 +- .../noCrashOnParameterNamedRequire.js | 11 ++++++++ .../noCrashOnParameterNamedRequire.symbols | 14 +++++++++++ .../noCrashOnParameterNamedRequire.types | 25 +++++++++++++++++++ .../noCrashOnParameterNamedRequire.ts | 8 ++++++ 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/noCrashOnParameterNamedRequire.js create mode 100644 tests/baselines/reference/noCrashOnParameterNamedRequire.symbols create mode 100644 tests/baselines/reference/noCrashOnParameterNamedRequire.types create mode 100644 tests/cases/compiler/noCrashOnParameterNamedRequire.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a8ba45b8825..0ae9486aa4e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17179,7 +17179,7 @@ namespace ts { if (targetDeclarationKind !== SyntaxKind.Unknown) { const decl = getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!(decl.flags & NodeFlags.Ambient); + return !!decl && !!(decl.flags & NodeFlags.Ambient); } return false; } diff --git a/tests/baselines/reference/noCrashOnParameterNamedRequire.js b/tests/baselines/reference/noCrashOnParameterNamedRequire.js new file mode 100644 index 00000000000..beb7429a47c --- /dev/null +++ b/tests/baselines/reference/noCrashOnParameterNamedRequire.js @@ -0,0 +1,11 @@ +//// [index.js] +(function(require, module, exports){ + const mod = require("./mod"); + mod.foo; +})(null, null, null); + +//// [index.js] +(function (require, module, exports) { + var mod = require("./mod"); + mod.foo; +})(null, null, null); diff --git a/tests/baselines/reference/noCrashOnParameterNamedRequire.symbols b/tests/baselines/reference/noCrashOnParameterNamedRequire.symbols new file mode 100644 index 00000000000..824a61db10f --- /dev/null +++ b/tests/baselines/reference/noCrashOnParameterNamedRequire.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/index.js === +(function(require, module, exports){ +>require : Symbol(require, Decl(index.js, 0, 10)) +>module : Symbol(module, Decl(index.js, 0, 18)) +>exports : Symbol(exports, Decl(index.js, 0, 26)) + + const mod = require("./mod"); +>mod : Symbol(mod, Decl(index.js, 1, 9)) +>require : Symbol(require, Decl(index.js, 0, 10)) + + mod.foo; +>mod : Symbol(mod, Decl(index.js, 1, 9)) + +})(null, null, null); diff --git a/tests/baselines/reference/noCrashOnParameterNamedRequire.types b/tests/baselines/reference/noCrashOnParameterNamedRequire.types new file mode 100644 index 00000000000..2fe629f9d51 --- /dev/null +++ b/tests/baselines/reference/noCrashOnParameterNamedRequire.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/index.js === +(function(require, module, exports){ +>(function(require, module, exports){ const mod = require("./mod"); mod.foo;})(null, null, null) : void +>(function(require, module, exports){ const mod = require("./mod"); mod.foo;}) : (require: any, module: any, exports: any) => void +>function(require, module, exports){ const mod = require("./mod"); mod.foo;} : (require: any, module: any, exports: any) => void +>require : any +>module : any +>exports : any + + const mod = require("./mod"); +>mod : any +>require("./mod") : any +>require : any +>"./mod" : "./mod" + + mod.foo; +>mod.foo : any +>mod : any +>foo : any + +})(null, null, null); +>null : null +>null : null +>null : null + diff --git a/tests/cases/compiler/noCrashOnParameterNamedRequire.ts b/tests/cases/compiler/noCrashOnParameterNamedRequire.ts new file mode 100644 index 00000000000..bb4b9d53460 --- /dev/null +++ b/tests/cases/compiler/noCrashOnParameterNamedRequire.ts @@ -0,0 +1,8 @@ +// @allowJs: true +// @checkJs: true +// @outDir: ./built +// @filename: index.js +(function(require, module, exports){ + const mod = require("./mod"); + mod.foo; +})(null, null, null); \ No newline at end of file From 9be4d601b2119bb1c82f10f532250e89c617bf18 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 13 Nov 2017 16:44:09 -0800 Subject: [PATCH 13/26] react starter needs node ref, accept fixed leveldown (#19994) --- tests/baselines/reference/user/leveldown.log | 20 ------------------- .../user/TypeScript-React-Starter/test.json | 2 +- 2 files changed, 1 insertion(+), 21 deletions(-) delete mode 100644 tests/baselines/reference/user/leveldown.log diff --git a/tests/baselines/reference/user/leveldown.log b/tests/baselines/reference/user/leveldown.log deleted file mode 100644 index 011071ebc52..00000000000 --- a/tests/baselines/reference/user/leveldown.log +++ /dev/null @@ -1,20 +0,0 @@ -Exit Code: 1 -Standard output: -node_modules/abstract-leveldown/index.d.ts(2,3): error TS7010: 'open', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(3,3): error TS7010: 'open', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(5,3): error TS7010: 'close', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(7,3): error TS7010: 'get', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(7,26): error TS7006: Parameter 'err' implicitly has an 'any' type. -node_modules/abstract-leveldown/index.d.ts(8,3): error TS7010: 'get', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(8,39): error TS7006: Parameter 'err' implicitly has an 'any' type. -node_modules/abstract-leveldown/index.d.ts(10,3): error TS7010: 'put', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(11,3): error TS7010: 'put', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(13,3): error TS7010: 'del', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(14,3): error TS7010: 'del', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(17,3): error TS7010: 'batch', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(18,3): error TS7010: 'batch', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/leveldown/leveldown.d.ts(66,3): error TS7010: 'seek', which lacks return-type annotation, implicitly has an 'any' return type. - - - -Standard error: diff --git a/tests/cases/user/TypeScript-React-Starter/test.json b/tests/cases/user/TypeScript-React-Starter/test.json index 8b177c575aa..f3613bf3b01 100644 --- a/tests/cases/user/TypeScript-React-Starter/test.json +++ b/tests/cases/user/TypeScript-React-Starter/test.json @@ -1,3 +1,3 @@ { - "types": ["jest"] + "types": ["jest", "node"] } From 492cd15e61049c3efaa7b0a420d54bd6b0f22a4b Mon Sep 17 00:00:00 2001 From: csigs Date: Tue, 14 Nov 2017 05:10:09 +0000 Subject: [PATCH 14/26] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 33 +++++++++++++++++++ .../diagnosticMessages.generated.json.lcl | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index 2e603f114b6..c4de80ab4c8 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1614,6 +1614,9 @@ + + + @@ -5274,24 +5277,36 @@ + + + + + + + + + + + + @@ -6003,18 +6018,27 @@ + + + + + + + + + @@ -6048,18 +6072,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index 7677920dd1d..e3c3a1d379a 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1601,6 +1601,9 @@ + + + @@ -5255,24 +5258,36 @@ + + + + + + + + + + + + @@ -5978,18 +5993,27 @@ + + + + + + + + + @@ -6023,18 +6047,27 @@ + + + + + + + + + From 7e8851e65ba97f2d1c56087e4149eb1c33afd9f3 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 14 Nov 2017 07:15:59 -0800 Subject: [PATCH 15/26] Always require '=' before parsing an initializer (#19979) * Always require '=' before parsing an initializer * Fix fourslash tests --- src/compiler/parser.ts | 55 +++------- .../reference/ClassDeclaration26.errors.txt | 4 +- .../baselines/reference/ClassDeclaration26.js | 3 +- .../reference/ClassDeclaration26.types | 2 +- .../FunctionDeclaration12_es6.errors.txt | 4 +- .../reference/FunctionDeclaration12_es6.js | 3 +- .../reference/FunctionDeclaration12_es6.types | 2 +- .../VariableDeclaration13_es6.errors.txt | 13 +-- .../reference/VariableDeclaration13_es6.js | 3 +- .../reference/arrayTypeOfTypeOf.errors.txt | 16 +-- .../baselines/reference/arrayTypeOfTypeOf.js | 6 +- .../asyncArrowFunction5_es2017.errors.txt | 8 +- .../reference/asyncArrowFunction5_es2017.js | 3 +- .../asyncArrowFunction5_es5.errors.txt | 8 +- .../reference/asyncArrowFunction5_es5.js | 3 +- .../asyncArrowFunction5_es6.errors.txt | 8 +- .../reference/asyncArrowFunction5_es6.js | 3 +- .../asyncArrowFunction9_es2017.errors.txt | 8 +- .../reference/asyncArrowFunction9_es2017.js | 3 +- .../asyncArrowFunction9_es5.errors.txt | 8 +- .../reference/asyncArrowFunction9_es5.js | 3 +- .../asyncArrowFunction9_es6.errors.txt | 8 +- .../reference/asyncArrowFunction9_es6.js | 3 +- ...yncFunctionDeclaration12_es2017.errors.txt | 4 +- .../asyncFunctionDeclaration12_es2017.js | 3 +- .../asyncFunctionDeclaration12_es2017.types | 2 +- .../asyncFunctionDeclaration12_es5.errors.txt | 4 +- .../asyncFunctionDeclaration12_es5.js | 3 +- .../asyncFunctionDeclaration12_es5.types | 2 +- .../asyncFunctionDeclaration12_es6.errors.txt | 4 +- .../asyncFunctionDeclaration12_es6.js | 3 +- .../asyncFunctionDeclaration12_es6.types | 2 +- ...lassMemberWithMissingIdentifier.errors.txt | 11 +- .../classMemberWithMissingIdentifier.js | 3 +- .../classMemberWithMissingIdentifier.types | 3 +- ...assMemberWithMissingIdentifier2.errors.txt | 20 ++-- .../classMemberWithMissingIdentifier2.js | 7 +- .../classMemberWithMissingIdentifier2.symbols | 1 - .../classMemberWithMissingIdentifier2.types | 4 +- ...torWithIncompleteTypeAnnotation.errors.txt | 34 +++--- ...constructorWithIncompleteTypeAnnotation.js | 39 +++---- ...ructorWithIncompleteTypeAnnotation.symbols | 7 -- ...structorWithIncompleteTypeAnnotation.types | 13 ++- ...perCallsInNonConstructorMembers.errors.txt | 102 +++++++++++++++--- ...dClassSuperCallsInNonConstructorMembers.js | 65 +++++------ ...sSuperCallsInNonConstructorMembers.symbols | 16 --- ...assSuperCallsInNonConstructorMembers.types | 31 ++++-- ...ontShowCompilerGeneratedMembers.errors.txt | 5 +- .../dontShowCompilerGeneratedMembers.js | 3 +- .../expressionTypeNodeShouldError.errors.txt | 4 +- .../expressionTypeNodeShouldError.types | 2 +- ...hSyntacticErrorsForMultipleFiles2.baseline | 2 +- .../invalidLetInForOfAndForIn_ES5.errors.txt | 25 +++-- .../invalidLetInForOfAndForIn_ES5.js | 6 +- .../invalidLetInForOfAndForIn_ES5.types | 9 +- .../invalidLetInForOfAndForIn_ES6.errors.txt | 25 +++-- .../invalidLetInForOfAndForIn_ES6.js | 6 +- .../invalidLetInForOfAndForIn_ES6.types | 9 +- .../reference/invalidTypeOfTarget.errors.txt | 14 +-- .../reference/invalidTypeOfTarget.js | 17 +-- .../reference/invalidTypeOfTarget.symbols | 1 + .../reference/invalidTypeOfTarget.types | 3 +- ...negateOperatorInvalidOperations.errors.txt | 9 +- .../negateOperatorInvalidOperations.js | 3 +- .../negateOperatorInvalidOperations.types | 4 +- ...ralsWithTrailingDecimalPoints01.errors.txt | 4 +- ...ericLiteralsWithTrailingDecimalPoints01.js | 3 +- ...tors.functionExpressions.esnext.errors.txt | 8 +- ...enerators.functionExpressions.esnext.types | 4 +- .../parserArrowFunctionExpression6.errors.txt | 37 +++++++ .../parserArrowFunctionExpression6.js | 3 +- .../parserArrowFunctionExpression6.symbols | 10 +- .../parserArrowFunctionExpression6.types | 26 ++--- .../parserArrowFunctionExpression7.js | 16 +++ .../parserArrowFunctionExpression7.symbols | 10 ++ .../parserArrowFunctionExpression7.types | 13 +++ ...overy_IncompleteMemberVariable2.errors.txt | 4 +- ...ErrorRecovery_IncompleteMemberVariable2.js | 1 - ...orRecovery_IncompleteMemberVariable2.types | 1 - .../reference/parserTypeQuery8.errors.txt | 4 +- tests/baselines/reference/parserTypeQuery8.js | 3 +- .../reference/restParamModifier.errors.txt | 16 +-- .../baselines/reference/restParamModifier.js | 3 +- .../reference/restParamModifier.symbols | 2 +- .../reference/restParamModifier.types | 6 +- .../thisTypeInFunctionsNegative.errors.txt | 44 +++++--- .../reference/thisTypeInFunctionsNegative.js | 20 ++-- .../thisTypeInFunctionsNegative.symbols | 14 +-- .../thisTypeInFunctionsNegative.types | 36 ++++--- .../typeGuardFunctionErrors.errors.txt | 25 +---- .../reference/typeGuardFunctionErrors.js | 6 +- .../reference/typeGuardFunctionErrors.symbols | 5 + .../reference/typeGuardFunctionErrors.types | 2 +- ...redicateOnVariableDeclaration02.errors.txt | 9 +- .../typePredicateOnVariableDeclaration02.js | 2 +- ...pePredicateOnVariableDeclaration02.symbols | 1 + .../parserArrowFunctionExpression7.ts | 7 ++ ...etionListImplementingInterfaceFunctions.ts | 4 +- tests/cases/fourslash/formattingReadonly.ts | 8 +- 99 files changed, 609 insertions(+), 455 deletions(-) create mode 100644 tests/baselines/reference/parserArrowFunctionExpression6.errors.txt create mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.js create mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.symbols create mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.types create mode 100644 tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 79b5eb30c49..5456e889353 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2271,7 +2271,7 @@ namespace ts { isStartOfType(/*inStartOfParameter*/ true); } - function parseParameter(requireEqualsToken?: boolean): ParameterDeclaration { + function parseParameter(): ParameterDeclaration { const node = createNode(SyntaxKind.Parameter); if (token() === SyntaxKind.ThisKeyword) { node.name = createIdentifier(/*isIdentifier*/ true); @@ -2300,7 +2300,7 @@ namespace ts { node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken); node.type = parseParameterType(); - node.initializer = parseInitializer(/*inParameter*/ true, requireEqualsToken); + node.initializer = parseInitializer(); return addJSDocComment(finishNode(node)); } @@ -2357,8 +2357,7 @@ namespace ts { setYieldContext(!!(flags & SignatureFlags.Yield)); setAwaitContext(!!(flags & SignatureFlags.Await)); - const result = parseDelimitedList(ParsingContext.Parameters, - flags & SignatureFlags.JSDoc ? parseJSDocParameter : () => parseParameter(!!(flags & SignatureFlags.RequireCompleteParameterList))); + const result = parseDelimitedList(ParsingContext.Parameters, flags & SignatureFlags.JSDoc ? parseJSDocParameter : parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); @@ -2499,7 +2498,7 @@ namespace ts { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - property.initializer = parseNonParameterInitializer(); + property.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -3039,34 +3038,8 @@ namespace ts { return expr; } - function parseInitializer(inParameter: boolean, requireEqualsToken?: boolean): Expression { - if (token() !== SyntaxKind.EqualsToken) { - // It's not uncommon during typing for the user to miss writing the '=' token. Check if - // there is no newline after the last token and if we're on an expression. If so, parse - // this as an equals-value clause with a missing equals. - // NOTE: There are two places where we allow equals-value clauses. The first is in a - // variable declarator. The second is with a parameter. For variable declarators - // it's more likely that a { would be a allowed (as an object literal). While this - // is also allowed for parameters, the risk is that we consume the { as an object - // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === SyntaxKind.OpenBraceToken) || !isStartOfExpression()) { - // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - - // do not try to parse initializer - return undefined; - } - if (inParameter && requireEqualsToken) { - // = is required when speculatively parsing arrow function parameters, - // so return a fake initializer as a signal that the equals token was missing - const result = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics._0_expected, "=") as Identifier; - result.escapedText = "= not found" as __String; - return result; - } - } - - // Initializer[In, Yield] : - // = AssignmentExpression[?In, ?Yield] - parseExpected(SyntaxKind.EqualsToken); - return parseAssignmentExpressionOrHigher(); + function parseInitializer(): Expression | undefined { + return parseOptional(SyntaxKind.EqualsToken) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher(): Expression { @@ -5234,7 +5207,7 @@ namespace ts { const node = createNode(SyntaxKind.BindingElement); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); node.name = parseIdentifierOrPattern(); - node.initializer = parseInitializer(/*inParameter*/ false); + node.initializer = parseInitializer(); return finishNode(node); } @@ -5251,7 +5224,7 @@ namespace ts { node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseInitializer(/*inParameter*/ false); + node.initializer = parseInitializer(); return finishNode(node); } @@ -5290,7 +5263,7 @@ namespace ts { node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { - node.initializer = parseNonParameterInitializer(); + node.initializer = parseInitializer(); } return finishNode(node); } @@ -5406,8 +5379,8 @@ namespace ts { // // The checker may still error in the static case to explicitly disallow the yield expression. property.initializer = hasModifier(property, ModifierFlags.Static) - ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(NodeFlags.YieldContext | NodeFlags.DisallowInContext, parseNonParameterInitializer); + ? allowInAnd(parseInitializer) + : doOutsideOfContext(NodeFlags.YieldContext | NodeFlags.DisallowInContext, parseInitializer); parseSemicolon(); return addJSDocComment(finishNode(property)); @@ -5428,10 +5401,6 @@ namespace ts { } } - function parseNonParameterInitializer() { - return parseInitializer(/*inParameter*/ false); - } - function parseAccessorDeclaration(kind: SyntaxKind, fullStart: number, decorators: NodeArray, modifiers: NodeArray): AccessorDeclaration { const node = createNode(kind, fullStart); node.decorators = decorators; @@ -5755,7 +5724,7 @@ namespace ts { function parseEnumMember(): EnumMember { const node = createNode(SyntaxKind.EnumMember, scanner.getStartPos()); node.name = parsePropertyName(); - node.initializer = allowInAnd(parseNonParameterInitializer); + node.initializer = allowInAnd(parseInitializer); return addJSDocComment(finishNode(node)); } diff --git a/tests/baselines/reference/ClassDeclaration26.errors.txt b/tests/baselines/reference/ClassDeclaration26.errors.txt index 5e2d570b801..0972a287de3 100644 --- a/tests/baselines/reference/ClassDeclaration26.errors.txt +++ b/tests/baselines/reference/ClassDeclaration26.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/ClassDeclaration26.ts(2,22): error TS1005: ';' expected. tests/cases/compiler/ClassDeclaration26.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -tests/cases/compiler/ClassDeclaration26.ts(4,20): error TS1005: '=' expected. +tests/cases/compiler/ClassDeclaration26.ts(4,20): error TS1005: ',' expected. tests/cases/compiler/ClassDeclaration26.ts(4,23): error TS1005: '=>' expected. tests/cases/compiler/ClassDeclaration26.ts(5,1): error TS1128: Declaration or statement expected. @@ -15,7 +15,7 @@ tests/cases/compiler/ClassDeclaration26.ts(5,1): error TS1128: Declaration or st ~~~ !!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1005: '=>' expected. } diff --git a/tests/baselines/reference/ClassDeclaration26.js b/tests/baselines/reference/ClassDeclaration26.js index 40be8d7baeb..8a240f696a4 100644 --- a/tests/baselines/reference/ClassDeclaration26.js +++ b/tests/baselines/reference/ClassDeclaration26.js @@ -12,4 +12,5 @@ var C = /** @class */ (function () { } return C; }()); -var constructor = function () { }; +var constructor; +(function () { }); diff --git a/tests/baselines/reference/ClassDeclaration26.types b/tests/baselines/reference/ClassDeclaration26.types index acdc0d56ab1..62879552349 100644 --- a/tests/baselines/reference/ClassDeclaration26.types +++ b/tests/baselines/reference/ClassDeclaration26.types @@ -8,6 +8,6 @@ class C { >10 : 10 var constructor() { } ->constructor : () => void +>constructor : any >() { } : () => void } diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt index 358ec5ea041..425536f8781 100644 --- a/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,20): error TS1005: '(' expected. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,25): error TS1005: '=' expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,25): error TS1005: ',' expected. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,28): error TS1005: '=>' expected. @@ -8,6 +8,6 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1, ~~~~~ !!! error TS1005: '(' expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1005: '=>' expected. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.js b/tests/baselines/reference/FunctionDeclaration12_es6.js index 5d55d3231b0..d2f490ef5e8 100644 --- a/tests/baselines/reference/FunctionDeclaration12_es6.js +++ b/tests/baselines/reference/FunctionDeclaration12_es6.js @@ -2,4 +2,5 @@ var v = function * yield() { } //// [FunctionDeclaration12_es6.js] -var v = function* () { }, yield = () => { }; +var v = function* () { }, yield; +() => { }; diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.types b/tests/baselines/reference/FunctionDeclaration12_es6.types index 5d413f99d07..336bde7a947 100644 --- a/tests/baselines/reference/FunctionDeclaration12_es6.types +++ b/tests/baselines/reference/FunctionDeclaration12_es6.types @@ -2,6 +2,6 @@ var v = function * yield() { } >v : () => any >function * : () => any ->yield : () => void +>yield : any >() { } : () => void diff --git a/tests/baselines/reference/VariableDeclaration13_es6.errors.txt b/tests/baselines/reference/VariableDeclaration13_es6.errors.txt index 1780e06e2af..c954969f19d 100644 --- a/tests/baselines/reference/VariableDeclaration13_es6.errors.txt +++ b/tests/baselines/reference/VariableDeclaration13_es6.errors.txt @@ -1,10 +1,9 @@ tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(4,5): error TS1181: Array element destructuring pattern expected. -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(4,6): error TS1005: ',' expected. -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(4,8): error TS1134: Variable declaration expected. -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(4,10): error TS1134: Variable declaration expected. +tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(4,6): error TS1005: ';' expected. +tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(4,8): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts (4 errors) ==== +==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts (3 errors) ==== // An ExpressionStatement cannot start with the two token sequence `let [` because // that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern. var let: any; @@ -12,8 +11,6 @@ tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(4, ~ !!! error TS1181: Array element destructuring pattern expected. ~ -!!! error TS1005: ',' expected. +!!! error TS1005: ';' expected. ~ -!!! error TS1134: Variable declaration expected. - ~~~ -!!! error TS1134: Variable declaration expected. \ No newline at end of file +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration13_es6.js b/tests/baselines/reference/VariableDeclaration13_es6.js index 1acd0fdbe02..152ca6a26d6 100644 --- a/tests/baselines/reference/VariableDeclaration13_es6.js +++ b/tests/baselines/reference/VariableDeclaration13_es6.js @@ -8,5 +8,6 @@ let[0] = 100; // An ExpressionStatement cannot start with the two token sequence `let [` because // that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern. var let; -let [] = 0; +let []; +0; 100; diff --git a/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt b/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt index 1c37f04be72..2726492f36d 100644 --- a/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt +++ b/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt @@ -1,28 +1,22 @@ -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,5): error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,22): error TS1005: '=' expected. +tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,22): error TS1005: ',' expected. tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,30): error TS1109: Expression expected. -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,5): error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,22): error TS1005: '=' expected. +tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,22): error TS1005: ',' expected. tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,32): error TS1109: Expression expected. -==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts (6 errors) ==== +==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts (4 errors) ==== // array type cannot use typeof. var x = 1; var xs: typeof x[]; // Not an error. This is equivalent to Array var xs2: typeof Array; var xs3: typeof Array; - ~~~ -!!! error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1109: Expression expected. var xs4: typeof Array; - ~~~ -!!! error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/arrayTypeOfTypeOf.js b/tests/baselines/reference/arrayTypeOfTypeOf.js index f3653346be4..ced62a73a07 100644 --- a/tests/baselines/reference/arrayTypeOfTypeOf.js +++ b/tests/baselines/reference/arrayTypeOfTypeOf.js @@ -12,5 +12,7 @@ var xs4: typeof Array; var x = 1; var xs; // Not an error. This is equivalent to Array var xs2; -var xs3 = ; -var xs4 = ; +var xs3; +; +var xs4; +; diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt index 594786d3005..1d3e9222ace 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,11): error TS2304: Cannot find name 'async'. tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,18): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,24): error TS1005: ',' expected. -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,33): error TS1005: '=' expected. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,33): error TS1005: ',' expected. tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,40): error TS1109: Expression expected. @@ -15,9 +15,9 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es20 ~ !!! error TS1005: ',' expected. ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.js b/tests/baselines/reference/asyncArrowFunction5_es2017.js index b12d06e6e32..c3ce23ad103 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es2017.js +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.js @@ -3,6 +3,7 @@ var foo = async (await): Promise => { } //// [asyncArrowFunction5_es2017.js] -var foo = async(await), Promise = ; +var foo = async(await), Promise; +; { } diff --git a/tests/baselines/reference/asyncArrowFunction5_es5.errors.txt b/tests/baselines/reference/asyncArrowFunction5_es5.errors.txt index 949e2401d35..03c98f0707c 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es5.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction5_es5.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,11): error TS2304: Cannot find name 'async'. tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,18): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,24): error TS1005: ',' expected. -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,33): error TS1005: '=' expected. +tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. +tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,33): error TS1005: ',' expected. tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,40): error TS1109: Expression expected. @@ -15,9 +15,9 @@ tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts( ~ !!! error TS1005: ',' expected. ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction5_es5.js b/tests/baselines/reference/asyncArrowFunction5_es5.js index 2e15f99e297..ac1e8801551 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es5.js +++ b/tests/baselines/reference/asyncArrowFunction5_es5.js @@ -3,6 +3,7 @@ var foo = async (await): Promise => { } //// [asyncArrowFunction5_es5.js] -var foo = async(await), Promise = ; +var foo = async(await), Promise; +; { } diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt index b3cb60c95ca..9fd82b6cc06 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,11): error TS2304: Cannot find name 'async'. tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,18): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,24): error TS1005: ',' expected. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,33): error TS1005: '=' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,33): error TS1005: ',' expected. tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,40): error TS1109: Expression expected. @@ -15,9 +15,9 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts( ~ !!! error TS1005: ',' expected. ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. ~ -!!! error TS1005: '=' expected. +!!! 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 index b5ae55a8f48..170962c6fd5 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es6.js +++ b/tests/baselines/reference/asyncArrowFunction5_es6.js @@ -3,6 +3,7 @@ var foo = async (await): Promise => { } //// [asyncArrowFunction5_es6.js] -var foo = async(await), Promise = ; +var foo = async(await), Promise; +; { } diff --git a/tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt index c888995f1fb..a14b3f44303 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,11): error TS2304: Cannot find name 'async'. tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,18): error TS2304: Cannot find name 'a'. tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,37): error TS1005: ',' expected. -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,46): error TS1005: '=' expected. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,46): error TS1005: ',' expected. tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,53): error TS1109: Expression expected. @@ -15,9 +15,9 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es20 ~ !!! error TS1005: ',' expected. ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction9_es2017.js b/tests/baselines/reference/asyncArrowFunction9_es2017.js index c1fec991ec1..a101892eb16 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es2017.js +++ b/tests/baselines/reference/asyncArrowFunction9_es2017.js @@ -3,6 +3,7 @@ var foo = async (a = await => await): Promise => { } //// [asyncArrowFunction9_es2017.js] -var foo = async(a = await => await), Promise = ; +var foo = async(a = await => await), Promise; +; { } diff --git a/tests/baselines/reference/asyncArrowFunction9_es5.errors.txt b/tests/baselines/reference/asyncArrowFunction9_es5.errors.txt index e215259245e..a9e03eb897d 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es5.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction9_es5.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,11): error TS2304: Cannot find name 'async'. tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,18): error TS2304: Cannot find name 'a'. tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,37): error TS1005: ',' expected. -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,46): error TS1005: '=' expected. +tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. +tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,46): error TS1005: ',' expected. tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,53): error TS1109: Expression expected. @@ -15,9 +15,9 @@ tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts( ~ !!! error TS1005: ',' expected. ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction9_es5.js b/tests/baselines/reference/asyncArrowFunction9_es5.js index 2506024f326..457d5ddc4c4 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es5.js +++ b/tests/baselines/reference/asyncArrowFunction9_es5.js @@ -3,6 +3,7 @@ var foo = async (a = await => await): Promise => { } //// [asyncArrowFunction9_es5.js] -var foo = async(a = function (await) { return await; }), Promise = ; +var foo = async(a = function (await) { return await; }), Promise; +; { } diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt index 8d974d75dd3..123f07c020c 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt @@ -1,8 +1,8 @@ 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' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, 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,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. +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. @@ -15,9 +15,9 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts( ~ !!! error TS1005: ',' expected. ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. ~ -!!! error TS1005: '=' expected. +!!! 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 index fb2f9d28a17..d7d5a167583 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es6.js +++ b/tests/baselines/reference/asyncArrowFunction9_es6.js @@ -3,6 +3,7 @@ var foo = async (a = await => await): Promise => { } //// [asyncArrowFunction9_es6.js] -var foo = async(a = await => await), Promise = ; +var foo = async(a = await => await), Promise; +; { } diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt index f951bee715c..37e2c3f847f 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,24): error TS1005: '(' expected. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,29): error TS1005: '=' expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,29): error TS1005: ',' expected. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,47): error TS1005: '=>' expected. @@ -9,7 +9,7 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati ~~~~~ !!! error TS1005: '(' expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~~~~~~~~~~~~ !!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ~ diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js index 93fbb061023..2ed6cf3191f 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js @@ -2,4 +2,5 @@ var v = async function await(): Promise { } //// [asyncFunctionDeclaration12_es2017.js] -var v = async function () { }, await = () => { }; +var v = async function () { }, await; +() => { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types index 1881a3cb4fd..5f4155c4975 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types @@ -2,7 +2,7 @@ var v = async function await(): Promise { } >v : () => any >async function : () => any ->await : () => Promise +>await : any >(): Promise { } : () => Promise >Promise : Promise diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es5.errors.txt index 6468ec69716..353e75ca6d5 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es5.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,24): error TS1005: '(' expected. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,29): error TS1005: '=' expected. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,29): error TS1005: ',' expected. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,47): error TS1005: '=>' expected. @@ -9,7 +9,7 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 ~~~~~ !!! error TS1005: '(' expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~~~~~~~~~~~~ !!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ~ diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es5.js b/tests/baselines/reference/asyncFunctionDeclaration12_es5.js index 21651a42796..19bca54f524 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es5.js @@ -6,4 +6,5 @@ var v = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/]; }); }); -}, await = function () { }; +}, await; +(function () { }); diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es5.types b/tests/baselines/reference/asyncFunctionDeclaration12_es5.types index 242eca7c5a4..c7e3a6feeb5 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es5.types +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es5.types @@ -2,7 +2,7 @@ var v = async function await(): Promise { } >v : () => any >async function : () => any ->await : () => Promise +>await : any >(): Promise { } : () => Promise >Promise : Promise diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt index 43df8e21659..ffe7227344f 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt @@ -1,5 +1,5 @@ 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,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. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,47): error TS1005: '=>' expected. @@ -9,7 +9,7 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 ~~~~~ !!! error TS1005: '(' expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~~~~~~~~~~~~ !!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ~ diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.js b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js index 9943c3896b6..17829af6f20 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js @@ -4,4 +4,5 @@ var v = async function await(): Promise { } //// [asyncFunctionDeclaration12_es6.js] var v = function () { return __awaiter(this, void 0, void 0, function* () { }); -}, await = () => { }; +}, await; +() => { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.types b/tests/baselines/reference/asyncFunctionDeclaration12_es6.types index acf108d9761..4eb4fcde054 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es6.types +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.types @@ -2,7 +2,7 @@ var v = async function await(): Promise { } >v : () => any >async function : () => any ->await : () => Promise +>await : any >(): Promise { } : () => Promise >Promise : Promise diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt b/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt index 4bbc2d8167d..2cd21b0e4f0 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt +++ b/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt @@ -1,12 +1,15 @@ tests/cases/compiler/classMemberWithMissingIdentifier.ts(2,11): error TS1146: Declaration expected. -tests/cases/compiler/classMemberWithMissingIdentifier.ts(2,12): error TS1005: '=' expected. +tests/cases/compiler/classMemberWithMissingIdentifier.ts(2,12): error TS1005: ';' expected. +tests/cases/compiler/classMemberWithMissingIdentifier.ts(3,1): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/classMemberWithMissingIdentifier.ts (2 errors) ==== +==== tests/cases/compiler/classMemberWithMissingIdentifier.ts (3 errors) ==== class C { public {}; !!! error TS1146: Declaration expected. ~ -!!! error TS1005: '=' expected. - } \ No newline at end of file +!!! error TS1005: ';' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier.js b/tests/baselines/reference/classMemberWithMissingIdentifier.js index 39582a670a4..55596754f20 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier.js +++ b/tests/baselines/reference/classMemberWithMissingIdentifier.js @@ -6,7 +6,8 @@ class C { //// [classMemberWithMissingIdentifier.js] var C = /** @class */ (function () { function C() { - this. = {}; } return C; }()); +{ } +; diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier.types b/tests/baselines/reference/classMemberWithMissingIdentifier.types index d0fb4dddd12..ebc14e9e8a6 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier.types +++ b/tests/baselines/reference/classMemberWithMissingIdentifier.types @@ -3,6 +3,5 @@ class C { >C : C public {}; -> : {} ->{} : {} +> : any } diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt b/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt index 9854a115aa6..65a9eac77a3 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,11): error TS1146: Declaration expected. -tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,12): error TS1005: '=' expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,12): error TS1005: ';' expected. tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,14): error TS2304: Cannot find name 'name'. -tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,18): error TS1005: ']' expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,18): error TS1005: ',' expected. tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,19): error TS2693: 'string' only refers to a type, but is being used as a value here. -tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,25): error TS1005: ',' expected. -tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,26): error TS1136: Property assignment expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,26): error TS1005: ';' expected. tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,27): error TS2304: Cannot find name 'VariableDeclaration'. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(3,1): error TS1128: Declaration or statement expected. ==== tests/cases/compiler/classMemberWithMissingIdentifier2.ts (8 errors) ==== @@ -14,17 +14,17 @@ tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,27): error TS2304: C !!! error TS1146: Declaration expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ';' expected. ~~~~ !!! error TS2304: Cannot find name 'name'. ~ -!!! error TS1005: ']' expected. +!!! error TS1005: ',' expected. ~~~~~~ !!! error TS2693: 'string' only refers to a type, but is being used as a value here. - ~ -!!! error TS1005: ',' expected. ~ -!!! error TS1136: Property assignment expected. +!!! error TS1005: ';' expected. ~~~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'VariableDeclaration'. - } \ No newline at end of file + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.js b/tests/baselines/reference/classMemberWithMissingIdentifier2.js index 798774af12c..f4cd26302c4 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier2.js +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.js @@ -6,8 +6,11 @@ class C { //// [classMemberWithMissingIdentifier2.js] var C = /** @class */ (function () { function C() { - this. = (_a = {}, _a[name] = string, _a.VariableDeclaration = VariableDeclaration, _a); - var _a; } return C; }()); +{ + [name, string]; + VariableDeclaration; +} +; diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.symbols b/tests/baselines/reference/classMemberWithMissingIdentifier2.symbols index 2b1d1a521e1..1ac5b055178 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier2.symbols +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.symbols @@ -4,5 +4,4 @@ class C { public {[name:string]:VariableDeclaration}; > : Symbol(C[(Missing)], Decl(classMemberWithMissingIdentifier2.ts, 0, 9)) ->VariableDeclaration : Symbol(VariableDeclaration, Decl(classMemberWithMissingIdentifier2.ts, 1, 26)) } diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.types b/tests/baselines/reference/classMemberWithMissingIdentifier2.types index 9b5e6cd64c1..8f9f62818a4 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier2.types +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.types @@ -3,8 +3,8 @@ class C { >C : C public {[name:string]:VariableDeclaration}; -> : { [x: number]: any; VariableDeclaration: any; } ->{[name:string]:VariableDeclaration} : { [x: number]: any; VariableDeclaration: any; } +> : any +>[name:string] : any[] >name : any >string : any >VariableDeclaration : any diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt index 708f175c002..1150fe0ff29 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt @@ -7,19 +7,21 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(24,28): error TS tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(24,29): error TS1005: ',' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(27,18): error TS1128: Declaration or statement expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(27,26): error TS2304: Cannot find name 'bfs'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,30): error TS1005: '=' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,30): error TS1005: ',' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,34): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(31,18): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,17): error TS2304: Cannot find name 'retValue'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,26): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,28): error TS2304: Cannot find name 'bfs'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(35,21): error TS2365: Operator '!=' cannot be applied to types 'boolean' and '0'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(35,21): error TS2304: Cannot find name 'retValue'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(38,17): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,17): error TS2304: Cannot find name 'retValue'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,28): error TS2304: Cannot find name 'bfs'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,41): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,45): error TS1002: Unterminated string literal. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(41,21): error TS2365: Operator '!=' cannot be applied to types 'boolean' and '0'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(41,21): error TS2304: Cannot find name 'retValue'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(46,13): error TS1005: 'try' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(47,17): error TS2304: Cannot find name 'console'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(49,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(53,13): error TS2304: Cannot find name 'console'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(58,5): error TS1128: Declaration or statement expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(69,13): error TS1109: Expression expected. @@ -87,7 +89,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,55): error T tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (87 errors) ==== +==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (89 errors) ==== declare module "fs" { export class File { constructor(filename: string); @@ -138,7 +140,9 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS !!! error TS2304: Cannot find name 'bfs'. if (retValue != 0) { ~~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. + ~ +!!! error TS1005: ';' expected. return 1; ^ @@ -148,14 +152,14 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS retValue = bfs.TYPES(); ~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2304: Cannot find name 'retValue'. ~ !!! error TS1005: ';' expected. ~~~ !!! error TS2304: Cannot find name 'bfs'. if (retValue != 0) { - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'boolean' and '0'. + ~~~~~~~~ +!!! error TS2304: Cannot find name 'retValue'. return 1 && } @@ -163,6 +167,8 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS !!! error TS1109: Expression expected. retValue = bfs.OPERATOR ' ); + ~~~~~~~~ +!!! error TS2304: Cannot find name 'retValue'. ~~~ !!! error TS2304: Cannot find name 'bfs'. ~~~~ @@ -170,20 +176,20 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS !!! error TS1002: Unterminated string literal. if (retValue != 0) { - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'boolean' and '0'. + ~~~~~~~~ +!!! error TS2304: Cannot find name 'retValue'. return 1; } } catch (e) { + ~~~~~ +!!! error TS1005: 'try' expected. console.log(e); ~~~~~~~ !!! error TS2304: Cannot find name 'console'. } finally { - ~~~~~~~ -!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. } diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js index 7a109888497..24a0f8f01c6 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js @@ -315,30 +315,31 @@ var TypeScriptAllInOne; finally { } }; - Program.prototype["if"] = function (retValue) { - if (retValue === void 0) { retValue = != 0; } - return 1; - ^ - retValue; - bfs.TYPES(); - if (retValue != 0) { - return 1 && - ; - } - retValue = bfs.OPERATOR; - ' );; - if (retValue != 0) { - return 1; - } - }; - Program.prototype["catch"] = function (e) { - console.log(e); - }; + Program.prototype["if"] = function (retValue) { }; return Program; }()); TypeScriptAllInOne.Program = Program; + != 0; + { + return 1; + ^ + retValue; + bfs.TYPES(); + if (retValue != 0) { + return 1 && + ; + } + retValue = bfs.OPERATOR; + ' );; + if (retValue != 0) { + return 1; + } + } try { } + catch (e) { + console.log(e); + } finally { } console.log('Done'); diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols index 7374c67325d..45a894d8895 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols @@ -64,25 +64,18 @@ module TypeScriptAllInOne { retValue = bfs.TYPES(); ->retValue : Symbol(retValue, Decl(constructorWithIncompleteTypeAnnotation.ts, 27, 20)) - if (retValue != 0) { ->retValue : Symbol(retValue, Decl(constructorWithIncompleteTypeAnnotation.ts, 27, 20)) return 1 && } retValue = bfs.OPERATOR ' ); ->retValue : Symbol(retValue, Decl(constructorWithIncompleteTypeAnnotation.ts, 27, 20)) - if (retValue != 0) { ->retValue : Symbol(retValue, Decl(constructorWithIncompleteTypeAnnotation.ts, 27, 20)) return 1; } } catch (e) { ->catch : Symbol(Program.catch, Decl(constructorWithIncompleteTypeAnnotation.ts, 44, 13)) >e : Symbol(e, Decl(constructorWithIncompleteTypeAnnotation.ts, 45, 19)) console.log(e); diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types index a0c5f95cbbd..d8217600a66 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types @@ -74,8 +74,8 @@ module TypeScriptAllInOne { >4 : 4 if (retValue != 0) { ->if : (retValue?: boolean) => any ->retValue : boolean +>if : (retValue: any) => any +>retValue : any >!= 0 : boolean > : any >0 : 0 @@ -89,7 +89,7 @@ module TypeScriptAllInOne { retValue = bfs.TYPES(); ->retValue : boolean +>retValue : any >bfs.TYPES() : any >bfs.TYPES : any >bfs : any @@ -97,7 +97,7 @@ module TypeScriptAllInOne { if (retValue != 0) { >retValue != 0 : boolean ->retValue : boolean +>retValue : any >0 : 0 return 1 && @@ -108,7 +108,7 @@ module TypeScriptAllInOne { retValue = bfs.OPERATOR ' ); >retValue = bfs.OPERATOR : any ->retValue : boolean +>retValue : any >bfs.OPERATOR : any >bfs : any >OPERATOR : any @@ -116,7 +116,7 @@ module TypeScriptAllInOne { if (retValue != 0) { >retValue != 0 : boolean ->retValue : boolean +>retValue : any >0 : 0 return 1; @@ -124,7 +124,6 @@ module TypeScriptAllInOne { } } catch (e) { ->catch : (e: any) => void >e : any console.log(e); diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt index 84d9c313995..1e471f9970c 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt @@ -1,18 +1,44 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2304: Cannot find name 'super'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,13): error TS1005: '=' expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,13): error TS1005: ';' expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,14): error TS1109: Expression expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(9,5): error TS2304: Cannot find name 'b'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(9,9): error TS1005: ';' expected. 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(12,5): error TS2304: Cannot find name 'get'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(12,9): error TS1005: ';' expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(12,9): error TS2304: Cannot find name 'C'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(12,13): error TS1005: ';' expected. 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(16,5): error TS2304: Cannot find name 'set'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,5): error TS7027: Unreachable code detected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,9): error TS1005: ';' expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,9): error TS2304: Cannot find name 'C'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,11): error TS2304: Cannot find name 'v'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,14): error TS1005: ';' expected. 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 TS2304: Cannot find name 'super'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,20): error TS1005: '=' expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,21): error TS1109: Expression expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,5): error TS1128: Declaration or statement 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(21,5): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(21,12): error TS2304: Cannot find name 'b'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(21,16): error TS1005: ';' expected. 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(24,5): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,12): error TS2304: Cannot find name 'get'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,16): error TS1005: ';' expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,16): error TS2304: Cannot find name 'C'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,20): error TS1005: ';' expected. 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(28,5): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,12): error TS2304: Cannot find name 'set'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,16): error TS1005: ';' expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,16): error TS2304: Cannot find name 'C'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,18): error TS2304: Cannot find name 'v'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,21): error TS1005: ';' expected. 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(31,1): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts (12 errors) ==== +==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts (38 errors) ==== // error to use super calls outside a constructor class Base { @@ -24,47 +50,99 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS ~~~~~ !!! error TS2304: Cannot find name 'super'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ';' expected. ~ !!! error TS1109: Expression expected. b() { + ~ +!!! error TS2304: Cannot find name 'b'. + ~ +!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } get C() { + ~~~ +!!! error TS2304: Cannot find name 'get'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'C'. + ~ +!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; } set C(v) { + ~~~ +!!! error TS2304: Cannot find name 'set'. + ~~~ +!!! error TS7027: Unreachable code detected. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'C'. + ~ +!!! error TS2304: Cannot find name 'v'. + ~ +!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } static a: super(); + ~~~~~~ +!!! error TS1128: Declaration or statement expected. ~~~~~ -!!! error TS2304: Cannot find name 'super'. - ~ -!!! error TS1005: '=' expected. - ~ -!!! error TS1109: Expression expected. +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. static b() { + ~~~~~~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS2304: Cannot find name 'b'. + ~ +!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } static get C() { + ~~~~~~ +!!! error TS1128: Declaration or statement expected. + ~~~ +!!! error TS2304: Cannot find name 'get'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'C'. + ~ +!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; } static set C(v) { + ~~~~~~ +!!! error TS1128: Declaration or statement expected. + ~~~ +!!! error TS2304: Cannot find name 'set'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'C'. + ~ +!!! error TS2304: Cannot find name 'v'. + ~ +!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } - } \ No newline at end of file + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js index 019e29f1940..cddd8e6c52c 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js @@ -51,38 +51,39 @@ var Base = /** @class */ (function () { var Derived = /** @class */ (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.a = (); - return _this; + return _super !== null && _super.apply(this, arguments) || this; } - Derived.prototype.b = function () { - _this = _super.call(this) || this; - }; - Object.defineProperty(Derived.prototype, "C", { - get: function () { - _this = _super.call(this) || this; - return 1; - }, - set: function (v) { - _this = _super.call(this) || this; - }, - enumerable: true, - configurable: true - }); - Derived.b = function () { - _this = _super.call(this) || this; - }; - Object.defineProperty(Derived, "C", { - get: function () { - _this = _super.call(this) || this; - return 1; - }, - set: function (v) { - _this = _super.call(this) || this; - }, - enumerable: true, - configurable: true - }); - Derived.a = (); return Derived; }(Base)); +(); +b(); +{ + _this = _super.call(this) || this; +} +get; +C(); +{ + _this = _super.call(this) || this; + return 1; +} +set; +C(v); +{ + _this = _super.call(this) || this; +} +a: _this = _super.call(this) || this; +b(); +{ + _this = _super.call(this) || this; +} +get; +C(); +{ + _this = _super.call(this) || this; + return 1; +} +set; +C(v); +{ + _this = _super.call(this) || this; +} diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.symbols b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.symbols index 0d5c10321cd..8a394e9d659 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.symbols +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.symbols @@ -16,41 +16,25 @@ class Derived extends Base { >a : Symbol(Derived.a, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 6, 28)) b() { ->b : Symbol(Derived.b, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 7, 15)) - super(); } get C() { ->C : Symbol(Derived.C, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 10, 5), Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 14, 5)) - super(); return 1; } set C(v) { ->C : Symbol(Derived.C, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 10, 5), Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 14, 5)) ->v : Symbol(v, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 15, 10)) - super(); } static a: super(); ->a : Symbol(Derived.a, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 17, 5)) - static b() { ->b : Symbol(Derived.b, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 19, 22)) - super(); } static get C() { ->C : Symbol(Derived.C, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 22, 5), Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 26, 5)) - super(); return 1; } static set C(v) { ->C : Symbol(Derived.C, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 22, 5), Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 26, 5)) ->v : Symbol(v, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 27, 17)) - super(); } } diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.types b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.types index 5964a25f6d4..ebefa744753 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.types +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.types @@ -19,14 +19,17 @@ class Derived extends Base { > : any b() { ->b : () => void +>b() : any +>b : any super(); >super() : void >super : any } get C() { ->C : number +>get : any +>C() : any +>C : any super(); >super() : void @@ -36,8 +39,10 @@ class Derived extends Base { >1 : 1 } set C(v) { ->C : number ->v : number +>set : any +>C(v) : any +>C : any +>v : any super(); >super() : void @@ -46,19 +51,21 @@ class Derived extends Base { static a: super(); >a : any ->super : No type information available! ->() : any -> : any +>super() : void +>super : any static b() { ->b : () => void +>b() : any +>b : any super(); >super() : void >super : any } static get C() { ->C : number +>get : any +>C() : any +>C : any super(); >super() : void @@ -68,8 +75,10 @@ class Derived extends Base { >1 : 1 } static set C(v) { ->C : number ->v : number +>set : any +>C(v) : any +>C : any +>v : any super(); >super() : void diff --git a/tests/baselines/reference/dontShowCompilerGeneratedMembers.errors.txt b/tests/baselines/reference/dontShowCompilerGeneratedMembers.errors.txt index d53571cc4a8..708cc37701f 100644 --- a/tests/baselines/reference/dontShowCompilerGeneratedMembers.errors.txt +++ b/tests/baselines/reference/dontShowCompilerGeneratedMembers.errors.txt @@ -1,12 +1,9 @@ -tests/cases/compiler/dontShowCompilerGeneratedMembers.ts(1,5): error TS2322: Type 'number' is not assignable to type '{ (): any; x: number; }'. tests/cases/compiler/dontShowCompilerGeneratedMembers.ts(3,6): error TS1139: Type parameter declaration expected. tests/cases/compiler/dontShowCompilerGeneratedMembers.ts(4,1): error TS1109: Expression expected. -==== tests/cases/compiler/dontShowCompilerGeneratedMembers.ts (3 errors) ==== +==== tests/cases/compiler/dontShowCompilerGeneratedMembers.ts (2 errors) ==== var f: { - ~ -!!! error TS2322: Type 'number' is not assignable to type '{ (): any; x: number; }'. x: number; <- ~ diff --git a/tests/baselines/reference/dontShowCompilerGeneratedMembers.js b/tests/baselines/reference/dontShowCompilerGeneratedMembers.js index 5815e49c893..f9d732e8786 100644 --- a/tests/baselines/reference/dontShowCompilerGeneratedMembers.js +++ b/tests/baselines/reference/dontShowCompilerGeneratedMembers.js @@ -5,5 +5,6 @@ var f: { }; //// [dontShowCompilerGeneratedMembers.js] -var f = -; +var f; +-; ; diff --git a/tests/baselines/reference/expressionTypeNodeShouldError.errors.txt b/tests/baselines/reference/expressionTypeNodeShouldError.errors.txt index 86a592779ca..2d655a59b9c 100644 --- a/tests/baselines/reference/expressionTypeNodeShouldError.errors.txt +++ b/tests/baselines/reference/expressionTypeNodeShouldError.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/base.d.ts(1,23): error TS1005: ',' expected. -tests/cases/compiler/base.d.ts(1,34): error TS1005: '=' expected. +tests/cases/compiler/base.d.ts(1,34): error TS1005: ',' expected. tests/cases/compiler/boolean.ts(7,23): error TS1005: ',' expected. tests/cases/compiler/boolean.ts(7,24): error TS1134: Variable declaration expected. tests/cases/compiler/boolean.ts(11,16): error TS2304: Cannot find name 'document'. @@ -19,7 +19,7 @@ tests/cases/compiler/string.ts(12,19): error TS1005: ';' expected. ~ !!! error TS1005: ',' expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ==== tests/cases/compiler/string.ts (4 errors) ==== interface String { diff --git a/tests/baselines/reference/expressionTypeNodeShouldError.types b/tests/baselines/reference/expressionTypeNodeShouldError.types index 67a44d061d1..907614aa7cd 100644 --- a/tests/baselines/reference/expressionTypeNodeShouldError.types +++ b/tests/baselines/reference/expressionTypeNodeShouldError.types @@ -1,7 +1,7 @@ === tests/cases/compiler/base.d.ts === declare const x: "foo".charCodeAt(0); >x : "foo" ->charCodeAt : 0 +>charCodeAt : any >(0) : 0 >0 : 0 diff --git a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline index b66f83dc6b6..0f526b85b4f 100644 --- a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline +++ b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline @@ -4,5 +4,5 @@ FileName : out.js // expected to not generate outputs because of the syntactic errors in the other file. var noErrors = true; // File not emitted, and contains syntactic errors -var syntactic = Error; +var syntactic, Error; diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.errors.txt b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.errors.txt index c31b03bae4c..d8168b14895 100644 --- a/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.errors.txt +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.errors.txt @@ -1,22 +1,31 @@ -tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,13): error TS1005: '=' expected. -tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,20): error TS1005: ',' expected. -tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(7,1): error TS1005: ';' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,13): error TS1005: ',' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,14): error TS1181: Array element destructuring pattern expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,14): error TS2695: Left side of comma operator is unused and has no side effects. +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,14): error TS2695: Left side of comma operator is unused and has no side effects. +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,19): error TS1005: ';' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,20): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts (3 errors) ==== +==== tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts (6 errors) ==== // This should be an error // More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements var let = 10; for (let of [1,2,3]) {} ~ -!!! error TS1005: '=' expected. - ~ !!! error TS1005: ',' expected. + ~ +!!! error TS1181: Array element destructuring pattern expected. + ~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + ~~~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. for (let in [1,2,3]) {} - ~~~ -!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.js b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.js index b9f4c126015..0f35b405df3 100644 --- a/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.js +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.js @@ -14,5 +14,7 @@ for (let in [1,2,3]) {} // This should be an error // More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements var let = 10; -for (let of = [1, 2, 3], {}; ; ) - for (let in [1, 2, 3]) { } +for (let of, []; 1, 2, 3; ) + ; +{ } +for (let in [1, 2, 3]) { } diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.types b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.types index 26a9f24aead..66f070e1ce5 100644 --- a/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.types +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.types @@ -7,15 +7,16 @@ var let = 10; >10 : 10 for (let of [1,2,3]) {} ->of : number[] ->[1,2,3] : number[] +>of : any +>1,2,3 : 3 +>1,2 : 2 >1 : 1 >2 : 2 >3 : 3 +> : any +> : any for (let in [1,2,3]) {} -> : any -> : any >[1,2,3] : number[] >1 : 1 >2 : 2 diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.errors.txt b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.errors.txt index c126e8b7443..b484a573b1e 100644 --- a/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.errors.txt +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.errors.txt @@ -1,22 +1,31 @@ -tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,13): error TS1005: '=' expected. -tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,20): error TS1005: ',' expected. -tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(7,1): error TS1005: ';' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,13): error TS1005: ',' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,14): error TS1181: Array element destructuring pattern expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,14): error TS2695: Left side of comma operator is unused and has no side effects. +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,14): error TS2695: Left side of comma operator is unused and has no side effects. +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,19): error TS1005: ';' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,20): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts (3 errors) ==== +==== tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts (6 errors) ==== // This should be an error // More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements var let = 10; for (let of [1,2,3]) {} ~ -!!! error TS1005: '=' expected. - ~ !!! error TS1005: ',' expected. + ~ +!!! error TS1181: Array element destructuring pattern expected. + ~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + ~~~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. for (let in [1,2,3]) {} - ~~~ -!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.js b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.js index be59a37d1a8..3cbadbabe37 100644 --- a/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.js +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.js @@ -14,5 +14,7 @@ for (let in [1,2,3]) {} // This should be an error // More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements var let = 10; -for (let of = [1, 2, 3], {}; ; ) - for (let in [1, 2, 3]) { } +for (let of, []; 1, 2, 3; ) + ; +{ } +for (let in [1, 2, 3]) { } diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.types b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.types index ff980012702..1473e01ba1a 100644 --- a/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.types +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.types @@ -7,15 +7,16 @@ var let = 10; >10 : 10 for (let of [1,2,3]) {} ->of : number[] ->[1,2,3] : number[] +>of : any +>1,2,3 : 3 +>1,2 : 2 >1 : 1 >2 : 2 >3 : 3 +> : any +> : any for (let in [1,2,3]) {} -> : any -> : any >[1,2,3] : number[] >1 : 1 >2 : 2 diff --git a/tests/baselines/reference/invalidTypeOfTarget.errors.txt b/tests/baselines/reference/invalidTypeOfTarget.errors.txt index e658ab68c81..04bf724e4b9 100644 --- a/tests/baselines/reference/invalidTypeOfTarget.errors.txt +++ b/tests/baselines/reference/invalidTypeOfTarget.errors.txt @@ -6,9 +6,9 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(5,16): error TS1003: Identifier expected. tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(6,16): error TS2304: Cannot find name 'null'. tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(7,16): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(7,25): error TS1005: '=' expected. -tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(7,25): error TS2304: Cannot find name 'f'. -tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(7,29): error TS1005: ',' expected. +tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(7,25): error TS1005: ',' expected. +tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(7,26): error TS1005: ',' expected. +tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(7,29): error TS1005: '=>' expected. tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(8,16): error TS1003: Identifier expected. @@ -37,11 +37,11 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ~ -!!! error TS1005: '=' expected. - ~ -!!! error TS2304: Cannot find name 'f'. - ~ !!! error TS1005: ',' expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1005: '=>' expected. var x8: typeof /123/; ~ !!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/invalidTypeOfTarget.js b/tests/baselines/reference/invalidTypeOfTarget.js index ebc5bb70875..78d31c91809 100644 --- a/tests/baselines/reference/invalidTypeOfTarget.js +++ b/tests/baselines/reference/invalidTypeOfTarget.js @@ -9,11 +9,16 @@ var x7: typeof function f() { }; var x8: typeof /123/; //// [invalidTypeOfTarget.js] -var x1 = {}; -var x2 = function () { return ; }; -var x3 = 1; -var x4 = ''; +var x1, _a = void 0; +var x2; +(function () { return ; }); +var x3; +1; +var x4; +''; var x5; var x6; -var x7 = f(), _a = void 0; -var x8 = /123/; +var x7, f; +(function () { }); +var x8; +/123/; diff --git a/tests/baselines/reference/invalidTypeOfTarget.symbols b/tests/baselines/reference/invalidTypeOfTarget.symbols index 007f7fafed8..273abba72de 100644 --- a/tests/baselines/reference/invalidTypeOfTarget.symbols +++ b/tests/baselines/reference/invalidTypeOfTarget.symbols @@ -19,6 +19,7 @@ var x6: typeof null; var x7: typeof function f() { }; >x7 : Symbol(x7, Decl(invalidTypeOfTarget.ts, 6, 3)) +>f : Symbol(f, Decl(invalidTypeOfTarget.ts, 6, 23)) var x8: typeof /123/; >x8 : Symbol(x8, Decl(invalidTypeOfTarget.ts, 7, 3)) diff --git a/tests/baselines/reference/invalidTypeOfTarget.types b/tests/baselines/reference/invalidTypeOfTarget.types index 159a2531cfb..554e6959ec2 100644 --- a/tests/baselines/reference/invalidTypeOfTarget.types +++ b/tests/baselines/reference/invalidTypeOfTarget.types @@ -2,7 +2,6 @@ var x1: typeof {}; >x1 : any > : any ->{} : {} var x2: typeof (): void; >x2 : any @@ -31,8 +30,8 @@ var x6: typeof null; var x7: typeof function f() { }; >x7 : any >function : any ->f() : any >f : any +>() { } : () => void var x8: typeof /123/; >x8 : any diff --git a/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt b/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt index e0f818ba9c1..d91d0fea02d 100644 --- a/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt +++ b/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,15): error TS1109: Expression expected. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,25): error TS1005: '=' expected. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,25): error TS1005: ',' expected. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,26): error TS1109: Expression expected. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,24): error TS2532: Object is possibly 'undefined'. @@ -7,10 +7,11 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperator tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(8,24): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,29): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(12,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'NUMBER' has type 'any' at tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts 3:18, but here has type 'number'. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(12,14): error TS1109: Expression expected. -==== tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts (10 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts (11 errors) ==== // Unary operator - // operand before - @@ -18,7 +19,7 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperator ~~~ !!! error TS1109: Expression expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1109: Expression expected. @@ -41,5 +42,7 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperator // miss operand var NUMBER =-; + ~~~~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'NUMBER' has type 'any' at tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts 3:18, but here has type 'number'. ~ !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/negateOperatorInvalidOperations.js b/tests/baselines/reference/negateOperatorInvalidOperations.js index d7aa6154eb2..f905cc28793 100644 --- a/tests/baselines/reference/negateOperatorInvalidOperations.js +++ b/tests/baselines/reference/negateOperatorInvalidOperations.js @@ -16,7 +16,8 @@ var NUMBER =-; // Unary operator - // operand before - var NUMBER1 = ; -var NUMBER = -; //expect error +var NUMBER; +-; //expect error // invalid expressions var NUMBER2 = -(null - undefined); var NUMBER3 = -(null - null); diff --git a/tests/baselines/reference/negateOperatorInvalidOperations.types b/tests/baselines/reference/negateOperatorInvalidOperations.types index a39bd2b9a1b..bce6fd7e180 100644 --- a/tests/baselines/reference/negateOperatorInvalidOperations.types +++ b/tests/baselines/reference/negateOperatorInvalidOperations.types @@ -5,7 +5,7 @@ var NUMBER1 = var NUMBER-; //expect error >NUMBER1 : any > : any ->NUMBER : number +>NUMBER : any >- : number > : any @@ -36,7 +36,7 @@ var NUMBER4 = -(undefined - undefined); // miss operand var NUMBER =-; ->NUMBER : number +>NUMBER : any >- : number > : any diff --git a/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt b/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt index f08750ff0a6..ca85c992fa4 100644 --- a/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt +++ b/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(3,3): error TS1005: ';' expected. tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,15): error TS1005: ',' expected. -tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,23): error TS1005: '=' expected. +tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,23): error TS1005: ',' expected. tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,24): error TS1109: Expression expected. @@ -19,7 +19,7 @@ tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,24): error ~~~~~~~~ !!! error TS1005: ',' expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1109: Expression expected. var test3 = 3 .toString(); diff --git a/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.js b/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.js index 54a0328c27c..efa7ae96cf2 100644 --- a/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.js +++ b/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.js @@ -27,7 +27,8 @@ toString(); // Preserve whitespace where important for JS compatibility var i = 1; var test1 = i.toString(); -var test2 = 2., toString = (); +var test2 = 2., toString; +(); var test3 = 3..toString(); var test4 = 3..toString(); var test5 = 3..toString(); diff --git a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.errors.txt b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.errors.txt index 0eed47d2039..20bf52d1ca4 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.errors.txt +++ b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitInParameterIn tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitMissingValueIsError.ts(2,10): error TS1109: Expression expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts(1,29): error TS1005: '(' expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts(1,29): error TS2451: Cannot redeclare block-scoped variable 'await'. -tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts(1,34): error TS1005: '=' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts(1,34): error TS1005: ',' expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts(1,37): error TS1005: '=>' expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(1,30): error TS1138: Parameter declaration expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(1,30): error TS2451: Cannot redeclare block-scoped variable 'await'. @@ -20,7 +20,7 @@ tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpr tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInParameterInitializerIsError.ts(1,34): error TS2523: 'yield' expressions cannot be used in a parameter initializer. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts(1,29): error TS1005: '(' expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts(1,29): error TS2451: Cannot redeclare block-scoped variable 'yield'. -tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts(1,34): error TS1005: '=' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts(1,34): error TS1005: ',' expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts(1,37): error TS1005: '=>' expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(1,30): error TS1138: Parameter declaration expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(1,30): error TS2451: Cannot redeclare block-scoped variable 'yield'. @@ -38,7 +38,7 @@ tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarMissingVa ~~~~~ !!! error TS2451: Cannot redeclare block-scoped variable 'await'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1005: '=>' expected. }; @@ -49,7 +49,7 @@ tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarMissingVa ~~~~~ !!! error TS2451: Cannot redeclare block-scoped variable 'yield'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1005: '=>' expected. }; diff --git a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types index 557956a3344..6524ee9008c 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types +++ b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types @@ -9,7 +9,7 @@ const f1 = async function * f() { const f2 = async function * await() { >f2 : () => any >async function * : () => any ->await : () => void +>await : any >() {} : () => void }; @@ -17,7 +17,7 @@ const f2 = async function * await() { const f3 = async function * yield() { >f3 : () => any >async function * : () => any ->yield : () => void +>yield : any >() {} : () => void }; diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.errors.txt b/tests/baselines/reference/parserArrowFunctionExpression6.errors.txt new file mode 100644 index 00000000000..03312b63438 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression6.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,23): error TS2300: Duplicate identifier '(Missing)'. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,24): error TS1005: ',' expected. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,29): error TS1138: Parameter declaration expected. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,30): error TS2300: Duplicate identifier '(Missing)'. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,31): error TS1003: Identifier expected. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,40): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,41): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,55): error TS1138: Parameter declaration expected. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,66): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,69): error TS1005: ':' expected. + + +==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts (10 errors) ==== + function foo(q: string, b: number) { + return true ? (q ? true : false) : (b = q.length, function() { }); + +!!! error TS2300: Duplicate identifier '(Missing)'. + ~~~~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1138: Parameter declaration expected. + +!!! error TS2300: Duplicate identifier '(Missing)'. + ~~~~~ +!!! error TS1003: Identifier expected. + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. + ~~~~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~~~~~~~ +!!! error TS1138: Parameter declaration expected. + ~ +!!! error TS1005: '=>' expected. + ~ +!!! error TS1005: ':' expected. + }; + \ No newline at end of file diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.js b/tests/baselines/reference/parserArrowFunctionExpression6.js index 1de3035cc76..75824704b16 100644 --- a/tests/baselines/reference/parserArrowFunctionExpression6.js +++ b/tests/baselines/reference/parserArrowFunctionExpression6.js @@ -6,6 +6,7 @@ function foo(q: string, b: number) { //// [parserArrowFunctionExpression6.js] function foo(q, b) { - return true ? (q ? true : false) : (b = q.length, function () { }); + return true ? function (q, , ) { } : ; + ; } ; diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.symbols b/tests/baselines/reference/parserArrowFunctionExpression6.symbols index 9b3afdbb950..3cf5f44877f 100644 --- a/tests/baselines/reference/parserArrowFunctionExpression6.symbols +++ b/tests/baselines/reference/parserArrowFunctionExpression6.symbols @@ -5,11 +5,11 @@ function foo(q: string, b: number) { >b : Symbol(b, Decl(parserArrowFunctionExpression6.ts, 0, 23)) return true ? (q ? true : false) : (b = q.length, function() { }); ->q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 0, 13)) ->b : Symbol(b, Decl(parserArrowFunctionExpression6.ts, 0, 23)) ->q.length : Symbol(String.length, Decl(lib.d.ts, --, --)) ->q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 0, 13)) ->length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 1, 19)) +> : Symbol((Missing), Decl(parserArrowFunctionExpression6.ts, 1, 22)) +> : Symbol((Missing), Decl(parserArrowFunctionExpression6.ts, 1, 29)) +>b : Symbol(b, Decl(parserArrowFunctionExpression6.ts, 1, 40)) +>q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 1, 19)) }; diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.types b/tests/baselines/reference/parserArrowFunctionExpression6.types index 6cc4f16e216..990670eea63 100644 --- a/tests/baselines/reference/parserArrowFunctionExpression6.types +++ b/tests/baselines/reference/parserArrowFunctionExpression6.types @@ -1,25 +1,21 @@ === tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts === function foo(q: string, b: number) { ->foo : (q: string, b: number) => boolean | (() => void) +>foo : (q: string, b: number) => any >q : string >b : number return true ? (q ? true : false) : (b = q.length, function() { }); ->true ? (q ? true : false) : (b = q.length, function() { }) : boolean | (() => void) +>true ? (q ? true : false) : (b = q.length, function() { } : any >true : true ->(q ? true : false) : boolean ->q ? true : false : boolean ->q : string ->true : true ->false : false ->(b = q.length, function() { }) : () => void ->b = q.length, function() { } : () => void ->b = q.length : number ->b : number ->q.length : number ->q : string ->length : number ->function() { } : () => void +>(q ? true : false) : (b = q.length, function() { } : (q?: any, : any, : any) => (b?: any) => () => any +>q : any +> : any +> : any +>b : any +>q.length : any +>q : any +>length : any +> : any }; diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.js b/tests/baselines/reference/parserArrowFunctionExpression7.js new file mode 100644 index 00000000000..0646a1bf438 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression7.js @@ -0,0 +1,16 @@ +//// [parserArrowFunctionExpression7.ts] +({ + async m() { + for (;;) { + } + } +}); + + +//// [parserArrowFunctionExpression7.js] +({ + async m() { + for (;;) { + } + } +}); diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.symbols b/tests/baselines/reference/parserArrowFunctionExpression7.symbols new file mode 100644 index 00000000000..0dbc2cf05a1 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression7.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts === +({ + async m() { +>m : Symbol(m, Decl(parserArrowFunctionExpression7.ts, 0, 2)) + + for (;;) { + } + } +}); + diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.types b/tests/baselines/reference/parserArrowFunctionExpression7.types new file mode 100644 index 00000000000..072a1548bd2 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression7.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts === +({ +>({ async m() { for (;;) { } }}) : { m(): Promise; } +>{ async m() { for (;;) { } }} : { m(): Promise; } + + async m() { +>m : () => Promise + + for (;;) { + } + } +}); + diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt index 6dec4e33c80..0a5ab5e26e6 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts(12,20): error TS2304: Cannot find name 'C'. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts(12,22): error TS1005: '=' expected. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts(12,22): error TS1005: ';' expected. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts (2 errors) ==== @@ -18,7 +18,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariabl ~ !!! error TS2304: Cannot find name 'C'. ~~~~~~~ -!!! error TS1005: '=' expected. +!!! error TS1005: ';' expected. // Constructor constructor (public x: number, public y: number) { } diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js index 757ec40cffb..2ff2b371822 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js @@ -38,7 +38,6 @@ var Shapes; function Point(x, y) { this.x = x; this.y = y; - this.con = "hello"; } // Instance member Point.prototype.getDist = function () { return Math.sqrt(this.x * this.x + this.y * this.y); }; diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.types b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.types index 964df6ddb1c..c83c4dcdd19 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.types +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.types @@ -19,7 +19,6 @@ module Shapes { public con:C "hello"; >con : any >C : No type information available! ->"hello" : "hello" // Constructor constructor (public x: number, public y: number) { } diff --git a/tests/baselines/reference/parserTypeQuery8.errors.txt b/tests/baselines/reference/parserTypeQuery8.errors.txt index 4a7098ea8fd..49582f8d1dd 100644 --- a/tests/baselines/reference/parserTypeQuery8.errors.txt +++ b/tests/baselines/reference/parserTypeQuery8.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,15): error TS2304: Cannot find name 'A'. -tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,16): error TS1005: '=' expected. +tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,16): error TS1005: ',' expected. tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,17): error TS2304: Cannot find name 'B'. tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,19): error TS1109: Expression expected. @@ -9,7 +9,7 @@ tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,19): erro ~ !!! error TS2304: Cannot find name 'A'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS2304: Cannot find name 'B'. diff --git a/tests/baselines/reference/parserTypeQuery8.js b/tests/baselines/reference/parserTypeQuery8.js index 995ad013c1f..0600a038db0 100644 --- a/tests/baselines/reference/parserTypeQuery8.js +++ b/tests/baselines/reference/parserTypeQuery8.js @@ -2,4 +2,5 @@ var v: typeof A //// [parserTypeQuery8.js] -var v = ; +var v; +; diff --git a/tests/baselines/reference/restParamModifier.errors.txt b/tests/baselines/reference/restParamModifier.errors.txt index 87c73fcdc71..6b0da564e68 100644 --- a/tests/baselines/reference/restParamModifier.errors.txt +++ b/tests/baselines/reference/restParamModifier.errors.txt @@ -1,21 +1,9 @@ -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(2,27): error TS1005: ',' expected. -==== tests/cases/compiler/restParamModifier.ts (5 errors) ==== +==== tests/cases/compiler/restParamModifier.ts (1 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 index 6e7ef6375bc..a8457d40c20 100644 --- a/tests/baselines/reference/restParamModifier.js +++ b/tests/baselines/reference/restParamModifier.js @@ -5,8 +5,7 @@ class C { //// [restParamModifier.js] var C = /** @class */ (function () { - function C(string) { - if (string === void 0) { string = []; } + function C(rest) { } return C; }()); diff --git a/tests/baselines/reference/restParamModifier.symbols b/tests/baselines/reference/restParamModifier.symbols index bd71f92bf2a..d5af28d3e88 100644 --- a/tests/baselines/reference/restParamModifier.symbols +++ b/tests/baselines/reference/restParamModifier.symbols @@ -4,5 +4,5 @@ class C { constructor(...public rest: string[]) {} >public : Symbol(public, Decl(restParamModifier.ts, 1, 16)) ->string : Symbol(string, Decl(restParamModifier.ts, 1, 31)) +>rest : Symbol(rest, Decl(restParamModifier.ts, 1, 25)) } diff --git a/tests/baselines/reference/restParamModifier.types b/tests/baselines/reference/restParamModifier.types index e758a26aea3..d2cbdf3664c 100644 --- a/tests/baselines/reference/restParamModifier.types +++ b/tests/baselines/reference/restParamModifier.types @@ -3,8 +3,6 @@ class C { >C : C constructor(...public rest: string[]) {} ->public : any ->rest : any ->string : any[] ->[] : undefined[] +>public : any[] +>rest : string[] } diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index b813c08705b..56ac090c02c 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -79,21 +79,27 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(162,9): er tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,31): error TS2681: A constructor cannot have a 'this' parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(165,30): error TS2680: A 'this' parameter must be the first parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,26): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,30): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,20): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,26): error TS2680: A 'this' parameter must be the first parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,23): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,27): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,23): error TS2680: A 'this' parameter must be the first parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,23): error TS1005: ',' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,28): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,32): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,28): error TS2680: A 'this' parameter must be the first parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,30): error TS1005: ',' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,32): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,37): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,38): error TS1109: Expression expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,39): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,40): error TS1128: Declaration or statement expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,42): error TS2693: 'number' only refers to a type, but is being used as a value here. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,49): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,1): error TS7027: Unreachable code detected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,29): error TS2304: Cannot find name 'm'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,32): error TS1005: ';' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): error TS2304: Cannot find name 'm'. -==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (59 errors) ==== +==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (65 errors) ==== class C { n: number; explicitThis(this: this, m: number): number { @@ -390,31 +396,43 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): e function modifiers(async this: C): number { return this.n; } ~~~~ !!! error TS1003: Identifier expected. - ~ -!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2680: A 'this' parameter must be the first parameter. function restParam(...this: C): number { return this.n; } - ~~~~~~~ -!!! error TS2370: A rest parameter must be of an array type. ~~~~ !!! error TS1003: Identifier expected. - ~ -!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2680: A 'this' parameter must be the first parameter. function optional(this?: C): number { return this.n; } ~ !!! error TS1005: ',' expected. function decorated(@deco() this: C): number { return this.n; } ~~~~ !!! error TS1003: Identifier expected. - ~ -!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2680: A 'this' parameter must be the first parameter. function initializer(this: C = new C()): number { return this.n; } ~ !!! error TS1005: ',' expected. ~~~ !!! error TS1003: Identifier expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~ +!!! error TS2693: 'number' only refers to a type, but is being used as a value here. + ~ +!!! error TS1005: ';' expected. // can't name parameters 'this' in a lambda. c.explicitProperty = (this, m) => m + this.n; + ~ +!!! error TS7027: Unreachable code detected. ~ !!! error TS2304: Cannot find name 'm'. ~~ diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.js b/tests/baselines/reference/thisTypeInFunctionsNegative.js index 94a0565e237..541bcd2ad36 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.js +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.js @@ -340,18 +340,20 @@ var ThisConstructor = /** @class */ (function () { var thisConstructorType; function notFirst(a) { return this.n; } ///// parse errors ///// -function modifiers(, C) { - if ( === void 0) { = this; } +function modifiers() { return this.n; } +function restParam() { + var = []; + for (var _i = 0; _i < arguments.length; _i++) { + [_i] = arguments[_i]; + } return this.n; } -function restParam(C) { return this.n; } function optional() { return this.n; } -function decorated(, C) { - if ( === void 0) { = this; } - return this.n; -} -function initializer() { - if ( === void 0) { = new C(); } +function decorated() { return this.n; } +function initializer(, C) { } +(); +number; +{ return this.n; } // can't name parameters 'this' in a lambda. diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.symbols b/tests/baselines/reference/thisTypeInFunctionsNegative.symbols index 207af4688f3..61b4274d99f 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.symbols +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.symbols @@ -627,12 +627,14 @@ function notFirst(a: number, this: C): number { return this.n; } function modifiers(async this: C): number { return this.n; } >modifiers : Symbol(modifiers, Decl(thisTypeInFunctionsNegative.ts, 164, 64)) > : Symbol((Missing), Decl(thisTypeInFunctionsNegative.ts, 167, 19)) ->C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 167, 30)) +>this : Symbol(this, Decl(thisTypeInFunctionsNegative.ts, 167, 24)) +>C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 0, 0)) function restParam(...this: C): number { return this.n; } >restParam : Symbol(restParam, Decl(thisTypeInFunctionsNegative.ts, 167, 60)) > : Symbol((Missing), Decl(thisTypeInFunctionsNegative.ts, 168, 19)) ->C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 168, 27)) +>this : Symbol(this, Decl(thisTypeInFunctionsNegative.ts, 168, 22)) +>C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 0, 0)) function optional(this?: C): number { return this.n; } >optional : Symbol(optional, Decl(thisTypeInFunctionsNegative.ts, 168, 57)) @@ -644,17 +646,15 @@ function optional(this?: C): number { return this.n; } function decorated(@deco() this: C): number { return this.n; } >decorated : Symbol(decorated, Decl(thisTypeInFunctionsNegative.ts, 169, 54)) > : Symbol((Missing), Decl(thisTypeInFunctionsNegative.ts, 170, 19)) ->C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 170, 32)) +>this : Symbol(this, Decl(thisTypeInFunctionsNegative.ts, 170, 26)) +>C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 0, 0)) function initializer(this: C = new C()): number { return this.n; } >initializer : Symbol(initializer, Decl(thisTypeInFunctionsNegative.ts, 170, 62)) >this : Symbol(this, Decl(thisTypeInFunctionsNegative.ts, 171, 21)) >C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 0, 0)) > : Symbol((Missing), Decl(thisTypeInFunctionsNegative.ts, 171, 30)) ->C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 0, 0)) ->this.n : Symbol(C.n, Decl(thisTypeInFunctionsNegative.ts, 0, 9)) ->this : Symbol(this, Decl(thisTypeInFunctionsNegative.ts, 171, 21)) ->n : Symbol(C.n, Decl(thisTypeInFunctionsNegative.ts, 0, 9)) +>C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 171, 34)) // can't name parameters 'this' in a lambda. c.explicitProperty = (this, m) => m + this.n; diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.types b/tests/baselines/reference/thisTypeInFunctionsNegative.types index 12d838c8012..a5a8db3e2ee 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.types +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.types @@ -725,19 +725,19 @@ function notFirst(a: number, this: C): number { return this.n; } ///// parse errors ///// function modifiers(async this: C): number { return this.n; } ->modifiers : (async : any, C: any) => number +>modifiers : (async : any, this: C) => number > : any ->this : any ->C : any +>this : C +>C : C >this.n : any >this : any >n : any function restParam(...this: C): number { return this.n; } ->restParam : (...: any, C: any) => number -> : any ->this : any ->C : any +>restParam : (...: any[], this: C) => number +> : any[] +>this : C +>C : C >this.n : any >this : any >n : any @@ -752,26 +752,28 @@ function optional(this?: C): number { return this.n; } >n : any function decorated(@deco() this: C): number { return this.n; } ->decorated : (: any, C: any) => number +>decorated : (: any, this: C) => number >deco() : any >deco : any > : any ->this : any ->C : any +>this : C +>C : C >this.n : any >this : any >n : any function initializer(this: C = new C()): number { return this.n; } ->initializer : (this: C, ?: C) => number +>initializer : (this: C, : any, C: any) => any >this : C >C : C -> : C ->new C() : C ->C : typeof C ->this.n : number ->this : C ->n : number +> : any +>C : any +>() : any +> : any +>number : any +>this.n : any +>this : any +>n : any // can't name parameters 'this' in a lambda. c.explicitProperty = (this, m) => m + this.n; diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index 46455687af2..52e8b3bf81b 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -2,7 +2,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(1,7): tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(14,5): error TS2322: Type '""' is not assignable to type 'boolean'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,55): error TS2304: Cannot find name 'x'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,57): error TS1144: '{' or ';' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,57): error TS2304: Cannot find name 'is'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,60): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,62): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(21,33): error TS2304: Cannot find name 'x'. @@ -33,17 +32,14 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(84,1): Parameter 'p2' is not in the same position as parameter 'p1'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(90,1): error TS2322: Type '(p1: any, p2: any, p3: any) => p1 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,9): error TS2304: Cannot find name 'b'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,11): error TS1005: '=' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,11): error TS2304: Cannot find name 'is'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,11): error TS1005: ',' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,14): error TS1005: ',' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,14): error TS2300: Duplicate identifier 'A'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,16): error TS2304: Cannot find name 'b'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,18): error TS1005: '=' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,18): error TS2304: Cannot find name 'is'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,18): error TS1005: ',' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,21): error TS1005: ',' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,20): error TS2304: Cannot find name 'b'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,22): error TS1144: '{' or ';' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,22): error TS2304: Cannot find name 'is'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,25): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,27): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(103,25): error TS1228: A type predicate is only allowed in return type position for functions and methods. @@ -55,7 +51,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(110,9) tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(115,18): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(119,22): error TS2304: Cannot find name 'p1'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(119,25): error TS1005: ';' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(119,25): error TS2304: Cannot find name 'is'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(119,28): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,1): error TS1128: Declaration or statement expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(123,20): error TS1229: A type predicate cannot reference a rest parameter. @@ -76,7 +71,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,45 tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54): error TS2344: Type 'number' does not satisfy the constraint 'Foo'. -==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (62 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (57 errors) ==== class A { ~ !!! error TS2300: Duplicate identifier 'A'. @@ -102,8 +97,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 !!! error TS2304: Cannot find name 'x'. ~~ !!! error TS1144: '{' or ';' expected. - ~~ -!!! error TS2304: Cannot find name 'is'. ~ !!! error TS1005: ';' expected. ~ @@ -233,9 +226,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 ~ !!! error TS2304: Cannot find name 'b'. ~~ -!!! error TS1005: '=' expected. - ~~ -!!! error TS2304: Cannot find name 'is'. +!!! error TS1005: ',' expected. ~ !!! error TS1005: ',' expected. ~ @@ -244,9 +235,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 ~ !!! error TS2304: Cannot find name 'b'. ~~ -!!! error TS1005: '=' expected. - ~~ -!!! error TS2304: Cannot find name 'is'. +!!! error TS1005: ',' expected. ~ !!! error TS1005: ',' expected. function b3(): A | b is A { @@ -254,8 +243,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 !!! error TS2304: Cannot find name 'b'. ~~ !!! error TS1144: '{' or ';' expected. - ~~ -!!! error TS2304: Cannot find name 'is'. ~ !!! error TS1005: ';' expected. ~ @@ -300,8 +287,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 !!! error TS2304: Cannot find name 'p1'. ~~ !!! error TS1005: ';' expected. - ~~ -!!! error TS2304: Cannot find name 'is'. ~ !!! error TS1005: ';' expected. } diff --git a/tests/baselines/reference/typeGuardFunctionErrors.js b/tests/baselines/reference/typeGuardFunctionErrors.js index 32f8244c48e..38e22248d7e 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.js +++ b/tests/baselines/reference/typeGuardFunctionErrors.js @@ -253,10 +253,8 @@ assign3 = function (p1, p2, p3) { return true; }; // Type predicates in non-return type positions -var b1 = is, A; -function b2(a, A) { - if (a === void 0) { a = is; } -} +var b1, is, A; +function b2(a, is, A) { } ; is; A; diff --git a/tests/baselines/reference/typeGuardFunctionErrors.symbols b/tests/baselines/reference/typeGuardFunctionErrors.symbols index 176a79a5855..59f30533674 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.symbols +++ b/tests/baselines/reference/typeGuardFunctionErrors.symbols @@ -34,6 +34,7 @@ function hasTypeGuardTypeInsideTypeGuardType(x): x is x is A { >hasTypeGuardTypeInsideTypeGuardType : Symbol(hasTypeGuardTypeInsideTypeGuardType, Decl(typeGuardFunctionErrors.ts, 14, 1)) >x : Symbol(x, Decl(typeGuardFunctionErrors.ts, 16, 45)) >x : Symbol(x, Decl(typeGuardFunctionErrors.ts, 16, 45)) +>is : Symbol(is, Decl(typeGuardFunctionErrors.ts, 94, 9)) >A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 0, 0)) return true; @@ -224,16 +225,19 @@ assign3 = function(p1, p2, p3): p1 is A { // Type predicates in non-return type positions var b1: b is A; >b1 : Symbol(b1, Decl(typeGuardFunctionErrors.ts, 94, 3)) +>is : Symbol(is, Decl(typeGuardFunctionErrors.ts, 94, 9)) >A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 94, 12)) function b2(a: b is A) {}; >b2 : Symbol(b2, Decl(typeGuardFunctionErrors.ts, 94, 15)) >a : Symbol(a, Decl(typeGuardFunctionErrors.ts, 95, 12)) +>is : Symbol(is, Decl(typeGuardFunctionErrors.ts, 95, 16)) >A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 95, 19)) function b3(): A | b is A { >b3 : Symbol(b3, Decl(typeGuardFunctionErrors.ts, 95, 26)) >A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 0, 0)) +>is : Symbol(is, Decl(typeGuardFunctionErrors.ts, 94, 9)) >A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 0, 0)) return true; @@ -286,6 +290,7 @@ interface I2 { [index: number]: p1 is C; >index : Symbol(index, Decl(typeGuardFunctionErrors.ts, 118, 5)) +>is : Symbol(is, Decl(typeGuardFunctionErrors.ts, 94, 9)) >C : Symbol(C, Decl(typeGuardFunctionErrors.ts, 6, 1)) } diff --git a/tests/baselines/reference/typeGuardFunctionErrors.types b/tests/baselines/reference/typeGuardFunctionErrors.types index b4d19baaa18..d8add236887 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.types +++ b/tests/baselines/reference/typeGuardFunctionErrors.types @@ -264,7 +264,7 @@ var b1: b is A; >A : any function b2(a: b is A) {}; ->b2 : (a: any, A: any) => void +>b2 : (a: any, is: any, A: any) => void >a : any >b : No type information available! >is : any diff --git a/tests/baselines/reference/typePredicateOnVariableDeclaration02.errors.txt b/tests/baselines/reference/typePredicateOnVariableDeclaration02.errors.txt index 30a9a2e49a9..7ce23b916d1 100644 --- a/tests/baselines/reference/typePredicateOnVariableDeclaration02.errors.txt +++ b/tests/baselines/reference/typePredicateOnVariableDeclaration02.errors.txt @@ -1,19 +1,16 @@ tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(1,8): error TS2304: Cannot find name 'z'. tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(1,8): error TS4025: Exported variable 'y' has or is using private name 'z'. -tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(1,10): error TS1005: '=' expected. -tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(1,10): error TS2304: Cannot find name 'is'. +tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(1,10): error TS1005: ',' expected. tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(1,13): error TS1005: ',' expected. -==== tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts (5 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts (4 errors) ==== var y: z is number; ~ !!! error TS2304: Cannot find name 'z'. ~ !!! error TS4025: Exported variable 'y' has or is using private name 'z'. ~~ -!!! error TS1005: '=' expected. - ~~ -!!! error TS2304: Cannot find name 'is'. +!!! error TS1005: ',' expected. ~~~~~~ !!! error TS1005: ',' expected. \ No newline at end of file diff --git a/tests/baselines/reference/typePredicateOnVariableDeclaration02.js b/tests/baselines/reference/typePredicateOnVariableDeclaration02.js index 02c4333d43b..c8f376f0d00 100644 --- a/tests/baselines/reference/typePredicateOnVariableDeclaration02.js +++ b/tests/baselines/reference/typePredicateOnVariableDeclaration02.js @@ -2,4 +2,4 @@ var y: z is number; //// [typePredicateOnVariableDeclaration02.js] -var y = is, number; +var y, is, number; diff --git a/tests/baselines/reference/typePredicateOnVariableDeclaration02.symbols b/tests/baselines/reference/typePredicateOnVariableDeclaration02.symbols index 09cb4059d71..7353b734183 100644 --- a/tests/baselines/reference/typePredicateOnVariableDeclaration02.symbols +++ b/tests/baselines/reference/typePredicateOnVariableDeclaration02.symbols @@ -1,5 +1,6 @@ === tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts === var y: z is number; >y : Symbol(y, Decl(typePredicateOnVariableDeclaration02.ts, 0, 3)) +>is : Symbol(is, Decl(typePredicateOnVariableDeclaration02.ts, 0, 8)) >number : Symbol(number, Decl(typePredicateOnVariableDeclaration02.ts, 0, 11)) diff --git a/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts new file mode 100644 index 00000000000..65911cf0fc6 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts @@ -0,0 +1,7 @@ +// @target: esnext +({ + async m() { + for (;;) { + } + } +}); diff --git a/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts b/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts index 06a1c24230c..42be3a51618 100644 --- a/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts +++ b/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts @@ -5,12 +5,12 @@ //// b(): void; ////} //// -////var imp1: I1 { +////var imp1: I1 = { //// a() {}, //// /*0*/ ////} //// -////var imp2: I1 { +////var imp2: I1 = { //// a: () => {}, //// /*1*/ ////} diff --git a/tests/cases/fourslash/formattingReadonly.ts b/tests/cases/fourslash/formattingReadonly.ts index e9ec9860032..cb67b3daf38 100644 --- a/tests/cases/fourslash/formattingReadonly.ts +++ b/tests/cases/fourslash/formattingReadonly.ts @@ -1,12 +1,12 @@ /// ////class C { -//// readonly property1 {};/*1*/ -//// public readonly property2 {};/*2*/ +//// readonly property1: {};/*1*/ +//// public readonly property2: {};/*2*/ ////} format.document(); goTo.marker("1"); -verify.currentLineContentIs(" readonly property1 {};"); +verify.currentLineContentIs(" readonly property1: {};"); goTo.marker("2"); -verify.currentLineContentIs(" public readonly property2 {};"); \ No newline at end of file +verify.currentLineContentIs(" public readonly property2: {};"); From 96dcf398bf319775e96ed96a213026ee8ca0eb09 Mon Sep 17 00:00:00 2001 From: csigs Date: Tue, 14 Nov 2017 17:10:10 +0000 Subject: [PATCH 16/26] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 45 ++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 292a20a49bf..2ab6f838ccd 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1614,6 +1614,9 @@ + + + @@ -3181,7 +3184,7 @@ - + @@ -3190,7 +3193,7 @@ - + @@ -3199,7 +3202,7 @@ - + @@ -3208,7 +3211,7 @@ - + @@ -3217,7 +3220,7 @@ - + @@ -3226,7 +3229,7 @@ - + @@ -5274,24 +5277,36 @@ + + + + + + + + + + + + @@ -6003,18 +6018,27 @@ + + + + + + + + + @@ -6048,18 +6072,27 @@ + + + + + + + + + From 36ce7eac5a6ae47937b38f4ba53d0a7f87b4ce22 Mon Sep 17 00:00:00 2001 From: meyer Date: Tue, 14 Nov 2017 09:40:32 -0800 Subject: [PATCH 17/26] =?UTF-8?q?Update=20JSX=20intrinsic=20element=20test?= =?UTF-8?q?=20to=20match=20babel=E2=80=99s=20(#19946)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update JSX intrinsic element test to match babel’s * Update baseline * Move regex out of isIntrinsicJsxName * Switch to non-regex intrinsic name test --- src/compiler/utilities.ts | 6 ++--- .../doubleUnderscoreReactNamespace.js | 13 ++++------ .../doubleUnderscoreReactNamespace.symbols | 24 +++++++------------ .../doubleUnderscoreReactNamespace.types | 20 +++++----------- .../reference/jsxEsprimaFbTestSuite.symbols | 4 ++-- .../reference/jsxFactoryIdentifier.js | 3 ++- .../reference/jsxFactoryIdentifier.symbols | 1 + .../reference/jsxFactoryIdentifier.types | 1 + .../reference/reactNamespaceJSXEmit.js | 3 +++ .../reference/reactNamespaceJSXEmit.symbols | 21 ++++++++++------ .../reference/reactNamespaceJSXEmit.types | 8 +++++++ .../doubleUnderscoreReactNamespace.ts | 10 +++----- tests/cases/compiler/jsxFactoryIdentifier.ts | 22 ++++++++--------- .../cases/compiler/reactNamespaceJSXEmit.tsx | 2 ++ 14 files changed, 68 insertions(+), 70 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e67635cba04..e488cdcc601 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2434,10 +2434,8 @@ namespace ts { } export function isIntrinsicJsxName(name: __String | string) { - // An escaped identifier had a leading underscore prior to being escaped, which would return true - // The escape adds an extra underscore which does not change the result - const ch = (name as string).substr(0, 1); - return ch.toLowerCase() === ch; + const ch = (name as string).charCodeAt(0); + return (ch >= CharacterCodes.a && ch <= CharacterCodes.z) || (name as string).indexOf("-") > -1; } function get16BitUnicodeEscapeSequence(charCode: number): string { diff --git a/tests/baselines/reference/doubleUnderscoreReactNamespace.js b/tests/baselines/reference/doubleUnderscoreReactNamespace.js index de2997d53a6..376a75d0e72 100644 --- a/tests/baselines/reference/doubleUnderscoreReactNamespace.js +++ b/tests/baselines/reference/doubleUnderscoreReactNamespace.js @@ -1,19 +1,16 @@ //// [index.tsx] declare global { - namespace JSX { - interface IntrinsicElements { - __foot: any; - } - } function __make (params: object): any; } +declare var __foot: any; -const thing = <__foot>; +const thing = <__foot />; -export {} +export {} + //// [index.js] "use strict"; exports.__esModule = true; -var thing = __make("__foot", null); +var thing = __make(__foot, null); diff --git a/tests/baselines/reference/doubleUnderscoreReactNamespace.symbols b/tests/baselines/reference/doubleUnderscoreReactNamespace.symbols index 3f942c5f69d..055fb7361e6 100644 --- a/tests/baselines/reference/doubleUnderscoreReactNamespace.symbols +++ b/tests/baselines/reference/doubleUnderscoreReactNamespace.symbols @@ -2,25 +2,17 @@ declare global { >global : Symbol(global, Decl(index.tsx, 0, 0)) - namespace JSX { ->JSX : Symbol(JSX, Decl(index.tsx, 0, 16)) - - interface IntrinsicElements { ->IntrinsicElements : Symbol(IntrinsicElements, Decl(index.tsx, 1, 19)) - - __foot: any; ->__foot : Symbol(IntrinsicElements.__foot, Decl(index.tsx, 2, 37)) - } - } function __make (params: object): any; ->__make : Symbol(__make, Decl(index.tsx, 5, 5)) ->params : Symbol(params, Decl(index.tsx, 6, 21)) +>__make : Symbol(__make, Decl(index.tsx, 0, 16)) +>params : Symbol(params, Decl(index.tsx, 1, 21)) } +declare var __foot: any; +>__foot : Symbol(__foot, Decl(index.tsx, 4, 11)) -const thing = <__foot>; ->thing : Symbol(thing, Decl(index.tsx, 10, 5)) ->__foot : Symbol(JSX.IntrinsicElements.__foot, Decl(index.tsx, 2, 37)) ->__foot : Symbol(JSX.IntrinsicElements.__foot, Decl(index.tsx, 2, 37)) +const thing = <__foot />; +>thing : Symbol(thing, Decl(index.tsx, 6, 5)) +>__foot : Symbol(__foot, Decl(index.tsx, 4, 11)) export {} + diff --git a/tests/baselines/reference/doubleUnderscoreReactNamespace.types b/tests/baselines/reference/doubleUnderscoreReactNamespace.types index 6a9b6d4c984..04382944d86 100644 --- a/tests/baselines/reference/doubleUnderscoreReactNamespace.types +++ b/tests/baselines/reference/doubleUnderscoreReactNamespace.types @@ -2,26 +2,18 @@ declare global { >global : typeof global - namespace JSX { ->JSX : any - - interface IntrinsicElements { ->IntrinsicElements : IntrinsicElements - - __foot: any; ->__foot : any - } - } function __make (params: object): any; >__make : (params: object) => any >params : object } - -const thing = <__foot>; ->thing : any -><__foot> : any +declare var __foot: any; >__foot : any + +const thing = <__foot />; +>thing : any +><__foot /> : any >__foot : any export {} + diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols b/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols index f8f3dfa28dc..969071e4350 100644 --- a/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols @@ -47,8 +47,8 @@ declare var props; />; <日本語>; ->日本語 : Symbol(unknown) ->日本語 : Symbol(unknown) +>日本語 : Symbol(日本語, Decl(jsxEsprimaFbTestSuite.tsx, 1, 11)) +>日本語 : Symbol(日本語, Decl(jsxEsprimaFbTestSuite.tsx, 1, 11)) AbC_def : Symbol(AbC_def, Decl(jsxEsprimaFbTestSuite.tsx, 2, 11)) diff --git a/tests/baselines/reference/jsxFactoryIdentifier.js b/tests/baselines/reference/jsxFactoryIdentifier.js index 3a3c360a8f1..817ef769d53 100644 --- a/tests/baselines/reference/jsxFactoryIdentifier.js +++ b/tests/baselines/reference/jsxFactoryIdentifier.js @@ -47,7 +47,8 @@ class A { ]; } -} +} + //// [Element.js] "use strict"; diff --git a/tests/baselines/reference/jsxFactoryIdentifier.symbols b/tests/baselines/reference/jsxFactoryIdentifier.symbols index b66976f8884..7c8ad0c97cf 100644 --- a/tests/baselines/reference/jsxFactoryIdentifier.symbols +++ b/tests/baselines/reference/jsxFactoryIdentifier.symbols @@ -122,3 +122,4 @@ class A { ]; } } + diff --git a/tests/baselines/reference/jsxFactoryIdentifier.types b/tests/baselines/reference/jsxFactoryIdentifier.types index 76f49568531..f6faa0784cd 100644 --- a/tests/baselines/reference/jsxFactoryIdentifier.types +++ b/tests/baselines/reference/jsxFactoryIdentifier.types @@ -137,3 +137,4 @@ class A { ]; } } + diff --git a/tests/baselines/reference/reactNamespaceJSXEmit.js b/tests/baselines/reference/reactNamespaceJSXEmit.js index fc30f7f7bfa..3feaea15b01 100644 --- a/tests/baselines/reference/reactNamespaceJSXEmit.js +++ b/tests/baselines/reference/reactNamespaceJSXEmit.js @@ -2,6 +2,7 @@ declare var myReactLib: any; declare var foo: any; declare var Bar: any; +declare var _Bar: any; declare var x: any; ; @@ -9,6 +10,7 @@ declare var x: any; ; ; ; +<_Bar { ...x } />; //// [reactNamespaceJSXEmit.js] @@ -25,3 +27,4 @@ myReactLib.createElement(Bar, { x: x }); myReactLib.createElement("x-component", null); myReactLib.createElement(Bar, __assign({}, x)); myReactLib.createElement(Bar, __assign({}, x, { y: 2 })); +myReactLib.createElement(_Bar, __assign({}, x)); diff --git a/tests/baselines/reference/reactNamespaceJSXEmit.symbols b/tests/baselines/reference/reactNamespaceJSXEmit.symbols index b8e58fb1702..ff52f0bff87 100644 --- a/tests/baselines/reference/reactNamespaceJSXEmit.symbols +++ b/tests/baselines/reference/reactNamespaceJSXEmit.symbols @@ -8,27 +8,34 @@ declare var foo: any; declare var Bar: any; >Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 2, 11)) +declare var _Bar: any; +>_Bar : Symbol(_Bar, Decl(reactNamespaceJSXEmit.tsx, 3, 11)) + declare var x: any; ->x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 3, 11)) +>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11)) ; >foo : Symbol(unknown) ->data : Symbol(data, Decl(reactNamespaceJSXEmit.tsx, 5, 4)) +>data : Symbol(data, Decl(reactNamespaceJSXEmit.tsx, 6, 4)) ; >Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 2, 11)) ->x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 6, 4)) ->x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 3, 11)) +>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 7, 4)) +>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11)) ; >x-component : Symbol(unknown) ; >Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 2, 11)) ->x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 3, 11)) +>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11)) ; >Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 2, 11)) ->x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 3, 11)) ->y : Symbol(y, Decl(reactNamespaceJSXEmit.tsx, 9, 13)) +>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11)) +>y : Symbol(y, Decl(reactNamespaceJSXEmit.tsx, 10, 13)) + +<_Bar { ...x } />; +>_Bar : Symbol(_Bar, Decl(reactNamespaceJSXEmit.tsx, 3, 11)) +>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11)) diff --git a/tests/baselines/reference/reactNamespaceJSXEmit.types b/tests/baselines/reference/reactNamespaceJSXEmit.types index 0c1200b362b..e1d76dbfcec 100644 --- a/tests/baselines/reference/reactNamespaceJSXEmit.types +++ b/tests/baselines/reference/reactNamespaceJSXEmit.types @@ -8,6 +8,9 @@ declare var foo: any; declare var Bar: any; >Bar : any +declare var _Bar: any; +>_Bar : any + declare var x: any; >x : any @@ -38,3 +41,8 @@ declare var x: any; >y : number >2 : 2 +<_Bar { ...x } />; +><_Bar { ...x } /> : any +>_Bar : any +>x : any + diff --git a/tests/cases/compiler/doubleUnderscoreReactNamespace.ts b/tests/cases/compiler/doubleUnderscoreReactNamespace.ts index bd7789ab1d9..0b718b48e2b 100644 --- a/tests/cases/compiler/doubleUnderscoreReactNamespace.ts +++ b/tests/cases/compiler/doubleUnderscoreReactNamespace.ts @@ -4,15 +4,11 @@ // @filename: index.tsx declare global { - namespace JSX { - interface IntrinsicElements { - __foot: any; - } - } function __make (params: object): any; } +declare var __foot: any; -const thing = <__foot>; +const thing = <__foot />; -export {} \ No newline at end of file +export {} diff --git a/tests/cases/compiler/jsxFactoryIdentifier.ts b/tests/cases/compiler/jsxFactoryIdentifier.ts index 88caf27482e..0ea5c7e850d 100644 --- a/tests/cases/compiler/jsxFactoryIdentifier.ts +++ b/tests/cases/compiler/jsxFactoryIdentifier.ts @@ -1,10 +1,10 @@ -//@jsx: react -//@target: es6 -//@module: commonjs -//@jsxFactory: createElement -//@sourcemap: true - -// @filename: Element.ts +//@jsx: react +//@target: es6 +//@module: commonjs +//@jsxFactory: createElement +//@sourcemap: true + +// @filename: Element.ts declare namespace JSX { interface Element { name: string; @@ -33,9 +33,9 @@ export let createElement = Element.createElement; function toCamelCase(text: string): string { return text[0].toLowerCase() + text.substring(1); -} - -// @filename: test.tsx +} + +// @filename: test.tsx import { Element} from './Element'; let createElement = Element.createElement; let c: { @@ -51,4 +51,4 @@ class A { ]; } -} \ No newline at end of file +} diff --git a/tests/cases/compiler/reactNamespaceJSXEmit.tsx b/tests/cases/compiler/reactNamespaceJSXEmit.tsx index f5ec957a78b..0d11789a275 100644 --- a/tests/cases/compiler/reactNamespaceJSXEmit.tsx +++ b/tests/cases/compiler/reactNamespaceJSXEmit.tsx @@ -4,6 +4,7 @@ declare var myReactLib: any; declare var foo: any; declare var Bar: any; +declare var _Bar: any; declare var x: any; ; @@ -11,3 +12,4 @@ declare var x: any; ; ; ; +<_Bar { ...x } />; From 9c51a8534e1578893c6e5b8e97a0e75b3e970626 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 14 Nov 2017 14:20:18 -0800 Subject: [PATCH 18/26] Synchronize getEntityNameForDecoratorMetadata and serializeUnionOrIntersectionType (#19879) --- src/compiler/checker.ts | 11 +++- .../reference/metadataOfClassFromAlias.js | 1 + .../metadataReferencedWithinFilteredUnion.js | 60 +++++++++++++++++++ ...adataReferencedWithinFilteredUnion.symbols | 28 +++++++++ ...etadataReferencedWithinFilteredUnion.types | 28 +++++++++ .../metadataReferencedWithinFilteredUnion.ts | 18 ++++++ 6 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/metadataReferencedWithinFilteredUnion.js create mode 100644 tests/baselines/reference/metadataReferencedWithinFilteredUnion.symbols create mode 100644 tests/baselines/reference/metadataReferencedWithinFilteredUnion.types create mode 100644 tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0ae9486aa4e..6edce1036cb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -20191,7 +20191,16 @@ namespace ts { case SyntaxKind.IntersectionType: case SyntaxKind.UnionType: let commonEntityName: EntityName; - for (const typeNode of (node).types) { + for (let typeNode of (node).types) { + while (typeNode.kind === SyntaxKind.ParenthesizedType) { + typeNode = (typeNode as ParenthesizedTypeNode).type; // Skip parens if need be + } + if (typeNode.kind === SyntaxKind.NeverKeyword) { + continue; // Always elide `never` from the union/intersection if possible + } + if (!strictNullChecks && (typeNode.kind === SyntaxKind.NullKeyword || typeNode.kind === SyntaxKind.UndefinedKeyword)) { + continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks + } const individualEntityName = getEntityNameForDecoratorMetadata(typeNode); if (!individualEntityName) { // Individual is something like string number diff --git a/tests/baselines/reference/metadataOfClassFromAlias.js b/tests/baselines/reference/metadataOfClassFromAlias.js index 77ae5c33898..1a8b6b8523c 100644 --- a/tests/baselines/reference/metadataOfClassFromAlias.js +++ b/tests/baselines/reference/metadataOfClassFromAlias.js @@ -35,6 +35,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); +var auxiliry_1 = require("./auxiliry"); function annotation() { return function (target) { }; } diff --git a/tests/baselines/reference/metadataReferencedWithinFilteredUnion.js b/tests/baselines/reference/metadataReferencedWithinFilteredUnion.js new file mode 100644 index 00000000000..6192ac3c0fd --- /dev/null +++ b/tests/baselines/reference/metadataReferencedWithinFilteredUnion.js @@ -0,0 +1,60 @@ +//// [tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts] //// + +//// [Class1.ts] +export class Class1 { +} +//// [Class2.ts] +import { Class1 } from './Class1'; + +function decorate(target: any, propertyKey: string) { +} + +export class Class2 { + @decorate + get prop(): Class1 | undefined { + return undefined; + } +} + +//// [Class1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Class1 = /** @class */ (function () { + function Class1() { + } + return Class1; +}()); +exports.Class1 = Class1; +//// [Class2.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var Class1_1 = require("./Class1"); +function decorate(target, propertyKey) { +} +var Class2 = /** @class */ (function () { + function Class2() { + } + Object.defineProperty(Class2.prototype, "prop", { + get: function () { + return undefined; + }, + enumerable: true, + configurable: true + }); + __decorate([ + decorate, + __metadata("design:type", Class1_1.Class1), + __metadata("design:paramtypes", []) + ], Class2.prototype, "prop", null); + return Class2; +}()); +exports.Class2 = Class2; diff --git a/tests/baselines/reference/metadataReferencedWithinFilteredUnion.symbols b/tests/baselines/reference/metadataReferencedWithinFilteredUnion.symbols new file mode 100644 index 00000000000..22a198daeca --- /dev/null +++ b/tests/baselines/reference/metadataReferencedWithinFilteredUnion.symbols @@ -0,0 +1,28 @@ +=== tests/cases/compiler/Class1.ts === +export class Class1 { +>Class1 : Symbol(Class1, Decl(Class1.ts, 0, 0)) +} +=== tests/cases/compiler/Class2.ts === +import { Class1 } from './Class1'; +>Class1 : Symbol(Class1, Decl(Class2.ts, 0, 8)) + +function decorate(target: any, propertyKey: string) { +>decorate : Symbol(decorate, Decl(Class2.ts, 0, 34)) +>target : Symbol(target, Decl(Class2.ts, 2, 18)) +>propertyKey : Symbol(propertyKey, Decl(Class2.ts, 2, 30)) +} + +export class Class2 { +>Class2 : Symbol(Class2, Decl(Class2.ts, 3, 1)) + + @decorate +>decorate : Symbol(decorate, Decl(Class2.ts, 0, 34)) + + get prop(): Class1 | undefined { +>prop : Symbol(Class2.prop, Decl(Class2.ts, 5, 21)) +>Class1 : Symbol(Class1, Decl(Class2.ts, 0, 8)) + + return undefined; +>undefined : Symbol(undefined) + } +} diff --git a/tests/baselines/reference/metadataReferencedWithinFilteredUnion.types b/tests/baselines/reference/metadataReferencedWithinFilteredUnion.types new file mode 100644 index 00000000000..834d490d951 --- /dev/null +++ b/tests/baselines/reference/metadataReferencedWithinFilteredUnion.types @@ -0,0 +1,28 @@ +=== tests/cases/compiler/Class1.ts === +export class Class1 { +>Class1 : Class1 +} +=== tests/cases/compiler/Class2.ts === +import { Class1 } from './Class1'; +>Class1 : typeof Class1 + +function decorate(target: any, propertyKey: string) { +>decorate : (target: any, propertyKey: string) => void +>target : any +>propertyKey : string +} + +export class Class2 { +>Class2 : Class2 + + @decorate +>decorate : (target: any, propertyKey: string) => void + + get prop(): Class1 | undefined { +>prop : Class1 +>Class1 : Class1 + + return undefined; +>undefined : undefined + } +} diff --git a/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts b/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts new file mode 100644 index 00000000000..6fd19622f88 --- /dev/null +++ b/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts @@ -0,0 +1,18 @@ +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @target: es5 +// @filename: Class1.ts +export class Class1 { +} +// @filename: Class2.ts +import { Class1 } from './Class1'; + +function decorate(target: any, propertyKey: string) { +} + +export class Class2 { + @decorate + get prop(): Class1 | undefined { + return undefined; + } +} \ No newline at end of file From 592ee00906557ed313f7692fe6662251e65f915d Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 14 Nov 2017 14:26:49 -0800 Subject: [PATCH 19/26] Have CompletionEntryDetails source use a relative path (#19917) * Have CompletionEntryDetails source use a relative path * Use getCanonicalFileName from services Instead of creating a new one --- src/compiler/builder.ts | 2 +- src/compiler/commandLineParser.ts | 10 ++++----- src/compiler/core.ts | 5 +++-- src/compiler/program.ts | 2 +- src/harness/fourslash.ts | 18 ++++++++++++---- src/services/codefixes/importFixes.ts | 10 ++++----- src/services/completions.ts | 21 ++++++++++++------- src/services/rename.ts | 2 +- src/services/services.ts | 5 +++-- ...letionsImport_default_addToNamedImports.ts | 5 ++++- ...ionsImport_default_addToNamespaceImport.ts | 5 ++++- ...Import_default_alreadyExistedWithRename.ts | 5 ++++- .../completionsImport_default_anonymous.ts | 8 +++++-- ...letionsImport_default_didNotExistBefore.ts | 5 ++++- .../fourslash/completionsImport_matching.ts | 2 +- .../completionsImport_multipleWithSameName.ts | 6 +++--- ...mpletionsImport_named_addToNamedImports.ts | 5 ++++- ...mpletionsImport_named_didNotExistBefore.ts | 4 ++-- ...tionsImport_named_namespaceImportExists.ts | 5 ++++- .../fourslash/completionsImport_ofAlias.ts | 2 +- ...pletionsImport_previousTokenIsSemicolon.ts | 5 ++++- .../fourslash/completionsImport_require.ts | 10 +++++++-- .../completionsImport_shadowedByLocal.ts | 2 +- tests/cases/fourslash/fourslash.ts | 2 +- 24 files changed, 97 insertions(+), 49 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 635855083c0..34ca1bdf0e9 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -77,7 +77,7 @@ namespace ts { } export interface BuilderOptions { - getCanonicalFileName: (fileName: string) => string; + getCanonicalFileName: GetCanonicalFileName; computeHash: (data: string) => string; } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 43ea77c8020..8cec21113c8 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1540,7 +1540,7 @@ namespace ts { host: ParseConfigHost, basePath: string, configFileName: string, - getCanonicalFileName: (fileName: string) => string, + getCanonicalFileName: GetCanonicalFileName, resolutionStack: Path[], errors: Push, ): ParsedTsconfig { @@ -1588,7 +1588,7 @@ namespace ts { json: any, host: ParseConfigHost, basePath: string, - getCanonicalFileName: (fileName: string) => string, + getCanonicalFileName: GetCanonicalFileName, configFileName: string | undefined, errors: Push ): ParsedTsconfig { @@ -1619,7 +1619,7 @@ namespace ts { sourceFile: JsonSourceFile, host: ParseConfigHost, basePath: string, - getCanonicalFileName: (fileName: string) => string, + getCanonicalFileName: GetCanonicalFileName, configFileName: string | undefined, errors: Push ): ParsedTsconfig { @@ -1688,7 +1688,7 @@ namespace ts { extendedConfig: string, host: ParseConfigHost, basePath: string, - getCanonicalFileName: (fileName: string) => string, + getCanonicalFileName: GetCanonicalFileName, errors: Push, createDiagnostic: (message: DiagnosticMessage, arg1?: string) => Diagnostic) { extendedConfig = normalizeSlashes(extendedConfig); @@ -1713,7 +1713,7 @@ namespace ts { extendedConfigPath: Path, host: ts.ParseConfigHost, basePath: string, - getCanonicalFileName: (fileName: string) => string, + getCanonicalFileName: GetCanonicalFileName, resolutionStack: Path[], errors: Push, ): ParsedTsconfig | undefined { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index f3dd99ee5bf..9f839923e7d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2033,7 +2033,7 @@ namespace ts { } } - export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean) { + export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: GetCanonicalFileName, isAbsolutePathAnUrl: boolean) { const pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); const directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { @@ -2819,7 +2819,8 @@ namespace ts { } } - export function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): (fileName: string) => string { + export type GetCanonicalFileName = (fileName: string) => string; + export function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): GetCanonicalFileName { return useCaseSensitiveFileNames ? ((fileName) => fileName) : ((fileName) => fileName.toLowerCase()); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index cf7c03556f1..6a8c88c3014 100755 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -20,7 +20,7 @@ namespace ts { } /* @internal */ - export function computeCommonSourceDirectoryOfFilenames(fileNames: string[], currentDirectory: string, getCanonicalFileName: (fileName: string) => string): string { + export function computeCommonSourceDirectoryOfFilenames(fileNames: string[], currentDirectory: string, getCanonicalFileName: GetCanonicalFileName): string { let commonPathComponents: string[]; const failed = forEach(fileNames, sourceFile => { // Each file contributes into common source file path diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 2687a660ca8..6f08b900ec3 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -867,10 +867,10 @@ namespace FourSlash { }); } - public verifyCompletionListContains(entryId: ts.Completions.CompletionEntryIdentifier, text?: string, documentation?: string, kind?: string, spanIndex?: number, hasAction?: boolean, options?: ts.GetCompletionsAtPositionOptions) { + public verifyCompletionListContains(entryId: ts.Completions.CompletionEntryIdentifier, text?: string, documentation?: string, kind?: string, spanIndex?: number, hasAction?: boolean, options?: FourSlashInterface.VerifyCompletionListContainsOptions) { const completions = this.getCompletionListAtCaret(options); if (completions) { - this.assertItemInCompletionList(completions.entries, entryId, text, documentation, kind, spanIndex, hasAction); + this.assertItemInCompletionList(completions.entries, entryId, text, documentation, kind, spanIndex, hasAction, options); } else { this.raiseError(`No completions at position '${this.currentCaretPosition}' when looking for '${JSON.stringify(entryId)}'.`); @@ -3071,6 +3071,7 @@ Actual: ${stringify(fullActual)}`); kind: string | undefined, spanIndex: number | undefined, hasAction: boolean | undefined, + options: FourSlashInterface.VerifyCompletionListContainsOptions | undefined, ) { for (const item of items) { if (item.name === entryId.name && item.source === entryId.source) { @@ -3084,7 +3085,12 @@ Actual: ${stringify(fullActual)}`); assert.equal(ts.displayPartsToString(details.displayParts), text, this.assertionMessageAtLastKnownMarker("completion item detail text for " + entryId)); } - assert.deepEqual(details.source, entryId.source === undefined ? undefined : [ts.textPart(entryId.source)]); + if (entryId.source === undefined) { + assert.equal(options && options.sourceDisplay, undefined); + } + else { + assert.deepEqual(details.source, [ts.textPart(options!.sourceDisplay)]); + } } if (kind !== undefined) { @@ -3811,7 +3817,7 @@ namespace FourSlashInterface { // Verifies the completion list contains the specified symbol. The // completion list is brought up if necessary - public completionListContains(entryId: string | ts.Completions.CompletionEntryIdentifier, text?: string, documentation?: string, kind?: string, spanIndex?: number, hasAction?: boolean, options?: ts.GetCompletionsAtPositionOptions) { + public completionListContains(entryId: string | ts.Completions.CompletionEntryIdentifier, text?: string, documentation?: string, kind?: string, spanIndex?: number, hasAction?: boolean, options?: VerifyCompletionListContainsOptions) { if (typeof entryId === "string") { entryId = { name: entryId, source: undefined }; } @@ -4547,6 +4553,10 @@ namespace FourSlashInterface { isNewIdentifierLocation?: boolean; } + export interface VerifyCompletionListContainsOptions extends ts.GetCompletionsAtPositionOptions { + sourceDisplay: string; + } + export interface NewContentOptions { // Exactly one of these should be defined. newFileContent?: string; diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 838e19fa35d..8971d1aa75e 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -34,7 +34,7 @@ namespace ts.codefix { host: LanguageServiceHost; checker: TypeChecker; compilerOptions: CompilerOptions; - getCanonicalFileName(fileName: string): string; + getCanonicalFileName: GetCanonicalFileName; cachedImportDeclarations?: ImportDeclarationMap; } @@ -313,7 +313,7 @@ namespace ts.codefix { } } - function getModuleSpecifierForNewImport(sourceFile: SourceFile, moduleSymbol: Symbol, options: CompilerOptions, getCanonicalFileName: (file: string) => string, host: LanguageServiceHost): string | undefined { + export function getModuleSpecifierForNewImport(sourceFile: SourceFile, moduleSymbol: Symbol, options: CompilerOptions, getCanonicalFileName: (file: string) => string, host: LanguageServiceHost): string | undefined { const moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; const sourceDirectory = getDirectoryPath(sourceFile.fileName); @@ -523,7 +523,7 @@ namespace ts.codefix { return state > States.NodeModules ? { topLevelNodeModulesIndex, topLevelPackageNameIndex, packageRootIndex, fileNameIndex } : undefined; } - function getPathRelativeToRootDirs(path: string, rootDirs: ReadonlyArray, getCanonicalFileName: (fileName: string) => string): string | undefined { + function getPathRelativeToRootDirs(path: string, rootDirs: ReadonlyArray, getCanonicalFileName: GetCanonicalFileName): string | undefined { return firstDefined(rootDirs, rootDir => getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName)); } @@ -535,12 +535,12 @@ namespace ts.codefix { return fileName; } - function getRelativePathIfInDirectory(path: string, directoryPath: string, getCanonicalFileName: (fileName: string) => string): string | undefined { + function getRelativePathIfInDirectory(path: string, directoryPath: string, getCanonicalFileName: GetCanonicalFileName): string | undefined { const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); return isRootedDiskPath(relativePath) || startsWith(relativePath, "..") ? undefined : relativePath; } - function getRelativePath(path: string, directoryPath: string, getCanonicalFileName: (fileName: string) => string) { + function getRelativePath(path: string, directoryPath: string, getCanonicalFileName: GetCanonicalFileName) { const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); return !pathIsRelative(relativePath) ? "./" + relativePath : relativePath; } diff --git a/src/services/completions.ts b/src/services/completions.ts index 6a9af1e1941..423919f5353 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -422,8 +422,9 @@ namespace ts.Completions { allSourceFiles: ReadonlyArray, host: LanguageServiceHost, formatContext: formatting.FormatContext, + getCanonicalFileName: GetCanonicalFileName, ): CompletionEntryDetails { - const { name, source } = entryId; + const { name } = entryId; // Compute all the completion symbols again. const symbolCompletion = getSymbolCompletionFromEntryId(typeChecker, log, compilerOptions, sourceFile, position, entryId, allSourceFiles); switch (symbolCompletion.type) { @@ -442,10 +443,10 @@ namespace ts.Completions { } case "symbol": { const { symbol, location, symbolToOriginInfoMap } = symbolCompletion; - const codeActions = getCompletionEntryCodeActions(symbolToOriginInfoMap, symbol, typeChecker, host, compilerOptions, sourceFile, formatContext); + const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, typeChecker, host, compilerOptions, sourceFile, formatContext, getCanonicalFileName); const kindModifiers = SymbolDisplay.getSymbolModifiers(symbol); const { displayParts, documentation, symbolKind, tags } = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location, location, SemanticMeaning.All); - return { name, kindModifiers, kind: symbolKind, displayParts, documentation, tags, codeActions, source: source === undefined ? undefined : [textPart(source)] }; + return { name, kindModifiers, kind: symbolKind, displayParts, documentation, tags, codeActions, source: sourceDisplay }; } case "none": { // Didn't find a symbol with this name. See if we can find a keyword instead. @@ -466,7 +467,7 @@ namespace ts.Completions { } } - function getCompletionEntryCodeActions( + function getCompletionEntryCodeActionsAndSourceDisplay( symbolToOriginInfoMap: SymbolOriginInfoMap, symbol: Symbol, checker: TypeChecker, @@ -474,14 +475,17 @@ namespace ts.Completions { compilerOptions: CompilerOptions, sourceFile: SourceFile, formatContext: formatting.FormatContext, - ): CodeAction[] | undefined { + getCanonicalFileName: GetCanonicalFileName, + ): { codeActions: CodeAction[] | undefined, sourceDisplay: SymbolDisplayPart[] | undefined } { const symbolOriginInfo = symbolToOriginInfoMap[getSymbolId(symbol)]; if (!symbolOriginInfo) { - return undefined; + return { codeActions: undefined, sourceDisplay: undefined }; } const { moduleSymbol, isDefaultExport } = symbolOriginInfo; - return codefix.getCodeActionForImport(moduleSymbol, { + + const sourceDisplay = [textPart(codefix.getModuleSpecifierForNewImport(sourceFile, moduleSymbol, compilerOptions, getCanonicalFileName, host))]; + const codeActions = codefix.getCodeActionForImport(moduleSymbol, { host, checker, newLineCharacter: host.getNewLine(), @@ -489,10 +493,11 @@ namespace ts.Completions { sourceFile, formatContext, symbolName: getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), - getCanonicalFileName: createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : false), + getCanonicalFileName, symbolToken: undefined, kind: isDefaultExport ? codefix.ImportKind.Default : codefix.ImportKind.Named, }); + return { sourceDisplay, codeActions }; } export function getCompletionEntrySymbol( diff --git a/src/services/rename.ts b/src/services/rename.ts index 8411e8200a3..cfe79679fba 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -1,6 +1,6 @@ /* @internal */ namespace ts.Rename { - export function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string, sourceFile: SourceFile, position: number): RenameInfo { + export function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: GetCanonicalFileName, sourceFile: SourceFile, position: number): RenameInfo { const getCanonicalDefaultLibName = memoize(() => getCanonicalFileName(ts.normalizePath(defaultLibFileName))); const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); const renameInfo = node && nodeIsEligibleForRename(node) diff --git a/src/services/services.ts b/src/services/services.ts index 95e23a708a3..8fcd7ef13b8 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -938,7 +938,7 @@ namespace ts { private _compilationSettings: CompilerOptions; private currentDirectory: string; - constructor(private host: LanguageServiceHost, getCanonicalFileName: (fileName: string) => string) { + constructor(private host: LanguageServiceHost, getCanonicalFileName: GetCanonicalFileName) { // script id => script index this.currentDirectory = host.getCurrentDirectory(); this.fileNameToEntry = createMap(); @@ -1447,7 +1447,8 @@ namespace ts { { name, source }, program.getSourceFiles(), host, - formattingOptions && formatting.getFormatContext(formattingOptions)); + formattingOptions && formatting.getFormatContext(formattingOptions), + getCanonicalFileName); } function getCompletionEntrySymbol(fileName: string, position: number, name: string, source?: string): Symbol { diff --git a/tests/cases/fourslash/completionsImport_default_addToNamedImports.ts b/tests/cases/fourslash/completionsImport_default_addToNamedImports.ts index 7a7a220ca77..fb561355c36 100644 --- a/tests/cases/fourslash/completionsImport_default_addToNamedImports.ts +++ b/tests/cases/fourslash/completionsImport_default_addToNamedImports.ts @@ -9,7 +9,10 @@ ////f/**/; goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_default_addToNamespaceImport.ts b/tests/cases/fourslash/completionsImport_default_addToNamespaceImport.ts index 43e3854c5e3..986c2550572 100644 --- a/tests/cases/fourslash/completionsImport_default_addToNamespaceImport.ts +++ b/tests/cases/fourslash/completionsImport_default_addToNamespaceImport.ts @@ -8,7 +8,10 @@ ////f/**/; goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts b/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts index ed34d5e4e9c..d8cb53167f5 100644 --- a/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts +++ b/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts @@ -8,7 +8,10 @@ ////f/**/; goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_default_anonymous.ts b/tests/cases/fourslash/completionsImport_default_anonymous.ts index 7c0697584f9..4be0184d9fa 100644 --- a/tests/cases/fourslash/completionsImport_default_anonymous.ts +++ b/tests/cases/fourslash/completionsImport_default_anonymous.ts @@ -10,10 +10,14 @@ ////fooB/*1*/ goTo.marker("0"); -verify.not.completionListContains({ name: "default", source: "/src/foo-bar" }, undefined, undefined, undefined, undefined, undefined, { includeExternalModuleExports: true }); +const options = { + includeExternalModuleExports: true, + sourceDisplay: "./foo-bar", +}; +verify.not.completionListContains({ name: "default", source: "/src/foo-bar" }, undefined, undefined, undefined, undefined, undefined, options); goTo.marker("1"); -verify.completionListContains({ name: "fooBar", source: "/src/foo-bar" }, "(property) default: 0", "", "property", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "fooBar", source: "/src/foo-bar" }, "(property) default: 0", "", "property", /*spanIndex*/ undefined, /*hasAction*/ true, options); verify.applyCodeActionFromCompletion("1", { name: "fooBar", source: "/src/foo-bar", diff --git a/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts b/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts index 82b8e92a570..a36e4336e61 100644 --- a/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts +++ b/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts @@ -7,7 +7,10 @@ ////f/**/; goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_matching.ts b/tests/cases/fourslash/completionsImport_matching.ts index f5f9108fa6c..d8979e18bd9 100644 --- a/tests/cases/fourslash/completionsImport_matching.ts +++ b/tests/cases/fourslash/completionsImport_matching.ts @@ -14,7 +14,7 @@ goTo.marker(""); -const options = { includeExternalModuleExports: true }; +const options = { includeExternalModuleExports: true, sourceDisplay: "./a" }; verify.not.completionListContains({ name: "abcde", source: "/a" }, undefined, undefined, undefined, undefined, undefined, options); verify.not.completionListContains({ name: "dbf", source: "/a" }, undefined, undefined, undefined, undefined, undefined, options); diff --git a/tests/cases/fourslash/completionsImport_multipleWithSameName.ts b/tests/cases/fourslash/completionsImport_multipleWithSameName.ts index c9bb33d6c79..81a054e3d23 100644 --- a/tests/cases/fourslash/completionsImport_multipleWithSameName.ts +++ b/tests/cases/fourslash/completionsImport_multipleWithSameName.ts @@ -14,10 +14,10 @@ ////fo/**/ goTo.marker(""); -const options = { includeExternalModuleExports: true }; +const options = { includeExternalModuleExports: true, sourceDisplay: undefined }; verify.completionListContains("foo", "var foo: number", "", "var", undefined, undefined, options); -verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, options); -verify.completionListContains({ name: "foo", source: "/b" }, "const foo: 1", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, options); +verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { ...options, sourceDisplay: "./a" }); +verify.completionListContains({ name: "foo", source: "/b" }, "const foo: 1", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { ...options, sourceDisplay: "./b" }); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_named_addToNamedImports.ts b/tests/cases/fourslash/completionsImport_named_addToNamedImports.ts index b11552d0327..8c0beb058fb 100644 --- a/tests/cases/fourslash/completionsImport_named_addToNamedImports.ts +++ b/tests/cases/fourslash/completionsImport_named_addToNamedImports.ts @@ -9,7 +9,10 @@ ////f/**/; goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts b/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts index 9397ee004c2..c13fb27f16b 100644 --- a/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts +++ b/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts @@ -9,8 +9,8 @@ ////t/**/ goTo.marker(""); -const options = { includeExternalModuleExports: true }; -verify.completionListContains({ name: "Test1", source: "/a" }, "function Test1(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, options); +const options = { includeExternalModuleExports: true, sourceDisplay: undefined }; +verify.completionListContains({ name: "Test1", source: "/a" }, "function Test1(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { ...options, sourceDisplay: "./a" }); verify.completionListContains("Test2", "import Test2", "", "alias", /*spanIndex*/ undefined, /*hasAction*/ undefined, options); verify.not.completionListContains({ name: "Test2", source: "/a" }, undefined, undefined, undefined, undefined, undefined, options); diff --git a/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts b/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts index d4602795280..17b909b48ed 100644 --- a/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts +++ b/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts @@ -8,7 +8,10 @@ ////f/**/; goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_ofAlias.ts b/tests/cases/fourslash/completionsImport_ofAlias.ts index e7cdb366497..69c5041f94f 100644 --- a/tests/cases/fourslash/completionsImport_ofAlias.ts +++ b/tests/cases/fourslash/completionsImport_ofAlias.ts @@ -15,7 +15,7 @@ ////fo/**/ goTo.marker(""); -const options = { includeExternalModuleExports: true }; +const options = { includeExternalModuleExports: true, sourceDisplay: "./a" }; // TODO: https://github.com/Microsoft/TypeScript/issues/14003 verify.completionListContains({ name: "foo", source: "/a" }, "import foo", "", "alias", /*spanIndex*/ undefined, /*hasAction*/ true, options); verify.not.completionListContains({ name: "foo", source: "/a_reexport" }, undefined, undefined, undefined, undefined, undefined, options); diff --git a/tests/cases/fourslash/completionsImport_previousTokenIsSemicolon.ts b/tests/cases/fourslash/completionsImport_previousTokenIsSemicolon.ts index 93c2cc01b0b..06fb93283ee 100644 --- a/tests/cases/fourslash/completionsImport_previousTokenIsSemicolon.ts +++ b/tests/cases/fourslash/completionsImport_previousTokenIsSemicolon.ts @@ -8,4 +8,7 @@ /////**/ goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); diff --git a/tests/cases/fourslash/completionsImport_require.ts b/tests/cases/fourslash/completionsImport_require.ts index e0a6b00d462..8ec750d2c48 100644 --- a/tests/cases/fourslash/completionsImport_require.ts +++ b/tests/cases/fourslash/completionsImport_require.ts @@ -14,7 +14,10 @@ ////fo/*c*/ goTo.marker("b"); -verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("b", { name: "foo", @@ -28,7 +31,10 @@ fo`, }); goTo.marker("c"); -verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("c", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_shadowedByLocal.ts b/tests/cases/fourslash/completionsImport_shadowedByLocal.ts index 20e8c4a4bc8..622f21a2fc7 100644 --- a/tests/cases/fourslash/completionsImport_shadowedByLocal.ts +++ b/tests/cases/fourslash/completionsImport_shadowedByLocal.ts @@ -8,6 +8,6 @@ ////fo/**/ goTo.marker(""); -const options = { includeExternalModuleExports: true }; +const options = { includeExternalModuleExports: true, sourceDisplay: undefined }; verify.completionListContains("foo", "const foo: 1", "", "const", undefined, undefined, options); verify.not.completionListContains({ name: "foo", source: "/a" }, undefined, undefined, undefined, undefined, undefined, options); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index a0ee392a82e..f5984712648 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -148,7 +148,7 @@ declare namespace FourSlashInterface { kind?: string, spanIndex?: number, hasAction?: boolean, - options?: { includeExternalModuleExports: boolean }, + options?: { includeExternalModuleExports: boolean, sourceDisplay: string }, ): void; completionListItemsCountIsGreaterThan(count: number): void; completionListIsEmpty(): void; From 0c77b776ce23eac210f3ef094b055c210c15bf7c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 14 Nov 2017 16:06:48 -0800 Subject: [PATCH 20/26] Rename and inline functions --- src/compiler/checker.ts | 47 ++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4f261fbff2c..be57daf6fea 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5111,7 +5111,7 @@ namespace ts { * to "this" in its body, if all base types are interfaces, * and if none of the base interfaces have a "this" type. */ - function isInterfaceFreeOfThisReference(symbol: Symbol): boolean { + function isThislessInterface(symbol: Symbol): boolean { for (const declaration of symbol.declarations) { if (declaration.kind === SyntaxKind.InterfaceDeclaration) { if (declaration.flags & NodeFlags.ContainsThis) { @@ -5145,7 +5145,7 @@ namespace ts { // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === ObjectFlags.Class || !isInterfaceFreeOfThisReference(symbol)) { + if (outerTypeParameters || localTypeParameters || kind === ObjectFlags.Class || !isThislessInterface(symbol)) { type.objectFlags |= ObjectFlags.Reference; type.typeParameters = concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -5327,17 +5327,12 @@ namespace ts { return undefined; } - /** A type reference is free of this references if each type argument is free of this references. */ - function isTypeReferenceFreeOfThisReference(node: TypeReferenceNode): boolean { - return !node.typeArguments || node.typeArguments.every(isTypeFreeOfThisReference); - } - /** * A type is free of this references if it's the any, string, number, boolean, symbol, or void keyword, a string * literal type, an array with an element type that is free of this references, or a type reference that is * free of this references. */ - function isTypeFreeOfThisReference(node: TypeNode): boolean { + function isThislessType(node: TypeNode): boolean { switch (node.kind) { case SyntaxKind.AnyKeyword: case SyntaxKind.StringKeyword: @@ -5352,37 +5347,37 @@ namespace ts { case SyntaxKind.LiteralType: return true; case SyntaxKind.ArrayType: - return isTypeFreeOfThisReference((node).elementType); + return isThislessType((node).elementType); case SyntaxKind.TypeReference: - return isTypeReferenceFreeOfThisReference(node); + return !(node as TypeReferenceNode).typeArguments || (node as TypeReferenceNode).typeArguments.every(isThislessType); } return false; } - /** A type parameter is this-free if its contraint is this-free, or if it has no constraint. */ - function isTypeParameterFreeOfThisReference(node: TypeParameterDeclaration) { - return !node.constraint || isTypeFreeOfThisReference(node.constraint); + /** A type parameter is thisless if its contraint is thisless, or if it has no constraint. */ + function isThislessTypeParameter(node: TypeParameterDeclaration) { + return !node.constraint || isThislessType(node.constraint); } /** * A variable-like declaration is free of this references if it has a type annotation - * that is this-free, or if it has no type annotation and no initializer (and is thus of type any). + * that is thisless, or if it has no type annotation and no initializer (and is thus of type any). */ - function isVariableLikeDeclarationFreeOfThisReference(node: VariableLikeDeclaration): boolean { + function isThislessVariableLikeDeclaration(node: VariableLikeDeclaration): boolean { const typeNode = getEffectiveTypeAnnotationNode(node); - return typeNode ? isTypeFreeOfThisReference(typeNode) : !node.initializer; + return typeNode ? isThislessType(typeNode) : !node.initializer; } /** * A function-like declaration is considered free of `this` references if it has a return type - * annotation that is free of this references and if each parameter is this-free and if - * each type parameter (if present) is this-free. + * annotation that is free of this references and if each parameter is thisless and if + * each type parameter (if present) is thisless. */ - function isFunctionLikeDeclarationFreeOfThisReference(node: FunctionLikeDeclaration): boolean { + function isThislessFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { const returnType = getEffectiveReturnTypeNode(node); - return (node.kind === SyntaxKind.Constructor || (returnType && isTypeFreeOfThisReference(returnType))) && - node.parameters.every(isVariableLikeDeclarationFreeOfThisReference) && - (!node.typeParameters || node.typeParameters.every(isTypeParameterFreeOfThisReference)); + return (node.kind === SyntaxKind.Constructor || (returnType && isThislessType(returnType))) && + node.parameters.every(isThislessVariableLikeDeclaration) && + (!node.typeParameters || node.typeParameters.every(isThislessTypeParameter)); } /** @@ -5392,18 +5387,18 @@ namespace ts { * inferred from their initializers and function members with inferred return types are conservatively * assumed not to be free of "this" references. */ - function isFreeOfThisReference(symbol: Symbol): boolean { + function isThisless(symbol: Symbol): boolean { if (symbol.declarations && symbol.declarations.length === 1) { const declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: - return isVariableLikeDeclarationFreeOfThisReference(declaration); + return isThislessVariableLikeDeclaration(declaration); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.Constructor: - return isFunctionLikeDeclarationFreeOfThisReference(declaration); + return isThislessFunctionLikeDeclaration(declaration); } } } @@ -5415,7 +5410,7 @@ namespace ts { function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable { const result = createSymbolTable(); for (const symbol of symbols) { - result.set(symbol.escapedName, mappingThisOnly && isFreeOfThisReference(symbol) ? symbol : instantiateSymbol(symbol, mapper)); + result.set(symbol.escapedName, mappingThisOnly && isThisless(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } From fe75696e9dcaffe256e2b688d9bc3937257c262e Mon Sep 17 00:00:00 2001 From: csigs Date: Wed, 15 Nov 2017 11:10:25 +0000 Subject: [PATCH 21/26] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 80c5f4e15d2..bf004b18bc6 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1614,6 +1614,9 @@ + + + @@ -5274,24 +5277,36 @@ + + + + + + + + + + + + @@ -6003,18 +6018,27 @@ + + + + + + + + + @@ -6048,18 +6072,27 @@ + + + + + + + + + From b8c34a5b628c40027450ce419ff70598005f3468 Mon Sep 17 00:00:00 2001 From: csigs Date: Wed, 15 Nov 2017 17:10:09 +0000 Subject: [PATCH 22/26] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 33 +++++++++++++++++++ .../diagnosticMessages.generated.json.lcl | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 6ea7ba86fc7..2de627949fb 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1614,6 +1614,9 @@ + + + @@ -5274,24 +5277,36 @@ + + + + + + + + + + + + @@ -6003,18 +6018,27 @@ + + + + + + + + + @@ -6048,18 +6072,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index b71915fbd67..6d200bf7e3b 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1613,6 +1613,9 @@ + + + @@ -5273,24 +5276,36 @@ + + + + + + + + + + + + @@ -6002,18 +6017,27 @@ + + + + + + + + + @@ -6047,18 +6071,27 @@ + + + + + + + + + From d49491b3a71a4b561d9a6ecb7dc397d3beba3193 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 15 Nov 2017 11:08:51 -0800 Subject: [PATCH 23/26] smartIndenter: Don't indent after control-flow ending statements like `break;` (#20016) * smartIndenter: Don't indent after control-flow ending statements like `break;` * Fix bug * Fix bug for function after `return` --- src/services/formatting/smartIndenter.ts | 167 ++++++++++-------- src/services/utilities.ts | 1 + .../fourslash/smartIndentStatementSwitch.ts | 2 +- 3 files changed, 100 insertions(+), 70 deletions(-) diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 5afe4cb1d31..0a444a7280a 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -36,24 +36,7 @@ namespace ts.formatting { const enclosingCommentRange = getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true, precedingToken || null); // tslint:disable-line:no-null-keyword if (enclosingCommentRange) { - const previousLine = getLineAndCharacterOfPosition(sourceFile, position).line - 1; - const commentStartLine = getLineAndCharacterOfPosition(sourceFile, enclosingCommentRange.pos).line; - - Debug.assert(commentStartLine >= 0); - - if (previousLine <= commentStartLine) { - return findFirstNonWhitespaceColumn(getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options); - } - - const startPostionOfLine = getStartPositionOfLine(previousLine, sourceFile); - const { column, character } = findFirstNonWhitespaceCharacterAndColumn(startPostionOfLine, position, sourceFile, options); - - if (column === 0) { - return column; - } - - const firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPostionOfLine + character); - return firstNonWhitespaceCharacterCode === CharacterCodes.asterisk ? column - 1 : column; + return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -72,20 +55,7 @@ namespace ts.formatting { // for block indentation, we should look for a line which contains something that's not // whitespace. if (options.indentStyle === IndentStyle.Block) { - - // move backwards until we find a line with a non-whitespace character, - // then find the first non-whitespace character for that line. - let current = position; - while (current > 0) { - const char = sourceFile.text.charCodeAt(current); - if (!isWhiteSpaceLike(char)) { - break; - } - current--; - } - - const lineStart = ts.getLineStartPositionForPosition(current, sourceFile); - return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current, sourceFile, options); + return getBlockIndent(sourceFile, position, options); } if (precedingToken.kind === SyntaxKind.CommaToken && precedingToken.parent.kind !== SyntaxKind.BinaryExpression) { @@ -96,26 +66,60 @@ namespace ts.formatting { } } + return getSmartIndent(sourceFile, position, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options); + } + + function getCommentIndent(sourceFile: SourceFile, position: number, options: EditorSettings, enclosingCommentRange: CommentRange): number { + const previousLine = getLineAndCharacterOfPosition(sourceFile, position).line - 1; + const commentStartLine = getLineAndCharacterOfPosition(sourceFile, enclosingCommentRange.pos).line; + + Debug.assert(commentStartLine >= 0); + + if (previousLine <= commentStartLine) { + return findFirstNonWhitespaceColumn(getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options); + } + + const startPostionOfLine = getStartPositionOfLine(previousLine, sourceFile); + const { column, character } = findFirstNonWhitespaceCharacterAndColumn(startPostionOfLine, position, sourceFile, options); + + if (column === 0) { + return column; + } + + const firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPostionOfLine + character); + return firstNonWhitespaceCharacterCode === CharacterCodes.asterisk ? column - 1 : column; + } + + function getBlockIndent(sourceFile: SourceFile, position: number, options: EditorSettings): number { + // move backwards until we find a line with a non-whitespace character, + // then find the first non-whitespace character for that line. + let current = position; + while (current > 0) { + const char = sourceFile.text.charCodeAt(current); + if (!isWhiteSpaceLike(char)) { + break; + } + current--; + } + + const lineStart = ts.getLineStartPositionForPosition(current, sourceFile); + return findFirstNonWhitespaceColumn(lineStart, current, sourceFile, options); + } + + function getSmartIndent(sourceFile: SourceFile, position: number, precedingToken: Node, lineAtPosition: number, assumeNewLineBeforeCloseBrace: boolean, options: EditorSettings): number { // try to find node that can contribute to indentation and includes 'position' starting from 'precedingToken' // if such node is found - compute initial indentation for 'position' inside this node - let previous: Node; + let previous: Node | undefined; let current = precedingToken; - let currentStart: LineAndCharacter; - let indentationDelta: number; - while (current) { - if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) { - currentStart = getStartLineAndCharacterForNode(current, sourceFile); - + if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous, /*isNextChild*/ true)) { + const currentStart = getStartLineAndCharacterForNode(current, sourceFile); const nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); - if (nextTokenKind !== NextTokenKind.Unknown) { + const indentationDelta = nextTokenKind !== NextTokenKind.Unknown // handle cases when codefix is about to be inserted before the close brace - indentationDelta = assumeNewLineBeforeCloseBrace && nextTokenKind === NextTokenKind.CloseBrace ? options.indentSize : 0; - } - else { - indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; - } - break; + ? assumeNewLineBeforeCloseBrace && nextTokenKind === NextTokenKind.CloseBrace ? options.indentSize : 0 + : lineAtPosition !== currentStart.line ? options.indentSize : 0; + return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); } // check if current node is a list item - if yes, take indentation from it @@ -131,18 +135,13 @@ namespace ts.formatting { previous = current; current = current.parent; } - - if (!current) { - // no parent was found - return the base indentation of the SourceFile - return getBaseIndentation(options); - } - - return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); + // no parent was found - return the base indentation of the SourceFile + return getBaseIndentation(options); } export function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: EditorSettings): number { const start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); - return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options); + return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, /*isNextChild*/ false, options); } export function getBaseIndentation(options: EditorSettings) { @@ -155,11 +154,9 @@ namespace ts.formatting { ignoreActualIndentationRange: TextRange, indentationDelta: number, sourceFile: SourceFile, + isNextChild: boolean, options: EditorSettings): number { - - let parent: Node = current.parent; - let containingListOrParentStart: LineAndCharacter; - + let parent = current.parent!; // Walk up the tree and collect indentation for parent-child node pairs. Indentation is not added if // * parent and child nodes start on the same line, or // * parent is an IfStatement and child starts on the same line as an 'else clause'. @@ -178,7 +175,7 @@ namespace ts.formatting { } } - containingListOrParentStart = getContainingListOrParentStart(parent, current, sourceFile); + const containingListOrParentStart = getContainingListOrParentStart(parent, current, sourceFile); const parentAndChildShareLine = containingListOrParentStart.line === currentStart.line || childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); @@ -196,7 +193,7 @@ namespace ts.formatting { } // increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line - if (shouldIndentChildNode(parent, current) && !parentAndChildShareLine) { + if (shouldIndentChildNode(parent, current, isNextChild) && !parentAndChildShareLine) { indentationDelta += options.indentSize; } @@ -214,7 +211,7 @@ namespace ts.formatting { current = parent; parent = current.parent; - currentStart = useTrueStart ? sourceFile.getLineAndCharacterOfPosition(current.getStart()) : containingListOrParentStart; + currentStart = useTrueStart ? sourceFile.getLineAndCharacterOfPosition(current.getStart(sourceFile)) : containingListOrParentStart; } return indentationDelta + getBaseIndentation(options); @@ -533,8 +530,7 @@ namespace ts.formatting { return false; } - /* @internal */ - export function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean) { + export function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind | undefined, indentByDefault: boolean): boolean { const childKind = child ? child.kind : SyntaxKind.Unknown; switch (parent.kind) { case SyntaxKind.DoStatement: @@ -555,7 +551,7 @@ namespace ts.formatting { return childKind !== SyntaxKind.NamedExports; case SyntaxKind.ImportDeclaration: return childKind !== SyntaxKind.ImportClause || - ((child).namedBindings && (child).namedBindings.kind !== SyntaxKind.NamedImports); + (!!(child).namedBindings && (child).namedBindings.kind !== SyntaxKind.NamedImports); case SyntaxKind.JsxElement: return childKind !== SyntaxKind.JsxClosingElement; } @@ -563,11 +559,44 @@ namespace ts.formatting { return indentByDefault; } - /* - Function returns true when the parent node should indent the given child by an explicit rule - */ - export function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean { - return nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(parent, child, /*indentByDefault*/ false); + function isControlFlowEndingStatement(kind: SyntaxKind, parent: TextRangeWithKind): boolean { + switch (kind) { + case SyntaxKind.ReturnStatement: + case SyntaxKind.ThrowStatement: + switch (parent.kind) { + case SyntaxKind.Block: + const grandParent = (parent as Node).parent; + switch (grandParent && grandParent.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + // We may want to write inner functions after this. + return false; + default: + return true; + } + case SyntaxKind.CaseClause: + case SyntaxKind.DefaultClause: + case SyntaxKind.SourceFile: + case SyntaxKind.ModuleBlock: + return true; + default: + throw Debug.fail(); + } + case SyntaxKind.ContinueStatement: + case SyntaxKind.BreakStatement: + return true; + default: + return false; + } + } + + /** + * True when the parent node should indent the given child by an explicit rule. + * @param isNextChild If true, we are judging indent of a hypothetical child *after* this one, not the current child. + */ + export function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind, isNextChild = false): boolean { + return (nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(parent, child, /*indentByDefault*/ false)) + && !(isNextChild && child && isControlFlowEndingStatement(child.kind, parent)); } } } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index cf71118292a..be925e5c170 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -441,6 +441,7 @@ namespace ts { * Assumes `candidate.start <= position` holds. */ export function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean { + Debug.assert(candidate.pos <= position); return position < candidate.end || !isCompletedNode(candidate, sourceFile); } diff --git a/tests/cases/fourslash/smartIndentStatementSwitch.ts b/tests/cases/fourslash/smartIndentStatementSwitch.ts index c2c2d09fd45..9e3057e9231 100644 --- a/tests/cases/fourslash/smartIndentStatementSwitch.ts +++ b/tests/cases/fourslash/smartIndentStatementSwitch.ts @@ -11,7 +11,7 @@ //// case 1: //// {| "indentation": 12 |} //// break; -//// {| "indentation": 12 |} // content of case clauses is always indented relatively to case clause +//// {| "indentation": 8 |} // since we just saw "break" //// } //// {| "indentation": 4 |} ////} From 3d05952719a8b5023ca342ca353c04b5f552f71c Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 15 Nov 2017 12:43:16 -0800 Subject: [PATCH 24/26] Change "isThisless" predicates to "mayReferenceThis" predicates (#20036) * Change "isThisless" predicates to "mayReferenceThis" predicates * Fix name * Code review --- src/compiler/checker.ts | 125 ++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 74 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 022aa18a50e..5862a436f97 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5111,26 +5111,18 @@ namespace ts { * to "this" in its body, if all base types are interfaces, * and if none of the base interfaces have a "this" type. */ - function isThislessInterface(symbol: Symbol): boolean { - for (const declaration of symbol.declarations) { - if (declaration.kind === SyntaxKind.InterfaceDeclaration) { - if (declaration.flags & NodeFlags.ContainsThis) { - return false; - } - const baseTypeNodes = getInterfaceBaseTypeNodes(declaration); - if (baseTypeNodes) { - for (const node of baseTypeNodes) { - if (isEntityNameExpression(node.expression)) { - const baseSymbol = resolveEntityName(node.expression, SymbolFlags.Type, /*ignoreErrors*/ true); - if (!baseSymbol || !(baseSymbol.flags & SymbolFlags.Interface) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { - return false; - } - } - } - } - } + function interfaceReferencesThis(symbol: Symbol): boolean { + return some(symbol.declarations, declaration => + isInterfaceDeclaration(declaration) && ( + !!(declaration.flags & NodeFlags.ContainsThis) + || some(getInterfaceBaseTypeNodes(declaration), baseTypeReferencesThis))); + } + function baseTypeReferencesThis({ expression }: ExpressionWithTypeArguments): boolean { + if (!isEntityNameExpression(expression)) { + return false; } - return true; + const baseSymbol = resolveEntityName(expression, SymbolFlags.Type, /*ignoreErrors*/ true); + return !baseSymbol || !(baseSymbol.flags & SymbolFlags.Interface) || !!getDeclaredTypeOfClassOrInterface(baseSymbol).thisType; } function getDeclaredTypeOfClassOrInterface(symbol: Symbol): InterfaceType { @@ -5145,7 +5137,7 @@ namespace ts { // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === ObjectFlags.Class || !isThislessInterface(symbol)) { + if (outerTypeParameters || localTypeParameters || kind === ObjectFlags.Class || interfaceReferencesThis(symbol)) { type.objectFlags |= ObjectFlags.Reference; type.typeParameters = concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -5327,13 +5319,9 @@ namespace ts { return undefined; } - /** - * A type is free of this references if it's the any, string, number, boolean, symbol, or void keyword, a string - * literal type, an array with an element type that is free of this references, or a type reference that is - * free of this references. - */ - function isThislessType(node: TypeNode): boolean { - switch (node.kind) { + /** A type may reference `this` unless it's one of a few special types. */ + function typeReferencesThis(node: TypeNode | undefined): boolean { + switch (node && node.kind) { case SyntaxKind.AnyKeyword: case SyntaxKind.StringKeyword: case SyntaxKind.NumberKeyword: @@ -5345,64 +5333,53 @@ namespace ts { case SyntaxKind.NullKeyword: case SyntaxKind.NeverKeyword: case SyntaxKind.LiteralType: - return true; + return false; case SyntaxKind.ArrayType: - return isThislessType((node).elementType); + return typeReferencesThis((node).elementType); case SyntaxKind.TypeReference: - return !(node as TypeReferenceNode).typeArguments || (node as TypeReferenceNode).typeArguments.every(isThislessType); + return some((node as TypeReferenceNode).typeArguments, typeReferencesThis); } - return false; + return true; // TODO: GH#20034 } - /** A type parameter is thisless if its contraint is thisless, or if it has no constraint. */ - function isThislessTypeParameter(node: TypeParameterDeclaration) { - return !node.constraint || isThislessType(node.constraint); - } - - /** - * A variable-like declaration is free of this references if it has a type annotation - * that is thisless, or if it has no type annotation and no initializer (and is thus of type any). - */ - function isThislessVariableLikeDeclaration(node: VariableLikeDeclaration): boolean { + /** A variable-like declaration may reference `this` if its type does or if it has no declared type and an initializer (which may infer a `this` type). */ + function variableLikeDeclarationReferencesThis(node: VariableLikeDeclaration): boolean { const typeNode = getEffectiveTypeAnnotationNode(node); - return typeNode ? isThislessType(typeNode) : !node.initializer; + return typeNode ? typeReferencesThis(typeNode) : !!node.initializer; } /** - * A function-like declaration is considered free of `this` references if it has a return type - * annotation that is free of this references and if each parameter is thisless and if - * each type parameter (if present) is thisless. + * Returns true if the class/interface member may reference `this`. + * May return true for symbols that don't actually reference `this` because it would be slow to do a complete analysis. + * For example, property members with types inferred from initializers or function members with inferred return types are + * conservatively assumed to reference `this`. */ - function isThislessFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { - const returnType = getEffectiveReturnTypeNode(node); - return (node.kind === SyntaxKind.Constructor || (returnType && isThislessType(returnType))) && - node.parameters.every(isThislessVariableLikeDeclaration) && - (!node.typeParameters || node.typeParameters.every(isThislessTypeParameter)); - } - - /** - * Returns true if the class or interface member given by the symbol is free of "this" references. The - * function may return false for symbols that are actually free of "this" references because it is not - * feasible to perform a complete analysis in all cases. In particular, property members with types - * inferred from their initializers and function members with inferred return types are conservatively - * assumed not to be free of "this" references. - */ - function isThisless(symbol: Symbol): boolean { - if (symbol.declarations && symbol.declarations.length === 1) { - const declaration = symbol.declarations[0]; - if (declaration) { - switch (declaration.kind) { - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - return isThislessVariableLikeDeclaration(declaration); - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.Constructor: - return isThislessFunctionLikeDeclaration(declaration); - } + function symbolReferencesThis(symbol: Symbol): boolean { + const declaration = singleOrUndefined(symbol.declarations); + if (!declaration) return true; + switch (declaration.kind) { + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + return variableLikeDeclarationReferencesThis(declaration); + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.Constructor: { + // A function-like declaration references `this` if its return type does or some parameter / type parameter does. + const fn = declaration as MethodDeclaration | MethodSignature | ConstructorDeclaration; + return typeReferencesThis(getEffectiveReturnTypeNode(fn)) + || fn.parameters.some(variableLikeDeclarationReferencesThis) + // A type parameter references `this` if its constraint does. + || some(fn.typeParameters, tp => typeReferencesThis(tp.constraint)); } + case SyntaxKind.Parameter: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.BinaryExpression: + case SyntaxKind.PropertyAccessExpression: // See `tests/cases/fourslash/renameJsThisProperty05` and 06 + return true; // TODO: GH#20034 + default: + throw Debug.failBadSyntaxKind(declaration); } - return false; } // The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true, @@ -5410,7 +5387,7 @@ namespace ts { function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable { const result = createSymbolTable(); for (const symbol of symbols) { - result.set(symbol.escapedName, mappingThisOnly && isThisless(symbol) ? symbol : instantiateSymbol(symbol, mapper)); + result.set(symbol.escapedName, mappingThisOnly && !symbolReferencesThis(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } From 4b96edf72faf6f9b6b464e148c9c02eac96aa4bd Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 15 Nov 2017 13:04:08 -0800 Subject: [PATCH 25/26] Treat `...` in jsdoc type as creating a synthetic rest parameter -- not as an array type (#19483) * Treat `...` in jsdoc type as creating a synthetic rest parameter -- not as an array type * Change type parsing so `...T[]` parses as `...(T[])` and not `(...T)[]` * Replace the last parameter with ...args, and make access to it potentially undefined * Code review --- src/compiler/checker.ts | 176 ++++++++++++------ src/compiler/diagnosticMessages.json | 4 + src/compiler/parser.ts | 8 +- src/compiler/utilities.ts | 14 +- ...jsFileCompilationRestParamJsDocFunction.js | 8 +- ...eCompilationRestParamJsDocFunction.symbols | 2 +- ...ileCompilationRestParamJsDocFunction.types | 6 +- .../jsdocDisallowedInTypescript.errors.txt | 13 +- .../jsdocDisallowedInTypescript.types | 4 +- .../jsdocPrefixPostfixParsing.errors.txt | 43 +++++ .../reference/jsdocPrefixPostfixParsing.types | 18 +- .../reference/jsdocRestParameter.errors.txt | 19 ++ .../reference/jsdocRestParameter.symbols | 22 +++ .../reference/jsdocRestParameter.types | 34 ++++ .../reference/jsdocRestParameter_es6.symbols | 10 + .../reference/jsdocRestParameter_es6.types | 10 + ...jsFileCompilationRestParamJsDocFunction.ts | 2 +- tests/cases/compiler/jsdocRestParameter.ts | 15 ++ .../cases/compiler/jsdocRestParameter_es6.ts | 10 + .../fourslash/codeFixChangeJSDocSyntax27.ts | 10 - .../fourslash/codeFixChangeJSDocSyntax3.ts | 7 - .../fourslash/getJavaScriptCompletions6.ts | 13 -- .../fourslash/getJavaScriptCompletions7.ts | 13 -- 23 files changed, 336 insertions(+), 125 deletions(-) create mode 100644 tests/baselines/reference/jsdocPrefixPostfixParsing.errors.txt create mode 100644 tests/baselines/reference/jsdocRestParameter.errors.txt create mode 100644 tests/baselines/reference/jsdocRestParameter.symbols create mode 100644 tests/baselines/reference/jsdocRestParameter.types create mode 100644 tests/baselines/reference/jsdocRestParameter_es6.symbols create mode 100644 tests/baselines/reference/jsdocRestParameter_es6.types create mode 100644 tests/cases/compiler/jsdocRestParameter.ts create mode 100644 tests/cases/compiler/jsdocRestParameter_es6.ts delete mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts delete mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax3.ts delete mode 100644 tests/cases/fourslash/getJavaScriptCompletions6.ts delete mode 100644 tests/cases/fourslash/getJavaScriptCompletions7.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5862a436f97..631960f24ba 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2924,32 +2924,24 @@ namespace ts { function symbolToParameterDeclaration(parameterSymbol: Symbol, context: NodeBuilderContext): ParameterDeclaration { const parameterDeclaration = getDeclarationOfKind(parameterSymbol, SyntaxKind.Parameter); - if (isTransientSymbol(parameterSymbol) && parameterSymbol.isRestParameter) { - // special-case synthetic rest parameters in JS files - return createParameter( - /*decorators*/ undefined, - /*modifiers*/ undefined, - parameterSymbol.isRestParameter ? createToken(SyntaxKind.DotDotDotToken) : undefined, - "args", - /*questionToken*/ undefined, - typeToTypeNodeHelper(anyArrayType, context), - /*initializer*/ undefined); - } - const modifiers = parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedClone); - const dotDotDotToken = isRestParameter(parameterDeclaration) ? createToken(SyntaxKind.DotDotDotToken) : undefined; - const name = parameterDeclaration.name ? - parameterDeclaration.name.kind === SyntaxKind.Identifier ? - setEmitFlags(getSynthesizedClone(parameterDeclaration.name), EmitFlags.NoAsciiEscaping) : - cloneBindingName(parameterDeclaration.name) : - symbolName(parameterSymbol); - const questionToken = isOptionalParameter(parameterDeclaration) ? createToken(SyntaxKind.QuestionToken) : undefined; + Debug.assert(!!parameterDeclaration || isTransientSymbol(parameterSymbol) && !!parameterSymbol.isRestParameter); let parameterType = getTypeOfSymbol(parameterSymbol); - if (isRequiredInitializedParameter(parameterDeclaration)) { - parameterType = getNullableType(parameterType, TypeFlags.Undefined); + if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { + parameterType = getOptionalType(parameterType); } const parameterTypeNode = typeToTypeNodeHelper(parameterType, context); + const modifiers = parameterDeclaration && parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedClone); + const dotDotDotToken = !parameterDeclaration || isRestParameter(parameterDeclaration) ? createToken(SyntaxKind.DotDotDotToken) : undefined; + const name = parameterDeclaration + ? parameterDeclaration.name ? + parameterDeclaration.name.kind === SyntaxKind.Identifier ? + setEmitFlags(getSynthesizedClone(parameterDeclaration.name), EmitFlags.NoAsciiEscaping) : + cloneBindingName(parameterDeclaration.name) : + symbolName(parameterSymbol) + : symbolName(parameterSymbol); + const questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? createToken(SyntaxKind.QuestionToken) : undefined; const parameterNode = createParameter( /*decorators*/ undefined, modifiers, @@ -3717,7 +3709,7 @@ namespace ts { let type = getTypeOfSymbol(p); if (parameterNode && isRequiredInitializedParameter(parameterNode)) { - type = getNullableType(type, TypeFlags.Undefined); + type = getOptionalType(type); } buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } @@ -4288,8 +4280,8 @@ namespace ts { return expr.kind === SyntaxKind.ArrayLiteralExpression && (expr).elements.length === 0; } - function addOptionality(type: Type, optional: boolean): Type { - return strictNullChecks && optional ? getNullableType(type, TypeFlags.Undefined) : type; + function addOptionality(type: Type, optional = true): Type { + return strictNullChecks && optional ? getOptionalType(type) : type; } // Return the inferred type for a variable, parameter, or property declaration @@ -4318,7 +4310,7 @@ namespace ts { const typeNode = getEffectiveTypeAnnotationNode(declaration); if (typeNode) { const declaredType = getTypeFromTypeNode(typeNode); - return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality); + return addOptionality(declaredType, /*optional*/ !!declaration.questionToken && includeOptionality); } if ((noImplicitAny || isInJavaScriptFile(declaration)) && @@ -4362,14 +4354,14 @@ namespace ts { type = getContextuallyTypedParameterType(declaration); } if (type) { - return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); + return addOptionality(type, /*optional*/ !!declaration.questionToken && includeOptionality); } } // Use the type of the initializer expression if one is present if (declaration.initializer) { const type = checkDeclarationInitializer(declaration); - return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); + return addOptionality(type, /*optional*/ !!declaration.questionToken && includeOptionality); } if (isJsxAttribute(declaration)) { @@ -4707,7 +4699,7 @@ namespace ts { links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; } else { - links.type = strictNullChecks && symbol.flags & SymbolFlags.Optional ? getNullableType(type, TypeFlags.Undefined) : type; + links.type = strictNullChecks && symbol.flags & SymbolFlags.Optional ? getOptionalType(type) : type; } } } @@ -6505,21 +6497,35 @@ namespace ts { const typePredicate = declaration.type && declaration.type.kind === SyntaxKind.TypePredicate ? createTypePredicateFromTypePredicateNode(declaration.type as TypePredicateNode) : undefined; - // JS functions get a free rest parameter if they reference `arguments` - let hasRestLikeParameter = hasRestParameter(declaration); - if (!hasRestLikeParameter && isInJavaScriptFile(declaration) && containsArgumentsReference(declaration)) { - hasRestLikeParameter = true; - const syntheticArgsSymbol = createSymbol(SymbolFlags.Variable, "args" as __String); - syntheticArgsSymbol.type = anyArrayType; - syntheticArgsSymbol.isRestParameter = true; - parameters.push(syntheticArgsSymbol); - } - + const hasRestLikeParameter = hasRestParameter(declaration) || isInJavaScriptFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters); links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, hasRestLikeParameter, hasLiteralTypes); } return links.resolvedSignature; } + function maybeAddJsSyntheticRestParameter(declaration: SignatureDeclaration, parameters: Symbol[]): boolean { + // JS functions get a free rest parameter if: + // a) The last parameter has `...` preceding its type + // b) It references `arguments` somewhere + const lastParam = lastOrUndefined(declaration.parameters); + const lastParamTags = lastParam && getJSDocParameterTags(lastParam); + const lastParamVariadicType = lastParamTags && firstDefined(lastParamTags, p => + p.typeExpression && isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined); + if (!lastParamVariadicType && !containsArgumentsReference(declaration)) { + return false; + } + + const syntheticArgsSymbol = createSymbol(SymbolFlags.Variable, "args" as __String); + syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType; + syntheticArgsSymbol.isRestParameter = true; + if (lastParamVariadicType) { + // Replace the last parameter with a rest parameter. + parameters.pop(); + } + parameters.push(syntheticArgsSymbol); + return true; + } + function getSignatureReturnTypeFromDeclaration(declaration: SignatureDeclaration, isJSConstructSignature: boolean, classType: Type) { if (isJSConstructSignature) { return getTypeFromTypeNode(declaration.parameters[0].type); @@ -7074,7 +7080,7 @@ namespace ts { function getTypeFromJSDocNullableTypeNode(node: JSDocNullableType) { const type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getUnionType([type, nullType]) : type; + return strictNullChecks ? getNullableType(type, TypeFlags.Null) : type; } function getTypeFromTypeReference(node: TypeReferenceType): Type { @@ -8048,15 +8054,6 @@ namespace ts { return links.resolvedType; } - function getTypeFromJSDocVariadicType(node: JSDocVariadicType): Type { - const links = getNodeLinks(node); - if (!links.resolvedType) { - const type = getTypeFromTypeNode(node.type); - links.resolvedType = type ? createArrayType(type) : unknownType; - } - return links.resolvedType; - } - function getThisType(node: Node): Type { const container = getThisContainer(node, /*includeArrowFunctions*/ false); const parent = container && container.parent; @@ -8130,6 +8127,8 @@ namespace ts { case SyntaxKind.JSDocOptionalType: case SyntaxKind.JSDocTypeExpression: return getTypeFromTypeNode((node).type); + case SyntaxKind.JSDocVariadicType: + return getTypeFromJSDocVariadicType(node as JSDocVariadicType); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: case SyntaxKind.TypeLiteral: @@ -8148,8 +8147,6 @@ namespace ts { case SyntaxKind.QualifiedName: const symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case SyntaxKind.JSDocVariadicType: - return getTypeFromJSDocVariadicType(node); default: return unknownType; } @@ -10416,6 +10413,11 @@ namespace ts { getUnionType([type, undefinedType, nullType]); } + function getOptionalType(type: Type): Type { + Debug.assert(strictNullChecks); + return type.flags & TypeFlags.Undefined ? type : getUnionType([type, undefinedType]); + } + function getNonNullableType(type: Type): Type { return strictNullChecks ? getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull) : type; } @@ -12765,7 +12767,7 @@ namespace ts { declaration.flags & NodeFlags.Ambient; const initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, getRootDeclaration(declaration) as VariableLikeDeclaration) : type) : type === autoType || type === autoArrayType ? undefinedType : - getNullableType(type, TypeFlags.Undefined); + getOptionalType(type); const flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the @@ -17211,7 +17213,7 @@ namespace ts { if (strictNullChecks) { const declaration = symbol.valueDeclaration; if (declaration && (declaration).initializer) { - return getNullableType(type, TypeFlags.Undefined); + return getOptionalType(type); } } return type; @@ -23060,14 +23062,15 @@ namespace ts { case SyntaxKind.JSDocFunctionType: checkSignatureDeclaration(node as JSDocFunctionType); // falls through - case SyntaxKind.JSDocVariadicType: case SyntaxKind.JSDocNonNullableType: case SyntaxKind.JSDocNullableType: case SyntaxKind.JSDocAllType: case SyntaxKind.JSDocUnknownType: - if (!isInJavaScriptFile(node) && !isInJSDoc(node)) { - grammarErrorOnNode(node, Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); - } + checkJSDocTypeIsInJsFile(node); + forEachChild(node, checkSourceElement); + return; + case SyntaxKind.JSDocVariadicType: + checkJSDocVariadicType(node as JSDocVariadicType); return; case SyntaxKind.JSDocTypeExpression: return checkSourceElement((node as JSDocTypeExpression).type); @@ -23144,6 +23147,65 @@ namespace ts { } } + function checkJSDocTypeIsInJsFile(node: Node): void { + if (!isInJavaScriptFile(node)) { + grammarErrorOnNode(node, Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); + } + } + + function checkJSDocVariadicType(node: JSDocVariadicType): void { + checkJSDocTypeIsInJsFile(node); + checkSourceElement(node.type); + + // Only legal location is in the *last* parameter tag. + const { parent } = node; + if (!isJSDocTypeExpression(parent)) { + error(node, Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature); + } + + const paramTag = parent.parent; + if (!isJSDocParameterTag(paramTag)) { + error(node, Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature); + return; + } + + const param = getParameterSymbolFromJSDoc(paramTag); + if (!param) { + // We will error in `checkJSDocParameterTag`. + return; + } + + const host = getHostSignatureFromJSDoc(paramTag); + if (!host || last(host.parameters).symbol !== param) { + error(node, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); + } + } + + function getTypeFromJSDocVariadicType(node: JSDocVariadicType): Type { + const type = getTypeFromTypeNode(node.type); + const { parent } = node; + const paramTag = parent.parent; + if (isJSDocTypeExpression(parent) && isJSDocParameterTag(paramTag)) { + // Else we will add a diagnostic, see `checkJSDocVariadicType`. + const param = getParameterSymbolFromJSDoc(paramTag); + if (param) { + const host = getHostSignatureFromJSDoc(paramTag); + /* + Only return an array type if the corresponding parameter is marked as a rest parameter. + So in the following situation we will not create an array type: + /** @param {...number} a * / + function f(a) {} + Because `a` will just be of type `number | undefined`. A synthetic `...args` will also be added, which *will* get an array type. + */ + const lastParamDeclaration = host && last(host.parameters); + if (lastParamDeclaration.symbol === param && isRestParameter(lastParamDeclaration)) { + return createArrayType(type); + } + } + } + return addOptionality(type); + } + // Function and class expression bodies are checked after all statements in the enclosing body. This is // to ensure constructs like the following are permitted: // const foo = function () { @@ -24272,7 +24334,7 @@ namespace ts { ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : unknownType; if (flags & TypeFormatFlags.AddUndefined) { - type = getNullableType(type, TypeFlags.Undefined); + type = getOptionalType(type); } getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 964264ff6e8..a552122609a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3547,6 +3547,10 @@ "category": "Error", "code": 8027 }, + "JSDoc '...' may only appear in the last parameter of a signature.": { + "category": "Error", + "code": 8028 + }, "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause.": { "category": "Error", "code": 9002 diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 5456e889353..6f1a9e1a561 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2678,8 +2678,6 @@ namespace ts { return parseJSDocUnknownOrNullableType(); case SyntaxKind.FunctionKeyword: return parseJSDocFunctionType(); - case SyntaxKind.DotDotDotToken: - return parseJSDocNodeWithType(SyntaxKind.JSDocVariadicType); case SyntaxKind.ExclamationToken: return parseJSDocNodeWithType(SyntaxKind.JSDocNonNullableType); case SyntaxKind.NoSubstitutionTemplateLiteral: @@ -2819,6 +2817,12 @@ namespace ts { switch (token()) { case SyntaxKind.KeyOfKeyword: return parseTypeOperator(SyntaxKind.KeyOfKeyword); + case SyntaxKind.DotDotDotToken: { + const result = createNode(SyntaxKind.JSDocVariadicType) as JSDocVariadicType; + nextToken(); + result.type = parsePostfixTypeOrHigher(); + return finishNode(result); + } } return parsePostfixTypeOrHigher(); } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e488cdcc601..1857ca10bd2 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1626,16 +1626,22 @@ namespace ts { return undefined; } const name = node.name.escapedText; + const decl = getHostSignatureFromJSDoc(node); + if (!decl) { + return undefined; + } + const parameter = find(decl.parameters, p => p.name.kind === SyntaxKind.Identifier && p.name.escapedText === name); + return parameter && parameter.symbol; + } + + export function getHostSignatureFromJSDoc(node: JSDocParameterTag): FunctionLike | undefined { const host = getJSDocHost(node); const decl = getSourceOfAssignment(host) || getSingleInitializerOfVariableStatement(host) || getSingleVariableOfVariableStatement(host) || getNestedModuleDeclaration(host) || host; - if (decl && isFunctionLike(decl)) { - const parameter = find(decl.parameters, p => p.name.kind === SyntaxKind.Identifier && p.name.escapedText === name); - return parameter && parameter.symbol; - } + return decl && isFunctionLike(decl) ? decl : undefined; } export function getJSDocHost(node: JSDocTag): HasJSDoc { diff --git a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.js b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.js index acc590418e9..fbe8df0c1c4 100644 --- a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.js +++ b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.js @@ -9,7 +9,7 @@ * @param {...*} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ -function apply(func, thisArg, args) { +function apply(func, thisArg, ...args) { var length = args.length; switch (length) { case 0: return func.call(thisArg); @@ -36,7 +36,11 @@ define("_apply", ["require", "exports"], function (require, exports) { * @param {...*} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ - function apply(func, thisArg, args) { + function apply(func, thisArg) { + var args = []; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; + } var length = args.length; switch (length) { case 0: return func.call(thisArg); diff --git a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols index e7589f6ce55..fc70ae01a6c 100644 --- a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols +++ b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols @@ -9,7 +9,7 @@ * @param {...*} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ -function apply(func, thisArg, args) { +function apply(func, thisArg, ...args) { >apply : Symbol(apply, Decl(_apply.js, 0, 0)) >func : Symbol(func, Decl(_apply.js, 10, 15)) >thisArg : Symbol(thisArg, Decl(_apply.js, 10, 20)) diff --git a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types index 72c3388f226..c0247bb045f 100644 --- a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types +++ b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types @@ -9,8 +9,8 @@ * @param {...*} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ -function apply(func, thisArg, args) { ->apply : (func: Function, thisArg: any, args: any[]) => any +function apply(func, thisArg, ...args) { +>apply : (func: Function, thisArg: any, ...args: any[]) => any >func : Function >thisArg : any >args : any[] @@ -84,5 +84,5 @@ function apply(func, thisArg, args) { } export default apply; ->apply : (func: Function, thisArg: any, args: any[]) => any +>apply : (func: Function, thisArg: any, ...args: any[]) => any diff --git a/tests/baselines/reference/jsdocDisallowedInTypescript.errors.txt b/tests/baselines/reference/jsdocDisallowedInTypescript.errors.txt index d176e1aa22e..2823981cc95 100644 --- a/tests/baselines/reference/jsdocDisallowedInTypescript.errors.txt +++ b/tests/baselines/reference/jsdocDisallowedInTypescript.errors.txt @@ -7,7 +7,10 @@ tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(11,12): error TS255 tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(13,14): error TS8020: JSDoc types can only be used inside documentation comments. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(14,11): error TS8020: JSDoc types can only be used inside documentation comments. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(15,8): error TS8020: JSDoc types can only be used inside documentation comments. +tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(16,5): error TS2322: Type 'boolean[]' is not assignable to type 'boolean | undefined'. + Type 'boolean[]' is not assignable to type 'false'. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(16,15): error TS8020: JSDoc types can only be used inside documentation comments. +tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(16,15): error TS8028: JSDoc '...' may only appear in the last parameter of a signature. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(17,11): error TS8020: JSDoc types can only be used inside documentation comments. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(18,17): error TS8020: JSDoc types can only be used inside documentation comments. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(19,5): error TS2322: Type 'undefined' is not assignable to type 'number | null'. @@ -16,9 +19,10 @@ tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(21,16): error TS802 tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(22,16): error TS8020: JSDoc types can only be used inside documentation comments. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(23,17): error TS8020: JSDoc types can only be used inside documentation comments. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(24,17): error TS8020: JSDoc types can only be used inside documentation comments. +tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(24,17): error TS8028: JSDoc '...' may only appear in the last parameter of a signature. -==== tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts (18 errors) ==== +==== tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts (21 errors) ==== // grammar error from checker var ara: Array. = [1,2,3]; ~ @@ -53,8 +57,13 @@ tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(24,17): error TS802 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8020: JSDoc types can only be used inside documentation comments. var variadic: ...boolean = [true, false, true]; + ~~~~~~~~ +!!! error TS2322: Type 'boolean[]' is not assignable to type 'boolean | undefined'. +!!! error TS2322: Type 'boolean[]' is not assignable to type 'false'. ~~~~~~~~~~ !!! error TS8020: JSDoc types can only be used inside documentation comments. + ~~~~~~~~~~ +!!! error TS8028: JSDoc '...' may only appear in the last parameter of a signature. var most: !string = 'definite'; ~~~~~~~ !!! error TS8020: JSDoc types can only be used inside documentation comments. @@ -79,5 +88,7 @@ tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(24,17): error TS802 var vars: Array<...number>; ~~~~~~~~~ !!! error TS8020: JSDoc types can only be used inside documentation comments. + ~~~~~~~~~ +!!! error TS8028: JSDoc '...' may only appear in the last parameter of a signature. \ No newline at end of file diff --git a/tests/baselines/reference/jsdocDisallowedInTypescript.types b/tests/baselines/reference/jsdocDisallowedInTypescript.types index 49f16acfd19..8fe4a032f20 100644 --- a/tests/baselines/reference/jsdocDisallowedInTypescript.types +++ b/tests/baselines/reference/jsdocDisallowedInTypescript.types @@ -65,7 +65,7 @@ var g: function(number, number): number = (n,m) => n + m; >m : number var variadic: ...boolean = [true, false, true]; ->variadic : boolean[] +>variadic : boolean | undefined >[true, false, true] : boolean[] >true : true >false : false @@ -96,7 +96,7 @@ var anys: Array<*>; >Array : T[] var vars: Array<...number>; ->vars : number[][] +>vars : (number | undefined)[] >Array : T[] diff --git a/tests/baselines/reference/jsdocPrefixPostfixParsing.errors.txt b/tests/baselines/reference/jsdocPrefixPostfixParsing.errors.txt new file mode 100644 index 00000000000..2b3d0b1647c --- /dev/null +++ b/tests/baselines/reference/jsdocPrefixPostfixParsing.errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/jsdoc/prefixPostfix.js(8,13): error TS8028: JSDoc '...' may only appear in the last parameter of a signature. +tests/cases/conformance/jsdoc/prefixPostfix.js(9,12): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/jsdoc/prefixPostfix.js(10,12): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/jsdoc/prefixPostfix.js(11,12): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/jsdoc/prefixPostfix.js(12,12): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/jsdoc/prefixPostfix.js(13,12): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/jsdoc/prefixPostfix.js(14,12): error TS1014: A rest parameter must be last in a parameter list. + + +==== tests/cases/conformance/jsdoc/prefixPostfix.js (7 errors) ==== + /** + * @param {number![]} x - number[] + * @param {!number[]} y - number[] + * @param {(number[])!} z - number[] + * @param {number?[]} a - (number | null)[] + * @param {?number[]} b - number[] | null + * @param {(number[])?} c - number[] | null + * @param {?...number} d - number[] | null + ~~~~~~~~~ +!!! error TS8028: JSDoc '...' may only appear in the last parameter of a signature. + * @param {...?number} e - (number | null)[] + ~~~~~~~~~~ +!!! error TS1014: A rest parameter must be last in a parameter list. + * @param {...number?} f - number[] | null + ~~~~~~~~~~ +!!! error TS1014: A rest parameter must be last in a parameter list. + * @param {...number!?} g - number[] | null + ~~~~~~~~~~~ +!!! error TS1014: A rest parameter must be last in a parameter list. + * @param {...number?!} h - number[] | null + ~~~~~~~~~~~ +!!! error TS1014: A rest parameter must be last in a parameter list. + * @param {...number[]} i - number[][] + ~~~~~~~~~~~ +!!! error TS1014: A rest parameter must be last in a parameter list. + * @param {...number![]?} j - number[][] | null + ~~~~~~~~~~~~~ +!!! error TS1014: A rest parameter must be last in a parameter list. + * @param {...number?[]!} k - (number[] | null)[] + */ + function f(x, y, z, a, b, c, d, e, f, g, h, i, j, k) { + } + \ No newline at end of file diff --git a/tests/baselines/reference/jsdocPrefixPostfixParsing.types b/tests/baselines/reference/jsdocPrefixPostfixParsing.types index 9961af48e27..cf69cf9d40c 100644 --- a/tests/baselines/reference/jsdocPrefixPostfixParsing.types +++ b/tests/baselines/reference/jsdocPrefixPostfixParsing.types @@ -16,20 +16,20 @@ * @param {...number?[]!} k - (number[] | null)[] */ function f(x, y, z, a, b, c, d, e, f, g, h, i, j, k) { ->f : (x: number[], y: number[], z: number[], a: (number | null)[], b: number[] | null, c: number[] | null, d: number[] | null, e: (number | null)[], f: number[] | null, g: number[] | null, h: number[] | null, i: number[][], j: number[][] | null, k: (number[] | null)[]) => void +>f : (x: number[], y: number[], z: number[], a: (number | null)[], b: number[] | null, c: number[] | null, d: number | null | undefined, e: number | null | undefined, f: number | null | undefined, g: number | null | undefined, h: number | null | undefined, i: number[] | undefined, j: number[] | null | undefined, ...args: (number | null)[][]) => void >x : number[] >y : number[] >z : number[] >a : (number | null)[] >b : number[] | null >c : number[] | null ->d : number[] | null ->e : (number | null)[] ->f : number[] | null ->g : number[] | null ->h : number[] | null ->i : number[][] ->j : number[][] | null ->k : (number[] | null)[] +>d : number | null | undefined +>e : number | null | undefined +>f : number | null | undefined +>g : number | null | undefined +>h : number | null | undefined +>i : number[] | undefined +>j : number[] | null | undefined +>k : (number | null)[] | undefined } diff --git a/tests/baselines/reference/jsdocRestParameter.errors.txt b/tests/baselines/reference/jsdocRestParameter.errors.txt new file mode 100644 index 00000000000..ec34bcdcb20 --- /dev/null +++ b/tests/baselines/reference/jsdocRestParameter.errors.txt @@ -0,0 +1,19 @@ +/a.js(7,3): error TS2345: Argument of type 'number[]' is not assignable to parameter of type 'number'. +/a.js(8,6): error TS2345: Argument of type '"2"' is not assignable to parameter of type 'number'. + + +==== /a.js (2 errors) ==== + /** @param {...number} a */ + function f(a) { + a; // number | undefined + // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. + arguments[0]; + } + f([1, 2]); // Error + ~~~~~~ +!!! error TS2345: Argument of type 'number[]' is not assignable to parameter of type 'number'. + f(1, "2"); // Error + ~~~ +!!! error TS2345: Argument of type '"2"' is not assignable to parameter of type 'number'. + f(1, 2); + \ No newline at end of file diff --git a/tests/baselines/reference/jsdocRestParameter.symbols b/tests/baselines/reference/jsdocRestParameter.symbols new file mode 100644 index 00000000000..24e7c4635e9 --- /dev/null +++ b/tests/baselines/reference/jsdocRestParameter.symbols @@ -0,0 +1,22 @@ +=== /a.js === +/** @param {...number} a */ +function f(a) { +>f : Symbol(f, Decl(a.js, 0, 0)) +>a : Symbol(a, Decl(a.js, 1, 11)) + + a; // number | undefined +>a : Symbol(a, Decl(a.js, 1, 11)) + + // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. + arguments[0]; +>arguments : Symbol(arguments) +} +f([1, 2]); // Error +>f : Symbol(f, Decl(a.js, 0, 0)) + +f(1, "2"); // Error +>f : Symbol(f, Decl(a.js, 0, 0)) + +f(1, 2); +>f : Symbol(f, Decl(a.js, 0, 0)) + diff --git a/tests/baselines/reference/jsdocRestParameter.types b/tests/baselines/reference/jsdocRestParameter.types new file mode 100644 index 00000000000..51b12c37fad --- /dev/null +++ b/tests/baselines/reference/jsdocRestParameter.types @@ -0,0 +1,34 @@ +=== /a.js === +/** @param {...number} a */ +function f(a) { +>f : (...args: number[]) => void +>a : number | undefined + + a; // number | undefined +>a : number | undefined + + // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. + arguments[0]; +>arguments[0] : any +>arguments : IArguments +>0 : 0 +} +f([1, 2]); // Error +>f([1, 2]) : void +>f : (...args: number[]) => void +>[1, 2] : number[] +>1 : 1 +>2 : 2 + +f(1, "2"); // Error +>f(1, "2") : void +>f : (...args: number[]) => void +>1 : 1 +>"2" : "2" + +f(1, 2); +>f(1, 2) : void +>f : (...args: number[]) => void +>1 : 1 +>2 : 2 + diff --git a/tests/baselines/reference/jsdocRestParameter_es6.symbols b/tests/baselines/reference/jsdocRestParameter_es6.symbols new file mode 100644 index 00000000000..c82eaad37a2 --- /dev/null +++ b/tests/baselines/reference/jsdocRestParameter_es6.symbols @@ -0,0 +1,10 @@ +=== /a.js === +/** @param {...number} a */ +function f(...a) { +>f : Symbol(f, Decl(a.js, 0, 0)) +>a : Symbol(a, Decl(a.js, 1, 11)) + + a; // number[] +>a : Symbol(a, Decl(a.js, 1, 11)) +} + diff --git a/tests/baselines/reference/jsdocRestParameter_es6.types b/tests/baselines/reference/jsdocRestParameter_es6.types new file mode 100644 index 00000000000..b07d7d931f1 --- /dev/null +++ b/tests/baselines/reference/jsdocRestParameter_es6.types @@ -0,0 +1,10 @@ +=== /a.js === +/** @param {...number} a */ +function f(...a) { +>f : (...a: number[]) => void +>a : number[] + + a; // number[] +>a : number[] +} + diff --git a/tests/cases/compiler/jsFileCompilationRestParamJsDocFunction.ts b/tests/cases/compiler/jsFileCompilationRestParamJsDocFunction.ts index 03ad2d1b2ff..3588a739948 100644 --- a/tests/cases/compiler/jsFileCompilationRestParamJsDocFunction.ts +++ b/tests/cases/compiler/jsFileCompilationRestParamJsDocFunction.ts @@ -13,7 +13,7 @@ * @param {...*} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ -function apply(func, thisArg, args) { +function apply(func, thisArg, ...args) { var length = args.length; switch (length) { case 0: return func.call(thisArg); diff --git a/tests/cases/compiler/jsdocRestParameter.ts b/tests/cases/compiler/jsdocRestParameter.ts new file mode 100644 index 00000000000..e67ce1faafc --- /dev/null +++ b/tests/cases/compiler/jsdocRestParameter.ts @@ -0,0 +1,15 @@ +// @allowJs: true +// @checkJs: true +// @strict: true +// @noEmit: true + +// @Filename: /a.js +/** @param {...number} a */ +function f(a) { + a; // number | undefined + // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. + arguments[0]; +} +f([1, 2]); // Error +f(1, "2"); // Error +f(1, 2); diff --git a/tests/cases/compiler/jsdocRestParameter_es6.ts b/tests/cases/compiler/jsdocRestParameter_es6.ts new file mode 100644 index 00000000000..0a4db35c998 --- /dev/null +++ b/tests/cases/compiler/jsdocRestParameter_es6.ts @@ -0,0 +1,10 @@ +// @allowJs: true +// @checkJs: true +// @strict: true +// @noEmit: true + +// @Filename: /a.js +/** @param {...number} a */ +function f(...a) { + a; // number[] +} diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts deleted file mode 100644 index 998a9ebd28a..00000000000 --- a/tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @strict: true -/// -////type T = [|...number?|]; - -verify.codeFix({ - description: "Change '...number?' to 'number[] | null'.", - errorCode: 8020, - index: 0, - newRangeContent: "number[] | null", -}); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax3.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax3.ts deleted file mode 100644 index 2c804edb615..00000000000 --- a/tests/cases/fourslash/codeFixChangeJSDocSyntax3.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// -//// var x: [|......number[][]|] = 12; - -verify.codeFix({ - description: "Change '......number[][]' to 'number[][][][]'.", - newRangeContent: "number[][][][]", -}); diff --git a/tests/cases/fourslash/getJavaScriptCompletions6.ts b/tests/cases/fourslash/getJavaScriptCompletions6.ts deleted file mode 100644 index 9f9a42b5762..00000000000 --- a/tests/cases/fourslash/getJavaScriptCompletions6.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// - -// @allowNonTsExtensions: true -// @Filename: Foo.js -/////** -//// * @param {...number} a -//// */ -////function foo(a) { -//// a./**/ -////} - -goTo.marker(); -verify.completionListContains("concat", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptCompletions7.ts b/tests/cases/fourslash/getJavaScriptCompletions7.ts deleted file mode 100644 index d8b01cfb757..00000000000 --- a/tests/cases/fourslash/getJavaScriptCompletions7.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// - -// @allowNonTsExtensions: true -// @Filename: Foo.js -/////** -//// * @param {...number} a -//// */ -////function foo(a) { -//// a[0]./**/ -////} - -goTo.marker(); -verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file From 21f6b1615647c568192b0df3b3f4b0c07a46d0c6 Mon Sep 17 00:00:00 2001 From: csigs Date: Wed, 15 Nov 2017 23:11:36 +0000 Subject: [PATCH 26/26] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 33 +++++++++++++++++++ .../diagnosticMessages.generated.json.lcl | 33 +++++++++++++++++++ .../diagnosticMessages.generated.json.lcl | 33 +++++++++++++++++++ .../diagnosticMessages.generated.json.lcl | 33 +++++++++++++++++++ .../diagnosticMessages.generated.json.lcl | 33 +++++++++++++++++++ .../diagnosticMessages.generated.json.lcl | 4 +-- .../diagnosticMessages.generated.json.lcl | 33 +++++++++++++++++++ .../diagnosticMessages.generated.json.lcl | 33 +++++++++++++++++++ 8 files changed, 233 insertions(+), 2 deletions(-) diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index a55da48f2c2..b840d498fc5 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1614,6 +1614,9 @@ + + + @@ -5274,24 +5277,36 @@ + + + + + + + + + + + + @@ -6003,18 +6018,27 @@ + + + + + + + + + @@ -6048,18 +6072,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index 3bb9642d207..20ef6bead25 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1623,6 +1623,9 @@ + + + @@ -5283,24 +5286,36 @@ + + + + + + + + + + + + @@ -6012,18 +6027,27 @@ + + + + + + + + + @@ -6057,18 +6081,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index d362101e51f..b44c64df54b 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1608,6 +1608,9 @@ + + + @@ -5262,24 +5265,36 @@ + + + + + + + + + + + + @@ -5985,18 +6000,27 @@ + + + + + + + + + @@ -6030,18 +6054,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 58a00519e04..ed935efe263 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1623,6 +1623,9 @@ + + + @@ -5283,24 +5286,36 @@ + + + + + + + + + + + + @@ -6012,18 +6027,27 @@ + + + + + + + + + @@ -6057,18 +6081,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index 803d5940ac2..8f93f56d3a5 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1623,6 +1623,9 @@ + + + @@ -5283,24 +5286,36 @@ + + + + + + + + + + + + @@ -6012,18 +6027,27 @@ + + + + + + + + + @@ -6057,18 +6081,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index bf004b18bc6..77eb0455379 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5449,7 +5449,7 @@ - + @@ -7954,7 +7954,7 @@ - + diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 0badf531a75..1b11c502992 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1601,6 +1601,9 @@ + + + @@ -5255,24 +5258,36 @@ + + + + + + + + + + + + @@ -5978,18 +5993,27 @@ + + + + + + + + + @@ -6023,18 +6047,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 6c92a1c0bd1..5cba29af5e2 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1607,6 +1607,9 @@ + + + @@ -5267,24 +5270,36 @@ + + + + + + + + + + + + @@ -5996,18 +6011,27 @@ + + + + + + + + + @@ -6041,18 +6065,27 @@ + + + + + + + + +