Browse Source

Update deps

Alex Dima 5 years ago
parent
commit
07cbd6dacb
5 changed files with 299 additions and 221 deletions
  1. 9 9
      package-lock.json
  2. 3 3
      package.json
  3. 143 104
      src/lib/typescriptServices-amd.js
  4. 143 104
      src/lib/typescriptServices.js
  5. 1 1
      src/lib/typescriptServicesMetadata.ts

+ 9 - 9
package-lock.json

@@ -11,15 +11,15 @@
       "dev": true
     },
     "monaco-editor-core": {
-      "version": "0.18.0",
-      "resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.18.0.tgz",
-      "integrity": "sha512-URcHNAqH9X2JvO2skkIisAL4XAcZXxrDC8kcyr453sXQpOHUxicZpXHQb4/arXGvxrWvei3a6zZzpdT1gjeVJA==",
+      "version": "0.18.1",
+      "resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.18.1.tgz",
+      "integrity": "sha512-euzXzmwjZFG0oAPGjICMwINcZBzQDyfGDYlAR5YNMBJZO9Bmkqq1xpTTze/qQ0KKbVmawFXiwgUbg7WVgebP9Q==",
       "dev": true
     },
     "monaco-languages": {
-      "version": "1.7.0",
-      "resolved": "https://registry.npmjs.org/monaco-languages/-/monaco-languages-1.7.0.tgz",
-      "integrity": "sha512-2YrYlkCF/g2H0PDt/ERax2IStaihZ17v1JkYnj2xEALYNah0pbQvGH9gXJvdVx0EpBoSRmxVnrwwM2oBWWOjSQ==",
+      "version": "1.8.0",
+      "resolved": "https://registry.npmjs.org/monaco-languages/-/monaco-languages-1.8.0.tgz",
+      "integrity": "sha512-vC/lqNgSslQT3vSlNOpyT34ELK0eoNbA/rHUvTUjQemIiR1GpRMKhuwB21BqzWk+0MjZuJydGSCQMCebBge7jg==",
       "dev": true
     },
     "monaco-plugin-helpers": {
@@ -81,9 +81,9 @@
       }
     },
     "typescript": {
-      "version": "3.7.2",
-      "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz",
-      "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==",
+      "version": "3.7.3",
+      "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz",
+      "integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==",
       "dev": true
     }
   }

+ 3 - 3
package.json

@@ -20,11 +20,11 @@
     "url": "https://github.com/Microsoft/monaco-typescript/issues"
   },
   "devDependencies": {
-    "monaco-editor-core": "^0.18.0",
-    "monaco-languages": "^1.7.0",
+    "monaco-editor-core": "^0.18.1",
+    "monaco-languages": "^1.8.0",
     "monaco-plugin-helpers": "^1.0.2",
     "requirejs": "^2.3.6",
     "terser": "^4.4.3",
-    "typescript": "^3.7.2"
+    "typescript": "^3.7.3"
   }
 }

+ 143 - 104
src/lib/typescriptServices-amd.js

@@ -233,7 +233,7 @@ var ts;
     // If changing the text in this section, be sure to test `configureNightly` too.
     ts.versionMajorMinor = "3.7";
     /** The version of the TypeScript compiler release */
-    ts.version = ts.versionMajorMinor + ".2";
+    ts.version = ts.versionMajorMinor + ".3";
 })(ts || (ts = {}));
 (function (ts) {
     /* @internal */
@@ -3942,11 +3942,13 @@ var ts;
         SignatureFlags[SignatureFlags["None"] = 0] = "None";
         SignatureFlags[SignatureFlags["HasRestParameter"] = 1] = "HasRestParameter";
         SignatureFlags[SignatureFlags["HasLiteralTypes"] = 2] = "HasLiteralTypes";
-        SignatureFlags[SignatureFlags["IsOptionalCall"] = 4] = "IsOptionalCall";
-        // We do not propagate `IsOptionalCall` to instantiated signatures, as that would result in us
+        SignatureFlags[SignatureFlags["IsInnerCallChain"] = 4] = "IsInnerCallChain";
+        SignatureFlags[SignatureFlags["IsOuterCallChain"] = 8] = "IsOuterCallChain";
+        // We do not propagate `IsInnerCallChain` to instantiated signatures, as that would result in us
         // attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when
         // instantiating the return type.
         SignatureFlags[SignatureFlags["PropagatingFlags"] = 3] = "PropagatingFlags";
+        SignatureFlags[SignatureFlags["CallChainFlags"] = 12] = "CallChainFlags";
     })(SignatureFlags = ts.SignatureFlags || (ts.SignatureFlags = {}));
     var IndexKind;
     (function (IndexKind) {
@@ -6486,7 +6488,7 @@ var ts;
         Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: diag(5059, ts.DiagnosticCategory.Error, "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier."),
         Option_paths_cannot_be_used_without_specifying_baseUrl_option: diag(5060, ts.DiagnosticCategory.Error, "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", "Option 'paths' cannot be used without specifying '--baseUrl' option."),
         Pattern_0_can_have_at_most_one_Asterisk_character: diag(5061, ts.DiagnosticCategory.Error, "Pattern_0_can_have_at_most_one_Asterisk_character_5061", "Pattern '{0}' can have at most one '*' character."),
-        Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' in can have at most one '*' character."),
+        Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' can have at most one '*' character."),
         Substitutions_for_pattern_0_should_be_an_array: diag(5063, ts.DiagnosticCategory.Error, "Substitutions_for_pattern_0_should_be_an_array_5063", "Substitutions for pattern '{0}' should be an array."),
         Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: diag(5064, ts.DiagnosticCategory.Error, "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'."),
         File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5065, ts.DiagnosticCategory.Error, "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'."),
@@ -12485,30 +12487,31 @@ var ts;
      * @param host An EmitHost.
      * @param targetSourceFile An optional target source file to emit.
      */
-    function getSourceFilesToEmit(host, targetSourceFile) {
+    function getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit) {
         var options = host.getCompilerOptions();
-        var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); };
-        var getResolvedProjectReferenceToRedirect = function (fileName) { return host.getResolvedProjectReferenceToRedirect(fileName); };
         if (options.outFile || options.out) {
             var moduleKind = ts.getEmitModuleKind(options);
             var moduleEmitEnabled_1 = options.emitDeclarationOnly || moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System;
             // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified
             return ts.filter(host.getSourceFiles(), function (sourceFile) {
-                return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect);
+                return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) &&
+                    sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit);
             });
         }
         else {
             var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile];
-            return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); });
+            return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit); });
         }
     }
     ts.getSourceFilesToEmit = getSourceFilesToEmit;
     /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */
-    function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) {
+    function sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit) {
+        var options = host.getCompilerOptions();
         return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) &&
             !sourceFile.isDeclarationFile &&
-            !isSourceFileFromExternalLibrary(sourceFile) &&
-            !(isJsonSourceFile(sourceFile) && getResolvedProjectReferenceToRedirect(sourceFile.fileName));
+            !host.isSourceFileFromExternalLibrary(sourceFile) &&
+            !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) &&
+            (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName));
     }
     ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted;
     function getSourceFilePathInNewDir(fileName, host, newDirPath) {
@@ -14600,14 +14603,36 @@ var ts;
                 || kind === 195 /* CallExpression */);
     }
     ts.isOptionalChain = isOptionalChain;
+    /* @internal */
+    function isOptionalChainRoot(node) {
+        return isOptionalChain(node) && !!node.questionDotToken;
+    }
+    ts.isOptionalChainRoot = isOptionalChainRoot;
     /**
      * Determines whether a node is the expression preceding an optional chain (i.e. `a` in `a?.b`).
      */
     /* @internal */
     function isExpressionOfOptionalChainRoot(node) {
-        return ts.isOptionalChainRoot(node.parent) && node.parent.expression === node;
+        return isOptionalChainRoot(node.parent) && node.parent.expression === node;
     }
     ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot;
+    /**
+     * Determines whether a node is the outermost `OptionalChain` in an ECMAScript `OptionalExpression`:
+     *
+     * 1. For `a?.b.c`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.`)
+     * 2. For `(a?.b.c).d`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.` since parens end the chain)
+     * 3. For `a?.b.c?.d`, both `a?.b.c` and `a?.b.c?.d` are outermost (`c` is the end of the chain starting at `a?.`, and `d` is
+     *   the end of the chain starting at `c?.`)
+     * 4. For `a?.(b?.c).d`, both `b?.c` and `a?.(b?.c)d` are outermost (`c` is the end of the chain starting at `b`, and `d` is
+     *   the end of the chain starting at `a?.`)
+     */
+    /* @internal */
+    function isOutermostOptionalChain(node) {
+        return !isOptionalChain(node.parent) // cases 1 and 2
+            || isOptionalChainRoot(node.parent) // case 3
+            || node !== node.parent.expression; // case 4
+    }
+    ts.isOutermostOptionalChain = isOutermostOptionalChain;
     function isNullishCoalesce(node) {
         return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */;
     }
@@ -15882,11 +15907,6 @@ var ts;
         return node.kind === 162 /* GetAccessor */;
     }
     ts.isGetAccessor = isGetAccessor;
-    /* @internal */
-    function isOptionalChainRoot(node) {
-        return ts.isOptionalChain(node) && !!node.questionDotToken;
-    }
-    ts.isOptionalChainRoot = isOptionalChainRoot;
     /** True if has jsdoc nodes attached to it. */
     /* @internal */
     // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times
@@ -16787,6 +16807,8 @@ var ts;
         var patterns = [];
         for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
             var patternString = patternStrings_1[_i];
+            if (!ts.hasZeroOrOneAsteriskCharacter(patternString))
+                continue;
             var pattern = tryParsePattern(patternString);
             if (pattern) {
                 patterns.push(pattern);
@@ -29221,7 +29243,7 @@ var ts;
         }
         function bindCondition(node, trueTarget, falseTarget) {
             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
-            if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) {
+            if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
                 addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
                 addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
             }
@@ -29693,12 +29715,9 @@ var ts;
                 addDeclarationToSymbol(host.symbol, host, 32 /* Class */);
             }
         }
-        function isOutermostOptionalChain(node) {
-            return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression;
-        }
         function bindOptionalExpression(node, trueTarget, falseTarget) {
             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
-            if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) {
+            if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
                 addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
                 addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
             }
@@ -29736,7 +29755,7 @@ var ts;
                 currentFlow = finishFlowLabel(preChainLabel);
             }
             doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
-            if (isOutermostOptionalChain(node)) {
+            if (ts.isOutermostOptionalChain(node)) {
                 addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
                 addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
             }
@@ -30821,7 +30840,7 @@ var ts;
         }
         function bindObjectDefinePrototypeProperty(node) {
             var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
-            if (namespaceSymbol) {
+            if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
                 // Ensure the namespace symbol becomes class-like
                 addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */);
             }
@@ -31548,7 +31567,8 @@ var ts;
             || ts.hasModifier(node, 2270 /* TypeScriptModifier */)
             || node.typeParameters
             || node.type
-            || !node.body) {
+            || !node.body
+            || node.questionToken) {
             transformFlags |= 1 /* AssertTypeScript */;
         }
         // function declarations with object rest destructuring are ES2018 syntax
@@ -31585,7 +31605,7 @@ var ts;
     function computePropertyDeclaration(node, subtreeFlags) {
         var transformFlags = subtreeFlags | 1048576 /* ContainsClassFields */;
         // Decorators, TypeScript-specific modifiers, and type annotations are TypeScript syntax.
-        if (ts.some(node.decorators) || ts.hasModifier(node, 2270 /* TypeScriptModifier */) || node.type) {
+        if (ts.some(node.decorators) || ts.hasModifier(node, 2270 /* TypeScriptModifier */) || node.type || node.questionToken) {
             transformFlags |= 1 /* AssertTypeScript */;
         }
         // Hoisted variables related to class properties should live within the TypeScript class wrapper.
@@ -40115,13 +40135,21 @@ var ts;
             result.mapper = undefined;
             return result;
         }
-        function getOptionalCallSignature(signature) {
-            return signatureIsOptionalCall(signature) ? signature :
-                (signature.optionalCallSignatureCache || (signature.optionalCallSignatureCache = createOptionalCallSignature(signature)));
+        function getOptionalCallSignature(signature, callChainFlags) {
+            if ((signature.flags & 12 /* CallChainFlags */) === callChainFlags) {
+                return signature;
+            }
+            if (!signature.optionalCallSignatureCache) {
+                signature.optionalCallSignatureCache = {};
+            }
+            var key = callChainFlags === 4 /* IsInnerCallChain */ ? "inner" : "outer";
+            return signature.optionalCallSignatureCache[key]
+                || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
         }
-        function createOptionalCallSignature(signature) {
+        function createOptionalCallSignature(signature, callChainFlags) {
+            ts.Debug.assert(callChainFlags === 4 /* IsInnerCallChain */ || callChainFlags === 8 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both.");
             var result = cloneSignature(signature);
-            result.flags |= 4 /* IsOptionalCall */;
+            result.flags |= callChainFlags;
             return result;
         }
         function getExpandedParameters(sig) {
@@ -41633,9 +41661,12 @@ var ts;
                     signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) :
                         getReturnTypeFromAnnotation(signature.declaration) ||
                             (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
-                if (signatureIsOptionalCall(signature)) {
+                if (signature.flags & 4 /* IsInnerCallChain */) {
                     type = addOptionalTypeMarker(type);
                 }
+                else if (signature.flags & 8 /* IsOuterCallChain */) {
+                    type = getOptionalType(type);
+                }
                 if (!popTypeResolution()) {
                     if (signature.declaration) {
                         var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration);
@@ -42108,7 +42139,9 @@ var ts;
                     isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol;
                 }
                 var isDelayedMergeClass = symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol;
-                if (isRequireAlias || node.kind === 187 /* ImportType */ || isDelayedMergeClass) {
+                var isImportTypeWithQualifier = node.kind === 187 /* ImportType */ && node.qualifier;
+                // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL}
+                if (valueType.symbol && (isRequireAlias || isImportTypeWithQualifier || isDelayedMergeClass)) {
                     typeType = getTypeReferenceType(node, valueType.symbol);
                 }
             }
@@ -47648,8 +47681,8 @@ var ts;
         function removeOptionalTypeMarker(type) {
             return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type;
         }
-        function propagateOptionalTypeMarker(type, wasOptional) {
-            return wasOptional ? addOptionalTypeMarker(type) : type;
+        function propagateOptionalTypeMarker(type, node, wasOptional) {
+            return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type;
         }
         function getOptionalExpressionType(exprType, expression) {
             return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) :
@@ -53276,7 +53309,7 @@ var ts;
         function checkPropertyAccessChain(node) {
             var leftType = checkExpression(node.expression);
             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
-            return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), nonOptionalType !== leftType);
+            return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
         }
         function checkQualifiedName(node) {
             return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
@@ -53668,7 +53701,7 @@ var ts;
         function checkElementAccessChain(node) {
             var exprType = checkExpression(node.expression);
             var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
-            return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), nonOptionalType !== exprType);
+            return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
         }
         function checkElementAccessExpression(node, exprType) {
             var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
@@ -53757,7 +53790,7 @@ var ts;
         // interface B extends A { (x: 'foo'): string }
         // const b: B;
         // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void]
-        function reorderCandidates(signatures, result, isOptionalCall) {
+        function reorderCandidates(signatures, result, callChainFlags) {
             var lastParent;
             var lastSymbol;
             var cutoffIndex = 0;
@@ -53798,7 +53831,7 @@ var ts;
                 else {
                     spliceIndex = index;
                 }
-                result.splice(spliceIndex, 0, isOptionalCall ? getOptionalCallSignature(signature) : signature);
+                result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
             }
         }
         function isSpreadArgument(arg) {
@@ -54388,7 +54421,7 @@ var ts;
             }
             return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
         }
-        function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) {
+        function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
             var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */;
             var isDecorator = node.kind === 156 /* Decorator */;
             var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
@@ -54403,7 +54436,7 @@ var ts;
             }
             var candidates = candidatesOutArray || [];
             // reorderCandidates fills up the candidates array directly
-            reorderCandidates(signatures, candidates, isOptionalCall);
+            reorderCandidates(signatures, candidates, callChainFlags);
             if (!candidates.length) {
                 if (reportErrors) {
                     diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
@@ -54761,20 +54794,22 @@ var ts;
                     var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
                     if (baseTypeNode) {
                         var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
-                        return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false);
+                        return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */);
                     }
                 }
                 return resolveUntypedCall(node);
             }
-            var isOptional;
+            var callChainFlags;
             var funcType = checkExpression(node.expression);
             if (ts.isCallChain(node)) {
                 var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
-                isOptional = nonOptionalType !== funcType;
+                callChainFlags = nonOptionalType === funcType ? 0 /* None */ :
+                    ts.isOutermostOptionalChain(node) ? 8 /* IsOuterCallChain */ :
+                        4 /* IsInnerCallChain */;
                 funcType = nonOptionalType;
             }
             else {
-                isOptional = false;
+                callChainFlags = 0 /* None */;
             }
             funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
             if (funcType === silentNeverType) {
@@ -54842,7 +54877,7 @@ var ts;
                 error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
                 return resolveErrorCall(node);
             }
-            return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional);
+            return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
         }
         function isGenericFunctionReturningFunction(signature) {
             return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
@@ -54905,7 +54940,7 @@ var ts;
                     error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
                     return resolveErrorCall(node);
                 }
-                return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
+                return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */);
             }
             // If expressionType's apparent type is an object type with no construct signatures but
             // one or more call signatures, the expression is processed as a function call. A compile-time
@@ -54913,7 +54948,7 @@ var ts;
             // operation is Any. It is an error to have a Void this type.
             var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */);
             if (callSignatures.length) {
-                var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
+                var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
                 if (!noImplicitAny) {
                     if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
                         error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
@@ -55090,7 +55125,7 @@ var ts;
                 invocationError(node.tag, apparentType, 0 /* Call */);
                 return resolveErrorCall(node);
             }
-            return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
+            return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
         }
         /**
          * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression.
@@ -55143,7 +55178,7 @@ var ts;
                 invocationErrorRecovery(apparentType, 0 /* Call */, diag);
                 return resolveErrorCall(node);
             }
-            return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, headMessage);
+            return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
         }
         function createSignatureForJSXIntrinsic(node, result) {
             var namespace = getJsxNamespaceAt(node);
@@ -55181,7 +55216,7 @@ var ts;
                 error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
                 return resolveErrorCall(node);
             }
-            return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false);
+            return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
         }
         /**
          * Sometimes, we have a decorator that could accept zero arguments,
@@ -57441,6 +57476,18 @@ var ts;
                 }
             }
         }
+        function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
+            var signature = getSingleCallSignature(funcType);
+            if (signature && !signature.typeParameters) {
+                return getReturnTypeOfSignature(signature);
+            }
+        }
+        function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
+            var funcType = checkExpression(expr.expression);
+            var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
+            var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
+            return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
+        }
         /**
          * Returns the type of an expression. Unlike checkExpression, this function is simply concerned
          * with computing the type and may not fully check all contained sub-expressions for errors.
@@ -57452,21 +57499,10 @@ var ts;
             // Optimize for the common case of a call to a function with a single non-generic call
             // signature where we can just fetch the return type without checking the arguments.
             if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) {
-                var isOptional = void 0;
-                var funcType = void 0;
-                if (ts.isCallChain(expr)) {
-                    funcType = checkExpression(expr.expression);
-                    var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
-                    isOptional = funcType !== nonOptionalType;
-                    funcType = checkNonNullType(nonOptionalType, expr.expression);
-                }
-                else {
-                    isOptional = false;
-                    funcType = checkNonNullExpression(expr.expression);
-                }
-                var signature = getSingleCallSignature(funcType);
-                if (signature && !signature.typeParameters) {
-                    return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional);
+                var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
+                    getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
+                if (type) {
+                    return type;
                 }
             }
             else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
@@ -65321,10 +65357,6 @@ var ts;
         return !!(s.flags & 2 /* HasLiteralTypes */);
     }
     ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
-    function signatureIsOptionalCall(s) {
-        return !!(s.flags & 4 /* IsOptionalCall */);
-    }
-    ts.signatureIsOptionalCall = signatureIsOptionalCall;
 })(ts || (ts = {}));
 var ts;
 (function (ts) {
@@ -73316,12 +73348,12 @@ var ts;
                 for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
                     var parameter = parametersWithPropertyAssignments_1[_i];
                     if (ts.isIdentifier(parameter.name)) {
-                        members.push(ts.aggregateTransformFlags(ts.createProperty(
+                        members.push(ts.setOriginalNode(ts.aggregateTransformFlags(ts.createProperty(
                         /*decorators*/ undefined, 
                         /*modifiers*/ undefined, parameter.name, 
                         /*questionOrExclamationToken*/ undefined, 
                         /*type*/ undefined, 
-                        /*initializer*/ undefined)));
+                        /*initializer*/ undefined)), parameter));
                     }
                 }
             }
@@ -74136,6 +74168,9 @@ var ts;
             return !ts.nodeIsMissing(node.body);
         }
         function visitPropertyDeclaration(node) {
+            if (node.flags & 8388608 /* Ambient */) {
+                return undefined;
+            }
             var updated = ts.updateProperty(node, 
             /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), 
             /*questionOrExclamationToken*/ undefined, 
@@ -74520,7 +74555,12 @@ var ts;
          *
          * @param node The module declaration node.
          */
-        function shouldEmitModuleDeclaration(node) {
+        function shouldEmitModuleDeclaration(nodeIn) {
+            var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
+            if (!node) {
+                // If we can't find a parse tree node, assume the node is instantiated.
+                return true;
+            }
             return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules);
         }
         /**
@@ -75244,9 +75284,9 @@ var ts;
     /**
      * Transforms ECMAScript Class Syntax.
      * TypeScript parameter property syntax is transformed in the TypeScript transformer.
-     * For now, this transforms public field declarations using TypeScript class semantics
-     * (where the declarations get elided and initializers are transformed as assignments in the constructor).
-     * Eventually, this transform will change to the ECMAScript semantics (with Object.defineProperty).
+     * For now, this transforms public field declarations using TypeScript class semantics,
+     * where declarations are elided and initializers are transformed as assignments in the constructor.
+     * When --useDefineForClassFields is on, this transforms to ECMAScript semantics, with Object.defineProperty.
      */
     function transformClassFields(context) {
         var hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment;
@@ -75457,7 +75497,9 @@ var ts;
             /*modifiers*/ undefined, parameters, body), constructor || node), constructor));
         }
         function transformConstructorBody(node, constructor, isDerivedClass) {
-            var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false);
+            var _a;
+            var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
+            var properties = ts.getProperties(node, /*requireInitializer*/ !useDefineForClassFields, /*isStatic*/ false);
             // Only generate synthetic constructor when there are property initializers to move.
             if (!constructor && !ts.some(properties)) {
                 return ts.visitFunctionBody(/*node*/ undefined, visitor, context);
@@ -75486,19 +75528,16 @@ var ts;
             //      this.x = 1;
             //  }
             //
-            if (constructor && constructor.body) {
-                var parameterPropertyDeclarationCount = 0;
-                for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) {
-                    if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) {
-                        parameterPropertyDeclarationCount++;
-                    }
-                    else {
-                        break;
-                    }
+            if ((_a = constructor) === null || _a === void 0 ? void 0 : _a.body) {
+                var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
+                if (afterParameterProperties === -1) {
+                    afterParameterProperties = constructor.body.statements.length;
                 }
-                if (parameterPropertyDeclarationCount > 0) {
-                    ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, parameterPropertyDeclarationCount));
-                    indexOfFirstStatement += parameterPropertyDeclarationCount;
+                if (afterParameterProperties > indexOfFirstStatement) {
+                    if (!useDefineForClassFields) {
+                        ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
+                    }
+                    indexOfFirstStatement = afterParameterProperties;
                 }
             }
             addPropertyStatements(statements, properties, ts.createThis());
@@ -75559,7 +75598,9 @@ var ts;
             var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
                 ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name))
                 : property.name;
-            var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero();
+            var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression)
+                : ts.hasModifier(ts.getOriginalNode(property), 92 /* ParameterPropertyModifier */) && ts.isIdentifier(propertyName) ? propertyName
+                    : ts.createVoidZero();
             if (emitAssignment) {
                 var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName);
                 return ts.createAssignment(memberAccess, initializer);
@@ -88786,7 +88827,7 @@ var ts;
      */
     function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) {
         if (forceDtsEmit === void 0) { forceDtsEmit = false; }
-        var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile);
+        var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile, forceDtsEmit);
         var options = host.getCompilerOptions();
         if (options.outFile || options.out) {
             var prepends = host.getPrependNodes();
@@ -89030,7 +89071,7 @@ var ts;
         var exportedModulesFromDeclarationEmit;
         // Emit each output file
         enter();
-        forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
+        forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
         exit();
         return {
             emitSkipped: emitSkipped,
@@ -89418,6 +89459,7 @@ var ts;
             getLibFileFromReference: ts.notImplemented,
             isSourceFileFromExternalLibrary: ts.returnFalse,
             getResolvedProjectReferenceToRedirect: ts.returnUndefined,
+            isSourceOfProjectReferenceRedirect: ts.returnFalse,
             writeFile: function (name, text, writeByteOrderMark) {
                 switch (name) {
                     case jsFilePath:
@@ -94534,14 +94576,9 @@ var ts;
         function toPath(fileName) {
             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
         }
-        function isValidSourceFileForEmit(file) {
-            // source file is allowed to be emitted and its not source of project reference redirect
-            return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) &&
-                !isSourceOfProjectReferenceRedirect(file.fileName);
-        }
         function getCommonSourceDirectory() {
             if (commonSourceDirectory === undefined) {
-                var emittedFiles = ts.filter(files, function (file) { return isValidSourceFileForEmit(file); });
+                var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, program); });
                 if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) {
                     // If a rootDir is specified use it as the commonSourceDirectory
                     commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory);
@@ -94944,6 +94981,7 @@ var ts;
             return __assign(__assign({ getPrependNodes: getPrependNodes,
                 getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
                 getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
+                isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
                 getProbableSymlinks: getProbableSymlinks, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) {
                     // Use local caches
                     var path = toPath(f);
@@ -96164,7 +96202,7 @@ var ts;
                 for (var _i = 0, files_3 = files; _i < files_3.length; _i++) {
                     var file = files_3[_i];
                     // Ignore file that is not emitted
-                    if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) {
+                    if (ts.sourceFileMayBeEmitted(file, program) && !rootPaths.has(file.path)) {
                         addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "");
                     }
                 }
@@ -96187,7 +96225,7 @@ var ts;
                             var typeOfSubst = typeof subst;
                             if (typeOfSubst === "string") {
                                 if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
-                                    createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key);
+                                    createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
                                 }
                             }
                             else {
@@ -104184,10 +104222,11 @@ var ts;
         }
         var dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
         var stringContent = host.readFile(fileName);
-        var content = stringContent && tryParseJson(stringContent);
-        if (!content) {
+        if (!stringContent)
             return undefined;
-        }
+        var content = tryParseJson(stringContent);
+        if (!content)
+            return false;
         var info = {};
         for (var _i = 0, dependencyKeys_1 = dependencyKeys; _i < dependencyKeys_1.length; _i++) {
             var key = dependencyKeys_1[_i];

+ 143 - 104
src/lib/typescriptServices.js

@@ -233,7 +233,7 @@ var ts;
     // If changing the text in this section, be sure to test `configureNightly` too.
     ts.versionMajorMinor = "3.7";
     /** The version of the TypeScript compiler release */
-    ts.version = ts.versionMajorMinor + ".2";
+    ts.version = ts.versionMajorMinor + ".3";
 })(ts || (ts = {}));
 (function (ts) {
     /* @internal */
@@ -3942,11 +3942,13 @@ var ts;
         SignatureFlags[SignatureFlags["None"] = 0] = "None";
         SignatureFlags[SignatureFlags["HasRestParameter"] = 1] = "HasRestParameter";
         SignatureFlags[SignatureFlags["HasLiteralTypes"] = 2] = "HasLiteralTypes";
-        SignatureFlags[SignatureFlags["IsOptionalCall"] = 4] = "IsOptionalCall";
-        // We do not propagate `IsOptionalCall` to instantiated signatures, as that would result in us
+        SignatureFlags[SignatureFlags["IsInnerCallChain"] = 4] = "IsInnerCallChain";
+        SignatureFlags[SignatureFlags["IsOuterCallChain"] = 8] = "IsOuterCallChain";
+        // We do not propagate `IsInnerCallChain` to instantiated signatures, as that would result in us
         // attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when
         // instantiating the return type.
         SignatureFlags[SignatureFlags["PropagatingFlags"] = 3] = "PropagatingFlags";
+        SignatureFlags[SignatureFlags["CallChainFlags"] = 12] = "CallChainFlags";
     })(SignatureFlags = ts.SignatureFlags || (ts.SignatureFlags = {}));
     var IndexKind;
     (function (IndexKind) {
@@ -6486,7 +6488,7 @@ var ts;
         Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: diag(5059, ts.DiagnosticCategory.Error, "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier."),
         Option_paths_cannot_be_used_without_specifying_baseUrl_option: diag(5060, ts.DiagnosticCategory.Error, "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", "Option 'paths' cannot be used without specifying '--baseUrl' option."),
         Pattern_0_can_have_at_most_one_Asterisk_character: diag(5061, ts.DiagnosticCategory.Error, "Pattern_0_can_have_at_most_one_Asterisk_character_5061", "Pattern '{0}' can have at most one '*' character."),
-        Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' in can have at most one '*' character."),
+        Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' can have at most one '*' character."),
         Substitutions_for_pattern_0_should_be_an_array: diag(5063, ts.DiagnosticCategory.Error, "Substitutions_for_pattern_0_should_be_an_array_5063", "Substitutions for pattern '{0}' should be an array."),
         Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: diag(5064, ts.DiagnosticCategory.Error, "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'."),
         File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5065, ts.DiagnosticCategory.Error, "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'."),
@@ -12485,30 +12487,31 @@ var ts;
      * @param host An EmitHost.
      * @param targetSourceFile An optional target source file to emit.
      */
-    function getSourceFilesToEmit(host, targetSourceFile) {
+    function getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit) {
         var options = host.getCompilerOptions();
-        var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); };
-        var getResolvedProjectReferenceToRedirect = function (fileName) { return host.getResolvedProjectReferenceToRedirect(fileName); };
         if (options.outFile || options.out) {
             var moduleKind = ts.getEmitModuleKind(options);
             var moduleEmitEnabled_1 = options.emitDeclarationOnly || moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System;
             // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified
             return ts.filter(host.getSourceFiles(), function (sourceFile) {
-                return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect);
+                return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) &&
+                    sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit);
             });
         }
         else {
             var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile];
-            return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); });
+            return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit); });
         }
     }
     ts.getSourceFilesToEmit = getSourceFilesToEmit;
     /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */
-    function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) {
+    function sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit) {
+        var options = host.getCompilerOptions();
         return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) &&
             !sourceFile.isDeclarationFile &&
-            !isSourceFileFromExternalLibrary(sourceFile) &&
-            !(isJsonSourceFile(sourceFile) && getResolvedProjectReferenceToRedirect(sourceFile.fileName));
+            !host.isSourceFileFromExternalLibrary(sourceFile) &&
+            !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) &&
+            (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName));
     }
     ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted;
     function getSourceFilePathInNewDir(fileName, host, newDirPath) {
@@ -14600,14 +14603,36 @@ var ts;
                 || kind === 195 /* CallExpression */);
     }
     ts.isOptionalChain = isOptionalChain;
+    /* @internal */
+    function isOptionalChainRoot(node) {
+        return isOptionalChain(node) && !!node.questionDotToken;
+    }
+    ts.isOptionalChainRoot = isOptionalChainRoot;
     /**
      * Determines whether a node is the expression preceding an optional chain (i.e. `a` in `a?.b`).
      */
     /* @internal */
     function isExpressionOfOptionalChainRoot(node) {
-        return ts.isOptionalChainRoot(node.parent) && node.parent.expression === node;
+        return isOptionalChainRoot(node.parent) && node.parent.expression === node;
     }
     ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot;
+    /**
+     * Determines whether a node is the outermost `OptionalChain` in an ECMAScript `OptionalExpression`:
+     *
+     * 1. For `a?.b.c`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.`)
+     * 2. For `(a?.b.c).d`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.` since parens end the chain)
+     * 3. For `a?.b.c?.d`, both `a?.b.c` and `a?.b.c?.d` are outermost (`c` is the end of the chain starting at `a?.`, and `d` is
+     *   the end of the chain starting at `c?.`)
+     * 4. For `a?.(b?.c).d`, both `b?.c` and `a?.(b?.c)d` are outermost (`c` is the end of the chain starting at `b`, and `d` is
+     *   the end of the chain starting at `a?.`)
+     */
+    /* @internal */
+    function isOutermostOptionalChain(node) {
+        return !isOptionalChain(node.parent) // cases 1 and 2
+            || isOptionalChainRoot(node.parent) // case 3
+            || node !== node.parent.expression; // case 4
+    }
+    ts.isOutermostOptionalChain = isOutermostOptionalChain;
     function isNullishCoalesce(node) {
         return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */;
     }
@@ -15882,11 +15907,6 @@ var ts;
         return node.kind === 162 /* GetAccessor */;
     }
     ts.isGetAccessor = isGetAccessor;
-    /* @internal */
-    function isOptionalChainRoot(node) {
-        return ts.isOptionalChain(node) && !!node.questionDotToken;
-    }
-    ts.isOptionalChainRoot = isOptionalChainRoot;
     /** True if has jsdoc nodes attached to it. */
     /* @internal */
     // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times
@@ -16787,6 +16807,8 @@ var ts;
         var patterns = [];
         for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
             var patternString = patternStrings_1[_i];
+            if (!ts.hasZeroOrOneAsteriskCharacter(patternString))
+                continue;
             var pattern = tryParsePattern(patternString);
             if (pattern) {
                 patterns.push(pattern);
@@ -29221,7 +29243,7 @@ var ts;
         }
         function bindCondition(node, trueTarget, falseTarget) {
             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
-            if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) {
+            if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
                 addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
                 addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
             }
@@ -29693,12 +29715,9 @@ var ts;
                 addDeclarationToSymbol(host.symbol, host, 32 /* Class */);
             }
         }
-        function isOutermostOptionalChain(node) {
-            return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression;
-        }
         function bindOptionalExpression(node, trueTarget, falseTarget) {
             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
-            if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) {
+            if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
                 addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
                 addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
             }
@@ -29736,7 +29755,7 @@ var ts;
                 currentFlow = finishFlowLabel(preChainLabel);
             }
             doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
-            if (isOutermostOptionalChain(node)) {
+            if (ts.isOutermostOptionalChain(node)) {
                 addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
                 addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
             }
@@ -30821,7 +30840,7 @@ var ts;
         }
         function bindObjectDefinePrototypeProperty(node) {
             var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
-            if (namespaceSymbol) {
+            if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
                 // Ensure the namespace symbol becomes class-like
                 addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */);
             }
@@ -31548,7 +31567,8 @@ var ts;
             || ts.hasModifier(node, 2270 /* TypeScriptModifier */)
             || node.typeParameters
             || node.type
-            || !node.body) {
+            || !node.body
+            || node.questionToken) {
             transformFlags |= 1 /* AssertTypeScript */;
         }
         // function declarations with object rest destructuring are ES2018 syntax
@@ -31585,7 +31605,7 @@ var ts;
     function computePropertyDeclaration(node, subtreeFlags) {
         var transformFlags = subtreeFlags | 1048576 /* ContainsClassFields */;
         // Decorators, TypeScript-specific modifiers, and type annotations are TypeScript syntax.
-        if (ts.some(node.decorators) || ts.hasModifier(node, 2270 /* TypeScriptModifier */) || node.type) {
+        if (ts.some(node.decorators) || ts.hasModifier(node, 2270 /* TypeScriptModifier */) || node.type || node.questionToken) {
             transformFlags |= 1 /* AssertTypeScript */;
         }
         // Hoisted variables related to class properties should live within the TypeScript class wrapper.
@@ -40115,13 +40135,21 @@ var ts;
             result.mapper = undefined;
             return result;
         }
-        function getOptionalCallSignature(signature) {
-            return signatureIsOptionalCall(signature) ? signature :
-                (signature.optionalCallSignatureCache || (signature.optionalCallSignatureCache = createOptionalCallSignature(signature)));
+        function getOptionalCallSignature(signature, callChainFlags) {
+            if ((signature.flags & 12 /* CallChainFlags */) === callChainFlags) {
+                return signature;
+            }
+            if (!signature.optionalCallSignatureCache) {
+                signature.optionalCallSignatureCache = {};
+            }
+            var key = callChainFlags === 4 /* IsInnerCallChain */ ? "inner" : "outer";
+            return signature.optionalCallSignatureCache[key]
+                || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
         }
-        function createOptionalCallSignature(signature) {
+        function createOptionalCallSignature(signature, callChainFlags) {
+            ts.Debug.assert(callChainFlags === 4 /* IsInnerCallChain */ || callChainFlags === 8 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both.");
             var result = cloneSignature(signature);
-            result.flags |= 4 /* IsOptionalCall */;
+            result.flags |= callChainFlags;
             return result;
         }
         function getExpandedParameters(sig) {
@@ -41633,9 +41661,12 @@ var ts;
                     signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) :
                         getReturnTypeFromAnnotation(signature.declaration) ||
                             (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
-                if (signatureIsOptionalCall(signature)) {
+                if (signature.flags & 4 /* IsInnerCallChain */) {
                     type = addOptionalTypeMarker(type);
                 }
+                else if (signature.flags & 8 /* IsOuterCallChain */) {
+                    type = getOptionalType(type);
+                }
                 if (!popTypeResolution()) {
                     if (signature.declaration) {
                         var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration);
@@ -42108,7 +42139,9 @@ var ts;
                     isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol;
                 }
                 var isDelayedMergeClass = symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol;
-                if (isRequireAlias || node.kind === 187 /* ImportType */ || isDelayedMergeClass) {
+                var isImportTypeWithQualifier = node.kind === 187 /* ImportType */ && node.qualifier;
+                // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL}
+                if (valueType.symbol && (isRequireAlias || isImportTypeWithQualifier || isDelayedMergeClass)) {
                     typeType = getTypeReferenceType(node, valueType.symbol);
                 }
             }
@@ -47648,8 +47681,8 @@ var ts;
         function removeOptionalTypeMarker(type) {
             return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type;
         }
-        function propagateOptionalTypeMarker(type, wasOptional) {
-            return wasOptional ? addOptionalTypeMarker(type) : type;
+        function propagateOptionalTypeMarker(type, node, wasOptional) {
+            return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type;
         }
         function getOptionalExpressionType(exprType, expression) {
             return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) :
@@ -53276,7 +53309,7 @@ var ts;
         function checkPropertyAccessChain(node) {
             var leftType = checkExpression(node.expression);
             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
-            return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), nonOptionalType !== leftType);
+            return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
         }
         function checkQualifiedName(node) {
             return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
@@ -53668,7 +53701,7 @@ var ts;
         function checkElementAccessChain(node) {
             var exprType = checkExpression(node.expression);
             var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
-            return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), nonOptionalType !== exprType);
+            return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
         }
         function checkElementAccessExpression(node, exprType) {
             var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
@@ -53757,7 +53790,7 @@ var ts;
         // interface B extends A { (x: 'foo'): string }
         // const b: B;
         // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void]
-        function reorderCandidates(signatures, result, isOptionalCall) {
+        function reorderCandidates(signatures, result, callChainFlags) {
             var lastParent;
             var lastSymbol;
             var cutoffIndex = 0;
@@ -53798,7 +53831,7 @@ var ts;
                 else {
                     spliceIndex = index;
                 }
-                result.splice(spliceIndex, 0, isOptionalCall ? getOptionalCallSignature(signature) : signature);
+                result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
             }
         }
         function isSpreadArgument(arg) {
@@ -54388,7 +54421,7 @@ var ts;
             }
             return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
         }
-        function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) {
+        function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
             var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */;
             var isDecorator = node.kind === 156 /* Decorator */;
             var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
@@ -54403,7 +54436,7 @@ var ts;
             }
             var candidates = candidatesOutArray || [];
             // reorderCandidates fills up the candidates array directly
-            reorderCandidates(signatures, candidates, isOptionalCall);
+            reorderCandidates(signatures, candidates, callChainFlags);
             if (!candidates.length) {
                 if (reportErrors) {
                     diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
@@ -54761,20 +54794,22 @@ var ts;
                     var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
                     if (baseTypeNode) {
                         var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
-                        return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false);
+                        return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */);
                     }
                 }
                 return resolveUntypedCall(node);
             }
-            var isOptional;
+            var callChainFlags;
             var funcType = checkExpression(node.expression);
             if (ts.isCallChain(node)) {
                 var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
-                isOptional = nonOptionalType !== funcType;
+                callChainFlags = nonOptionalType === funcType ? 0 /* None */ :
+                    ts.isOutermostOptionalChain(node) ? 8 /* IsOuterCallChain */ :
+                        4 /* IsInnerCallChain */;
                 funcType = nonOptionalType;
             }
             else {
-                isOptional = false;
+                callChainFlags = 0 /* None */;
             }
             funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
             if (funcType === silentNeverType) {
@@ -54842,7 +54877,7 @@ var ts;
                 error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
                 return resolveErrorCall(node);
             }
-            return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional);
+            return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
         }
         function isGenericFunctionReturningFunction(signature) {
             return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
@@ -54905,7 +54940,7 @@ var ts;
                     error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
                     return resolveErrorCall(node);
                 }
-                return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
+                return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */);
             }
             // If expressionType's apparent type is an object type with no construct signatures but
             // one or more call signatures, the expression is processed as a function call. A compile-time
@@ -54913,7 +54948,7 @@ var ts;
             // operation is Any. It is an error to have a Void this type.
             var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */);
             if (callSignatures.length) {
-                var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
+                var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
                 if (!noImplicitAny) {
                     if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
                         error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
@@ -55090,7 +55125,7 @@ var ts;
                 invocationError(node.tag, apparentType, 0 /* Call */);
                 return resolveErrorCall(node);
             }
-            return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
+            return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
         }
         /**
          * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression.
@@ -55143,7 +55178,7 @@ var ts;
                 invocationErrorRecovery(apparentType, 0 /* Call */, diag);
                 return resolveErrorCall(node);
             }
-            return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, headMessage);
+            return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
         }
         function createSignatureForJSXIntrinsic(node, result) {
             var namespace = getJsxNamespaceAt(node);
@@ -55181,7 +55216,7 @@ var ts;
                 error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
                 return resolveErrorCall(node);
             }
-            return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false);
+            return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
         }
         /**
          * Sometimes, we have a decorator that could accept zero arguments,
@@ -57441,6 +57476,18 @@ var ts;
                 }
             }
         }
+        function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
+            var signature = getSingleCallSignature(funcType);
+            if (signature && !signature.typeParameters) {
+                return getReturnTypeOfSignature(signature);
+            }
+        }
+        function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
+            var funcType = checkExpression(expr.expression);
+            var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
+            var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
+            return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
+        }
         /**
          * Returns the type of an expression. Unlike checkExpression, this function is simply concerned
          * with computing the type and may not fully check all contained sub-expressions for errors.
@@ -57452,21 +57499,10 @@ var ts;
             // Optimize for the common case of a call to a function with a single non-generic call
             // signature where we can just fetch the return type without checking the arguments.
             if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) {
-                var isOptional = void 0;
-                var funcType = void 0;
-                if (ts.isCallChain(expr)) {
-                    funcType = checkExpression(expr.expression);
-                    var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
-                    isOptional = funcType !== nonOptionalType;
-                    funcType = checkNonNullType(nonOptionalType, expr.expression);
-                }
-                else {
-                    isOptional = false;
-                    funcType = checkNonNullExpression(expr.expression);
-                }
-                var signature = getSingleCallSignature(funcType);
-                if (signature && !signature.typeParameters) {
-                    return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional);
+                var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
+                    getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
+                if (type) {
+                    return type;
                 }
             }
             else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
@@ -65321,10 +65357,6 @@ var ts;
         return !!(s.flags & 2 /* HasLiteralTypes */);
     }
     ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
-    function signatureIsOptionalCall(s) {
-        return !!(s.flags & 4 /* IsOptionalCall */);
-    }
-    ts.signatureIsOptionalCall = signatureIsOptionalCall;
 })(ts || (ts = {}));
 var ts;
 (function (ts) {
@@ -73316,12 +73348,12 @@ var ts;
                 for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
                     var parameter = parametersWithPropertyAssignments_1[_i];
                     if (ts.isIdentifier(parameter.name)) {
-                        members.push(ts.aggregateTransformFlags(ts.createProperty(
+                        members.push(ts.setOriginalNode(ts.aggregateTransformFlags(ts.createProperty(
                         /*decorators*/ undefined, 
                         /*modifiers*/ undefined, parameter.name, 
                         /*questionOrExclamationToken*/ undefined, 
                         /*type*/ undefined, 
-                        /*initializer*/ undefined)));
+                        /*initializer*/ undefined)), parameter));
                     }
                 }
             }
@@ -74136,6 +74168,9 @@ var ts;
             return !ts.nodeIsMissing(node.body);
         }
         function visitPropertyDeclaration(node) {
+            if (node.flags & 8388608 /* Ambient */) {
+                return undefined;
+            }
             var updated = ts.updateProperty(node, 
             /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), 
             /*questionOrExclamationToken*/ undefined, 
@@ -74520,7 +74555,12 @@ var ts;
          *
          * @param node The module declaration node.
          */
-        function shouldEmitModuleDeclaration(node) {
+        function shouldEmitModuleDeclaration(nodeIn) {
+            var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
+            if (!node) {
+                // If we can't find a parse tree node, assume the node is instantiated.
+                return true;
+            }
             return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules);
         }
         /**
@@ -75244,9 +75284,9 @@ var ts;
     /**
      * Transforms ECMAScript Class Syntax.
      * TypeScript parameter property syntax is transformed in the TypeScript transformer.
-     * For now, this transforms public field declarations using TypeScript class semantics
-     * (where the declarations get elided and initializers are transformed as assignments in the constructor).
-     * Eventually, this transform will change to the ECMAScript semantics (with Object.defineProperty).
+     * For now, this transforms public field declarations using TypeScript class semantics,
+     * where declarations are elided and initializers are transformed as assignments in the constructor.
+     * When --useDefineForClassFields is on, this transforms to ECMAScript semantics, with Object.defineProperty.
      */
     function transformClassFields(context) {
         var hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment;
@@ -75457,7 +75497,9 @@ var ts;
             /*modifiers*/ undefined, parameters, body), constructor || node), constructor));
         }
         function transformConstructorBody(node, constructor, isDerivedClass) {
-            var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false);
+            var _a;
+            var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
+            var properties = ts.getProperties(node, /*requireInitializer*/ !useDefineForClassFields, /*isStatic*/ false);
             // Only generate synthetic constructor when there are property initializers to move.
             if (!constructor && !ts.some(properties)) {
                 return ts.visitFunctionBody(/*node*/ undefined, visitor, context);
@@ -75486,19 +75528,16 @@ var ts;
             //      this.x = 1;
             //  }
             //
-            if (constructor && constructor.body) {
-                var parameterPropertyDeclarationCount = 0;
-                for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) {
-                    if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) {
-                        parameterPropertyDeclarationCount++;
-                    }
-                    else {
-                        break;
-                    }
+            if ((_a = constructor) === null || _a === void 0 ? void 0 : _a.body) {
+                var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
+                if (afterParameterProperties === -1) {
+                    afterParameterProperties = constructor.body.statements.length;
                 }
-                if (parameterPropertyDeclarationCount > 0) {
-                    ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, parameterPropertyDeclarationCount));
-                    indexOfFirstStatement += parameterPropertyDeclarationCount;
+                if (afterParameterProperties > indexOfFirstStatement) {
+                    if (!useDefineForClassFields) {
+                        ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
+                    }
+                    indexOfFirstStatement = afterParameterProperties;
                 }
             }
             addPropertyStatements(statements, properties, ts.createThis());
@@ -75559,7 +75598,9 @@ var ts;
             var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
                 ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name))
                 : property.name;
-            var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero();
+            var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression)
+                : ts.hasModifier(ts.getOriginalNode(property), 92 /* ParameterPropertyModifier */) && ts.isIdentifier(propertyName) ? propertyName
+                    : ts.createVoidZero();
             if (emitAssignment) {
                 var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName);
                 return ts.createAssignment(memberAccess, initializer);
@@ -88786,7 +88827,7 @@ var ts;
      */
     function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) {
         if (forceDtsEmit === void 0) { forceDtsEmit = false; }
-        var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile);
+        var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile, forceDtsEmit);
         var options = host.getCompilerOptions();
         if (options.outFile || options.out) {
             var prepends = host.getPrependNodes();
@@ -89030,7 +89071,7 @@ var ts;
         var exportedModulesFromDeclarationEmit;
         // Emit each output file
         enter();
-        forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
+        forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
         exit();
         return {
             emitSkipped: emitSkipped,
@@ -89418,6 +89459,7 @@ var ts;
             getLibFileFromReference: ts.notImplemented,
             isSourceFileFromExternalLibrary: ts.returnFalse,
             getResolvedProjectReferenceToRedirect: ts.returnUndefined,
+            isSourceOfProjectReferenceRedirect: ts.returnFalse,
             writeFile: function (name, text, writeByteOrderMark) {
                 switch (name) {
                     case jsFilePath:
@@ -94534,14 +94576,9 @@ var ts;
         function toPath(fileName) {
             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
         }
-        function isValidSourceFileForEmit(file) {
-            // source file is allowed to be emitted and its not source of project reference redirect
-            return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) &&
-                !isSourceOfProjectReferenceRedirect(file.fileName);
-        }
         function getCommonSourceDirectory() {
             if (commonSourceDirectory === undefined) {
-                var emittedFiles = ts.filter(files, function (file) { return isValidSourceFileForEmit(file); });
+                var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, program); });
                 if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) {
                     // If a rootDir is specified use it as the commonSourceDirectory
                     commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory);
@@ -94944,6 +94981,7 @@ var ts;
             return __assign(__assign({ getPrependNodes: getPrependNodes,
                 getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
                 getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
+                isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
                 getProbableSymlinks: getProbableSymlinks, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) {
                     // Use local caches
                     var path = toPath(f);
@@ -96164,7 +96202,7 @@ var ts;
                 for (var _i = 0, files_3 = files; _i < files_3.length; _i++) {
                     var file = files_3[_i];
                     // Ignore file that is not emitted
-                    if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) {
+                    if (ts.sourceFileMayBeEmitted(file, program) && !rootPaths.has(file.path)) {
                         addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "");
                     }
                 }
@@ -96187,7 +96225,7 @@ var ts;
                             var typeOfSubst = typeof subst;
                             if (typeOfSubst === "string") {
                                 if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
-                                    createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key);
+                                    createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
                                 }
                             }
                             else {
@@ -104184,10 +104222,11 @@ var ts;
         }
         var dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
         var stringContent = host.readFile(fileName);
-        var content = stringContent && tryParseJson(stringContent);
-        if (!content) {
+        if (!stringContent)
             return undefined;
-        }
+        var content = tryParseJson(stringContent);
+        if (!content)
+            return false;
         var info = {};
         for (var _i = 0, dependencyKeys_1 = dependencyKeys; _i < dependencyKeys_1.length; _i++) {
             var key = dependencyKeys_1[_i];

+ 1 - 1
src/lib/typescriptServicesMetadata.ts

@@ -1 +1 @@
-export const typescriptVersion = "3.7.2";
+export const typescriptVersion = "3.7.3";