diff --git a/lib/lib.d.ts b/lib/lib.d.ts index cb9294153fc..80e09b844cb 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -1762,13 +1762,6 @@ interface Int8Array { */ reverse(): Int8Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -2053,13 +2046,6 @@ interface Uint8Array { */ reverse(): Uint8Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -2345,19 +2331,12 @@ interface Uint8ClampedArray { */ reverse(): Uint8ClampedArray; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint8ClampedArray, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2636,13 +2615,6 @@ interface Int16Array { */ reverse(): Int16Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -2928,13 +2900,6 @@ interface Uint16Array { */ reverse(): Uint16Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -3219,13 +3184,6 @@ interface Int32Array { */ reverse(): Int32Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -3510,13 +3468,6 @@ interface Uint32Array { */ reverse(): Uint32Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -3801,13 +3752,6 @@ interface Float32Array { */ reverse(): Float32Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -4093,13 +4037,6 @@ interface Float64Array { */ reverse(): Float64Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. diff --git a/lib/lib.es2015.collection.d.ts b/lib/lib.es2015.collection.d.ts index 37ebed50a90..4d84af429be 100644 --- a/lib/lib.es2015.collection.d.ts +++ b/lib/lib.es2015.collection.d.ts @@ -78,7 +78,7 @@ interface ReadonlySet { readonly size: number; } -interface WeakSet { +interface WeakSet { add(value: T): this; delete(value: T): boolean; has(value: T): boolean; diff --git a/lib/lib.es2015.iterable.d.ts b/lib/lib.es2015.iterable.d.ts index e083a89f75d..1fe1a0e0ca1 100644 --- a/lib/lib.es2015.iterable.d.ts +++ b/lib/lib.es2015.iterable.d.ts @@ -138,7 +138,7 @@ interface SetConstructor { new (iterable: Iterable): Set; } -interface WeakSet { } +interface WeakSet { } interface WeakSetConstructor { new (iterable: Iterable): WeakSet; diff --git a/lib/lib.es2015.symbol.wellknown.d.ts b/lib/lib.es2015.symbol.wellknown.d.ts index 869da0561e8..1d17534723a 100644 --- a/lib/lib.es2015.symbol.wellknown.d.ts +++ b/lib/lib.es2015.symbol.wellknown.d.ts @@ -138,7 +138,7 @@ interface Set { readonly [Symbol.toStringTag]: "Set"; } -interface WeakSet { +interface WeakSet { readonly [Symbol.toStringTag]: "WeakSet"; } diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index f43d062adf1..1d19198d1d1 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -1762,13 +1762,6 @@ interface Int8Array { */ reverse(): Int8Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -2053,13 +2046,6 @@ interface Uint8Array { */ reverse(): Uint8Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -2345,19 +2331,12 @@ interface Uint8ClampedArray { */ reverse(): Uint8ClampedArray; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint8ClampedArray, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2636,13 +2615,6 @@ interface Int16Array { */ reverse(): Int16Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -2928,13 +2900,6 @@ interface Uint16Array { */ reverse(): Uint16Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -3219,13 +3184,6 @@ interface Int32Array { */ reverse(): Int32Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -3510,13 +3468,6 @@ interface Uint32Array { */ reverse(): Uint32Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -3801,13 +3752,6 @@ interface Float32Array { */ reverse(): Float32Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -4093,13 +4037,6 @@ interface Float64Array { */ reverse(): Float64Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 9136af4375f..4bc7e03e341 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -1762,13 +1762,6 @@ interface Int8Array { */ reverse(): Int8Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -2053,13 +2046,6 @@ interface Uint8Array { */ reverse(): Uint8Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -2345,19 +2331,12 @@ interface Uint8ClampedArray { */ reverse(): Uint8ClampedArray; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint8ClampedArray, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2636,13 +2615,6 @@ interface Int16Array { */ reverse(): Int16Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -2928,13 +2900,6 @@ interface Uint16Array { */ reverse(): Uint16Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -3219,13 +3184,6 @@ interface Int32Array { */ reverse(): Int32Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -3510,13 +3468,6 @@ interface Uint32Array { */ reverse(): Uint32Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -3801,13 +3752,6 @@ interface Float32Array { */ reverse(): Float32Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -4093,13 +4037,6 @@ interface Float64Array { */ reverse(): Float64Array; - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. @@ -4938,7 +4875,7 @@ interface ReadonlySet { readonly size: number; } -interface WeakSet { +interface WeakSet { add(value: T): this; delete(value: T): boolean; has(value: T): boolean; @@ -5126,7 +5063,7 @@ interface SetConstructor { new (iterable: Iterable): Set; } -interface WeakSet { } +interface WeakSet { } interface WeakSetConstructor { new (iterable: Iterable): WeakSet; @@ -5893,7 +5830,7 @@ interface Set { readonly [Symbol.toStringTag]: "Set"; } -interface WeakSet { +interface WeakSet { readonly [Symbol.toStringTag]: "WeakSet"; } diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index 59bb95a50ed..b02ff258bb3 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -770,6 +770,11 @@ declare namespace ts.server.protocol { * "TS", "JS", "TSX", "JSX" */ scriptKindName?: ScriptKindName; + /** + * Used to limit the searching for project config file. If given the searching will stop at this + * root path; otherwise it will go all the way up to the dist root path. + */ + projectRootPath?: string; } type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; /** diff --git a/lib/tsc.js b/lib/tsc.js index dd752b850e6..9ca9a64dabe 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -21113,7 +21113,7 @@ var ts; recordMergedSymbol(target, source); } else if (target.flags & 1024) { - error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations[0].name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { var message_2 = target.flags & 2 || source.flags & 2 @@ -35821,7 +35821,7 @@ var ts; } } var iteratorMethodSignatures; - var mayBeIterable = false; + var isNonAsyncIterable = false; if (isAsyncIterable) { var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); if (isTypeAny(iteratorMethod)) { @@ -35835,13 +35835,13 @@ var ts; return undefined; } iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0); - mayBeIterable = true; + isNonAsyncIterable = true; } if (ts.some(iteratorMethodSignatures)) { var iteratorMethodReturnType = getUnionType(ts.map(iteratorMethodSignatures, getReturnTypeOfSignature), true); - var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, false); + var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, !isNonAsyncIterable); if (checkAssignability && errorNode && iteratedType) { - checkTypeAssignableTo(type, mayBeIterable + checkTypeAssignableTo(type, isNonAsyncIterable ? createIterableType(iteratedType) : createAsyncIterableType(iteratedType), errorNode); } @@ -40721,7 +40721,7 @@ var ts; var hasExtendsClause = ts.getClassExtendsHeritageClauseElement(node) !== undefined; var isDecoratedClass = shouldEmitDecorateCallForClass(node); var name = node.name; - if (!name && staticProperties.length > 0) { + if (!name && (staticProperties.length > 0 || ts.childIsDecorated(node))) { name = ts.getGeneratedNameForNode(node); } var classStatement = isDecoratedClass @@ -42775,7 +42775,7 @@ var ts; var asyncGeneratorHelper = { name: "typescript:asyncGenerator", scoped: false, - text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? _yield : r.value[0] === \"delegate\" ? delegate : fulfill, reject); }\n function _yield(value) { settle(c[2], { value: value, done: false }); }\n function delegate(r) { step(r.done ? r : { value: [\"yield\", r.value], done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " + text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? send : fulfill, reject); }\n function send(value) { settle(c[2], { value: value, done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " }; function createAsyncGeneratorHelper(context, generatorFunc) { context.requestEmitHelper(asyncGeneratorHelper); @@ -42789,10 +42789,11 @@ var ts; var asyncDelegator = { name: "typescript:asyncDelegator", scoped: false, - text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) };\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return { value: [\"delegate\", (o[n] || f).call(o, v)], done: false }; }; }\n };\n " + text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) }, p;\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return v = p && n === \"throw\" ? f(v) : p && v.done ? v : { value: p ? [\"yield\", v.value] : [\"await\", (o[n] || f).call(o, v)], done: false }, p = !p, v; }; }\n };\n " }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(asyncValues); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), undefined, [expression]), location); } var asyncValues = { @@ -44526,8 +44527,8 @@ var ts; else { loopBody = ts.createBlock([loopBody], true); } - var isAsyncBlockContainingAwait = hierarchyFacts & 4 - && (node.statement.transformFlags & 16777216) !== 0; + var containsYield = (node.statement.transformFlags & 16777216) !== 0; + var isAsyncBlockContainingAwait = containsYield && (hierarchyFacts & 4) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 8; @@ -44536,7 +44537,7 @@ var ts; loopBodyFlags |= 131072; } var convertedLoopVariable = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) ]), 1048576)); var statements = [convertedLoopVariable]; var extraVariableDeclarations; @@ -44582,7 +44583,7 @@ var ts; if (extraVariableDeclarations) { statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, containsYield); var loop; if (convert) { loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); @@ -53688,6 +53689,9 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { + if (options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) { + return emptyArray; + } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; @@ -55431,10 +55435,11 @@ var ts; var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + var baseCompileOnSave; if (json["extends"]) { var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseCompileOnSave, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseCompileOnSave = _b[3], baseOptions = _b[4]; } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); @@ -55454,6 +55459,9 @@ var ts; options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + if (baseCompileOnSave && json[ts.compileOnSaveCommandLineOption.name] === undefined) { + compileOnSave = baseCompileOnSave; + } return { options: options, fileNames: fileNames, @@ -55491,7 +55499,7 @@ var ts; return ts.map(extendedResult.config[key], updatePath); } }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; + return [include, exclude, files, result.compileOnSave, result.options]; } function getFileNames(errors) { var fileNames; diff --git a/lib/tsserver.js b/lib/tsserver.js index 7a567b0d3af..a7c1ca52410 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -22274,7 +22274,7 @@ var ts; recordMergedSymbol(target, source); } else if (target.flags & 1024) { - error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations[0].name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { var message_2 = target.flags & 2 || source.flags & 2 @@ -36989,7 +36989,7 @@ var ts; } } var iteratorMethodSignatures; - var mayBeIterable = false; + var isNonAsyncIterable = false; if (isAsyncIterable) { var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); if (isTypeAny(iteratorMethod)) { @@ -37003,13 +37003,13 @@ var ts; return undefined; } iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0); - mayBeIterable = true; + isNonAsyncIterable = true; } if (ts.some(iteratorMethodSignatures)) { var iteratorMethodReturnType = getUnionType(ts.map(iteratorMethodSignatures, getReturnTypeOfSignature), true); - var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, false); + var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, !isNonAsyncIterable); if (checkAssignability && errorNode && iteratedType) { - checkTypeAssignableTo(type, mayBeIterable + checkTypeAssignableTo(type, isNonAsyncIterable ? createIterableType(iteratedType) : createAsyncIterableType(iteratedType), errorNode); } @@ -41900,7 +41900,7 @@ var ts; var hasExtendsClause = ts.getClassExtendsHeritageClauseElement(node) !== undefined; var isDecoratedClass = shouldEmitDecorateCallForClass(node); var name = node.name; - if (!name && staticProperties.length > 0) { + if (!name && (staticProperties.length > 0 || ts.childIsDecorated(node))) { name = ts.getGeneratedNameForNode(node); } var classStatement = isDecoratedClass @@ -43962,7 +43962,7 @@ var ts; var asyncGeneratorHelper = { name: "typescript:asyncGenerator", scoped: false, - text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? _yield : r.value[0] === \"delegate\" ? delegate : fulfill, reject); }\n function _yield(value) { settle(c[2], { value: value, done: false }); }\n function delegate(r) { step(r.done ? r : { value: [\"yield\", r.value], done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " + text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? send : fulfill, reject); }\n function send(value) { settle(c[2], { value: value, done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " }; function createAsyncGeneratorHelper(context, generatorFunc) { context.requestEmitHelper(asyncGeneratorHelper); @@ -43976,10 +43976,11 @@ var ts; var asyncDelegator = { name: "typescript:asyncDelegator", scoped: false, - text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) };\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return { value: [\"delegate\", (o[n] || f).call(o, v)], done: false }; }; }\n };\n " + text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) }, p;\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return v = p && n === \"throw\" ? f(v) : p && v.done ? v : { value: p ? [\"yield\", v.value] : [\"await\", (o[n] || f).call(o, v)], done: false }, p = !p, v; }; }\n };\n " }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(asyncValues); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), undefined, [expression]), location); } var asyncValues = { @@ -45782,8 +45783,8 @@ var ts; else { loopBody = ts.createBlock([loopBody], true); } - var isAsyncBlockContainingAwait = hierarchyFacts & 4 - && (node.statement.transformFlags & 16777216) !== 0; + var containsYield = (node.statement.transformFlags & 16777216) !== 0; + var isAsyncBlockContainingAwait = containsYield && (hierarchyFacts & 4) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 8; @@ -45792,7 +45793,7 @@ var ts; loopBodyFlags |= 131072; } var convertedLoopVariable = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) ]), 1048576)); var statements = [convertedLoopVariable]; var extraVariableDeclarations; @@ -45838,7 +45839,7 @@ var ts; if (extraVariableDeclarations) { statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, containsYield); var loop; if (convert) { loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); @@ -55069,6 +55070,9 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { + if (options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) { + return emptyArray; + } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; @@ -56812,10 +56816,11 @@ var ts; var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + var baseCompileOnSave; if (json["extends"]) { var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseCompileOnSave, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseCompileOnSave = _b[3], baseOptions = _b[4]; } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); @@ -56835,6 +56840,9 @@ var ts; options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + if (baseCompileOnSave && json[ts.compileOnSaveCommandLineOption.name] === undefined) { + compileOnSave = baseCompileOnSave; + } return { options: options, fileNames: fileNames, @@ -56872,7 +56880,7 @@ var ts; return ts.map(extendedResult.config[key], updatePath); } }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; + return [include, exclude, files, result.compileOnSave, result.options]; } function getFileNames(errors) { var fileNames; @@ -75251,10 +75259,10 @@ var ts; this.filenameToScriptInfo.remove(info.path); } }; - ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { + ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName, projectRootPath) { var searchPath = ts.getDirectoryPath(fileName); this.logger.info("Search path: " + searchPath); - var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath)); + var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath), projectRootPath); if (!configFileName) { this.logger.info("No config files found."); return {}; @@ -75276,8 +75284,8 @@ var ts; } return { configFileName: configFileName }; }; - ProjectService.prototype.findConfigFile = function (searchPath) { - while (true) { + ProjectService.prototype.findConfigFile = function (searchPath, projectRootPath) { + while (!projectRootPath || searchPath.indexOf(projectRootPath) >= 0) { var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); if (this.host.fileExists(tsconfigFileName)) { return tsconfigFileName; @@ -75672,15 +75680,15 @@ var ts; } this.printProjects(); }; - ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind); + ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind, projectRootPath) { + return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind, false, projectRootPath ? server.toNormalizedPath(projectRootPath) : undefined); }; - ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent) { + ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent, projectRootPath) { var configFileName; var configFileErrors; var project = this.findContainingExternalProject(fileName); if (!project) { - (_a = this.openOrUpdateConfiguredProjectForFile(fileName), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors); + (_a = this.openOrUpdateConfiguredProjectForFile(fileName, projectRootPath), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors); if (configFileName) { project = this.findConfiguredProjectByProjectName(configFileName); } @@ -76001,14 +76009,13 @@ var ts; var nanoseconds = time[1]; return ((1e9 * seconds) + nanoseconds) / 1000000.0; } - function shouldSkipSemanticCheck(project) { - if (project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) { - return project.isJsOnlyProject(); - } - else { - var options = project.getCompilerOptions(); - return options.skipLibCheck && !options.checkJs && project.isJsOnlyProject(); + function isDeclarationFileInJSOnlyNonConfiguredProject(project, file) { + if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && + project.isJsOnlyProject()) { + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + return scriptInfo && !scriptInfo.isJavaScript(); } + return false; } function compareNumber(a, b) { return a - b; @@ -76291,7 +76298,7 @@ var ts; return _this.requiredResponse(_this.getRenameInfo(request.arguments)); }, _a[CommandNames.Open] = function (request) { - _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName)); + _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName), request.arguments.projectRootPath ? server.toNormalizedPath(request.arguments.projectRootPath) : undefined); return _this.notRequired(); }, _a[CommandNames.Quickinfo] = function (request) { @@ -76585,7 +76592,7 @@ var ts; Session.prototype.semanticCheck = function (file, project) { try { var diags = []; - if (!shouldSkipSemanticCheck(project)) { + if (!isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) { diags = project.getLanguageService().getSemanticDiagnostics(file); } var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); @@ -76688,7 +76695,7 @@ var ts; }; Session.prototype.getDiagnosticsWorker = function (args, isSemantic, selector, includeLinePosition) { var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; - if (isSemantic && shouldSkipSemanticCheck(project)) { + if (isSemantic && isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) { return []; } var scriptInfo = project.getScriptInfoForNormalizedPath(file); @@ -77003,8 +77010,8 @@ var ts; return false; } }; - Session.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; + Session.prototype.openClientFile = function (fileName, fileContent, scriptKind, projectRootPath) { + var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind, false, projectRootPath), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; if (this.eventHandler) { this.eventHandler({ eventName: "configFileDiag", diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index e4391e49fef..4f38b599336 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -2380,7 +2380,7 @@ declare namespace ts { error?: Diagnostic; }; function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine; - function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; + function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean | undefined; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; @@ -3869,6 +3869,7 @@ declare namespace ts.server.protocol { interface OpenRequestArgs extends FileRequestArgs { fileContent?: string; scriptKindName?: ScriptKindName; + projectRootPath?: string; } type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; interface OpenRequest extends Request { @@ -4505,7 +4506,7 @@ declare namespace ts.server { private getDefaultProject(args); private getRenameLocations(args, simplifiedResult); private getReferences(args, simplifiedResult); - private openClientFile(fileName, fileContent?, scriptKind?); + private openClientFile(fileName, fileContent?, scriptKind?, projectRootPath?); private getPosition(args, scriptInfo); private getFileAndProject(args, errorOnMissingProject?); private getFileAndProjectWithoutRefreshingInferredProjects(args, errorOnMissingProject?); @@ -5086,8 +5087,8 @@ declare namespace ts.server { private removeProject(project); private assignScriptInfoToInferredProjectIfNecessary(info, addToListOfOpenFiles); private closeOpenFile(info); - private openOrUpdateConfiguredProjectForFile(fileName); - private findConfigFile(searchPath); + private openOrUpdateConfiguredProjectForFile(fileName, projectRootPath?); + private findConfigFile(searchPath, projectRootPath?); private printProjects(); private findConfiguredProjectByProjectName(configFileName); private findExternalProjectByProjectName(projectFileName); @@ -5111,8 +5112,8 @@ declare namespace ts.server { closeLog(): void; reloadProjects(): void; refreshInferredProjects(): void; - openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind): OpenConfiguredProjectResult; - openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): OpenConfiguredProjectResult; + openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind, projectRootPath?: string): OpenConfiguredProjectResult; + openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult; closeClientFile(uncheckedFileName: string): void; private collectChanges(lastKnownProjectVersions, currentProjects, result); private closeConfiguredProject(configFile); diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 3f03613d7a2..6422bd23965 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -6860,10 +6860,11 @@ var ts; var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + var baseCompileOnSave; if (json["extends"]) { var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseCompileOnSave, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseCompileOnSave = _b[3], baseOptions = _b[4]; } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); @@ -6883,6 +6884,9 @@ var ts; options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + if (baseCompileOnSave && json[ts.compileOnSaveCommandLineOption.name] === undefined) { + compileOnSave = baseCompileOnSave; + } return { options: options, fileNames: fileNames, @@ -6920,7 +6924,7 @@ var ts; return ts.map(extendedResult.config[key], updatePath); } }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; + return [include, exclude, files, result.compileOnSave, result.options]; } function getFileNames(errors) { var fileNames; @@ -23616,7 +23620,7 @@ var ts; recordMergedSymbol(target, source); } else if (target.flags & 1024) { - error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations[0].name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { var message_2 = target.flags & 2 || source.flags & 2 @@ -38331,7 +38335,7 @@ var ts; } } var iteratorMethodSignatures; - var mayBeIterable = false; + var isNonAsyncIterable = false; if (isAsyncIterable) { var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); if (isTypeAny(iteratorMethod)) { @@ -38345,13 +38349,13 @@ var ts; return undefined; } iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0); - mayBeIterable = true; + isNonAsyncIterable = true; } if (ts.some(iteratorMethodSignatures)) { var iteratorMethodReturnType = getUnionType(ts.map(iteratorMethodSignatures, getReturnTypeOfSignature), true); - var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, false); + var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, !isNonAsyncIterable); if (checkAssignability && errorNode && iteratedType) { - checkTypeAssignableTo(type, mayBeIterable + checkTypeAssignableTo(type, isNonAsyncIterable ? createIterableType(iteratedType) : createAsyncIterableType(iteratedType), errorNode); } @@ -43242,7 +43246,7 @@ var ts; var hasExtendsClause = ts.getClassExtendsHeritageClauseElement(node) !== undefined; var isDecoratedClass = shouldEmitDecorateCallForClass(node); var name = node.name; - if (!name && staticProperties.length > 0) { + if (!name && (staticProperties.length > 0 || ts.childIsDecorated(node))) { name = ts.getGeneratedNameForNode(node); } var classStatement = isDecoratedClass @@ -45304,7 +45308,7 @@ var ts; var asyncGeneratorHelper = { name: "typescript:asyncGenerator", scoped: false, - text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? _yield : r.value[0] === \"delegate\" ? delegate : fulfill, reject); }\n function _yield(value) { settle(c[2], { value: value, done: false }); }\n function delegate(r) { step(r.done ? r : { value: [\"yield\", r.value], done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " + text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? send : fulfill, reject); }\n function send(value) { settle(c[2], { value: value, done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " }; function createAsyncGeneratorHelper(context, generatorFunc) { context.requestEmitHelper(asyncGeneratorHelper); @@ -45318,10 +45322,11 @@ var ts; var asyncDelegator = { name: "typescript:asyncDelegator", scoped: false, - text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) };\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return { value: [\"delegate\", (o[n] || f).call(o, v)], done: false }; }; }\n };\n " + text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) }, p;\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return v = p && n === \"throw\" ? f(v) : p && v.done ? v : { value: p ? [\"yield\", v.value] : [\"await\", (o[n] || f).call(o, v)], done: false }, p = !p, v; }; }\n };\n " }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(asyncValues); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), undefined, [expression]), location); } var asyncValues = { @@ -47124,8 +47129,8 @@ var ts; else { loopBody = ts.createBlock([loopBody], true); } - var isAsyncBlockContainingAwait = hierarchyFacts & 4 - && (node.statement.transformFlags & 16777216) !== 0; + var containsYield = (node.statement.transformFlags & 16777216) !== 0; + var isAsyncBlockContainingAwait = containsYield && (hierarchyFacts & 4) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 8; @@ -47134,7 +47139,7 @@ var ts; loopBodyFlags |= 131072; } var convertedLoopVariable = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) ]), 1048576)); var statements = [convertedLoopVariable]; var extraVariableDeclarations; @@ -47180,7 +47185,7 @@ var ts; if (extraVariableDeclarations) { statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, containsYield); var loop; if (convert) { loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); @@ -56411,6 +56416,9 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { + if (options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) { + return emptyArray; + } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; @@ -72320,14 +72328,13 @@ var ts; var nanoseconds = time[1]; return ((1e9 * seconds) + nanoseconds) / 1000000.0; } - function shouldSkipSemanticCheck(project) { - if (project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) { - return project.isJsOnlyProject(); - } - else { - var options = project.getCompilerOptions(); - return options.skipLibCheck && !options.checkJs && project.isJsOnlyProject(); + function isDeclarationFileInJSOnlyNonConfiguredProject(project, file) { + if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && + project.isJsOnlyProject()) { + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + return scriptInfo && !scriptInfo.isJavaScript(); } + return false; } function compareNumber(a, b) { return a - b; @@ -72610,7 +72617,7 @@ var ts; return _this.requiredResponse(_this.getRenameInfo(request.arguments)); }, _a[CommandNames.Open] = function (request) { - _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName)); + _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName), request.arguments.projectRootPath ? server.toNormalizedPath(request.arguments.projectRootPath) : undefined); return _this.notRequired(); }, _a[CommandNames.Quickinfo] = function (request) { @@ -72904,7 +72911,7 @@ var ts; Session.prototype.semanticCheck = function (file, project) { try { var diags = []; - if (!shouldSkipSemanticCheck(project)) { + if (!isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) { diags = project.getLanguageService().getSemanticDiagnostics(file); } var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); @@ -73007,7 +73014,7 @@ var ts; }; Session.prototype.getDiagnosticsWorker = function (args, isSemantic, selector, includeLinePosition) { var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; - if (isSemantic && shouldSkipSemanticCheck(project)) { + if (isSemantic && isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) { return []; } var scriptInfo = project.getScriptInfoForNormalizedPath(file); @@ -73322,8 +73329,8 @@ var ts; return false; } }; - Session.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; + Session.prototype.openClientFile = function (fileName, fileContent, scriptKind, projectRootPath) { + var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind, false, projectRootPath), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; if (this.eventHandler) { this.eventHandler({ eventName: "configFileDiag", @@ -77037,10 +77044,10 @@ var ts; this.filenameToScriptInfo.remove(info.path); } }; - ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { + ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName, projectRootPath) { var searchPath = ts.getDirectoryPath(fileName); this.logger.info("Search path: " + searchPath); - var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath)); + var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath), projectRootPath); if (!configFileName) { this.logger.info("No config files found."); return {}; @@ -77062,8 +77069,8 @@ var ts; } return { configFileName: configFileName }; }; - ProjectService.prototype.findConfigFile = function (searchPath) { - while (true) { + ProjectService.prototype.findConfigFile = function (searchPath, projectRootPath) { + while (!projectRootPath || searchPath.indexOf(projectRootPath) >= 0) { var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); if (this.host.fileExists(tsconfigFileName)) { return tsconfigFileName; @@ -77458,15 +77465,15 @@ var ts; } this.printProjects(); }; - ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind); + ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind, projectRootPath) { + return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind, false, projectRootPath ? server.toNormalizedPath(projectRootPath) : undefined); }; - ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent) { + ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent, projectRootPath) { var configFileName; var configFileErrors; var project = this.findContainingExternalProject(fileName); if (!project) { - (_a = this.openOrUpdateConfiguredProjectForFile(fileName), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors); + (_a = this.openOrUpdateConfiguredProjectForFile(fileName, projectRootPath), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors); if (configFileName) { project = this.findConfiguredProjectByProjectName(configFileName); } diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index f754353d871..16c4d98c829 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -3242,7 +3242,7 @@ declare namespace ts { * file to. e.g. outDir */ function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine; - function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; + function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean | undefined; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; diff --git a/lib/typescript.js b/lib/typescript.js index d4304ed4fbe..a52d86c4e10 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -25908,7 +25908,7 @@ var ts; recordMergedSymbol(target, source); } else if (target.flags & 1024 /* NamespaceModule */) { - error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations[0].name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { var message_2 = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ @@ -43342,7 +43342,7 @@ var ts; } } var iteratorMethodSignatures; - var mayBeIterable = false; + var isNonAsyncIterable = false; if (isAsyncIterable) { var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); if (isTypeAny(iteratorMethod)) { @@ -43356,16 +43356,16 @@ var ts; return undefined; } iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0 /* Call */); - mayBeIterable = true; + isNonAsyncIterable = true; } if (ts.some(iteratorMethodSignatures)) { var iteratorMethodReturnType = getUnionType(ts.map(iteratorMethodSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); - var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, /*isAsyncIterator*/ false); + var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, /*isAsyncIterator*/ !isNonAsyncIterable); if (checkAssignability && errorNode && iteratedType) { // If `checkAssignability` was specified, we were called from // `checkIteratedTypeOrElementType`. As such, we need to validate that // the type passed in is actually an Iterable. - checkTypeAssignableTo(type, mayBeIterable + checkTypeAssignableTo(type, isNonAsyncIterable ? createIterableType(iteratedType) : createAsyncIterableType(iteratedType), errorNode); } @@ -49104,9 +49104,10 @@ var ts; // emit name if // - node has a name // - node has static initializers + // - node has a member that is decorated // var name = node.name; - if (!name && staticProperties.length > 0) { + if (!name && (staticProperties.length > 0 || ts.childIsDecorated(node))) { name = ts.getGeneratedNameForNode(node); } var classStatement = isDecoratedClass @@ -52351,7 +52352,7 @@ var ts; var asyncGeneratorHelper = { name: "typescript:asyncGenerator", scoped: false, - text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? _yield : r.value[0] === \"delegate\" ? delegate : fulfill, reject); }\n function _yield(value) { settle(c[2], { value: value, done: false }); }\n function delegate(r) { step(r.done ? r : { value: [\"yield\", r.value], done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " + text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? send : fulfill, reject); }\n function send(value) { settle(c[2], { value: value, done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " }; function createAsyncGeneratorHelper(context, generatorFunc) { context.requestEmitHelper(asyncGeneratorHelper); @@ -52367,10 +52368,11 @@ var ts; var asyncDelegator = { name: "typescript:asyncDelegator", scoped: false, - text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) };\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return { value: [\"delegate\", (o[n] || f).call(o, v)], done: false }; }; }\n };\n " + text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) }, p;\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return v = p && n === \"throw\" ? f(v) : p && v.done ? v : { value: p ? [\"yield\", v.value] : [\"await\", (o[n] || f).call(o, v)], done: false }, p = !p, v; }; }\n };\n " }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(asyncValues); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } @@ -54860,8 +54862,8 @@ var ts; else { loopBody = ts.createBlock([loopBody], /*multiline*/ true); } - var isAsyncBlockContainingAwait = hierarchyFacts & 4 /* AsyncFunctionBody */ - && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; + var containsYield = (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; + var isAsyncBlockContainingAwait = containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 8 /* CapturesThis */; @@ -54873,7 +54875,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, isAsyncBlockContainingAwait ? ts.createToken(38 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(38 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, loopParameters, /*type*/ undefined, loopBody), loopBodyFlags)) @@ -54940,7 +54942,7 @@ var ts; statements.push(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, containsYield); var loop; if (convert) { loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); @@ -67202,6 +67204,12 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { + // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. + // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a + // '/// ' directive. + if (options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) { + return emptyArray; + } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; @@ -69113,10 +69121,11 @@ var ts; // It should be removed in future releases - use typeAcquisition instead. var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + var baseCompileOnSave; if (json["extends"]) { var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseCompileOnSave, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseCompileOnSave = _b[3], baseOptions = _b[4]; } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); @@ -69136,6 +69145,9 @@ var ts; options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + if (baseCompileOnSave && json[ts.compileOnSaveCommandLineOption.name] === undefined) { + compileOnSave = baseCompileOnSave; + } return { options: options, fileNames: fileNames, @@ -69175,7 +69187,7 @@ var ts; return ts.map(extendedResult.config[key], updatePath); } }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; + return [include, exclude, files, result.compileOnSave, result.options]; } function getFileNames(errors) { var fileNames; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 91861efed25..3e922940be2 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -3242,7 +3242,7 @@ declare namespace ts { * file to. e.g. outDir */ function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine; - function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; + function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean | undefined; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index d4304ed4fbe..a52d86c4e10 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -25908,7 +25908,7 @@ var ts; recordMergedSymbol(target, source); } else if (target.flags & 1024 /* NamespaceModule */) { - error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations[0].name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { var message_2 = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ @@ -43342,7 +43342,7 @@ var ts; } } var iteratorMethodSignatures; - var mayBeIterable = false; + var isNonAsyncIterable = false; if (isAsyncIterable) { var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); if (isTypeAny(iteratorMethod)) { @@ -43356,16 +43356,16 @@ var ts; return undefined; } iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0 /* Call */); - mayBeIterable = true; + isNonAsyncIterable = true; } if (ts.some(iteratorMethodSignatures)) { var iteratorMethodReturnType = getUnionType(ts.map(iteratorMethodSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); - var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, /*isAsyncIterator*/ false); + var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, /*isAsyncIterator*/ !isNonAsyncIterable); if (checkAssignability && errorNode && iteratedType) { // If `checkAssignability` was specified, we were called from // `checkIteratedTypeOrElementType`. As such, we need to validate that // the type passed in is actually an Iterable. - checkTypeAssignableTo(type, mayBeIterable + checkTypeAssignableTo(type, isNonAsyncIterable ? createIterableType(iteratedType) : createAsyncIterableType(iteratedType), errorNode); } @@ -49104,9 +49104,10 @@ var ts; // emit name if // - node has a name // - node has static initializers + // - node has a member that is decorated // var name = node.name; - if (!name && staticProperties.length > 0) { + if (!name && (staticProperties.length > 0 || ts.childIsDecorated(node))) { name = ts.getGeneratedNameForNode(node); } var classStatement = isDecoratedClass @@ -52351,7 +52352,7 @@ var ts; var asyncGeneratorHelper = { name: "typescript:asyncGenerator", scoped: false, - text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? _yield : r.value[0] === \"delegate\" ? delegate : fulfill, reject); }\n function _yield(value) { settle(c[2], { value: value, done: false }); }\n function delegate(r) { step(r.done ? r : { value: [\"yield\", r.value], done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " + text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? send : fulfill, reject); }\n function send(value) { settle(c[2], { value: value, done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " }; function createAsyncGeneratorHelper(context, generatorFunc) { context.requestEmitHelper(asyncGeneratorHelper); @@ -52367,10 +52368,11 @@ var ts; var asyncDelegator = { name: "typescript:asyncDelegator", scoped: false, - text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) };\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return { value: [\"delegate\", (o[n] || f).call(o, v)], done: false }; }; }\n };\n " + text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) }, p;\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return v = p && n === \"throw\" ? f(v) : p && v.done ? v : { value: p ? [\"yield\", v.value] : [\"await\", (o[n] || f).call(o, v)], done: false }, p = !p, v; }; }\n };\n " }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(asyncValues); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } @@ -54860,8 +54862,8 @@ var ts; else { loopBody = ts.createBlock([loopBody], /*multiline*/ true); } - var isAsyncBlockContainingAwait = hierarchyFacts & 4 /* AsyncFunctionBody */ - && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; + var containsYield = (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; + var isAsyncBlockContainingAwait = containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 8 /* CapturesThis */; @@ -54873,7 +54875,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, isAsyncBlockContainingAwait ? ts.createToken(38 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(38 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, loopParameters, /*type*/ undefined, loopBody), loopBodyFlags)) @@ -54940,7 +54942,7 @@ var ts; statements.push(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, containsYield); var loop; if (convert) { loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); @@ -67202,6 +67204,12 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { + // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. + // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a + // '/// ' directive. + if (options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) { + return emptyArray; + } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; @@ -69113,10 +69121,11 @@ var ts; // It should be removed in future releases - use typeAcquisition instead. var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + var baseCompileOnSave; if (json["extends"]) { var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseCompileOnSave, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseCompileOnSave = _b[3], baseOptions = _b[4]; } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); @@ -69136,6 +69145,9 @@ var ts; options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + if (baseCompileOnSave && json[ts.compileOnSaveCommandLineOption.name] === undefined) { + compileOnSave = baseCompileOnSave; + } return { options: options, fileNames: fileNames, @@ -69175,7 +69187,7 @@ var ts; return ts.map(extendedResult.config[key], updatePath); } }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; + return [include, exclude, files, result.compileOnSave, result.options]; } function getFileNames(errors) { var fileNames; diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 7a0f21d5e6e..642652b5b04 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -5880,10 +5880,11 @@ var ts; var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + var baseCompileOnSave; if (json["extends"]) { var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseCompileOnSave, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseCompileOnSave = _b[3], baseOptions = _b[4]; } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); @@ -5903,6 +5904,9 @@ var ts; options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + if (baseCompileOnSave && json[ts.compileOnSaveCommandLineOption.name] === undefined) { + compileOnSave = baseCompileOnSave; + } return { options: options, fileNames: fileNames, @@ -5940,7 +5944,7 @@ var ts; return ts.map(extendedResult.config[key], updatePath); } }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; + return [include, exclude, files, result.compileOnSave, result.options]; } function getFileNames(errors) { var fileNames;