diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md index 62647a8b163..7b9b2c4a630 100644 --- a/.github/ISSUE_TEMPLATE/Bug_report.md +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -1,41 +1,44 @@ ---- -name: Bug report -about: Create a report to help us improve - ---- - - - - -**TypeScript Version:** 3.7.x-dev.201xxxxx - - -**Search Terms:** - -**Code** - -```ts -// A *self-contained* demonstration of the problem follows... -// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc. -``` - -**Expected behavior:** - -**Actual behavior:** - -**Playground Link:** - -**Related Issues:** +--- +name: Bug +about: Create a report to help us improve TypeScript +title: '' +labels: '' +assignees: '' + +--- + + + + +**TypeScript Version:** 3.7.x-dev.201xxxxx + + +**Search Terms:** + +**Code** + +```ts +// A *self-contained* demonstration of the problem follows... +// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc. +``` + +**Expected behavior:** + +**Actual behavior:** + +**Playground Link:** + +**Related Issues:** diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md index 74525bf2f80..e5f21faeafe 100644 --- a/.github/ISSUE_TEMPLATE/Feature_request.md +++ b/.github/ISSUE_TEMPLATE/Feature_request.md @@ -1,45 +1,47 @@ ---- -name: Feature request -about: Suggest an idea for this project - ---- - - - -## Search Terms - - - -## Suggestion - - - -## Use Cases - - - -## Examples - - - -## Checklist - -My suggestion meets these guidelines: - -* [ ] This wouldn't be a breaking change in existing TypeScript/JavaScript code -* [ ] This wouldn't change the runtime behavior of existing JavaScript code -* [ ] This could be implemented without emitting different JS based on the types of the expressions -* [ ] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.) -* [ ] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals). - +--- +name: Feature Request +about: Suggest an idea +title: '' +labels: '' +assignees: '' + +--- + + + +## Search Terms + + + +## Suggestion + + + +## Use Cases + + + +## Examples + + + +## Checklist + +My suggestion meets these guidelines: + +* [ ] This wouldn't be a breaking change in existing TypeScript/JavaScript code +* [ ] This wouldn't change the runtime behavior of existing JavaScript code +* [ ] This could be implemented without emitting different JS based on the types of the expressions +* [ ] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.) +* [ ] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals). diff --git a/.github/ISSUE_TEMPLATE/Question.md b/.github/ISSUE_TEMPLATE/Question.md deleted file mode 100644 index fbb9d150a7c..00000000000 --- a/.github/ISSUE_TEMPLATE/Question.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -name: Question -about: The issue tracker is not for questions. Please use Stack Overflow or other resources for help writing TypeScript code. - ---- - -THE ISSUE TRACKER IS NOT FOR QUESTIONS. - -DO NOT CREATE A NEW ISSUE TO ASK A QUESTION. - -IF YOU ARE HAVING PROBLEMS WITH YOUR TYPESCRIPT CODE, DO NOT ASK A QUESTION HERE. - -Tens of thousands of TypeScript questions have been asked and answered on StackOverflow; see https://stackoverflow.com/questions/tagged/typescript . You can ask questions there or on other websites. - -The only exception is if you have a question about *the TypeScript compiler API itself*. Please post a complete example of what you're trying to do and precisely describe what your question is. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000000..e4c59996bd0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: Question + url: https://stackoverflow.com/questions/tagged/typescript + about: Please ask and answer questions here. + - name: TypeScript FAQ + url: https://github.com/microsoft/TypeScript/wiki/FAQ + about: Please check the FAQ before filing new issues \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..69f2bf06f8b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,37 @@ +name: CI + +on: + push: + branches: + - master + - release-* + pull_request: + branches: + - master + - release-* + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [8.x, 10.x, 12.x] + + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 5 + - name: Use node version ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Remove existing TypeScript + run: | + npm uninstall typescript --no-save + npm uninstall tslint --no-save + - name: npm install and test + run: | + npm install + npm update + npm test diff --git a/.vscode/launch.template.json b/.vscode/launch.template.json index 4ba7f8ab880..ede5febb3bf 100644 --- a/.vscode/launch.template.json +++ b/.vscode/launch.template.json @@ -1,5 +1,17 @@ -// Rename this file 'launch.json' or merge its -// contents into your existing configurations. +/* + + Copy this file into '.vscode/launch.json' or merge its + contents into your existing configurations. + + If you want to remove the errors in comments for all JSON + files, add this to your settings in ~/.vscode/User/settings.json + + "files.associations": { + "*.json": "jsonc" + }, + +*/ + { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. @@ -10,7 +22,7 @@ "type": "node", "protocol": "inspector", "request": "launch", - "name": "MochaΒ TestsΒ (currentlyΒ openedΒ test)", + "name": "Mocha Tests (currently opened test)", "runtimeArgs": ["--nolazy"], "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", "args": [ @@ -20,6 +32,8 @@ "--colors", "built/local/run.js", "-f", + // You can change this to be the name of a specific test file (without the file extension) + // to consistently launch the same test "${fileBasenameNoExtension}", "--skip-percent", "0" @@ -34,6 +48,13 @@ "outFiles": [ "${workspaceRoot}/built/local/run.js" ] + }, + { + // See: https://github.com/microsoft/TypeScript/wiki/Debugging-Language-Service-in-VS-Code + "type": "node", + "request": "attach", + "name": "Attach to VS Code TS Server via Port", + "processId": "${command:PickProcess}" } ] -} \ No newline at end of file +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dda3ab28a7b..85fd6ddb233 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -59,11 +59,11 @@ Run `gulp` to build a version of the compiler/language service that reflects cha ## Contributing bug fixes -TypeScript is currently accepting contributions in the form of bug fixes. A bug must have an issue tracking it in the issue tracker that has been approved (labelled ["help wanted"](https://github.com/Microsoft/TypeScript/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)) by the TypeScript team. Your pull request should include a link to the bug that you are fixing. If you've submitted a PR for a bug, please post a comment in the bug to avoid duplication of effort. +TypeScript is currently accepting contributions in the form of bug fixes. A bug must have an issue tracking it in the issue tracker that has been approved (labelled ["help wanted"](https://github.com/Microsoft/TypeScript/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) or in the "Backlog milestone") by the TypeScript team. Your pull request should include a link to the bug that you are fixing. If you've submitted a PR for a bug, please post a comment in the bug to avoid duplication of effort. ## Contributing features -Features (things that add new or improved functionality to TypeScript) may be accepted, but will need to first be approved ([labelled "help wanted"](https://github.com/Microsoft/TypeScript/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) by a TypeScript project maintainer) in the suggestion issue. Features with language design impact, or that are adequately satisfied with external tools, will not be accepted. +Features (things that add new or improved functionality to TypeScript) may be accepted, but will need to first be approved ([labelled "help wanted"](https://github.com/Microsoft/TypeScript/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22 or in the "Backlog" milestone) by a TypeScript project maintainer) in the suggestion issue. Features with language design impact, or that are adequately satisfied with external tools, will not be accepted. Design changes will not be accepted at this time. If you have a design change proposal, please log a suggestion issue. diff --git a/README.md b/README.md index 459cebe95b9..a422999ce19 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,15 @@ # TypeScript -[![Join the chat at https://gitter.im/microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/microsoft/TypeScript) [![VSTS Build Status](https://dev.azure.com/typescript/TypeScript/_apis/build/status/Typescript/node10)](https://dev.azure.com/typescript/TypeScript/_build/latest?definitionId=4&view=logs) [![npm version](https://badge.fury.io/js/typescript.svg)](https://www.npmjs.com/package/typescript) [![Downloads](https://img.shields.io/npm/dm/typescript.svg)](https://www.npmjs.com/package/typescript) - - [TypeScript](https://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types to JavaScript that support tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](https://www.typescriptlang.org/play/), and stay up to date via [our blog](https://blogs.msdn.microsoft.com/typescript) and [Twitter account](https://twitter.com/typescript). +Find others who are using TypeScript at [our community page](https://www.typescriptlang.org/community/). + ## Installing For the latest stable version: @@ -31,6 +30,7 @@ There are many ways to [contribute](https://github.com/microsoft/TypeScript/blob * [Submit bugs](https://github.com/microsoft/TypeScript/issues) and help us verify fixes as they are checked in. * Review the [source code changes](https://github.com/microsoft/TypeScript/pulls). * Engage with other TypeScript users and developers on [StackOverflow](https://stackoverflow.com/questions/tagged/typescript). +* Help each other in the [TypeScript Community Discord](https://discord.gg/typescript). * Join the [#typescript](https://twitter.com/search?q=%23TypeScript) discussion on Twitter. * [Contribute bug fixes](https://github.com/microsoft/TypeScript/blob/master/CONTRIBUTING.md). * Read the language specification ([docx](https://github.com/microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.docx?raw=true), diff --git a/package.json b/package.json index 1e314c216c4..bbba0c28e93 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "3.7.0", + "version": "3.8.0", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/scripts/post-vsts-artifact-comment.js b/scripts/post-vsts-artifact-comment.js index 5b1685ae040..4e2abb3e7e5 100644 --- a/scripts/post-vsts-artifact-comment.js +++ b/scripts/post-vsts-artifact-comment.js @@ -49,7 +49,8 @@ and then running \`npm install\`. }); // Send a ping to https://github.com/orta/make-monaco-builds#pull-request-builds - await gh.request("POST /repos/orta/make-monaco-builds/dispatches", { event_type: +process.env.SOURCE_ISSUE }) + await gh.request("POST /repos/orta/make-monaco-builds/dispatches", + { event_type: +process.env.SOURCE_ISSUE, headers: { "Accept": "application/vnd.github.everest-preview+json" }}) } main().catch(async e => { diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a0bc2a155a9..50551759c2c 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1,3 +1,4 @@ + /* @internal */ namespace ts { export const enum ModuleInstanceState { @@ -951,11 +952,10 @@ namespace ts { if (!expression) { return flags & FlowFlags.TrueCondition ? antecedent : unreachableFlow; } - if (expression.kind === SyntaxKind.TrueKeyword && flags & FlowFlags.FalseCondition || - expression.kind === SyntaxKind.FalseKeyword && flags & FlowFlags.TrueCondition) { - if (!isExpressionOfOptionalChainRoot(expression)) { - return unreachableFlow; - } + if ((expression.kind === SyntaxKind.TrueKeyword && flags & FlowFlags.FalseCondition || + expression.kind === SyntaxKind.FalseKeyword && flags & FlowFlags.TrueCondition) && + !isExpressionOfOptionalChainRoot(expression) && !isNullishCoalesce(expression.parent)) { + return unreachableFlow; } if (!isNarrowingExpression(expression)) { return antecedent; @@ -1999,7 +1999,12 @@ namespace ts { switch (getAssignmentDeclarationPropertyAccessKind(declName.parent)) { case AssignmentDeclarationKind.ExportsProperty: case AssignmentDeclarationKind.ModuleExports: - container = file; + if (!isExternalOrCommonJsModule(file)) { + container = undefined!; + } + else { + container = file; + } break; case AssignmentDeclarationKind.ThisProperty: container = declName.parent.expression; @@ -2013,7 +2018,9 @@ namespace ts { case AssignmentDeclarationKind.None: return Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } - declareModuleMember(typeAlias, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); + if (container) { + declareModuleMember(typeAlias, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); + } container = oldContainer; } } @@ -2686,7 +2693,8 @@ namespace ts { const flags = exportAssignmentIsAlias(node) ? SymbolFlags.Alias // An export= with an EntityNameExpression or a ClassExpression exports all meanings of that identifier or class : SymbolFlags.Property | SymbolFlags.ExportValue | SymbolFlags.ValueModule; - declareSymbol(file.symbol.exports!, file.symbol, node, flags | SymbolFlags.Assignment, SymbolFlags.None); + const symbol = declareSymbol(file.symbol.exports!, file.symbol, node, flags | SymbolFlags.Assignment, SymbolFlags.None); + setValueDeclaration(symbol, node); } function bindThisPropertyAssignment(node: BindablePropertyAssignmentExpression | PropertyAccessExpression | LiteralLikeElementAccessExpression) { @@ -2704,7 +2712,7 @@ namespace ts { } } - if (constructorSymbol) { + if (constructorSymbol && constructorSymbol.valueDeclaration) { // Declare a 'member' if the container is an ES5 class or ES6 constructor constructorSymbol.members = constructorSymbol.members || createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b7287ff9e24..dc39353c23b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -319,6 +319,7 @@ namespace ts { const globalThisSymbol = createSymbol(SymbolFlags.Module, "globalThis" as __String, CheckFlags.Readonly); globalThisSymbol.exports = globals; + globalThisSymbol.declarations = []; globals.set(globalThisSymbol.escapedName, globalThisSymbol); const argumentsSymbol = createSymbol(SymbolFlags.Property, "arguments" as __String); @@ -2629,7 +2630,12 @@ namespace ts { return undefined; } const init = isVariableDeclaration(decl) ? getDeclaredExpandoInitializer(decl) : getAssignedExpandoInitializer(decl); - return init && getSymbolOfNode(init) || undefined; + if (init) { + const initSymbol = getSymbolOfNode(init); + if (initSymbol) { + return mergeJSSymbols(initSymbol, symbol); + } + } } @@ -4087,8 +4093,6 @@ namespace ts { else if (context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral && type.symbol.valueDeclaration && isClassLike(type.symbol.valueDeclaration) && - // Use `import` types for refs to other scopes, only anonymize something defined in the same scope - findAncestor(type.symbol.valueDeclaration, d => d === getSourceFileOfNode(context.enclosingDeclaration)) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration) ) { return createAnonymousTypeNode(type); @@ -10766,19 +10770,23 @@ namespace ts { /** * A JSdoc TypeReference may be to a value, but resolve it as a type anyway. * Note: If the value is imported from commonjs, it should really be an alias, - * but this function fakes special-case code fakes alias resolution as well. + * but this function's special-case code fakes alias resolution as well. */ function getTypeFromJSDocValueReference(node: NodeWithTypeArguments, symbol: Symbol): Type | undefined { const valueType = getTypeOfSymbol(symbol); let typeType = valueType; if (symbol.valueDeclaration) { const decl = getRootDeclaration(symbol.valueDeclaration); - const isRequireAlias = isVariableDeclaration(decl) - && decl.initializer - && isCallExpression(decl.initializer) - && isRequireCall(decl.initializer, /*requireStringLiteralLikeArgument*/ true) - && valueType.symbol; - if (isRequireAlias) { + let isRequireAlias = false; + if (isVariableDeclaration(decl) && decl.initializer) { + let expr = decl.initializer; + // skip past entity names, eg `require("x").a.b.c` + while (isPropertyAccessExpression(expr)) { + expr = expr.expression; + } + isRequireAlias = isCallExpression(expr) && isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol; + } + if (isRequireAlias || node.kind === SyntaxKind.ImportType) { typeType = getTypeReferenceType(node, valueType.symbol); } } @@ -13970,13 +13978,13 @@ namespace ts { // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly const targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType - : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(target.declaration.symbol) + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol)) : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } const sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType - : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(source.declaration.symbol) + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(source.declaration.symbol)) : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions @@ -14169,7 +14177,7 @@ namespace ts { return true; } if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) { - const related = relation.get(getRelationKey(source, target, relation)); + const related = relation.get(getRelationKey(source, target, /*isIntersectionConstituent*/ false, relation)); if (related !== undefined) { return !!(related & RelationComparisonResult.Succeeded); } @@ -14575,7 +14583,7 @@ namespace ts { // and we need to handle "each" relations before "some" relations for the same kind of type. if (source.flags & TypeFlags.Union) { result = relation === comparableRelation ? - someTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive), isIntersectionConstituent) : + someTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive)) : eachTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive)); } else { @@ -14613,7 +14621,7 @@ namespace ts { // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } if (!result && (source.flags & TypeFlags.StructuredOrInstantiable || target.flags & TypeFlags.StructuredOrInstantiable)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { @@ -14907,14 +14915,14 @@ namespace ts { return result; } - function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean, isIntersectionConstituent: boolean): Ternary { + function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean): Ternary { const sourceTypes = source.types; if (source.flags & TypeFlags.Union && containsType(sourceTypes, target)) { return Ternary.True; } const len = sourceTypes.length; for (let i = 0; i < len; i++) { - const related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); + const related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); if (related) { return related; } @@ -15001,7 +15009,7 @@ namespace ts { if (overflow) { return Ternary.False; } - const id = getRelationKey(source, target, relation); + const id = getRelationKey(source, target, isIntersectionConstituent, relation); const entry = relation.get(id); if (entry !== undefined) { if (reportErrors && entry & RelationComparisonResult.Failed && !(entry & RelationComparisonResult.Reported)) { @@ -16215,17 +16223,18 @@ namespace ts { * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters. * For other cases, the types ids are used. */ - function getRelationKey(source: Type, target: Type, relation: Map) { + function getRelationKey(source: Type, target: Type, isIntersectionConstituent: boolean, relation: Map) { if (relation === identityRelation && source.id > target.id) { const temp = source; source = target; target = temp; } + const intersection = isIntersectionConstituent ? "&" : ""; if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) { const typeParameters: Type[] = []; - return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters); + return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + intersection; } - return source.id + "," + target.id; + return source.id + "," + target.id + intersection; } // Invoke the callback for each underlying property symbol of the given symbol and return the first @@ -17366,10 +17375,7 @@ namespace ts { // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - const savePriority = priority; - priority |= InferencePriority.NakedTypeVariable; - inferFromTypes(source, target); - priority = savePriority; + inferWithPriority(source, target, InferencePriority.NakedTypeVariable); return; } source = getUnionType(sources); @@ -17471,10 +17477,7 @@ namespace ts { else if ((isLiteralType(source) || source.flags & TypeFlags.String) && target.flags & TypeFlags.Index) { const empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - const savePriority = priority; - priority |= InferencePriority.LiteralKeyof; - inferFromTypes(empty, (target as IndexType).type); - priority = savePriority; + inferWithPriority(empty, (target as IndexType).type, InferencePriority.LiteralKeyof); contravariant = !contravariant; } else if (source.flags & TypeFlags.IndexedAccess && target.flags & TypeFlags.IndexedAccess) { @@ -17526,6 +17529,13 @@ namespace ts { } } + function inferWithPriority(source: Type, target: Type, newPriority: InferencePriority) { + const savePriority = priority; + priority |= newPriority; + inferFromTypes(source, target); + priority = savePriority; + } + function invokeOnce(source: Type, target: Type, action: (source: Type, target: Type) => void) { const key = source.id + "," + target.id; const status = visited && visited.get(key); @@ -17593,6 +17603,18 @@ namespace ts { return undefined; } + function getSingleTypeVariableFromIntersectionTypes(types: Type[]) { + let typeVariable: Type | undefined; + for (const type of types) { + const t = type.flags & TypeFlags.Intersection && find((type).types, t => !!getInferenceInfoForType(t)); + if (!t || typeVariable && t !== typeVariable) { + return undefined; + } + typeVariable = t; + } + return typeVariable; + } + function inferToMultipleTypes(source: Type, targets: Type[], targetFlags: TypeFlags) { let typeVariableCount = 0; if (targetFlags & TypeFlags.Union) { @@ -17620,6 +17642,16 @@ namespace ts { } } } + if (typeVariableCount === 0) { + // If every target is an intersection of types containing a single naked type variable, + // make a lower priority inference to that type variable. This handles inferring from + // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. + const intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); + if (intersectionTypeVariable) { + inferWithPriority(source, intersectionTypeVariable, InferencePriority.NakedTypeVariable); + } + return; + } // If the target has a single naked type variable and no inference circularities were // encountered above (meaning we explored the types fully), create a union of the source // types from which no inferences have been made so far and infer from that union to the @@ -17650,14 +17682,11 @@ namespace ts { // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. if (targetFlags & TypeFlags.Intersection ? typeVariableCount === 1 : typeVariableCount > 0) { - const savePriority = priority; - priority |= InferencePriority.NakedTypeVariable; for (const t of targets) { if (getInferenceInfoForType(t)) { - inferFromTypes(source, t); + inferWithPriority(source, t, InferencePriority.NakedTypeVariable); } } - priority = savePriority; } } @@ -17678,14 +17707,13 @@ namespace ts { if (inference && !inference.isFixed) { const inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); if (inferredType) { - const savePriority = priority; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - priority |= getObjectFlags(source) & ObjectFlags.NonInferrableType ? - InferencePriority.PartialHomomorphicMappedType : InferencePriority.HomomorphicMappedType; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; + inferWithPriority(inferredType, inference.typeParameter, + getObjectFlags(source) & ObjectFlags.NonInferrableType ? + InferencePriority.PartialHomomorphicMappedType : + InferencePriority.HomomorphicMappedType); } } return true; @@ -17693,10 +17721,7 @@ namespace ts { if (constraintType.flags & TypeFlags.TypeParameter) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - const savePriority = priority; - priority |= InferencePriority.MappedTypeConstraint; - inferFromTypes(getIndexType(source), constraintType); - priority = savePriority; + inferWithPriority(getIndexType(source), constraintType, InferencePriority.MappedTypeConstraint); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -18782,6 +18807,14 @@ namespace ts { signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & TypeFlags.Never); } + function getTypePredicateArgument(predicate: TypePredicate, callExpression: CallExpression) { + if (predicate.kind === TypePredicateKind.Identifier || predicate.kind === TypePredicateKind.AssertsIdentifier) { + return callExpression.arguments[predicate.parameterIndex]; + } + const invokedExpression = skipParentheses(callExpression.expression); + return isAccessExpression(invokedExpression) ? skipParentheses(invokedExpression.expression) : undefined; + } + function reportFlowControlError(node: Node) { const block = findAncestor(node, isFunctionOrModuleBlock); const sourceFile = getSourceFileOfNode(node); @@ -19170,20 +19203,30 @@ namespace ts { if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeByDiscriminant( - type, - expr as AccessExpression, - t => narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd)); - } else if (expr.kind === SyntaxKind.TypeOfExpression && isMatchingReference(reference, (expr as TypeOfExpression).expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (containsMatchingReferenceDiscriminant(reference, expr)) { - type = declaredType; - } - else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { - return unreachableNeverType; + else { + if (strictNullChecks) { + if (optionalChainContainsReference(expr, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, + t => !(t.flags & (TypeFlags.Undefined | TypeFlags.Never))); + } + else if (expr.kind === SyntaxKind.TypeOfExpression && optionalChainContainsReference((expr as TypeOfExpression).expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, + t => !(t.flags & TypeFlags.Never || t.flags & TypeFlags.StringLiteral && (t).value === "undefined")); + } + } + if (isMatchingReferenceDiscriminant(expr, type)) { + type = narrowTypeByDiscriminant(type, expr as AccessExpression, + t => narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd)); + } + else if (containsMatchingReferenceDiscriminant(reference, expr)) { + type = declaredType; + } + else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return unreachableNeverType; + } } return createFlowType(type, isIncomplete(flowType)); } @@ -19328,6 +19371,9 @@ namespace ts { if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy); } + if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { + type = getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull); + } if (isMatchingReferenceDiscriminant(expr, declaredType)) { return narrowTypeByDiscriminant(type, expr, t => getTypeWithFacts(t, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy)); } @@ -19379,12 +19425,12 @@ namespace ts { if (isMatchingReference(reference, right)) { return narrowTypeByEquality(type, operator, left, assumeTrue); } - if (assumeTrue && strictNullChecks) { + if (strictNullChecks) { if (optionalChainContainsReference(left, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator, right); + type = narrowTypeByOptionalChainContainment(type, operator, right, assumeTrue); } else if (optionalChainContainsReference(right, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator, left); + type = narrowTypeByOptionalChainContainment(type, operator, left, assumeTrue); } } if (isMatchingReferenceDiscriminant(left, declaredType)) { @@ -19411,16 +19457,14 @@ namespace ts { return type; } - function narrowTypeByOptionalChainContainment(type: Type, operator: SyntaxKind, value: Expression): Type { - // We are in the true branch of obj?.foo === value or obj?.foo !== value. We remove undefined and null from + function narrowTypeByOptionalChainContainment(type: Type, operator: SyntaxKind, value: Expression, assumeTrue: boolean): Type { + // We are in a branch of obj?.foo === value or obj?.foo !== value. We remove undefined and null from // the type of obj if (a) the operator is === and the type of value doesn't include undefined or (b) the // operator is !== and the type of value is undefined. - const valueType = getTypeOfExpression(value); - return operator === SyntaxKind.EqualsEqualsToken && !(getTypeFacts(valueType) & TypeFacts.EQUndefinedOrNull) || - operator === SyntaxKind.EqualsEqualsEqualsToken && !(getTypeFacts(valueType) & TypeFacts.EQUndefined) || - operator === SyntaxKind.ExclamationEqualsToken && valueType.flags & TypeFlags.Nullable || - operator === SyntaxKind.ExclamationEqualsEqualsToken && valueType.flags & TypeFlags.Undefined ? - getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull) : type; + const effectiveTrue = operator === SyntaxKind.EqualsEqualsToken || operator === SyntaxKind.EqualsEqualsEqualsToken ? assumeTrue : !assumeTrue; + const doubleEquals = operator === SyntaxKind.EqualsEqualsToken || operator === SyntaxKind.ExclamationEqualsToken; + const valueNonNullish = !(getTypeFacts(getTypeOfExpression(value)) & (doubleEquals ? TypeFacts.EQUndefinedOrNull : TypeFacts.EQUndefined)); + return effectiveTrue === valueNonNullish ? getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull) : type; } function narrowTypeByEquality(type: Type, operator: SyntaxKind, value: Expression, assumeTrue: boolean): Type { @@ -19471,10 +19515,12 @@ namespace ts { function narrowTypeByTypeof(type: Type, typeOfExpr: TypeOfExpression, operator: SyntaxKind, literal: LiteralExpression, assumeTrue: boolean): Type { // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands + if (operator === SyntaxKind.ExclamationEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) { + assumeTrue = !assumeTrue; + } const target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { - if (assumeTrue && (operator === SyntaxKind.EqualsEqualsToken || operator === SyntaxKind.EqualsEqualsEqualsToken) && - strictNullChecks && optionalChainContainsReference(target, reference)) { + if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { return getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull); } // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the @@ -19484,9 +19530,6 @@ namespace ts { } return type; } - if (operator === SyntaxKind.ExclamationEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) { - assumeTrue = !assumeTrue; - } if (type.flags & TypeFlags.Any && literal.text === "function") { return type; } @@ -19521,6 +19564,11 @@ namespace ts { } } + function narrowTypeBySwitchOptionalChainContainment(type: Type, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number, clauseCheck: (type: Type) => boolean) { + const everyClauseChecks = clauseStart !== clauseEnd && every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); + return everyClauseChecks ? getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull) : type; + } + function narrowTypeBySwitchOnDiscriminant(type: Type, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number) { // We only narrow if all case expressions specify // values with unit types, except for the case where @@ -19741,32 +19789,21 @@ namespace ts { function narrowTypeByTypePredicate(type: Type, predicate: TypePredicate, callExpression: CallExpression, assumeTrue: boolean): Type { // Don't narrow from 'any' if the predicate type is exactly 'Object' or 'Function' - if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { - return type; - } - if (predicate.kind === TypePredicateKind.Identifier || predicate.kind === TypePredicateKind.AssertsIdentifier) { - const predicateArgument = callExpression.arguments[predicate.parameterIndex]; - if (predicateArgument && predicate.type) { + if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) { + const predicateArgument = getTypePredicateArgument(predicate, callExpression); + if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } + if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && + !(getTypeFacts(predicate.type) & TypeFacts.EQUndefined)) { + return getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull); + } if (containsMatchingReference(reference, predicateArgument)) { return declaredType; } } } - else { - const invokedExpression = skipParentheses(callExpression.expression); - if (isAccessExpression(invokedExpression) && predicate.type) { - const possibleReference = skipParentheses(invokedExpression.expression); - if (isMatchingReference(reference, possibleReference)) { - return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); - } - if (containsMatchingReference(reference, possibleReference)) { - return declaredType; - } - } - } return type; } @@ -23415,7 +23452,7 @@ namespace ts { // the declared number of type parameters, the call has an incorrect arity. const numTypeParameters = length(signature.typeParameters); const minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters); - return !typeArguments || + return !some(typeArguments) || (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); } @@ -24175,7 +24212,7 @@ namespace ts { if (isSingleNonGenericCandidate) { const candidate = candidates[0]; - if (typeArguments || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { + if (some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { return undefined; } if (getSignatureApplicabilityError(node, args, candidate, relation, CheckMode.Normal, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { @@ -24196,7 +24233,7 @@ namespace ts { if (candidate.typeParameters) { let typeArgumentTypes: Type[] | undefined; - if (typeArguments) { + if (some(typeArguments)) { typeArgumentTypes = checkTypeArguments(candidate, typeArguments, /*reportErrors*/ false); if (!typeArgumentTypes) { candidateForTypeArgumentError = candidate; @@ -24982,7 +25019,7 @@ namespace ts { } function mergeJSSymbols(target: Symbol, source: Symbol | undefined) { - if (source && (hasEntries(source.exports) || hasEntries(source.members))) { + if (source) { const links = getSymbolLinks(source); if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { const inferred = isTransientSymbol(target) ? target : cloneSymbol(target) as TransientSymbol; @@ -27452,7 +27489,7 @@ namespace ts { (node.parent.kind === SyntaxKind.ElementAccessExpression && (node.parent).expression === node) || ((node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName) && isInRightSideOfImportOrExportAssignment(node) || (node.parent.kind === SyntaxKind.TypeQuery && (node.parent).exprName === node)) || - (node.parent.kind === SyntaxKind.ExportSpecifier && (compilerOptions.preserveConstEnums || node.flags & NodeFlags.Ambient)); // We allow reexporting const enums + (node.parent.kind === SyntaxKind.ExportSpecifier); // We allow reexporting const enums if (!ok) { error(node, Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 4941257cabf..d03b7e1c85c 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1,7 +1,7 @@ namespace ts { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - export const versionMajorMinor = "3.7"; + export const versionMajorMinor = "3.8"; /** The version of the TypeScript compiler release */ export const version = `${versionMajorMinor}.0-dev`; } diff --git a/src/compiler/debug.ts b/src/compiler/debug.ts index 40ac6c9c94f..9adc4095054 100644 --- a/src/compiler/debug.ts +++ b/src/compiler/debug.ts @@ -100,11 +100,13 @@ namespace ts { if (isFlags) { let result = ""; let remainingFlags = value; - for (let i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) { - const [enumValue, enumName] = members[i]; - if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) { + for (const [enumValue, enumName] of members) { + if (enumValue > value) { + break; + } + if (enumValue !== 0 && enumValue & value) { + result = `${result}${result ? "|" : ""}${enumName}`; remainingFlags &= ~enumValue; - result = `${enumName}${result ? "|" : ""}${result}`; } } if (remainingFlags === 0) { diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 7ec85bd94c1..c09736a5c3c 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -5389,6 +5389,12 @@ namespace ts { * Gets the property name of a BindingOrAssignmentElement */ export function getPropertyNameOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): PropertyName | undefined { + const propertyName = tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement); + Debug.assert(!!propertyName || isSpreadAssignment(bindingElement), "Invalid property name for binding element."); + return propertyName; + } + + export function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): PropertyName | undefined { switch (bindingElement.kind) { case SyntaxKind.BindingElement: // `a` in `let { a: b } = ...` @@ -5429,8 +5435,6 @@ namespace ts { ? target.expression : target; } - - Debug.fail("Invalid property name for binding element."); } function isStringOrNumericLiteral(node: Node): node is StringLiteral | NumericLiteral { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 0c8444daa2f..c9592d55cf9 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -96,35 +96,51 @@ namespace ts { if (existingDirectories.has(directoryPath)) { return true; } - if (system.directoryExists(directoryPath)) { + if ((compilerHost.directoryExists || system.directoryExists)(directoryPath)) { existingDirectories.set(directoryPath, true); return true; } return false; } - function ensureDirectoriesExist(directoryPath: string) { - if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) { - const parentDirectory = getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - if (compilerHost.createDirectory) { - compilerHost.createDirectory(directoryPath); - } - else { - system.createDirectory(directoryPath); + function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) { + try { + performance.mark("beforeIOWrite"); + + // NOTE: If patchWriteFileEnsuringDirectory has been called, + // the system.writeFile will do its own directory creation and + // the ensureDirectoriesExist call will always be redundant. + writeFileEnsuringDirectories( + fileName, + data, + writeByteOrderMark, + (path, data, writeByteOrderMark) => writeFileWorker(path, data, writeByteOrderMark), + path => (compilerHost.createDirectory || system.createDirectory)(path), + path => directoryExists(path)); + + performance.mark("afterIOWrite"); + performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite"); + } + catch (e) { + if (onError) { + onError(e.message); } } } let outputFingerprints: Map; + function writeFileWorker(fileName: string, data: string, writeByteOrderMark: boolean) { + if (!isWatchSet(options) || !system.createHash || !system.getModifiedTime) { + system.writeFile(fileName, data, writeByteOrderMark); + return; + } - function writeFileIfUpdated(fileName: string, data: string, writeByteOrderMark: boolean): void { if (!outputFingerprints) { outputFingerprints = createMap(); } - const hash = system.createHash!(data); // TODO: GH#18217 - const mtimeBefore = system.getModifiedTime!(fileName); // TODO: GH#18217 + const hash = system.createHash(data); + const mtimeBefore = system.getModifiedTime(fileName); if (mtimeBefore) { const fingerprint = outputFingerprints.get(fileName); @@ -139,7 +155,7 @@ namespace ts { system.writeFile(fileName, data, writeByteOrderMark); - const mtimeAfter = system.getModifiedTime!(fileName) || missingFileModifiedTime; // TODO: GH#18217 + const mtimeAfter = system.getModifiedTime(fileName) || missingFileModifiedTime; outputFingerprints.set(fileName, { hash, @@ -148,28 +164,6 @@ namespace ts { }); } - function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) { - try { - performance.mark("beforeIOWrite"); - ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName))); - - if (isWatchSet(options) && system.createHash && system.getModifiedTime) { - writeFileIfUpdated(fileName, data, writeByteOrderMark); - } - else { - system.writeFile(fileName, data, writeByteOrderMark); - } - - performance.mark("afterIOWrite"); - performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite"); - } - catch (e) { - if (onError) { - onError(e.message); - } - } - } - function getDefaultLibLocation(): string { return getDirectoryPath(normalizePath(system.getExecutingFilePath())); } @@ -2277,7 +2271,19 @@ namespace ts { // Get source file from normalized fileName function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, ignoreNoDefaultLib: boolean, refFile: RefFile | undefined, packageId: PackageId | undefined): SourceFile | undefined { if (useSourceOfProjectReferenceRedirect) { - const source = getSourceOfProjectReferenceRedirect(fileName); + let source = getSourceOfProjectReferenceRedirect(fileName); + // If preserveSymlinks is true, module resolution wont jump the symlink + // but the resolved real path may be the .d.ts from project reference + // Note:: Currently we try the real path only if the + // file is from node_modules to avoid having to run real path on all file paths + if (!source && + host.realpath && + options.preserveSymlinks && + isDeclarationFileName(fileName) && + stringContains(fileName, nodeModulesPathPart)) { + const realPath = host.realpath(fileName); + if (realPath !== fileName) source = getSourceOfProjectReferenceRedirect(realPath); + } if (source) { const file = isString(source) ? findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) : diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index ad866cba130..31b422a12b9 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -522,17 +522,6 @@ namespace ts { } } - function recursiveCreateDirectory(directoryPath: string, sys: System) { - const basePath = getDirectoryPath(directoryPath); - const shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); - if (shouldCreateParent) { - recursiveCreateDirectory(basePath, sys); - } - if (shouldCreateParent || !sys.directoryExists(directoryPath)) { - sys.createDirectory(directoryPath); - } - } - /** * patch writefile to create folder before writing the file */ @@ -540,13 +529,14 @@ namespace ts { export function patchWriteFileEnsuringDirectory(sys: System) { // patch writefile to create folder before writing the file const originalWriteFile = sys.writeFile; - sys.writeFile = (path, data, writeBom) => { - const directoryPath = getDirectoryPath(normalizeSlashes(path)); - if (directoryPath && !sys.directoryExists(directoryPath)) { - recursiveCreateDirectory(directoryPath, sys); - } - originalWriteFile.call(sys, path, data, writeBom); - }; + sys.writeFile = (path, data, writeBom) => + writeFileEnsuringDirectories( + path, + data, + !!writeBom, + (path, data, writeByteOrderMark) => originalWriteFile.call(sys, path, data, writeByteOrderMark), + path => sys.createDirectory(path), + path => sys.directoryExists(path)); } /*@internal*/ diff --git a/src/compiler/transformers/destructuring.ts b/src/compiler/transformers/destructuring.ts index 10d090a152e..23f19ef9da8 100644 --- a/src/compiler/transformers/destructuring.ts +++ b/src/compiler/transformers/destructuring.ts @@ -68,7 +68,8 @@ namespace ts { if (value) { value = visitNode(value, visitor, isExpression); - if (isIdentifier(value) && bindingOrAssignmentElementAssignsToName(node, value.escapedText)) { + if (isIdentifier(value) && bindingOrAssignmentElementAssignsToName(node, value.escapedText) || + bindingOrAssignmentElementContainsNonLiteralComputedName(node)) { // If the right-hand value of the assignment is also an assignment target then // we need to cache the right-hand value. value = ensureIdentifier(flattenContext, value, /*reuseIdentifierExpressions*/ false, location); @@ -147,6 +148,19 @@ namespace ts { return false; } + function bindingOrAssignmentElementContainsNonLiteralComputedName(element: BindingOrAssignmentElement): boolean { + const propertyName = tryGetPropertyNameOfBindingOrAssignmentElement(element); + if (propertyName && isComputedPropertyName(propertyName) && !isLiteralExpression(propertyName.expression)) { + return true; + } + const target = getTargetOfBindingOrAssignmentElement(element); + return !!target && isBindingOrAssignmentPattern(target) && bindingOrAssignmentPatternContainsNonLiteralComputedName(target); + } + + function bindingOrAssignmentPatternContainsNonLiteralComputedName(pattern: BindingOrAssignmentPattern): boolean { + return !!forEach(getElementsOfBindingOrAssignmentPattern(pattern), bindingOrAssignmentElementContainsNonLiteralComputedName); + } + /** * Flattens a VariableDeclaration or ParameterDeclaration to one or more variable declarations. * @@ -184,7 +198,8 @@ namespace ts { if (isVariableDeclaration(node)) { let initializer = getInitializerOfBindingOrAssignmentElement(node); - if (initializer && isIdentifier(initializer) && bindingOrAssignmentElementAssignsToName(node, initializer.escapedText)) { + if (initializer && (isIdentifier(initializer) && bindingOrAssignmentElementAssignsToName(node, initializer.escapedText) || + bindingOrAssignmentElementContainsNonLiteralComputedName(node))) { // If the right-hand value of the assignment is also an assignment target then // we need to cache the right-hand value. initializer = ensureIdentifier(flattenContext, initializer, /*reuseIdentifierExpressions*/ false, initializer); diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index bdd0f5efcc7..d413a835d0d 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2452,7 +2452,12 @@ namespace ts { * * @param node The module declaration node. */ - function shouldEmitModuleDeclaration(node: ModuleDeclaration) { + function shouldEmitModuleDeclaration(nodeIn: ModuleDeclaration) { + const node = getParseTreeNode(nodeIn, isModuleDeclaration); + if (!node) { + // If we can't find a parse tree node, assume the node is instantiated. + return true; + } return isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7b73d560551..73fa849ec1c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6455,6 +6455,7 @@ namespace ts { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; + readonly includeAutomaticOptionalChainCompletions?: boolean; readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; /** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 1c51807a633..7ee5dcd8278 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2061,26 +2061,30 @@ namespace ts { isBindableStaticNameExpression(expr.arguments[0], /*excludeThisKeyword*/ true); } - export function isBindableStaticElementAccessExpression(node: Node, excludeThisKeyword?: boolean): node is BindableStaticElementAccessExpression { - return isLiteralLikeElementAccess(node) - && ((!excludeThisKeyword && node.expression.kind === SyntaxKind.ThisKeyword) || - isEntityNameExpression(node.expression) || - isBindableStaticElementAccessExpression(node.expression, /*excludeThisKeyword*/ true)); - } - + /** x.y OR x[0] */ export function isLiteralLikeAccess(node: Node): node is LiteralLikeElementAccessExpression | PropertyAccessExpression { return isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node); } + /** x[0] OR x['a'] OR x[Symbol.y] */ export function isLiteralLikeElementAccess(node: Node): node is LiteralLikeElementAccessExpression { return isElementAccessExpression(node) && ( isStringOrNumericLiteralLike(node.argumentExpression) || isWellKnownSymbolSyntactically(node.argumentExpression)); } + /** Any series of property and element accesses. */ export function isBindableStaticAccessExpression(node: Node, excludeThisKeyword?: boolean): node is BindableStaticAccessExpression { return isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === SyntaxKind.ThisKeyword || isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) - || isBindableStaticElementAccessExpression(node, excludeThisKeyword); + || isBindableStaticElementAccessExpression(node, excludeThisKeyword); + } + + /** Any series of property and element accesses, ending in a literal element access */ + export function isBindableStaticElementAccessExpression(node: Node, excludeThisKeyword?: boolean): node is BindableStaticElementAccessExpression { + return isLiteralLikeElementAccess(node) + && ((!excludeThisKeyword && node.expression.kind === SyntaxKind.ThisKeyword) || + isEntityNameExpression(node.expression) || + isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } export function isBindableStaticNameExpression(node: Node, excludeThisKeyword?: boolean): node is BindableStaticNameExpression { @@ -2111,7 +2115,7 @@ namespace ts { if (expr.operatorToken.kind !== SyntaxKind.EqualsToken || !isAccessExpression(expr.left)) { return AssignmentDeclarationKind.None; } - if (isBindableStaticNameExpression(expr.left.expression) && getElementOrPropertyAccessName(expr.left) === "prototype" && isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } return AssignmentDeclarationKind.Prototype; } @@ -2179,8 +2183,10 @@ namespace ts { // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... return AssignmentDeclarationKind.ExportsProperty; } - // F.G...x = expr - return AssignmentDeclarationKind.Property; + if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (isElementAccessExpression(lhs) && isDynamicName(lhs) && lhs.expression.kind !== SyntaxKind.ThisKeyword)) { + // F.G...x = expr + return AssignmentDeclarationKind.Property; + } } return AssignmentDeclarationKind.None; @@ -3700,6 +3706,36 @@ namespace ts { }, sourceFiles); } + function ensureDirectoriesExist( + directoryPath: string, + createDirectory: (path: string) => void, + directoryExists: (path: string) => boolean): void { + if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) { + const parentDirectory = getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory, createDirectory, directoryExists); + createDirectory(directoryPath); + } + } + + export function writeFileEnsuringDirectories( + path: string, + data: string, + writeByteOrderMark: boolean, + writeFile: (path: string, data: string, writeByteOrderMark: boolean) => void, + createDirectory: (path: string) => void, + directoryExists: (path: string) => boolean): void { + + // PERF: Checking for directory existence is expensive. Instead, assume the directory exists + // and fall back to creating it if the file write fails. + try { + writeFile(path, data, writeByteOrderMark); + } + catch { + ensureDirectoriesExist(getDirectoryPath(normalizePath(path)), createDirectory, directoryExists); + writeFile(path, data, writeByteOrderMark); + } + } + export function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number) { return getLineAndCharacterOfPosition(currentSourceFile, pos).line; } @@ -5941,6 +5977,10 @@ namespace ts { || node !== node.parent.expression; // case 4 } + export function isNullishCoalesce(node: Node) { + return node.kind === SyntaxKind.BinaryExpression && (node).operatorToken.kind === SyntaxKind.QuestionQuestionToken; + } + export function isNewExpression(node: Node): node is NewExpression { return node.kind === SyntaxKind.NewExpression; } diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 63b194c2077..52789783d01 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -303,20 +303,20 @@ namespace ts { readDirectory: maybeBind(host, host.readDirectory), }; - function ensureDirectoriesExist(directoryPath: string) { - if (directoryPath.length > getRootLength(directoryPath) && !host.directoryExists!(directoryPath)) { - const parentDirectory = getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - if (host.createDirectory) host.createDirectory(directoryPath); - } - } - function writeFile(fileName: string, text: string, writeByteOrderMark: boolean, onError: (message: string) => void) { try { performance.mark("beforeIOWrite"); - ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName))); - host.writeFile!(fileName, text, writeByteOrderMark); + // NOTE: If patchWriteFileEnsuringDirectory has been called, + // the host.writeFile will do its own directory creation and + // the ensureDirectoriesExist call will always be redundant. + writeFileEnsuringDirectories( + fileName, + text, + writeByteOrderMark, + (path, data, writeByteOrderMark) => host.writeFile!(path, data, writeByteOrderMark), + path => host.createDirectory!(path), + path => host.directoryExists!(path)); performance.mark("afterIOWrite"); performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite"); diff --git a/src/server/project.ts b/src/server/project.ts index c98e7660b38..5121556f53b 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -258,7 +258,8 @@ namespace ts.server { private compilerOptions: CompilerOptions, public compileOnSaveEnabled: boolean, directoryStructureHost: DirectoryStructureHost, - currentDirectory: string | undefined) { + currentDirectory: string | undefined, + customRealpath?: (s: string) => string) { this.directoryStructureHost = directoryStructureHost; this.currentDirectory = this.projectService.getNormalizedAbsolutePath(currentDirectory || ""); this.getCanonicalFileName = this.projectService.toCanonicalFileName; @@ -286,7 +287,7 @@ namespace ts.server { } if (host.realpath) { - this.realpath = path => host.realpath!(path); + this.realpath = customRealpath || (path => host.realpath!(path)); } // Use the current directory as resolution root only if the project created using current directory string @@ -1359,9 +1360,12 @@ namespace ts.server { return; } - // Search our peer node_modules, then any globally-specified probe paths - // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ - const searchPaths = [combinePaths(this.projectService.getExecutingFilePath(), "../../.."), ...this.projectService.pluginProbeLocations]; + // Search any globally-specified probe paths, then our peer node_modules + const searchPaths = [ + ...this.projectService.pluginProbeLocations, + // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ + combinePaths(this.projectService.getExecutingFilePath(), "../../.."), + ]; if (this.projectService.globalPlugins) { // Enable global plugins with synthetic configuration entries @@ -1657,6 +1661,12 @@ namespace ts.server { } } + /*@internal*/ + interface SymlinkedDirectory { + real: string; + realPath: Path; + } + /** * If a file is opened, the server will look for a tsconfig (or jsconfig) * and if successfull create a ConfiguredProject for it. @@ -1670,6 +1680,8 @@ namespace ts.server { readonly canonicalConfigFilePath: NormalizedPath; private projectReferenceCallbacks: ResolvedProjectReferenceCallbacks | undefined; private mapOfDeclarationDirectories: Map | undefined; + private symlinkedDirectories: Map | undefined; + private symlinkedFiles: Map | undefined; /* @internal */ pendingReload: ConfigFileProgramReloadLevel | undefined; @@ -1711,7 +1723,9 @@ namespace ts.server { /*compilerOptions*/ {}, /*compileOnSaveEnabled*/ false, cachedDirectoryStructureHost, - getDirectoryPath(configFileName)); + getDirectoryPath(configFileName), + projectService.host.realpath && (s => this.getRealpath(s)) + ); this.canonicalConfigFilePath = asNormalizedPath(projectService.toCanonicalFileName(configFileName)); } @@ -1724,18 +1738,34 @@ namespace ts.server { useSourceOfProjectReferenceRedirect = () => !!this.languageServiceEnabled && !this.getCompilerOptions().disableSourceOfProjectReferenceRedirect; + private fileExistsIfProjectReferenceDts(file: string) { + const source = this.projectReferenceCallbacks!.getSourceOfProjectReferenceRedirect(file); + return source !== undefined ? + isString(source) ? super.fileExists(source) : true : + undefined; + } + /** * This implementation of fileExists checks if the file being requested is * .d.ts file for the referenced Project. * If it is it returns true irrespective of whether that file exists on host */ fileExists(file: string): boolean { + if (super.fileExists(file)) return true; + if (!this.useSourceOfProjectReferenceRedirect() || !this.projectReferenceCallbacks) return false; + if (!isDeclarationFileName(file)) return false; + // Project references go to source file instead of .d.ts file - if (this.useSourceOfProjectReferenceRedirect() && this.projectReferenceCallbacks) { - const source = this.projectReferenceCallbacks.getSourceOfProjectReferenceRedirect(file); - if (source) return isString(source) ? super.fileExists(source) : true; - } - return super.fileExists(file); + return this.fileOrDirectoryExistsUsingSource(file, /*isFile*/ true); + } + + private directoryExistsIfProjectReferenceDeclDir(dir: string) { + const dirPath = this.toPath(dir); + const dirPathWithTrailingDirectorySeparator = `${dirPath}${directorySeparator}`; + return forEachKey( + this.mapOfDeclarationDirectories!, + declDirPath => dirPath === declDirPath || startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) + ); } /** @@ -1744,14 +1774,17 @@ namespace ts.server { * If it is it returns true irrespective of whether that directory exists on host */ directoryExists(path: string): boolean { - if (super.directoryExists(path)) return true; + if (super.directoryExists(path)) { + this.handleDirectoryCouldBeSymlink(path); + return true; + } if (!this.useSourceOfProjectReferenceRedirect() || !this.projectReferenceCallbacks) return false; if (!this.mapOfDeclarationDirectories) { this.mapOfDeclarationDirectories = createMap(); this.projectReferenceCallbacks.forEachResolvedProjectReference(ref => { if (!ref) return; - const out = ref.commandLine.options.outFile || ref.commandLine.options.outDir; + const out = ref.commandLine.options.outFile || ref.commandLine.options.out; if (out) { this.mapOfDeclarationDirectories!.set(getDirectoryPath(this.toPath(out)), true); } @@ -1764,12 +1797,74 @@ namespace ts.server { } }); } - const dirPath = this.toPath(path); - const dirPathWithTrailingDirectorySeparator = `${dirPath}${directorySeparator}`; - return !!forEachKey( - this.mapOfDeclarationDirectories, - declDirPath => dirPath === declDirPath || startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) - ); + + return this.fileOrDirectoryExistsUsingSource(path, /*isFile*/ false); + } + + private realpathIfSymlinkedProjectReferenceDts(s: string): string | undefined { + return this.symlinkedFiles && this.symlinkedFiles.get(this.toPath(s)); + } + + private getRealpath(s: string): string { + return this.realpathIfSymlinkedProjectReferenceDts(s) || + this.projectService.host.realpath!(s); + } + + private handleDirectoryCouldBeSymlink(directory: string) { + if (!this.useSourceOfProjectReferenceRedirect() || !this.projectReferenceCallbacks) return; + + // Because we already watch node_modules, handle symlinks in there + if (!this.realpath || !stringContains(directory, nodeModulesPathPart)) return; + if (!this.symlinkedDirectories) this.symlinkedDirectories = createMap(); + const directoryPath = ensureTrailingDirectorySeparator(this.toPath(directory)); + if (this.symlinkedDirectories.has(directoryPath)) return; + + const real = this.projectService.host.realpath!(directory); + let realPath: Path; + if (real === directory || + (realPath = ensureTrailingDirectorySeparator(this.toPath(real))) === directoryPath) { + // not symlinked + this.symlinkedDirectories.set(directoryPath, false); + return; + } + + this.symlinkedDirectories.set(directoryPath, { + real: ensureTrailingDirectorySeparator(real), + realPath + }); + } + + private fileOrDirectoryExistsUsingSource(fileOrDirectory: string, isFile: boolean): boolean { + const fileOrDirectoryExistsUsingSource = isFile ? + (file: string) => this.fileExistsIfProjectReferenceDts(file) : + (dir: string) => this.directoryExistsIfProjectReferenceDeclDir(dir); + // Check current directory or file + const result = fileOrDirectoryExistsUsingSource(fileOrDirectory); + if (result !== undefined) return result; + + if (!this.symlinkedDirectories) return false; + const fileOrDirectoryPath = this.toPath(fileOrDirectory); + if (!stringContains(fileOrDirectoryPath, nodeModulesPathPart)) return false; + if (isFile && this.symlinkedFiles && this.symlinkedFiles.has(fileOrDirectoryPath)) return true; + + // If it contains node_modules check if its one of the symlinked path we know of + return firstDefinedIterator( + this.symlinkedDirectories.entries(), + ([directoryPath, symlinkedDirectory]) => { + if (!symlinkedDirectory || !startsWith(fileOrDirectoryPath, directoryPath)) return undefined; + const result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath)); + if (isFile && result) { + if (!this.symlinkedFiles) this.symlinkedFiles = createMap(); + // Store the real path for the file' + const absolutePath = getNormalizedAbsolutePath(fileOrDirectory, this.currentDirectory); + this.symlinkedFiles.set( + fileOrDirectoryPath, + `${symlinkedDirectory.real}${absolutePath.replace(new RegExp(directoryPath, "i"), "")}` + ); + } + return result; + } + ) || false; } /** @@ -1782,6 +1877,8 @@ namespace ts.server { this.pendingReload = ConfigFileProgramReloadLevel.None; this.projectReferenceCallbacks = undefined; this.mapOfDeclarationDirectories = undefined; + this.symlinkedDirectories = undefined; + this.symlinkedFiles = undefined; let result: boolean; switch (reloadLevel) { case ConfigFileProgramReloadLevel.Partial: @@ -1914,6 +2011,8 @@ namespace ts.server { this.configFileSpecs = undefined; this.projectReferenceCallbacks = undefined; this.mapOfDeclarationDirectories = undefined; + this.symlinkedDirectories = undefined; + this.symlinkedFiles = undefined; super.close(); } diff --git a/src/server/protocol.ts b/src/server/protocol.ts index c86876f1caa..925e7638f9d 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -3007,6 +3007,12 @@ namespace ts.server.protocol { * For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`. */ readonly includeCompletionsWithInsertText?: boolean; + /** + * Unless this option is `false`, or `includeCompletionsWithInsertText` is not enabled, + * member completion lists triggered with `.` will include entries on potentially-null and potentially-undefined + * values, with insertion text to replace preceding `.` tokens with `?.`. + */ + readonly includeAutomaticOptionalChainCompletions?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly allowTextChangesInNewFiles?: boolean; readonly lazyConfiguredProjectsFromExternalProject?: boolean; diff --git a/src/services/completions.ts b/src/services/completions.ts index 11f92c3d4eb..076cc32f374 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -338,6 +338,7 @@ namespace ts.Completions { ): CompletionEntry | undefined { let insertText: string | undefined; let replacementSpan: TextSpan | undefined; + const insertQuestionDot = origin && originIsNullableMember(origin); const useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { @@ -780,7 +781,7 @@ namespace ts.Completions { sourceFile: SourceFile, isUncheckedFile: boolean, position: number, - preferences: Pick, + preferences: Pick, detailsEntryId: CompletionEntryIdentifier | undefined, host: LanguageServiceHost, ): CompletionData | Request | undefined { @@ -1116,8 +1117,17 @@ namespace ts.Completions { let type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); let insertQuestionDot = false; if (type.isNullableType()) { - insertQuestionDot = isRightOfDot && !isRightOfQuestionDot; - type = type.getNonNullableType(); + const canCorrectToQuestionDot = + isRightOfDot && + !isRightOfQuestionDot && + preferences.includeAutomaticOptionalChainCompletions !== false; + + if (canCorrectToQuestionDot || isRightOfQuestionDot) { + type = type.getNonNullableType(); + if (canCorrectToQuestionDot) { + insertQuestionDot = true; + } + } } addTypeProperties(type, !!(node.flags & NodeFlags.AwaitContext), insertQuestionDot); } @@ -1137,8 +1147,17 @@ namespace ts.Completions { let type = typeChecker.getTypeAtLocation(node).getNonOptionalType(); let insertQuestionDot = false; if (type.isNullableType()) { - insertQuestionDot = isRightOfDot && !isRightOfQuestionDot; - type = type.getNonNullableType(); + const canCorrectToQuestionDot = + isRightOfDot && + !isRightOfQuestionDot && + preferences.includeAutomaticOptionalChainCompletions !== false; + + if (canCorrectToQuestionDot || isRightOfQuestionDot) { + type = type.getNonNullableType(); + if (canCorrectToQuestionDot) { + insertQuestionDot = true; + } + } } addTypeProperties(type, !!(node.flags & NodeFlags.AwaitContext), insertQuestionDot); } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index bd0e63561da..8d41211439b 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -584,7 +584,7 @@ namespace ts.FindAllReferences.Core { } function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol: Symbol, program: Program, sourceFiles: readonly SourceFile[], cancellationToken: CancellationToken, options: Options, sourceFilesSet: ReadonlyMap) { - const moduleSourceFile = symbol.flags & SymbolFlags.Module ? find(symbol.declarations, isSourceFile) : undefined; + const moduleSourceFile = (symbol.flags & SymbolFlags.Module) && symbol.declarations && find(symbol.declarations, isSourceFile); if (!moduleSourceFile) return undefined; const exportEquals = symbol.exports!.get(InternalSymbolName.ExportEquals); // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 6cc654453e4..5539a8e30cb 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -326,8 +326,9 @@ namespace ts.formatting { export function argumentStartsOnSameLineAsPreviousArgument(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFileLike): boolean { if (isCallOrNewExpression(parent)) { if (!parent.arguments) return false; - - const currentNode = Debug.assertDefined(find(parent.arguments, arg => arg.pos === child.pos)); + const currentNode = find(parent.arguments, arg => arg.pos === child.pos); + // If it's not one of the arguments, don't look past this + if (!currentNode) return false; const currentIndex = parent.arguments.indexOf(currentNode); if (currentIndex === 0) return false; // Can't look at previous node if first diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 03b9d6216c8..49310ef827f 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -648,7 +648,8 @@ namespace ts.NavigationBar { const declName = getNameOfDeclaration(node); if (declName && isPropertyName(declName)) { - return unescapeLeadingUnderscores(getPropertyNameForPropertyNameNode(declName)!); // TODO: GH#18217 + const propertyName = getPropertyNameForPropertyNameNode(declName); + return propertyName && unescapeLeadingUnderscores(propertyName); } switch (node.kind) { case SyntaxKind.FunctionExpression: diff --git a/src/services/refactors/extractType.ts b/src/services/refactors/extractType.ts index ba06814c4ea..70934ef7a7c 100644 --- a/src/services/refactors/extractType.ts +++ b/src/services/refactors/extractType.ts @@ -68,7 +68,7 @@ namespace ts.refactor { if (!selection || !isTypeNode(selection)) return undefined; const checker = context.program.getTypeChecker(); - const firstStatement = Debug.assertDefined(isJS ? findAncestor(selection, isStatementAndHasJSDoc) : findAncestor(selection, isStatement), "Should find a statement"); + const firstStatement = Debug.assertDefined(findAncestor(selection, isStatement), "Should find a statement"); const typeParameters = collectTypeParameters(checker, selection, firstStatement, file); if (!typeParameters) return undefined; @@ -100,10 +100,6 @@ namespace ts.refactor { return undefined; } - function isStatementAndHasJSDoc(n: Node): n is (Statement & HasJSDoc) { - return isStatement(n) && hasJSDocNodes(n); - } - function rangeContainsSkipTrivia(r1: TextRange, node: Node, file: SourceFile): boolean { return rangeContainsStartEnd(r1, skipTrivia(file.text, node.pos), node.end); } diff --git a/src/services/services.ts b/src/services/services.ts index acd3688f332..a9bdcef8c5f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -953,9 +953,7 @@ namespace ts { names.push(entry); } else { - if (entry.scriptKind !== ScriptKind.JSON) { - names.push(entry.hostFileName); - } + names.push(entry.hostFileName); } }); return names; diff --git a/src/testRunner/unittests/services/colorization.ts b/src/testRunner/unittests/services/colorization.ts index 1970fea7b03..c8052cfc17b 100644 --- a/src/testRunner/unittests/services/colorization.ts +++ b/src/testRunner/unittests/services/colorization.ts @@ -57,7 +57,7 @@ describe("unittests:: services:: Colorization", () => { } describe("test getClassifications", () => { - it("Returns correct token classes", () => { + it("returns correct token classes", () => { testLexicalClassification("var x: string = \"foo\" ?? \"bar\"; //Hello", ts.EndOfLineState.None, keyword("var"), @@ -96,14 +96,14 @@ describe("unittests:: services:: Colorization", () => { operator(",")); }); - it("correctly classifies a multi-line string with one backslash", () => { + it("correctly classifies a multiline string with one backslash", () => { testLexicalClassification("'line1\\", ts.EndOfLineState.None, stringLiteral("'line1\\"), finalEndOfLineState(ts.EndOfLineState.InSingleQuoteStringLiteral)); }); - it("correctly classifies a multi-line string with three backslashes", () => { + it("correctly classifies a multiline string with three backslashes", () => { testLexicalClassification("'line1\\\\\\", ts.EndOfLineState.None, stringLiteral("'line1\\\\\\"), @@ -131,42 +131,42 @@ describe("unittests:: services:: Colorization", () => { finalEndOfLineState(ts.EndOfLineState.None)); }); - it("correctly classifies the continuing line of a multi-line string ending in one backslash", () => { + it("correctly classifies the continuing line of a multiline string ending in one backslash", () => { testLexicalClassification("\\", ts.EndOfLineState.InDoubleQuoteStringLiteral, stringLiteral("\\"), finalEndOfLineState(ts.EndOfLineState.InDoubleQuoteStringLiteral)); }); - it("correctly classifies the continuing line of a multi-line string ending in three backslashes", () => { + it("correctly classifies the continuing line of a multiline string ending in three backslashes", () => { testLexicalClassification("\\", ts.EndOfLineState.InDoubleQuoteStringLiteral, stringLiteral("\\"), finalEndOfLineState(ts.EndOfLineState.InDoubleQuoteStringLiteral)); }); - it("correctly classifies the last line of an unterminated multi-line string ending in no backslashes", () => { + it("correctly classifies the last line of an unterminated multiline string ending in no backslashes", () => { testLexicalClassification(" ", ts.EndOfLineState.InDoubleQuoteStringLiteral, stringLiteral(" "), finalEndOfLineState(ts.EndOfLineState.None)); }); - it("correctly classifies the last line of an unterminated multi-line string ending in two backslashes", () => { + it("correctly classifies the last line of an unterminated multiline string ending in two backslashes", () => { testLexicalClassification("\\\\", ts.EndOfLineState.InDoubleQuoteStringLiteral, stringLiteral("\\\\"), finalEndOfLineState(ts.EndOfLineState.None)); }); - it("correctly classifies the last line of an unterminated multi-line string ending in four backslashes", () => { + it("correctly classifies the last line of an unterminated multiline string ending in four backslashes", () => { testLexicalClassification("\\\\\\\\", ts.EndOfLineState.InDoubleQuoteStringLiteral, stringLiteral("\\\\\\\\"), finalEndOfLineState(ts.EndOfLineState.None)); }); - it("correctly classifies the last line of a multi-line string", () => { + it("correctly classifies the last line of a multiline string", () => { testLexicalClassification("'", ts.EndOfLineState.InSingleQuoteStringLiteral, stringLiteral("'"), diff --git a/src/testRunner/unittests/transform.ts b/src/testRunner/unittests/transform.ts index ffd5ba7609f..bcb0c93d1a8 100644 --- a/src/testRunner/unittests/transform.ts +++ b/src/testRunner/unittests/transform.ts @@ -447,6 +447,35 @@ namespace Foo { }).outputText; }); + testBaseline("transformUpdateModuleMember", () => { + return transpileModule(` +module MyModule { + const myVariable = 1; + function foo(param: string) {} +} +`, { + transformers: { + before: [renameVariable], + }, + compilerOptions: { + target: ScriptTarget.ES2015, + newLine: NewLineKind.CarriageReturnLineFeed, + } + }).outputText; + + function renameVariable(context: TransformationContext) { + return (sourceFile: SourceFile): SourceFile => { + return visitNode(sourceFile, rootTransform, isSourceFile); + }; + function rootTransform(node: T): Node { + if (isVariableDeclaration(node)) { + return updateVariableDeclaration(node, createIdentifier("newName"), /* type */ undefined, node.initializer); + } + return visitEachChild(node, rootTransform, context); + } + } + }); + // https://github.com/Microsoft/TypeScript/issues/24709 testBaseline("issue24709", () => { const fs = vfs.createFromFileSystem(Harness.IO, /*caseSensitive*/ true); diff --git a/src/testRunner/unittests/tsbuild/watchMode.ts b/src/testRunner/unittests/tsbuild/watchMode.ts index b2f2eac1582..9e3a0eb9388 100644 --- a/src/testRunner/unittests/tsbuild/watchMode.ts +++ b/src/testRunner/unittests/tsbuild/watchMode.ts @@ -283,8 +283,8 @@ function foo() { }`, /*local*/ true); }); it("builds when new file is added, and its subsequent updates", () => { - const additinalFiles: readonly [SubProject, string][] = [[SubProject.core, newFileWithoutExtension]]; - const { verifyChangeWithFile } = createSolutionInWatchModeToVerifyChanges(additinalFiles); + const additionalFiles: readonly [SubProject, string][] = [[SubProject.core, newFileWithoutExtension]]; + const { verifyChangeWithFile } = createSolutionInWatchModeToVerifyChanges(additionalFiles); verifyChange(newFile.content); // Another change requeues and builds it diff --git a/src/testRunner/unittests/tsserver/projectErrors.ts b/src/testRunner/unittests/tsserver/projectErrors.ts index f5c28eb7a74..64c07c77010 100644 --- a/src/testRunner/unittests/tsserver/projectErrors.ts +++ b/src/testRunner/unittests/tsserver/projectErrors.ts @@ -861,4 +861,76 @@ declare module '@custom/plugin' { ]); }); }); + + describe("unittests:: tsserver:: Project Errors with resolveJsonModule", () => { + function createSessionForTest({ include }: { include: readonly string[]; }) { + const test: File = { + path: `${projectRoot}/src/test.ts`, + content: `import * as blabla from "./blabla.json"; +declare var console: any; +console.log(blabla);` + }; + const blabla: File = { + path: `${projectRoot}/src/blabla.json`, + content: "{}" + }; + const tsconfig: File = { + path: `${projectRoot}/tsconfig.json`, + content: JSON.stringify({ + compilerOptions: { + resolveJsonModule: true, + composite: true + }, + include + }) + }; + + const host = createServerHost([test, blabla, libFile, tsconfig]); + const session = createSession(host, { canUseEvents: true }); + openFilesForSession([test], session); + return { host, session, test, blabla, tsconfig }; + } + + it("should not report incorrect error when json is root file found by tsconfig", () => { + const { host, session, test } = createSessionForTest({ + include: ["./src/*.ts", "./src/*.json"] + }); + verifyGetErrRequest({ + session, + host, + expected: [ + { + file: test, + syntax: [], + semantic: [], + suggestion: [] + } + ] + }); + }); + + it("should report error when json is not root file found by tsconfig", () => { + const { host, session, test, blabla, tsconfig } = createSessionForTest({ + include: ["./src/*.ts"] + }); + const span = protocolTextSpanFromSubstring(test.content, `"./blabla.json"`); + verifyGetErrRequest({ + session, + host, + expected: [{ + file: test, + syntax: [], + semantic: [ + createDiagnostic( + span.start, + span.end, + Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, + [blabla.path, tsconfig.path] + ) + ], + suggestion: [] + }] + }); + }); + }); } diff --git a/src/testRunner/unittests/tsserver/projectReferences.ts b/src/testRunner/unittests/tsserver/projectReferences.ts index bbc368b6d8a..0966ad911e3 100644 --- a/src/testRunner/unittests/tsserver/projectReferences.ts +++ b/src/testRunner/unittests/tsserver/projectReferences.ts @@ -1,6 +1,6 @@ namespace ts.projectSystem { describe("unittests:: tsserver:: with project references and tsbuild", () => { - function createHost(files: readonly File[], rootNames: readonly string[]) { + function createHost(files: readonly TestFSWithWatch.FileOrFolderOrSymLink[], rootNames: readonly string[]) { const host = createServerHost(files); // ts build should succeed @@ -1373,5 +1373,97 @@ function foo() { assert.isTrue(projectA.dirty); projectA.updateGraph(); }); + + describe("when references are monorepo like with symlinks", () => { + function verifySession(alreadyBuilt: boolean, extraOptions: CompilerOptions) { + const bPackageJson: File = { + path: `${projectRoot}/packages/B/package.json`, + content: JSON.stringify({ + main: "lib/index.js", + types: "lib/index.d.ts" + }) + }; + const aConfig = config("A", extraOptions, ["../B"]); + const bConfig = config("B", extraOptions); + const aIndex = index("A", `import { foo } from 'b'; +import { bar } from 'b/lib/bar'; +foo(); +bar();`); + const bIndex = index("B", `export function foo() { }`); + const bBar: File = { + path: `${projectRoot}/packages/B/src/bar.ts`, + content: `export function bar() { }` + }; + const bSymlink: SymLink = { + path: `${projectRoot}/node_modules/b`, + symLink: `${projectRoot}/packages/B` + }; + + const files = [libFile, bPackageJson, aConfig, bConfig, aIndex, bIndex, bBar, bSymlink]; + const host = alreadyBuilt ? + createHost(files, [aConfig.path]) : + createServerHost(files); + + // Create symlink in node module + const session = createSession(host, { canUseEvents: true }); + openFilesForSession([aIndex], session); + const service = session.getProjectService(); + const project = service.configuredProjects.get(aConfig.path.toLowerCase())!; + assert.deepEqual(project.getAllProjectErrors(), []); + checkProjectActualFiles( + project, + [aConfig.path, aIndex.path, bIndex.path, bBar.path, libFile.path] + ); + verifyGetErrRequest({ + host, + session, + expected: [ + { file: aIndex, syntax: [], semantic: [], suggestion: [] } + ] + }); + } + + function verifySymlinkScenario(alreadyBuilt: boolean) { + it("with preserveSymlinks turned off", () => { + verifySession(alreadyBuilt, {}); + }); + + it("with preserveSymlinks turned on", () => { + verifySession(alreadyBuilt, { preserveSymlinks: true }); + }); + } + + describe("when solution is not built", () => { + verifySymlinkScenario(/*alreadyBuilt*/ false); + }); + + describe("when solution is already built", () => { + verifySymlinkScenario(/*alreadyBuilt*/ true); + }); + + function config(packageName: string, extraOptions: CompilerOptions, references?: string[]): File { + return { + path: `${projectRoot}/packages/${packageName}/tsconfig.json`, + content: JSON.stringify({ + compilerOptions: { + baseUrl: ".", + outDir: "lib", + rootDir: "src", + composite: true, + ...extraOptions + }, + include: ["src"], + ...(references ? { references: references.map(path => ({ path })) } : {}) + }) + }; + } + + function index(packageName: string, content: string): File { + return { + path: `${projectRoot}/packages/${packageName}/src/index.ts`, + content + }; + } + }); }); } diff --git a/src/tsc/tsconfig.release.json b/src/tsc/tsconfig.release.json index 45a7577a342..5d6e1687c24 100644 --- a/src/tsc/tsconfig.release.json +++ b/src/tsc/tsconfig.release.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig-base", + "extends": "./tsconfig.json", "compilerOptions": { "outFile": "../../built/local/tsc.release.js", "stripInternal": true, @@ -8,11 +8,8 @@ "declarationMap": false, "sourceMap": false, "composite": false, - "incremental": true + "incremental": true }, - "files": [ - "tsc.ts" - ], "references": [ { "path": "../compiler/tsconfig.release.json", "prepend": true } ] diff --git a/tests/baselines/reference/anonClassDeclarationEmitIsAnon.js b/tests/baselines/reference/anonClassDeclarationEmitIsAnon.js new file mode 100644 index 00000000000..697348e1ba8 --- /dev/null +++ b/tests/baselines/reference/anonClassDeclarationEmitIsAnon.js @@ -0,0 +1,142 @@ +//// [tests/cases/compiler/anonClassDeclarationEmitIsAnon.ts] //// + +//// [wrapClass.ts] +export function wrapClass(param: any) { + return class Wrapped { + foo() { + return param; + } + } +} + +export type Constructor = new (...args: any[]) => T; + +export function Timestamped(Base: TBase) { + return class extends Base { + timestamp = Date.now(); + }; +} + +//// [index.ts] +import { wrapClass, Timestamped } from "./wrapClass"; + +export default wrapClass(0); + +// Simple class +export class User { + name = ''; +} + +// User that is Timestamped +export class TimestampedUser extends Timestamped(User) { + constructor() { + super(); + } +} + +//// [wrapClass.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +function wrapClass(param) { + return /** @class */ (function () { + function Wrapped() { + } + Wrapped.prototype.foo = function () { + return param; + }; + return Wrapped; + }()); +} +exports.wrapClass = wrapClass; +function Timestamped(Base) { + return /** @class */ (function (_super) { + __extends(class_1, _super); + function class_1() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.timestamp = Date.now(); + return _this; + } + return class_1; + }(Base)); +} +exports.Timestamped = Timestamped; +//// [index.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var wrapClass_1 = require("./wrapClass"); +exports["default"] = wrapClass_1.wrapClass(0); +// Simple class +var User = /** @class */ (function () { + function User() { + this.name = ''; + } + return User; +}()); +exports.User = User; +// User that is Timestamped +var TimestampedUser = /** @class */ (function (_super) { + __extends(TimestampedUser, _super); + function TimestampedUser() { + return _super.call(this) || this; + } + return TimestampedUser; +}(wrapClass_1.Timestamped(User))); +exports.TimestampedUser = TimestampedUser; + + +//// [wrapClass.d.ts] +export declare function wrapClass(param: any): { + new (): { + foo(): any; + }; +}; +export declare type Constructor = new (...args: any[]) => T; +export declare function Timestamped(Base: TBase): { + new (...args: any[]): { + timestamp: number; + }; +} & TBase; +//// [index.d.ts] +declare const _default: { + new (): { + foo(): any; + }; +}; +export default _default; +export declare class User { + name: string; +} +declare const TimestampedUser_base: { + new (...args: any[]): { + timestamp: number; + }; +} & typeof User; +export declare class TimestampedUser extends TimestampedUser_base { + constructor(); +} diff --git a/tests/baselines/reference/anonClassDeclarationEmitIsAnon.symbols b/tests/baselines/reference/anonClassDeclarationEmitIsAnon.symbols new file mode 100644 index 00000000000..f2988d8cb2e --- /dev/null +++ b/tests/baselines/reference/anonClassDeclarationEmitIsAnon.symbols @@ -0,0 +1,68 @@ +=== tests/cases/compiler/wrapClass.ts === +export function wrapClass(param: any) { +>wrapClass : Symbol(wrapClass, Decl(wrapClass.ts, 0, 0)) +>param : Symbol(param, Decl(wrapClass.ts, 0, 26)) + + return class Wrapped { +>Wrapped : Symbol(Wrapped, Decl(wrapClass.ts, 1, 10)) + + foo() { +>foo : Symbol(Wrapped.foo, Decl(wrapClass.ts, 1, 26)) + + return param; +>param : Symbol(param, Decl(wrapClass.ts, 0, 26)) + } + } +} + +export type Constructor = new (...args: any[]) => T; +>Constructor : Symbol(Constructor, Decl(wrapClass.ts, 6, 1)) +>T : Symbol(T, Decl(wrapClass.ts, 8, 24)) +>args : Symbol(args, Decl(wrapClass.ts, 8, 39)) +>T : Symbol(T, Decl(wrapClass.ts, 8, 24)) + +export function Timestamped(Base: TBase) { +>Timestamped : Symbol(Timestamped, Decl(wrapClass.ts, 8, 60)) +>TBase : Symbol(TBase, Decl(wrapClass.ts, 10, 28)) +>Constructor : Symbol(Constructor, Decl(wrapClass.ts, 6, 1)) +>Base : Symbol(Base, Decl(wrapClass.ts, 10, 55)) +>TBase : Symbol(TBase, Decl(wrapClass.ts, 10, 28)) + + return class extends Base { +>Base : Symbol(Base, Decl(wrapClass.ts, 10, 55)) + + timestamp = Date.now(); +>timestamp : Symbol((Anonymous class).timestamp, Decl(wrapClass.ts, 11, 31)) +>Date.now : Symbol(DateConstructor.now, Decl(lib.es5.d.ts, --, --)) +>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --)) +>now : Symbol(DateConstructor.now, Decl(lib.es5.d.ts, --, --)) + + }; +} + +=== tests/cases/compiler/index.ts === +import { wrapClass, Timestamped } from "./wrapClass"; +>wrapClass : Symbol(wrapClass, Decl(index.ts, 0, 8)) +>Timestamped : Symbol(Timestamped, Decl(index.ts, 0, 19)) + +export default wrapClass(0); +>wrapClass : Symbol(wrapClass, Decl(index.ts, 0, 8)) + +// Simple class +export class User { +>User : Symbol(User, Decl(index.ts, 2, 28)) + + name = ''; +>name : Symbol(User.name, Decl(index.ts, 5, 19)) +} + +// User that is Timestamped +export class TimestampedUser extends Timestamped(User) { +>TimestampedUser : Symbol(TimestampedUser, Decl(index.ts, 7, 1)) +>Timestamped : Symbol(Timestamped, Decl(index.ts, 0, 19)) +>User : Symbol(User, Decl(index.ts, 2, 28)) + + constructor() { + super(); + } +} diff --git a/tests/baselines/reference/anonClassDeclarationEmitIsAnon.types b/tests/baselines/reference/anonClassDeclarationEmitIsAnon.types new file mode 100644 index 00000000000..038b0a49bfb --- /dev/null +++ b/tests/baselines/reference/anonClassDeclarationEmitIsAnon.types @@ -0,0 +1,72 @@ +=== tests/cases/compiler/wrapClass.ts === +export function wrapClass(param: any) { +>wrapClass : (param: any) => typeof Wrapped +>param : any + + return class Wrapped { +>class Wrapped { foo() { return param; } } : typeof Wrapped +>Wrapped : typeof Wrapped + + foo() { +>foo : () => any + + return param; +>param : any + } + } +} + +export type Constructor = new (...args: any[]) => T; +>Constructor : Constructor +>args : any[] + +export function Timestamped(Base: TBase) { +>Timestamped : >(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped.(Anonymous class); } & TBase +>Base : TBase + + return class extends Base { +>class extends Base { timestamp = Date.now(); } : { new (...args: any[]): (Anonymous class); prototype: Timestamped.(Anonymous class); } & TBase +>Base : {} + + timestamp = Date.now(); +>timestamp : number +>Date.now() : number +>Date.now : () => number +>Date : DateConstructor +>now : () => number + + }; +} + +=== tests/cases/compiler/index.ts === +import { wrapClass, Timestamped } from "./wrapClass"; +>wrapClass : (param: any) => typeof Wrapped +>Timestamped : >(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped.(Anonymous class); } & TBase + +export default wrapClass(0); +>wrapClass(0) : typeof Wrapped +>wrapClass : (param: any) => typeof Wrapped +>0 : 0 + +// Simple class +export class User { +>User : User + + name = ''; +>name : string +>'' : "" +} + +// User that is Timestamped +export class TimestampedUser extends Timestamped(User) { +>TimestampedUser : TimestampedUser +>Timestamped(User) : Timestamped.(Anonymous class) & User +>Timestamped : >(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped.(Anonymous class); } & TBase +>User : typeof User + + constructor() { + super(); +>super() : void +>super : { new (...args: any[]): Timestamped.(Anonymous class); prototype: Timestamped.(Anonymous class); } & typeof User + } +} diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index aa1945e74b9..e775580c1fb 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.7"; + const versionMajorMinor = "3.8"; /** The version of the TypeScript compiler release */ const version: string; } @@ -3171,6 +3171,7 @@ declare namespace ts { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; + readonly includeAutomaticOptionalChainCompletions?: boolean; readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; /** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */ @@ -3524,6 +3525,7 @@ declare namespace ts { function isCallExpression(node: Node): node is CallExpression; function isCallChain(node: Node): node is CallChain; function isOptionalChain(node: Node): node is PropertyAccessChain | ElementAccessChain | CallChain; + function isNullishCoalesce(node: Node): boolean; function isNewExpression(node: Node): node is NewExpression; function isTaggedTemplateExpression(node: Node): node is TaggedTemplateExpression; function isTypeAssertion(node: Node): node is TypeAssertion; @@ -8295,6 +8297,12 @@ declare namespace ts.server.protocol { * For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`. */ readonly includeCompletionsWithInsertText?: boolean; + /** + * Unless this option is `false`, or `includeCompletionsWithInsertText` is not enabled, + * member completion lists triggered with `.` will include entries on potentially-null and potentially-undefined + * values, with insertion text to replace preceding `.` tokens with `?.`. + */ + readonly includeAutomaticOptionalChainCompletions?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly allowTextChangesInNewFiles?: boolean; readonly lazyConfiguredProjectsFromExternalProject?: boolean; @@ -8676,23 +8684,31 @@ declare namespace ts.server { readonly canonicalConfigFilePath: NormalizedPath; private projectReferenceCallbacks; private mapOfDeclarationDirectories; + private symlinkedDirectories; + private symlinkedFiles; /** Ref count to the project when opened from external project */ private externalProjectRefCount; private projectErrors; private projectReferences; protected isInitialLoadPending: () => boolean; + private fileExistsIfProjectReferenceDts; /** * This implementation of fileExists checks if the file being requested is * .d.ts file for the referenced Project. * If it is it returns true irrespective of whether that file exists on host */ fileExists(file: string): boolean; + private directoryExistsIfProjectReferenceDeclDir; /** * This implementation of directoryExists checks if the directory being requested is * directory of .d.ts file for the referenced Project. * If it is it returns true irrespective of whether that directory exists on host */ directoryExists(path: string): boolean; + private realpathIfSymlinkedProjectReferenceDts; + private getRealpath; + private handleDirectoryCouldBeSymlink; + private fileOrDirectoryExistsUsingSource; /** * If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph * @returns: true if set of files in the project stays the same and false - otherwise. diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 7c756d8a0a3..fe23df054da 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.7"; + const versionMajorMinor = "3.8"; /** The version of the TypeScript compiler release */ const version: string; } @@ -3171,6 +3171,7 @@ declare namespace ts { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; + readonly includeAutomaticOptionalChainCompletions?: boolean; readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; /** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */ @@ -3524,6 +3525,7 @@ declare namespace ts { function isCallExpression(node: Node): node is CallExpression; function isCallChain(node: Node): node is CallChain; function isOptionalChain(node: Node): node is PropertyAccessChain | ElementAccessChain | CallChain; + function isNullishCoalesce(node: Node): boolean; function isNewExpression(node: Node): node is NewExpression; function isTaggedTemplateExpression(node: Node): node is TaggedTemplateExpression; function isTypeAssertion(node: Node): node is TypeAssertion; diff --git a/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js index cc9ad56be88..adbba8ee8ae 100644 --- a/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js +++ b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js @@ -15,7 +15,7 @@ for (var _i = 0, _a = [{}]; _i < _a.length; _i++) { continue; } // 2: -for (var _c = a, a = {}[_c]; false;) +for (var _c = {}, _d = a, a = _c[_d]; false;) continue; // 3: -var _d = b, b = {}[_d]; +var _e = {}, _f = b, b = _e[_f]; diff --git a/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.errors.txt b/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.errors.txt new file mode 100644 index 00000000000..52b43068c04 --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/jsdoc/0.js(10,20): error TS2694: Namespace 'exports' has no exported member 'SomeName'. + + +==== tests/cases/conformance/jsdoc/0.js (1 errors) ==== + // @ts-check + + var exports = {}; + + /** + * @typedef {string} + */ + exports.SomeName; + + /** @type {exports.SomeName} */ + ~~~~~~~~ +!!! error TS2694: Namespace 'exports' has no exported member 'SomeName'. + const myString = 'str'; + \ No newline at end of file diff --git a/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.js b/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.js new file mode 100644 index 00000000000..7f4d7f4bcfd --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.js @@ -0,0 +1,23 @@ +//// [0.js] +// @ts-check + +var exports = {}; + +/** + * @typedef {string} + */ +exports.SomeName; + +/** @type {exports.SomeName} */ +const myString = 'str'; + + +//// [0.js] +// @ts-check +var exports = {}; +/** + * @typedef {string} + */ +exports.SomeName; +/** @type {exports.SomeName} */ +var myString = 'str'; diff --git a/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.symbols b/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.symbols new file mode 100644 index 00000000000..0adf9a93444 --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/jsdoc/0.js === +// @ts-check + +var exports = {}; +>exports : Symbol(exports, Decl(0.js, 2, 3)) + +/** + * @typedef {string} + */ +exports.SomeName; +>exports : Symbol(exports, Decl(0.js, 2, 3)) + +/** @type {exports.SomeName} */ +const myString = 'str'; +>myString : Symbol(myString, Decl(0.js, 10, 5)) + diff --git a/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.types b/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.types new file mode 100644 index 00000000000..fbb4f3ed0ba --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/jsdoc/0.js === +// @ts-check + +var exports = {}; +>exports : {} +>{} : {} + +/** + * @typedef {string} + */ +exports.SomeName; +>exports.SomeName : any +>exports : {} +>SomeName : any + +/** @type {exports.SomeName} */ +const myString = 'str'; +>myString : any +>'str' : "str" + diff --git a/tests/baselines/reference/commonTypeIntersection.errors.txt b/tests/baselines/reference/commonTypeIntersection.errors.txt new file mode 100644 index 00000000000..c10f8e2cfec --- /dev/null +++ b/tests/baselines/reference/commonTypeIntersection.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/types/intersection/commonTypeIntersection.ts(2,5): error TS2322: Type '{ __typename?: "TypeTwo"; } & { a: boolean; }' is not assignable to type '{ __typename?: "TypeOne"; } & { a: boolean; }'. + Type '{ __typename?: "TypeTwo"; } & { a: boolean; }' is not assignable to type '{ __typename?: "TypeOne"; }'. + Types of property '__typename' are incompatible. + Type '"TypeTwo"' is not assignable to type '"TypeOne"'. +tests/cases/conformance/types/intersection/commonTypeIntersection.ts(4,5): error TS2322: Type '{ __typename?: "TypeTwo"; } & string' is not assignable to type '{ __typename?: "TypeOne"; } & string'. + Type '{ __typename?: "TypeTwo"; } & string' is not assignable to type '{ __typename?: "TypeOne"; }'. + Types of property '__typename' are incompatible. + Type '"TypeTwo"' is not assignable to type '"TypeOne"'. + + +==== tests/cases/conformance/types/intersection/commonTypeIntersection.ts (2 errors) ==== + declare let x1: { __typename?: 'TypeTwo' } & { a: boolean }; + let y1: { __typename?: 'TypeOne' } & { a: boolean} = x1; // should error here + ~~ +!!! error TS2322: Type '{ __typename?: "TypeTwo"; } & { a: boolean; }' is not assignable to type '{ __typename?: "TypeOne"; } & { a: boolean; }'. +!!! error TS2322: Type '{ __typename?: "TypeTwo"; } & { a: boolean; }' is not assignable to type '{ __typename?: "TypeOne"; }'. +!!! error TS2322: Types of property '__typename' are incompatible. +!!! error TS2322: Type '"TypeTwo"' is not assignable to type '"TypeOne"'. + declare let x2: { __typename?: 'TypeTwo' } & string; + let y2: { __typename?: 'TypeOne' } & string = x2; // should error here + ~~ +!!! error TS2322: Type '{ __typename?: "TypeTwo"; } & string' is not assignable to type '{ __typename?: "TypeOne"; } & string'. +!!! error TS2322: Type '{ __typename?: "TypeTwo"; } & string' is not assignable to type '{ __typename?: "TypeOne"; }'. +!!! error TS2322: Types of property '__typename' are incompatible. +!!! error TS2322: Type '"TypeTwo"' is not assignable to type '"TypeOne"'. + \ No newline at end of file diff --git a/tests/baselines/reference/commonTypeIntersection.js b/tests/baselines/reference/commonTypeIntersection.js new file mode 100644 index 00000000000..1bef2b3b06c --- /dev/null +++ b/tests/baselines/reference/commonTypeIntersection.js @@ -0,0 +1,10 @@ +//// [commonTypeIntersection.ts] +declare let x1: { __typename?: 'TypeTwo' } & { a: boolean }; +let y1: { __typename?: 'TypeOne' } & { a: boolean} = x1; // should error here +declare let x2: { __typename?: 'TypeTwo' } & string; +let y2: { __typename?: 'TypeOne' } & string = x2; // should error here + + +//// [commonTypeIntersection.js] +var y1 = x1; // should error here +var y2 = x2; // should error here diff --git a/tests/baselines/reference/commonTypeIntersection.symbols b/tests/baselines/reference/commonTypeIntersection.symbols new file mode 100644 index 00000000000..3c81f5f4508 --- /dev/null +++ b/tests/baselines/reference/commonTypeIntersection.symbols @@ -0,0 +1,21 @@ +=== tests/cases/conformance/types/intersection/commonTypeIntersection.ts === +declare let x1: { __typename?: 'TypeTwo' } & { a: boolean }; +>x1 : Symbol(x1, Decl(commonTypeIntersection.ts, 0, 11)) +>__typename : Symbol(__typename, Decl(commonTypeIntersection.ts, 0, 17)) +>a : Symbol(a, Decl(commonTypeIntersection.ts, 0, 46)) + +let y1: { __typename?: 'TypeOne' } & { a: boolean} = x1; // should error here +>y1 : Symbol(y1, Decl(commonTypeIntersection.ts, 1, 3)) +>__typename : Symbol(__typename, Decl(commonTypeIntersection.ts, 1, 9)) +>a : Symbol(a, Decl(commonTypeIntersection.ts, 1, 38)) +>x1 : Symbol(x1, Decl(commonTypeIntersection.ts, 0, 11)) + +declare let x2: { __typename?: 'TypeTwo' } & string; +>x2 : Symbol(x2, Decl(commonTypeIntersection.ts, 2, 11)) +>__typename : Symbol(__typename, Decl(commonTypeIntersection.ts, 2, 17)) + +let y2: { __typename?: 'TypeOne' } & string = x2; // should error here +>y2 : Symbol(y2, Decl(commonTypeIntersection.ts, 3, 3)) +>__typename : Symbol(__typename, Decl(commonTypeIntersection.ts, 3, 9)) +>x2 : Symbol(x2, Decl(commonTypeIntersection.ts, 2, 11)) + diff --git a/tests/baselines/reference/commonTypeIntersection.types b/tests/baselines/reference/commonTypeIntersection.types new file mode 100644 index 00000000000..aa14b244bb0 --- /dev/null +++ b/tests/baselines/reference/commonTypeIntersection.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/types/intersection/commonTypeIntersection.ts === +declare let x1: { __typename?: 'TypeTwo' } & { a: boolean }; +>x1 : { __typename?: "TypeTwo"; } & { a: boolean; } +>__typename : "TypeTwo" +>a : boolean + +let y1: { __typename?: 'TypeOne' } & { a: boolean} = x1; // should error here +>y1 : { __typename?: "TypeOne"; } & { a: boolean; } +>__typename : "TypeOne" +>a : boolean +>x1 : { __typename?: "TypeTwo"; } & { a: boolean; } + +declare let x2: { __typename?: 'TypeTwo' } & string; +>x2 : { __typename?: "TypeTwo"; } & string +>__typename : "TypeTwo" + +let y2: { __typename?: 'TypeOne' } & string = x2; // should error here +>y2 : { __typename?: "TypeOne"; } & string +>__typename : "TypeOne" +>x2 : { __typename?: "TypeTwo"; } & string + diff --git a/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt b/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt index af63c18523d..9abaa6db803 100644 --- a/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt +++ b/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt @@ -5,20 +5,23 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t Type '"text" | "email"' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. Type '"text"' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. Type '"text"' is not assignable to type 'ChannelOfType["type"]'. - Type 'T' is not assignable to type 'ChannelOfType["type"]'. - Type '"text" | "email"' is not assignable to type 'ChannelOfType["type"]'. - Type '"text"' is not assignable to type 'ChannelOfType["type"]'. - Type '"text"' is not assignable to type 'T & "text"'. - Type '"text"' is not assignable to type 'T'. - '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. - Type 'T' is not assignable to type 'T & "text"'. - Type '"text" | "email"' is not assignable to type 'T & "text"'. - Type '"text"' is not assignable to type 'T & "text"'. - Type '"text"' is not assignable to type 'T'. - '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. - Type 'T' is not assignable to type '"text"'. - Type '"text" | "email"' is not assignable to type '"text"'. - Type '"email"' is not assignable to type '"text"'. + Type '"text"' is not assignable to type 'T & "text"'. + Type '"text"' is not assignable to type 'T'. + '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. + Type 'T' is not assignable to type 'ChannelOfType["type"]'. + Type '"text" | "email"' is not assignable to type 'ChannelOfType["type"]'. + Type '"text"' is not assignable to type 'ChannelOfType["type"]'. + Type '"text"' is not assignable to type 'T & "text"'. + Type '"text"' is not assignable to type 'T'. + '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. + Type 'T' is not assignable to type 'T & "text"'. + Type '"text" | "email"' is not assignable to type 'T & "text"'. + Type '"text"' is not assignable to type 'T & "text"'. + Type '"text"' is not assignable to type 'T'. + '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. + Type 'T' is not assignable to type '"text"'. + Type '"text" | "email"' is not assignable to type '"text"'. + Type '"email"' is not assignable to type '"text"'. ==== tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.ts (1 errors) ==== @@ -63,20 +66,23 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t !!! error TS2322: Type '"text" | "email"' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. !!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. !!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType["type"]'. -!!! error TS2322: Type 'T' is not assignable to type 'ChannelOfType["type"]'. -!!! error TS2322: Type '"text" | "email"' is not assignable to type 'ChannelOfType["type"]'. -!!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType["type"]'. -!!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'. -!!! error TS2322: Type '"text"' is not assignable to type 'T'. -!!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. -!!! error TS2322: Type 'T' is not assignable to type 'T & "text"'. -!!! error TS2322: Type '"text" | "email"' is not assignable to type 'T & "text"'. -!!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'. -!!! error TS2322: Type '"text"' is not assignable to type 'T'. -!!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. -!!! error TS2322: Type 'T' is not assignable to type '"text"'. -!!! error TS2322: Type '"text" | "email"' is not assignable to type '"text"'. -!!! error TS2322: Type '"email"' is not assignable to type '"text"'. +!!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'. +!!! error TS2322: Type '"text"' is not assignable to type 'T'. +!!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. +!!! error TS2322: Type 'T' is not assignable to type 'ChannelOfType["type"]'. +!!! error TS2322: Type '"text" | "email"' is not assignable to type 'ChannelOfType["type"]'. +!!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType["type"]'. +!!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'. +!!! error TS2322: Type '"text"' is not assignable to type 'T'. +!!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. +!!! error TS2322: Type 'T' is not assignable to type 'T & "text"'. +!!! error TS2322: Type '"text" | "email"' is not assignable to type 'T & "text"'. +!!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'. +!!! error TS2322: Type '"text"' is not assignable to type 'T'. +!!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. +!!! error TS2322: Type 'T' is not assignable to type '"text"'. +!!! error TS2322: Type '"text" | "email"' is not assignable to type '"text"'. +!!! error TS2322: Type '"email"' is not assignable to type '"text"'. } const newTextChannel = makeNewChannel('text'); diff --git a/tests/baselines/reference/computedPropertiesInDestructuring1.js b/tests/baselines/reference/computedPropertiesInDestructuring1.js index 4a0d6db3c1d..7dea81590c7 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring1.js +++ b/tests/baselines/reference/computedPropertiesInDestructuring1.js @@ -38,15 +38,15 @@ let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}]; //// [computedPropertiesInDestructuring1.js] -var _a, _b, _c, _d, _e, _f; +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; // destructuring in variable declarations var foo = "bar"; -var _g = foo, bar = { bar: "bar" }[_g]; +var _o = { bar: "bar" }, _p = foo, bar = _o[_p]; var bar2 = { bar: "bar" }["bar"]; var foo2 = function () { return "bar"; }; -var _h = foo2(), bar3 = { bar: "bar" }[_h]; -var _j = foo, bar4 = [{ bar: "bar" }][0][_j]; -var _k = foo2(), bar5 = [{ bar: "bar" }][0][_k]; +var _q = { bar: "bar" }, _r = foo2(), bar3 = _q[_r]; +var _s = [{ bar: "bar" }], _t = foo, bar4 = _s[0][_t]; +var _u = [{ bar: "bar" }], _v = foo2(), bar5 = _u[0][_v]; function f1(_a) { var x = _a["bar"]; } @@ -63,13 +63,13 @@ function f5(_a) { var _b = foo2(), x = _a[0][_b]; } // report errors on type errors in computed properties used in destructuring -var _l = foo(), bar6 = [{ bar: "bar" }][0][_l]; -var _m = foo.toExponential(), bar7 = [{ bar: "bar" }][0][_m]; +var _w = [{ bar: "bar" }], _x = foo(), bar6 = _w[0][_x]; +var _y = [{ bar: "bar" }], _z = foo.toExponential(), bar7 = _y[0][_z]; // destructuring assignment -(_a = foo, bar = { bar: "bar" }[_a]); +(_a = { bar: "bar" }, _b = foo, bar = _a[_b]); (bar2 = { bar: "bar" }["bar"]); -(_b = foo2(), bar3 = { bar: "bar" }[_b]); -_c = foo, bar4 = [{ bar: "bar" }][0][_c]; -_d = foo2(), bar5 = [{ bar: "bar" }][0][_d]; -_e = foo(), bar4 = [{ bar: "bar" }][0][_e]; -_f = (1 + {}), bar4 = [{ bar: "bar" }][0][_f]; +(_c = { bar: "bar" }, _d = foo2(), bar3 = _c[_d]); +_e = [{ bar: "bar" }], _f = foo, bar4 = _e[0][_f]; +_g = [{ bar: "bar" }], _h = foo2(), bar5 = _g[0][_h]; +_j = [{ bar: "bar" }], _k = foo(), bar4 = _j[0][_k]; +_l = [{ bar: "bar" }], _m = (1 + {}), bar4 = _l[0][_m]; diff --git a/tests/baselines/reference/computedPropertiesInDestructuring2.js b/tests/baselines/reference/computedPropertiesInDestructuring2.js index 8579881b775..e52acafcf49 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring2.js +++ b/tests/baselines/reference/computedPropertiesInDestructuring2.js @@ -4,4 +4,4 @@ let {[foo2()]: bar3} = {}; //// [computedPropertiesInDestructuring2.js] var foo2 = function () { return "bar"; }; -var _a = foo2(), bar3 = {}[_a]; +var _a = {}, _b = foo2(), bar3 = _a[_b]; diff --git a/tests/baselines/reference/constEnumNoEmitReexport.js b/tests/baselines/reference/constEnumNoEmitReexport.js new file mode 100644 index 00000000000..de1ed1ff032 --- /dev/null +++ b/tests/baselines/reference/constEnumNoEmitReexport.js @@ -0,0 +1,59 @@ +//// [tests/cases/compiler/constEnumNoEmitReexport.ts] //// + +//// [ConstEnum.ts] +export const enum MyConstEnum { + Foo, + Bar +}; +//// [ImportExport.ts] +import { MyConstEnum } from './ConstEnum'; +export { MyConstEnum }; +//// [ImportExportDefault.ts] +import { MyConstEnum } from './ConstEnum'; +export default MyConstEnum; +//// [ReExportDefault.ts] +export { MyConstEnum as default } from './ConstEnum'; +//// [ReExport.ts] +export { MyConstEnum } from './ConstEnum'; +//// [Usage1.ts] +import MyConstEnum1 from './ImportExportDefault'; +import MyConstEnum2 from './ReExportDefault'; +MyConstEnum1.Foo; +MyConstEnum2.Foo; +//// [Usage2.ts] +import { MyConstEnum } from './ImportExport'; +MyConstEnum.Foo; +//// [Usage3.ts] +import { MyConstEnum } from './ReExport'; +MyConstEnum.Foo; + + +//// [ConstEnum.js] +"use strict"; +exports.__esModule = true; +; +//// [ImportExport.js] +"use strict"; +exports.__esModule = true; +//// [ImportExportDefault.js] +"use strict"; +exports.__esModule = true; +//// [ReExportDefault.js] +"use strict"; +exports.__esModule = true; +//// [ReExport.js] +"use strict"; +exports.__esModule = true; +//// [Usage1.js] +"use strict"; +exports.__esModule = true; +0 /* Foo */; +0 /* Foo */; +//// [Usage2.js] +"use strict"; +exports.__esModule = true; +0 /* Foo */; +//// [Usage3.js] +"use strict"; +exports.__esModule = true; +0 /* Foo */; diff --git a/tests/baselines/reference/constEnumNoEmitReexport.symbols b/tests/baselines/reference/constEnumNoEmitReexport.symbols new file mode 100644 index 00000000000..894da1c6705 --- /dev/null +++ b/tests/baselines/reference/constEnumNoEmitReexport.symbols @@ -0,0 +1,69 @@ +=== tests/cases/compiler/ConstEnum.ts === +export const enum MyConstEnum { +>MyConstEnum : Symbol(MyConstEnum, Decl(ConstEnum.ts, 0, 0)) + + Foo, +>Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.ts, 0, 31)) + + Bar +>Bar : Symbol(MyConstEnum.Bar, Decl(ConstEnum.ts, 1, 8)) + +}; +=== tests/cases/compiler/ImportExport.ts === +import { MyConstEnum } from './ConstEnum'; +>MyConstEnum : Symbol(MyConstEnum, Decl(ImportExport.ts, 0, 8)) + +export { MyConstEnum }; +>MyConstEnum : Symbol(MyConstEnum, Decl(ImportExport.ts, 1, 8)) + +=== tests/cases/compiler/ImportExportDefault.ts === +import { MyConstEnum } from './ConstEnum'; +>MyConstEnum : Symbol(MyConstEnum, Decl(ImportExportDefault.ts, 0, 8)) + +export default MyConstEnum; +>MyConstEnum : Symbol(MyConstEnum, Decl(ImportExportDefault.ts, 0, 8)) + +=== tests/cases/compiler/ReExportDefault.ts === +export { MyConstEnum as default } from './ConstEnum'; +>MyConstEnum : Symbol(MyConstEnum, Decl(ConstEnum.ts, 0, 0)) +>default : Symbol(default, Decl(ReExportDefault.ts, 0, 8)) + +=== tests/cases/compiler/ReExport.ts === +export { MyConstEnum } from './ConstEnum'; +>MyConstEnum : Symbol(MyConstEnum, Decl(ReExport.ts, 0, 8)) + +=== tests/cases/compiler/Usage1.ts === +import MyConstEnum1 from './ImportExportDefault'; +>MyConstEnum1 : Symbol(MyConstEnum1, Decl(Usage1.ts, 0, 6)) + +import MyConstEnum2 from './ReExportDefault'; +>MyConstEnum2 : Symbol(MyConstEnum2, Decl(Usage1.ts, 1, 6)) + +MyConstEnum1.Foo; +>MyConstEnum1.Foo : Symbol(MyConstEnum1.Foo, Decl(ConstEnum.ts, 0, 31)) +>MyConstEnum1 : Symbol(MyConstEnum1, Decl(Usage1.ts, 0, 6)) +>Foo : Symbol(MyConstEnum1.Foo, Decl(ConstEnum.ts, 0, 31)) + +MyConstEnum2.Foo; +>MyConstEnum2.Foo : Symbol(MyConstEnum1.Foo, Decl(ConstEnum.ts, 0, 31)) +>MyConstEnum2 : Symbol(MyConstEnum2, Decl(Usage1.ts, 1, 6)) +>Foo : Symbol(MyConstEnum1.Foo, Decl(ConstEnum.ts, 0, 31)) + +=== tests/cases/compiler/Usage2.ts === +import { MyConstEnum } from './ImportExport'; +>MyConstEnum : Symbol(MyConstEnum, Decl(Usage2.ts, 0, 8)) + +MyConstEnum.Foo; +>MyConstEnum.Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.ts, 0, 31)) +>MyConstEnum : Symbol(MyConstEnum, Decl(Usage2.ts, 0, 8)) +>Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.ts, 0, 31)) + +=== tests/cases/compiler/Usage3.ts === +import { MyConstEnum } from './ReExport'; +>MyConstEnum : Symbol(MyConstEnum, Decl(Usage3.ts, 0, 8)) + +MyConstEnum.Foo; +>MyConstEnum.Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.ts, 0, 31)) +>MyConstEnum : Symbol(MyConstEnum, Decl(Usage3.ts, 0, 8)) +>Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.ts, 0, 31)) + diff --git a/tests/baselines/reference/constEnumNoEmitReexport.types b/tests/baselines/reference/constEnumNoEmitReexport.types new file mode 100644 index 00000000000..cec0dfeb03f --- /dev/null +++ b/tests/baselines/reference/constEnumNoEmitReexport.types @@ -0,0 +1,69 @@ +=== tests/cases/compiler/ConstEnum.ts === +export const enum MyConstEnum { +>MyConstEnum : MyConstEnum + + Foo, +>Foo : MyConstEnum.Foo + + Bar +>Bar : MyConstEnum.Bar + +}; +=== tests/cases/compiler/ImportExport.ts === +import { MyConstEnum } from './ConstEnum'; +>MyConstEnum : typeof MyConstEnum + +export { MyConstEnum }; +>MyConstEnum : typeof MyConstEnum + +=== tests/cases/compiler/ImportExportDefault.ts === +import { MyConstEnum } from './ConstEnum'; +>MyConstEnum : typeof MyConstEnum + +export default MyConstEnum; +>MyConstEnum : MyConstEnum + +=== tests/cases/compiler/ReExportDefault.ts === +export { MyConstEnum as default } from './ConstEnum'; +>MyConstEnum : typeof import("tests/cases/compiler/ConstEnum").MyConstEnum +>default : typeof import("tests/cases/compiler/ConstEnum").MyConstEnum + +=== tests/cases/compiler/ReExport.ts === +export { MyConstEnum } from './ConstEnum'; +>MyConstEnum : typeof import("tests/cases/compiler/ConstEnum").MyConstEnum + +=== tests/cases/compiler/Usage1.ts === +import MyConstEnum1 from './ImportExportDefault'; +>MyConstEnum1 : typeof MyConstEnum1 + +import MyConstEnum2 from './ReExportDefault'; +>MyConstEnum2 : typeof MyConstEnum1 + +MyConstEnum1.Foo; +>MyConstEnum1.Foo : MyConstEnum1.Foo +>MyConstEnum1 : typeof MyConstEnum1 +>Foo : MyConstEnum1.Foo + +MyConstEnum2.Foo; +>MyConstEnum2.Foo : MyConstEnum1.Foo +>MyConstEnum2 : typeof MyConstEnum1 +>Foo : MyConstEnum1.Foo + +=== tests/cases/compiler/Usage2.ts === +import { MyConstEnum } from './ImportExport'; +>MyConstEnum : typeof MyConstEnum + +MyConstEnum.Foo; +>MyConstEnum.Foo : MyConstEnum.Foo +>MyConstEnum : typeof MyConstEnum +>Foo : MyConstEnum.Foo + +=== tests/cases/compiler/Usage3.ts === +import { MyConstEnum } from './ReExport'; +>MyConstEnum : typeof MyConstEnum + +MyConstEnum.Foo; +>MyConstEnum.Foo : MyConstEnum.Foo +>MyConstEnum : typeof MyConstEnum +>Foo : MyConstEnum.Foo + diff --git a/tests/baselines/reference/controlFlowOptionalChain.errors.txt b/tests/baselines/reference/controlFlowOptionalChain.errors.txt index 987dca335dc..ee77494d1c8 100644 --- a/tests/baselines/reference/controlFlowOptionalChain.errors.txt +++ b/tests/baselines/reference/controlFlowOptionalChain.errors.txt @@ -31,9 +31,29 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(244,9): error TS tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(271,9): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(274,9): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(277,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(307,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(310,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(319,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(322,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(331,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(340,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(343,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(352,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(391,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(394,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(403,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(406,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(415,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(424,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(427,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(436,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(471,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(474,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(488,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(491,13): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts (33 errors) ==== +==== tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts (53 errors) ==== // assignments in shortcutting chain declare const o: undefined | { [key: string]: any; @@ -401,6 +421,76 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(277,9): error TS } } + function f15(o: Thing | undefined, value: number) { + if (o?.foo === value) { + o.foo; + } + else { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + if (o?.foo !== value) { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + else { + o.foo; + } + if (o?.foo == value) { + o.foo; + } + else { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + if (o?.foo != value) { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + else { + o.foo; + } + } + + function f16(o: Thing | undefined) { + if (o?.foo === undefined) { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + else { + o.foo; + } + if (o?.foo !== undefined) { + o.foo; + } + else { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + if (o?.foo == undefined) { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + else { + o.foo; + } + if (o?.foo != undefined) { + o.foo; + } + else { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + } + function f20(o: Thing | undefined) { if (typeof o?.foo === "number") { o.foo; @@ -430,4 +520,171 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(277,9): error TS o.baz; } } + + function f22(o: Thing | undefined) { + if (typeof o?.foo === "number") { + o.foo; + } + else { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + if (typeof o?.foo !== "number") { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + else { + o.foo; + } + if (typeof o?.foo == "number") { + o.foo; + } + else { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + if (typeof o?.foo != "number") { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + else { + o.foo; + } + } + + function f23(o: Thing | undefined) { + if (typeof o?.foo === "undefined") { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + else { + o.foo; + } + if (typeof o?.foo !== "undefined") { + o.foo; + } + else { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + if (typeof o?.foo == "undefined") { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + else { + o.foo; + } + if (typeof o?.foo != "undefined") { + o.foo; + } + else { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + } + + declare function assert(x: unknown): asserts x; + declare function assertNonNull(x: T): asserts x is NonNullable; + + function f30(o: Thing | undefined) { + if (!!true) { + assert(o?.foo); + o.foo; + } + if (!!true) { + assert(o?.foo === 42); + o.foo; + } + if (!!true) { + assert(typeof o?.foo === "number"); + o.foo; + } + if (!!true) { + assertNonNull(o?.foo); + o.foo; + } + } + + function f40(o: Thing | undefined) { + switch (o?.foo) { + case "abc": + o.foo; + break; + case 42: + o.foo; + break; + case undefined: + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + break; + default: + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + break; + } + } + + function f41(o: Thing | undefined) { + switch (typeof o?.foo) { + case "string": + o.foo; + break; + case "number": + o.foo; + break; + case "undefined": + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + break; + default: + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + break; + } + } + + // Repros from #34570 + + type Shape = + | { type: 'rectangle', width: number, height: number } + | { type: 'circle', radius: number } + + function getArea(shape?: Shape) { + switch (shape?.type) { + case 'circle': + return Math.PI * shape.radius ** 2 + case 'rectangle': + return shape.width * shape.height + default: + return 0 + } + } + + type Feature = { + id: string; + geometry?: { + type: string; + coordinates: number[]; + }; + }; + + + function extractCoordinates(f: Feature): number[] { + if (f.geometry?.type !== 'test') { + return []; + } + return f.geometry.coordinates; + } \ No newline at end of file diff --git a/tests/baselines/reference/controlFlowOptionalChain.js b/tests/baselines/reference/controlFlowOptionalChain.js index 21451528035..3bb2bab1c0d 100644 --- a/tests/baselines/reference/controlFlowOptionalChain.js +++ b/tests/baselines/reference/controlFlowOptionalChain.js @@ -300,6 +300,60 @@ function f14(o: Thing | null) { } } +function f15(o: Thing | undefined, value: number) { + if (o?.foo === value) { + o.foo; + } + else { + o.foo; // Error + } + if (o?.foo !== value) { + o.foo; // Error + } + else { + o.foo; + } + if (o?.foo == value) { + o.foo; + } + else { + o.foo; // Error + } + if (o?.foo != value) { + o.foo; // Error + } + else { + o.foo; + } +} + +function f16(o: Thing | undefined) { + if (o?.foo === undefined) { + o.foo; // Error + } + else { + o.foo; + } + if (o?.foo !== undefined) { + o.foo; + } + else { + o.foo; // Error + } + if (o?.foo == undefined) { + o.foo; // Error + } + else { + o.foo; + } + if (o?.foo != undefined) { + o.foo; + } + else { + o.foo; // Error + } +} + function f20(o: Thing | undefined) { if (typeof o?.foo === "number") { o.foo; @@ -329,6 +383,149 @@ function f21(o: Thing | null) { o.baz; } } + +function f22(o: Thing | undefined) { + if (typeof o?.foo === "number") { + o.foo; + } + else { + o.foo; // Error + } + if (typeof o?.foo !== "number") { + o.foo; // Error + } + else { + o.foo; + } + if (typeof o?.foo == "number") { + o.foo; + } + else { + o.foo; // Error + } + if (typeof o?.foo != "number") { + o.foo; // Error + } + else { + o.foo; + } +} + +function f23(o: Thing | undefined) { + if (typeof o?.foo === "undefined") { + o.foo; // Error + } + else { + o.foo; + } + if (typeof o?.foo !== "undefined") { + o.foo; + } + else { + o.foo; // Error + } + if (typeof o?.foo == "undefined") { + o.foo; // Error + } + else { + o.foo; + } + if (typeof o?.foo != "undefined") { + o.foo; + } + else { + o.foo; // Error + } +} + +declare function assert(x: unknown): asserts x; +declare function assertNonNull(x: T): asserts x is NonNullable; + +function f30(o: Thing | undefined) { + if (!!true) { + assert(o?.foo); + o.foo; + } + if (!!true) { + assert(o?.foo === 42); + o.foo; + } + if (!!true) { + assert(typeof o?.foo === "number"); + o.foo; + } + if (!!true) { + assertNonNull(o?.foo); + o.foo; + } +} + +function f40(o: Thing | undefined) { + switch (o?.foo) { + case "abc": + o.foo; + break; + case 42: + o.foo; + break; + case undefined: + o.foo; // Error + break; + default: + o.foo; // Error + break; + } +} + +function f41(o: Thing | undefined) { + switch (typeof o?.foo) { + case "string": + o.foo; + break; + case "number": + o.foo; + break; + case "undefined": + o.foo; // Error + break; + default: + o.foo; // Error + break; + } +} + +// Repros from #34570 + +type Shape = + | { type: 'rectangle', width: number, height: number } + | { type: 'circle', radius: number } + +function getArea(shape?: Shape) { + switch (shape?.type) { + case 'circle': + return Math.PI * shape.radius ** 2 + case 'rectangle': + return shape.width * shape.height + default: + return 0 + } +} + +type Feature = { + id: string; + geometry?: { + type: string; + coordinates: number[]; + }; +}; + + +function extractCoordinates(f: Feature): number[] { + if (f.geometry?.type !== 'test') { + return []; + } + return f.geometry.coordinates; +} //// [controlFlowOptionalChain.js] @@ -594,6 +791,60 @@ function f14(o) { o.bar; } } +function f15(o, value) { + var _a, _b, _c, _d; + if (((_a = o) === null || _a === void 0 ? void 0 : _a.foo) === value) { + o.foo; + } + else { + o.foo; // Error + } + if (((_b = o) === null || _b === void 0 ? void 0 : _b.foo) !== value) { + o.foo; // Error + } + else { + o.foo; + } + if (((_c = o) === null || _c === void 0 ? void 0 : _c.foo) == value) { + o.foo; + } + else { + o.foo; // Error + } + if (((_d = o) === null || _d === void 0 ? void 0 : _d.foo) != value) { + o.foo; // Error + } + else { + o.foo; + } +} +function f16(o) { + var _a, _b, _c, _d; + if (((_a = o) === null || _a === void 0 ? void 0 : _a.foo) === undefined) { + o.foo; // Error + } + else { + o.foo; + } + if (((_b = o) === null || _b === void 0 ? void 0 : _b.foo) !== undefined) { + o.foo; + } + else { + o.foo; // Error + } + if (((_c = o) === null || _c === void 0 ? void 0 : _c.foo) == undefined) { + o.foo; // Error + } + else { + o.foo; + } + if (((_d = o) === null || _d === void 0 ? void 0 : _d.foo) != undefined) { + o.foo; + } + else { + o.foo; // Error + } +} function f20(o) { var _a, _b, _c, _d; if (typeof ((_a = o) === null || _a === void 0 ? void 0 : _a.foo) === "number") { @@ -624,3 +875,128 @@ function f21(o) { o.baz; } } +function f22(o) { + var _a, _b, _c, _d; + if (typeof ((_a = o) === null || _a === void 0 ? void 0 : _a.foo) === "number") { + o.foo; + } + else { + o.foo; // Error + } + if (typeof ((_b = o) === null || _b === void 0 ? void 0 : _b.foo) !== "number") { + o.foo; // Error + } + else { + o.foo; + } + if (typeof ((_c = o) === null || _c === void 0 ? void 0 : _c.foo) == "number") { + o.foo; + } + else { + o.foo; // Error + } + if (typeof ((_d = o) === null || _d === void 0 ? void 0 : _d.foo) != "number") { + o.foo; // Error + } + else { + o.foo; + } +} +function f23(o) { + var _a, _b, _c, _d; + if (typeof ((_a = o) === null || _a === void 0 ? void 0 : _a.foo) === "undefined") { + o.foo; // Error + } + else { + o.foo; + } + if (typeof ((_b = o) === null || _b === void 0 ? void 0 : _b.foo) !== "undefined") { + o.foo; + } + else { + o.foo; // Error + } + if (typeof ((_c = o) === null || _c === void 0 ? void 0 : _c.foo) == "undefined") { + o.foo; // Error + } + else { + o.foo; + } + if (typeof ((_d = o) === null || _d === void 0 ? void 0 : _d.foo) != "undefined") { + o.foo; + } + else { + o.foo; // Error + } +} +function f30(o) { + var _a, _b, _c, _d; + if (!!true) { + assert((_a = o) === null || _a === void 0 ? void 0 : _a.foo); + o.foo; + } + if (!!true) { + assert(((_b = o) === null || _b === void 0 ? void 0 : _b.foo) === 42); + o.foo; + } + if (!!true) { + assert(typeof ((_c = o) === null || _c === void 0 ? void 0 : _c.foo) === "number"); + o.foo; + } + if (!!true) { + assertNonNull((_d = o) === null || _d === void 0 ? void 0 : _d.foo); + o.foo; + } +} +function f40(o) { + var _a; + switch ((_a = o) === null || _a === void 0 ? void 0 : _a.foo) { + case "abc": + o.foo; + break; + case 42: + o.foo; + break; + case undefined: + o.foo; // Error + break; + default: + o.foo; // Error + break; + } +} +function f41(o) { + var _a; + switch (typeof ((_a = o) === null || _a === void 0 ? void 0 : _a.foo)) { + case "string": + o.foo; + break; + case "number": + o.foo; + break; + case "undefined": + o.foo; // Error + break; + default: + o.foo; // Error + break; + } +} +function getArea(shape) { + var _a; + switch ((_a = shape) === null || _a === void 0 ? void 0 : _a.type) { + case 'circle': + return Math.PI * Math.pow(shape.radius, 2); + case 'rectangle': + return shape.width * shape.height; + default: + return 0; + } +} +function extractCoordinates(f) { + var _a; + if (((_a = f.geometry) === null || _a === void 0 ? void 0 : _a.type) !== 'test') { + return []; + } + return f.geometry.coordinates; +} diff --git a/tests/baselines/reference/controlFlowOptionalChain.symbols b/tests/baselines/reference/controlFlowOptionalChain.symbols index 2665a960a56..cac0899cc89 100644 --- a/tests/baselines/reference/controlFlowOptionalChain.symbols +++ b/tests/baselines/reference/controlFlowOptionalChain.symbols @@ -1039,93 +1039,627 @@ function f14(o: Thing | null) { } } -function f20(o: Thing | undefined) { ->f20 : Symbol(f20, Decl(controlFlowOptionalChain.ts, 299, 1)) +function f15(o: Thing | undefined, value: number) { +>f15 : Symbol(f15, Decl(controlFlowOptionalChain.ts, 299, 1)) >o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) >Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 301, 34)) - if (typeof o?.foo === "number") { + if (o?.foo === value) { >o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) >o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) >foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 301, 34)) o.foo; >o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) >o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) >foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) } - if (typeof o?.["foo"] === "number") { + else { + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) >o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.foo !== value) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 301, 34)) + + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.foo == value) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 301, 34)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.foo != value) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 301, 34)) + + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } +} + +function f16(o: Thing | undefined) { +>f16 : Symbol(f16, Decl(controlFlowOptionalChain.ts, 326, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 328, 13)) +>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) + + if (o?.foo === undefined) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 328, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>undefined : Symbol(undefined) + + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 328, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 328, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.foo !== undefined) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 328, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>undefined : Symbol(undefined) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 328, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 328, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.foo == undefined) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 328, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>undefined : Symbol(undefined) + + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 328, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 328, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.foo != undefined) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 328, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>undefined : Symbol(undefined) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 328, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 328, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } +} + +function f20(o: Thing | undefined) { +>f20 : Symbol(f20, Decl(controlFlowOptionalChain.ts, 353, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 355, 13)) +>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) + + if (typeof o?.foo === "number") { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 355, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 355, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (typeof o?.["foo"] === "number") { +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 355, 13)) o["foo"]; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 355, 13)) >"foo" : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) } if (typeof o?.bar() === "number") { >o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 355, 13)) >bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) o.bar; >o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 355, 13)) >bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) } if (o?.baz instanceof Error) { >o?.baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 355, 13)) >baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) o.baz; >o.baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 355, 13)) >baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) } } function f21(o: Thing | null) { ->f21 : Symbol(f21, Decl(controlFlowOptionalChain.ts, 314, 1)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>f21 : Symbol(f21, Decl(controlFlowOptionalChain.ts, 368, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 370, 13)) >Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) if (typeof o?.foo === "number") { >o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 370, 13)) >foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) o.foo; >o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 370, 13)) >foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) } if (typeof o?.["foo"] === "number") { ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 370, 13)) o["foo"]; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 370, 13)) >"foo" : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) } if (typeof o?.bar() === "number") { >o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 370, 13)) >bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) o.bar; >o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 370, 13)) >bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) } if (o?.baz instanceof Error) { >o?.baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 370, 13)) >baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) o.baz; >o.baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 370, 13)) >baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) } } +function f22(o: Thing | undefined) { +>f22 : Symbol(f22, Decl(controlFlowOptionalChain.ts, 383, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 385, 13)) +>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) + + if (typeof o?.foo === "number") { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 385, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 385, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 385, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (typeof o?.foo !== "number") { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 385, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 385, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 385, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (typeof o?.foo == "number") { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 385, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 385, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 385, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (typeof o?.foo != "number") { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 385, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 385, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 385, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } +} + +function f23(o: Thing | undefined) { +>f23 : Symbol(f23, Decl(controlFlowOptionalChain.ts, 410, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 412, 13)) +>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) + + if (typeof o?.foo === "undefined") { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 412, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 412, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 412, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (typeof o?.foo !== "undefined") { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 412, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 412, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 412, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (typeof o?.foo == "undefined") { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 412, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 412, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 412, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (typeof o?.foo != "undefined") { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 412, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 412, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + else { + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 412, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } +} + +declare function assert(x: unknown): asserts x; +>assert : Symbol(assert, Decl(controlFlowOptionalChain.ts, 437, 1)) +>x : Symbol(x, Decl(controlFlowOptionalChain.ts, 439, 24)) +>x : Symbol(x, Decl(controlFlowOptionalChain.ts, 439, 24)) + +declare function assertNonNull(x: T): asserts x is NonNullable; +>assertNonNull : Symbol(assertNonNull, Decl(controlFlowOptionalChain.ts, 439, 47)) +>T : Symbol(T, Decl(controlFlowOptionalChain.ts, 440, 31)) +>x : Symbol(x, Decl(controlFlowOptionalChain.ts, 440, 34)) +>T : Symbol(T, Decl(controlFlowOptionalChain.ts, 440, 31)) +>x : Symbol(x, Decl(controlFlowOptionalChain.ts, 440, 34)) +>NonNullable : Symbol(NonNullable, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(controlFlowOptionalChain.ts, 440, 31)) + +function f30(o: Thing | undefined) { +>f30 : Symbol(f30, Decl(controlFlowOptionalChain.ts, 440, 69)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 442, 13)) +>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) + + if (!!true) { + assert(o?.foo); +>assert : Symbol(assert, Decl(controlFlowOptionalChain.ts, 437, 1)) +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 442, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 442, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (!!true) { + assert(o?.foo === 42); +>assert : Symbol(assert, Decl(controlFlowOptionalChain.ts, 437, 1)) +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 442, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 442, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (!!true) { + assert(typeof o?.foo === "number"); +>assert : Symbol(assert, Decl(controlFlowOptionalChain.ts, 437, 1)) +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 442, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 442, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (!!true) { + assertNonNull(o?.foo); +>assertNonNull : Symbol(assertNonNull, Decl(controlFlowOptionalChain.ts, 439, 47)) +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 442, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 442, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } +} + +function f40(o: Thing | undefined) { +>f40 : Symbol(f40, Decl(controlFlowOptionalChain.ts, 459, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 461, 13)) +>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) + + switch (o?.foo) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 461, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + case "abc": + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 461, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + break; + case 42: + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 461, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + break; + case undefined: +>undefined : Symbol(undefined) + + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 461, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + break; + default: + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 461, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + break; + } +} + +function f41(o: Thing | undefined) { +>f41 : Symbol(f41, Decl(controlFlowOptionalChain.ts, 476, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 478, 13)) +>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) + + switch (typeof o?.foo) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 478, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + case "string": + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 478, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + break; + case "number": + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 478, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + break; + case "undefined": + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 478, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + break; + default: + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 478, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + break; + } +} + +// Repros from #34570 + +type Shape = +>Shape : Symbol(Shape, Decl(controlFlowOptionalChain.ts, 493, 1)) + + | { type: 'rectangle', width: number, height: number } +>type : Symbol(type, Decl(controlFlowOptionalChain.ts, 498, 7)) +>width : Symbol(width, Decl(controlFlowOptionalChain.ts, 498, 26)) +>height : Symbol(height, Decl(controlFlowOptionalChain.ts, 498, 41)) + + | { type: 'circle', radius: number } +>type : Symbol(type, Decl(controlFlowOptionalChain.ts, 499, 7)) +>radius : Symbol(radius, Decl(controlFlowOptionalChain.ts, 499, 23)) + +function getArea(shape?: Shape) { +>getArea : Symbol(getArea, Decl(controlFlowOptionalChain.ts, 499, 40)) +>shape : Symbol(shape, Decl(controlFlowOptionalChain.ts, 501, 17)) +>Shape : Symbol(Shape, Decl(controlFlowOptionalChain.ts, 493, 1)) + + switch (shape?.type) { +>shape?.type : Symbol(type, Decl(controlFlowOptionalChain.ts, 498, 7), Decl(controlFlowOptionalChain.ts, 499, 7)) +>shape : Symbol(shape, Decl(controlFlowOptionalChain.ts, 501, 17)) +>type : Symbol(type, Decl(controlFlowOptionalChain.ts, 498, 7), Decl(controlFlowOptionalChain.ts, 499, 7)) + + case 'circle': + return Math.PI * shape.radius ** 2 +>Math.PI : Symbol(Math.PI, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>PI : Symbol(Math.PI, Decl(lib.es5.d.ts, --, --)) +>shape.radius : Symbol(radius, Decl(controlFlowOptionalChain.ts, 499, 23)) +>shape : Symbol(shape, Decl(controlFlowOptionalChain.ts, 501, 17)) +>radius : Symbol(radius, Decl(controlFlowOptionalChain.ts, 499, 23)) + + case 'rectangle': + return shape.width * shape.height +>shape.width : Symbol(width, Decl(controlFlowOptionalChain.ts, 498, 26)) +>shape : Symbol(shape, Decl(controlFlowOptionalChain.ts, 501, 17)) +>width : Symbol(width, Decl(controlFlowOptionalChain.ts, 498, 26)) +>shape.height : Symbol(height, Decl(controlFlowOptionalChain.ts, 498, 41)) +>shape : Symbol(shape, Decl(controlFlowOptionalChain.ts, 501, 17)) +>height : Symbol(height, Decl(controlFlowOptionalChain.ts, 498, 41)) + + default: + return 0 + } +} + +type Feature = { +>Feature : Symbol(Feature, Decl(controlFlowOptionalChain.ts, 510, 1)) + + id: string; +>id : Symbol(id, Decl(controlFlowOptionalChain.ts, 512, 16)) + + geometry?: { +>geometry : Symbol(geometry, Decl(controlFlowOptionalChain.ts, 513, 13)) + + type: string; +>type : Symbol(type, Decl(controlFlowOptionalChain.ts, 514, 14)) + + coordinates: number[]; +>coordinates : Symbol(coordinates, Decl(controlFlowOptionalChain.ts, 515, 17)) + + }; +}; + + +function extractCoordinates(f: Feature): number[] { +>extractCoordinates : Symbol(extractCoordinates, Decl(controlFlowOptionalChain.ts, 518, 2)) +>f : Symbol(f, Decl(controlFlowOptionalChain.ts, 521, 28)) +>Feature : Symbol(Feature, Decl(controlFlowOptionalChain.ts, 510, 1)) + + if (f.geometry?.type !== 'test') { +>f.geometry?.type : Symbol(type, Decl(controlFlowOptionalChain.ts, 514, 14)) +>f.geometry : Symbol(geometry, Decl(controlFlowOptionalChain.ts, 513, 13)) +>f : Symbol(f, Decl(controlFlowOptionalChain.ts, 521, 28)) +>geometry : Symbol(geometry, Decl(controlFlowOptionalChain.ts, 513, 13)) +>type : Symbol(type, Decl(controlFlowOptionalChain.ts, 514, 14)) + + return []; + } + return f.geometry.coordinates; +>f.geometry.coordinates : Symbol(coordinates, Decl(controlFlowOptionalChain.ts, 515, 17)) +>f.geometry : Symbol(geometry, Decl(controlFlowOptionalChain.ts, 513, 13)) +>f : Symbol(f, Decl(controlFlowOptionalChain.ts, 521, 28)) +>geometry : Symbol(geometry, Decl(controlFlowOptionalChain.ts, 513, 13)) +>coordinates : Symbol(coordinates, Decl(controlFlowOptionalChain.ts, 515, 17)) +} + diff --git a/tests/baselines/reference/controlFlowOptionalChain.types b/tests/baselines/reference/controlFlowOptionalChain.types index ffec7d1525e..13dd6cd5fd0 100644 --- a/tests/baselines/reference/controlFlowOptionalChain.types +++ b/tests/baselines/reference/controlFlowOptionalChain.types @@ -1170,6 +1170,163 @@ function f14(o: Thing | null) { } } +function f15(o: Thing | undefined, value: number) { +>f15 : (o: Thing | undefined, value: number) => void +>o : Thing | undefined +>value : number + + if (o?.foo === value) { +>o?.foo === value : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>value : number + + o.foo; +>o.foo : number +>o : Thing +>foo : number + } + else { + o.foo; // Error +>o.foo : string | number +>o : Thing | undefined +>foo : string | number + } + if (o?.foo !== value) { +>o?.foo !== value : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>value : number + + o.foo; // Error +>o.foo : string | number +>o : Thing | undefined +>foo : string | number + } + else { + o.foo; +>o.foo : number +>o : Thing +>foo : number + } + if (o?.foo == value) { +>o?.foo == value : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>value : number + + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } + else { + o.foo; // Error +>o.foo : string | number +>o : Thing | undefined +>foo : string | number + } + if (o?.foo != value) { +>o?.foo != value : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>value : number + + o.foo; // Error +>o.foo : string | number +>o : Thing | undefined +>foo : string | number + } + else { + o.foo; +>o.foo : number +>o : Thing +>foo : number + } +} + +function f16(o: Thing | undefined) { +>f16 : (o: Thing | undefined) => void +>o : Thing | undefined + + if (o?.foo === undefined) { +>o?.foo === undefined : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>undefined : undefined + + o.foo; // Error +>o.foo : never +>o : Thing | undefined +>foo : never + } + else { + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } + if (o?.foo !== undefined) { +>o?.foo !== undefined : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>undefined : undefined + + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } + else { + o.foo; // Error +>o.foo : never +>o : Thing | undefined +>foo : never + } + if (o?.foo == undefined) { +>o?.foo == undefined : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>undefined : undefined + + o.foo; // Error +>o.foo : never +>o : Thing | undefined +>foo : never + } + else { + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } + if (o?.foo != undefined) { +>o?.foo != undefined : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>undefined : undefined + + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } + else { + o.foo; // Error +>o.foo : never +>o : Thing | undefined +>foo : never + } +} + function f20(o: Thing | undefined) { >f20 : (o: Thing | undefined) => void >o : Thing | undefined @@ -1287,3 +1444,445 @@ function f21(o: Thing | null) { } } +function f22(o: Thing | undefined) { +>f22 : (o: Thing | undefined) => void +>o : Thing | undefined + + if (typeof o?.foo === "number") { +>typeof o?.foo === "number" : boolean +>typeof o?.foo : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>"number" : "number" + + o.foo; +>o.foo : number +>o : Thing +>foo : number + } + else { + o.foo; // Error +>o.foo : string +>o : Thing | undefined +>foo : string + } + if (typeof o?.foo !== "number") { +>typeof o?.foo !== "number" : boolean +>typeof o?.foo : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>"number" : "number" + + o.foo; // Error +>o.foo : string +>o : Thing | undefined +>foo : string + } + else { + o.foo; +>o.foo : number +>o : Thing +>foo : number + } + if (typeof o?.foo == "number") { +>typeof o?.foo == "number" : boolean +>typeof o?.foo : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>"number" : "number" + + o.foo; +>o.foo : number +>o : Thing +>foo : number + } + else { + o.foo; // Error +>o.foo : string +>o : Thing | undefined +>foo : string + } + if (typeof o?.foo != "number") { +>typeof o?.foo != "number" : boolean +>typeof o?.foo : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>"number" : "number" + + o.foo; // Error +>o.foo : string +>o : Thing | undefined +>foo : string + } + else { + o.foo; +>o.foo : number +>o : Thing +>foo : number + } +} + +function f23(o: Thing | undefined) { +>f23 : (o: Thing | undefined) => void +>o : Thing | undefined + + if (typeof o?.foo === "undefined") { +>typeof o?.foo === "undefined" : boolean +>typeof o?.foo : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>"undefined" : "undefined" + + o.foo; // Error +>o.foo : never +>o : Thing | undefined +>foo : never + } + else { + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } + if (typeof o?.foo !== "undefined") { +>typeof o?.foo !== "undefined" : boolean +>typeof o?.foo : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>"undefined" : "undefined" + + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } + else { + o.foo; // Error +>o.foo : never +>o : Thing | undefined +>foo : never + } + if (typeof o?.foo == "undefined") { +>typeof o?.foo == "undefined" : boolean +>typeof o?.foo : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>"undefined" : "undefined" + + o.foo; // Error +>o.foo : never +>o : Thing | undefined +>foo : never + } + else { + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } + if (typeof o?.foo != "undefined") { +>typeof o?.foo != "undefined" : boolean +>typeof o?.foo : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>"undefined" : "undefined" + + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } + else { + o.foo; // Error +>o.foo : never +>o : Thing | undefined +>foo : never + } +} + +declare function assert(x: unknown): asserts x; +>assert : (x: unknown) => asserts x +>x : unknown + +declare function assertNonNull(x: T): asserts x is NonNullable; +>assertNonNull : (x: T) => asserts x is NonNullable +>x : T + +function f30(o: Thing | undefined) { +>f30 : (o: Thing | undefined) => void +>o : Thing | undefined + + if (!!true) { +>!!true : true +>!true : false +>true : true + + assert(o?.foo); +>assert(o?.foo) : void +>assert : (x: unknown) => asserts x +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined + + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } + if (!!true) { +>!!true : true +>!true : false +>true : true + + assert(o?.foo === 42); +>assert(o?.foo === 42) : void +>assert : (x: unknown) => asserts x +>o?.foo === 42 : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>42 : 42 + + o.foo; +>o.foo : 42 +>o : Thing +>foo : 42 + } + if (!!true) { +>!!true : true +>!true : false +>true : true + + assert(typeof o?.foo === "number"); +>assert(typeof o?.foo === "number") : void +>assert : (x: unknown) => asserts x +>typeof o?.foo === "number" : boolean +>typeof o?.foo : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>"number" : "number" + + o.foo; +>o.foo : number +>o : Thing +>foo : number + } + if (!!true) { +>!!true : true +>!true : false +>true : true + + assertNonNull(o?.foo); +>assertNonNull(o?.foo) : void +>assertNonNull : (x: T) => asserts x is NonNullable +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined + + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } +} + +function f40(o: Thing | undefined) { +>f40 : (o: Thing | undefined) => void +>o : Thing | undefined + + switch (o?.foo) { +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined + + case "abc": +>"abc" : "abc" + + o.foo; +>o.foo : "abc" +>o : Thing +>foo : "abc" + + break; + case 42: +>42 : 42 + + o.foo; +>o.foo : 42 +>o : Thing +>foo : 42 + + break; + case undefined: +>undefined : undefined + + o.foo; // Error +>o.foo : never +>o : Thing | undefined +>foo : never + + break; + default: + o.foo; // Error +>o.foo : string | number +>o : Thing | undefined +>foo : string | number + + break; + } +} + +function f41(o: Thing | undefined) { +>f41 : (o: Thing | undefined) => void +>o : Thing | undefined + + switch (typeof o?.foo) { +>typeof o?.foo : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined + + case "string": +>"string" : "string" + + o.foo; +>o.foo : string +>o : Thing +>foo : string + + break; + case "number": +>"number" : "number" + + o.foo; +>o.foo : number +>o : Thing +>foo : number + + break; + case "undefined": +>"undefined" : "undefined" + + o.foo; // Error +>o.foo : never +>o : Thing | undefined +>foo : never + + break; + default: + o.foo; // Error +>o.foo : never +>o : Thing | undefined +>foo : never + + break; + } +} + +// Repros from #34570 + +type Shape = +>Shape : Shape + + | { type: 'rectangle', width: number, height: number } +>type : "rectangle" +>width : number +>height : number + + | { type: 'circle', radius: number } +>type : "circle" +>radius : number + +function getArea(shape?: Shape) { +>getArea : (shape?: { type: "rectangle"; width: number; height: number; } | { type: "circle"; radius: number; } | undefined) => number +>shape : { type: "rectangle"; width: number; height: number; } | { type: "circle"; radius: number; } | undefined + + switch (shape?.type) { +>shape?.type : "rectangle" | "circle" | undefined +>shape : { type: "rectangle"; width: number; height: number; } | { type: "circle"; radius: number; } | undefined +>type : "rectangle" | "circle" | undefined + + case 'circle': +>'circle' : "circle" + + return Math.PI * shape.radius ** 2 +>Math.PI * shape.radius ** 2 : number +>Math.PI : number +>Math : Math +>PI : number +>shape.radius ** 2 : number +>shape.radius : number +>shape : { type: "circle"; radius: number; } +>radius : number +>2 : 2 + + case 'rectangle': +>'rectangle' : "rectangle" + + return shape.width * shape.height +>shape.width * shape.height : number +>shape.width : number +>shape : { type: "rectangle"; width: number; height: number; } +>width : number +>shape.height : number +>shape : { type: "rectangle"; width: number; height: number; } +>height : number + + default: + return 0 +>0 : 0 + } +} + +type Feature = { +>Feature : Feature + + id: string; +>id : string + + geometry?: { +>geometry : { type: string; coordinates: number[]; } | undefined + + type: string; +>type : string + + coordinates: number[]; +>coordinates : number[] + + }; +}; + + +function extractCoordinates(f: Feature): number[] { +>extractCoordinates : (f: Feature) => number[] +>f : Feature + + if (f.geometry?.type !== 'test') { +>f.geometry?.type !== 'test' : boolean +>f.geometry?.type : string | undefined +>f.geometry : { type: string; coordinates: number[]; } | undefined +>f : Feature +>geometry : { type: string; coordinates: number[]; } | undefined +>type : string | undefined +>'test' : "test" + + return []; +>[] : never[] + } + return f.geometry.coordinates; +>f.geometry.coordinates : number[] +>f.geometry : { type: string; coordinates: number[]; } +>f : Feature +>geometry : { type: string; coordinates: number[]; } +>coordinates : number[] +} + diff --git a/tests/baselines/reference/crashInGetTextOfComputedPropertyName.js b/tests/baselines/reference/crashInGetTextOfComputedPropertyName.js index 71d5df00e2a..15dd773c58d 100644 --- a/tests/baselines/reference/crashInGetTextOfComputedPropertyName.js +++ b/tests/baselines/reference/crashInGetTextOfComputedPropertyName.js @@ -36,12 +36,12 @@ exports.__esModule = true; var itemId = 'some-id'; // --- test on first level --- var items = {}; -var _a = itemId, itemOk1 = items[_a]; +var _a = items, _b = itemId, itemOk1 = _a[_b]; typeof itemOk1; // pass var objWithItems = { items: {} }; var itemOk2 = objWithItems.items[itemId]; typeof itemOk2; // pass -var _b = objWithItems.items /*happens when default value is provided*/, _c = itemId, itemWithTSError = (_b === void 0 ? {} /*happens when default value is provided*/ : _b)[_c]; +var _c = objWithItems, _d = _c.items /*happens when default value is provided*/, _e = itemId, itemWithTSError = (_d === void 0 ? {} /*happens when default value is provided*/ : _d)[_e]; // in order to re-produce the error, uncomment next line: typeof itemWithTSError; // :( // will result in: diff --git a/tests/baselines/reference/destructureComputedProperty.js b/tests/baselines/reference/destructureComputedProperty.js index 290f3f8119e..768684f90b6 100644 --- a/tests/baselines/reference/destructureComputedProperty.js +++ b/tests/baselines/reference/destructureComputedProperty.js @@ -13,7 +13,7 @@ const { p: p3 } = new C(); //// [destructureComputedProperty.js] var nameN = "n"; -var _a = nameN, n = ab[_a]; +var _a = ab, _b = nameN, n = _a[_b]; var C = /** @class */ (function () { function C() { } @@ -22,5 +22,5 @@ var C = /** @class */ (function () { var nameP = "p"; var p0 = new C()["p"]; var p1 = new C()["p"]; -var _b = nameP, p2 = new C()[_b]; +var _c = new C(), _d = nameP, p2 = _c[_d]; var p3 = new C().p; diff --git a/tests/baselines/reference/destructuredMaappedTypeIsNotImplicitlyAny.js b/tests/baselines/reference/destructuredMaappedTypeIsNotImplicitlyAny.js index 3fe1f2febcc..b4f784eadb8 100644 --- a/tests/baselines/reference/destructuredMaappedTypeIsNotImplicitlyAny.js +++ b/tests/baselines/reference/destructuredMaappedTypeIsNotImplicitlyAny.js @@ -9,7 +9,7 @@ function foo(key: T, obj: { [_ in T]: number }) { //// [destructuredMaappedTypeIsNotImplicitlyAny.js] function foo(key, obj) { - var _a = key, bar = obj[_a]; // Element implicitly has an 'any' type because type '{ [_ in T]: number; }' has no index signature. + var _a = obj, _b = key, bar = _a[_b]; // Element implicitly has an 'any' type because type '{ [_ in T]: number; }' has no index signature. bar; // bar : any // Note: this does work: var lorem = obj[key]; diff --git a/tests/baselines/reference/destructuringAssignment_private.js b/tests/baselines/reference/destructuringAssignment_private.js index b8f4130761b..cbf52ba202e 100644 --- a/tests/baselines/reference/destructuringAssignment_private.js +++ b/tests/baselines/reference/destructuringAssignment_private.js @@ -15,7 +15,7 @@ const nameO = "o"; //// [destructuringAssignment_private.js] -var _a, _b; +var _a, _b, _c, _d; var C = /** @class */ (function () { function C() { this.x = 0; @@ -27,6 +27,6 @@ var x; (x = [{ a: new C() }][0].a.x); (x = new C().o[0].a); var nameX = "x"; -(_a = nameX, x = [{ a: new C() }][0].a[_a]); +(_a = [{ a: new C() }], _b = nameX, x = _a[0].a[_b]); var nameO = "o"; -(_b = nameO, x = new C()[_b][0].a); +(_c = new C(), _d = nameO, x = _c[_d][0].a); diff --git a/tests/baselines/reference/destructuringControlFlow.js b/tests/baselines/reference/destructuringControlFlow.js index f3b5a8e0dd9..600cddc8bb2 100644 --- a/tests/baselines/reference/destructuringControlFlow.js +++ b/tests/baselines/reference/destructuringControlFlow.js @@ -69,11 +69,11 @@ function f3(obj) { } } function f4() { - var _a; + var _a, _b; var x; (x = 0..x); // Error (x = 0["x"]); // Error - (_a = "x" + "", x = 0[_a]); // Errpr + (_a = 0, _b = "x" + "", x = _a[_b]); // Errpr } var _a = ["foo"], key = _a[0], value = _a[1]; value.toUpperCase(); // Error diff --git a/tests/baselines/reference/docker/azure-sdk.log b/tests/baselines/reference/docker/azure-sdk.log index 03b78facc92..7d3ea51f7c0 100644 --- a/tests/baselines/reference/docker/azure-sdk.log +++ b/tests/baselines/reference/docker/azure-sdk.log @@ -2,30 +2,33 @@ Exit Code: 1 Standard output: Rush Multi-Project Build Tool 5.X.X - https://rushjs.io -Node.js version is 12.12.0 (pre-LTS) +Node.js version is 12.13.0 (LTS) Starting "rush rebuild" Executing a maximum of ?simultaneous processes... XX of XX: [@azure/core-tracing] completed successfully in ? seconds +XX of XX: [@azure/core-auth] completed successfully in ? seconds +XX of XX: [@azure/logger] completed successfully in ? seconds npm ERR! code ELIFECYCLE npm ERR! errno 2 -npm ERR! @azure/core-http@X.X.X-preview.5 build:tsc: `tsc -p tsconfig.es.json` +npm ERR! @azure/core-http@X.X.X-preview.6 build:tsc: `tsc -p tsconfig.es.json` npm ERR! Exit status 2 npm ERR! -npm ERR! Failed at the @azure/core-http@X.X.X-preview.5 build:tsc script. +npm ERR! Failed at the @azure/core-http@X.X.X-preview.6 build:tsc script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/XXXX-XX-XXXXXXXXX-debug.log ERROR: "build:tsc" exited with 2. npm ERR! code ELIFECYCLE npm ERR! errno 1 -npm ERR! @azure/core-http@X.X.X-preview.5 build:lib: `run-s build:tsc build:rollup build:minify-browser` +npm ERR! @azure/core-http@X.X.X-preview.6 build:lib: `run-s build:tsc build:rollup build:minify-browser` npm ERR! Exit status 1 npm ERR! -npm ERR! Failed at the @azure/core-http@X.X.X-preview.5 build:lib script. +npm ERR! Failed at the @azure/core-http@X.X.X-preview.6 build:lib script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/XXXX-XX-XXXXXXXXX-debug.log ERROR: "build:lib" exited with 1. +XX of XX: [@azure/test-utils-recorder] completed successfully in ? seconds Warning: You have changed the public API signature for this project. Updating review/event-processor-host.api.md Warning: typings/src/eventProcessorHost.d.ts:32:9 - (TS1086) An accessor cannot be declared in an ambient context. Warning: typings/src/eventProcessorHost.d.ts:36:9 - (TS1086) An accessor cannot be declared in an ambient context. @@ -35,10 +38,8 @@ Warning: typings/src/partitionContext.d.ts:27:9 - (TS1086) An accessor cannot be Warning: typings/src/partitionContext.d.ts:32:9 - (TS1086) An accessor cannot be declared in an ambient context. Warning: typings/src/partitionPump.d.ts:17:9 - (TS1086) An accessor cannot be declared in an ambient context. Warning: typings/src/partitionPump.d.ts:18:9 - (TS1086) An accessor cannot be declared in an ambient context. -XX of XX: [@azure/test-utils-recorder] completed successfully in ? seconds XX of XX: [@azure/abort-controller] completed successfully in ? seconds XX of XX: [@azure/core-asynciterator-polyfill] completed successfully in ? seconds -XX of XX: [@azure/core-auth] completed successfully in ? seconds XX of XX: [@azure/core-paging] completed successfully in ? seconds Warning: You have changed the public API signature for this project. Updating review/cosmos.api.md Warning: dist-esm/ChangeFeedIterator.d.ts:27:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. @@ -77,8 +78,14 @@ Warning: dist-esm/request/ResourceResponse.d.ts:9:9 - (TS1056) Accessors are onl Warning: dist-esm/request/ResourceResponse.d.ts:10:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. Warning: dist-esm/request/ResourceResponse.d.ts:11:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. dist-esm/index.js β†’ dist/index.js... +(!) Unresolved dependencies +https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency +os-name (imported by dist-esm/utils/user-agent.js) +(!) Missing global variable name +Use output.globals to specify browser global variable names corresponding to external modules +os-name (guessing 'osName') created dist/index.js in ?s -XX of XX: [@azure/logger] completed successfully in ? seconds +XX of XX: [@azure/eventhubs-checkpointstore-blob] completed successfully in ? seconds Warning: You have changed the public API signature for this project. Updating review/service-bus.api.md Warning: typings/src/receiver.d.ts:28:9 - (TS1086) An accessor cannot be declared in an ambient context. Warning: typings/src/receiver.d.ts:34:9 - (TS1086) An accessor cannot be declared in an ambient context. @@ -88,22 +95,17 @@ Warning: typings/src/receiver.d.ts:165:9 - (TS1086) An accessor cannot be declar Warning: typings/src/receiver.d.ts:175:9 - (TS1086) An accessor cannot be declared in an ambient context. Warning: typings/src/sender.d.ts:24:9 - (TS1086) An accessor cannot be declared in an ambient context. Warning: typings/src/serviceBusMessage.d.ts:453:9 - (TS1086) An accessor cannot be declared in an ambient context. -XX of XX: [@azure/storage-blob] completed successfully in ? seconds -XX of XX: [@azure/storage-file] completed successfully in ? seconds -XX of XX: [@azure/storage-queue] completed successfully in ? seconds XX of XX: [testhub] completed successfully in ? seconds -SUCCESS (11) +SUCCESS (9) ================================ @azure/core-tracing (? seconds) +@azure/core-auth (? seconds) +@azure/logger (? seconds) @azure/test-utils-recorder (? seconds) @azure/abort-controller (? seconds) @azure/core-asynciterator-polyfill (? seconds) -@azure/core-auth (? seconds) @azure/core-paging (? seconds) -@azure/logger (? seconds) -@azure/storage-blob (? seconds) -@azure/storage-file (? seconds) -@azure/storage-queue (? seconds) +@azure/eventhubs-checkpointstore-blob (? seconds) testhub (? seconds) ================================ SUCCESS WITH WARNINGS (3) @@ -129,20 +131,7 @@ Warning: dist-esm/ChangeFeedResponse.d.ts:45:9 - (TS1056) Accessors are only ava Warning: dist-esm/client/Conflict/Conflict.d.ts:17:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. Warning: dist-esm/client/Container/Container.d.ts:39:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. Warning: dist-esm/client/Container/Container.d.ts:44:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. -Warning: dist-esm/client/Container/Container.d.ts:51:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. -Warning: dist-esm/client/Container/Container.d.ts:55:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. -Warning: dist-esm/client/Database/Database.d.ts:41:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. -Warning: dist-esm/client/Item/Item.d.ts:20:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. -Warning: dist-esm/client/Offer/Offer.d.ts:18:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. -Warning: dist-esm/client/Permission/Permission.d.ts:18:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. -Warning: dist-esm/client/Script/Scripts.d.ts:41:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. -Warning: dist-esm/client/Script/Scripts.d.ts:48:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. -Warning: dist-esm/client/Script/Scripts.d.ts:55:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. -Warning: dist-esm/client/StoredProcedure/StoredProcedure.d.ts:18:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. -Warning: dist-esm/client/StoredProcedure/StoredProcedureResponse.d.ts:17:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. -Warning: dist-esm/client/Trigger/Trigger.d.ts:18:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. -Warning: dist-esm/client/User/User.d.ts:27:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. -Warning: dist-esm/client/UserDefinedFunction/UserDefinedFunction.d.ts:18:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. +[...14 lines omitted...] Warning: dist-esm/client/UserDefinedFunction/UserDefinedFunctionResponse.d.ts:15:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. Warning: dist-esm/queryMetrics/queryMetrics.d.ts:26:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. Warning: dist-esm/request/FeedResponse.d.ts:7:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. @@ -156,6 +145,12 @@ Warning: dist-esm/request/ResourceResponse.d.ts:9:9 - (TS1056) Accessors are onl Warning: dist-esm/request/ResourceResponse.d.ts:10:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. Warning: dist-esm/request/ResourceResponse.d.ts:11:9 - (TS1056) Accessors are only available when targeting ECMAScript 5 and higher. dist-esm/index.js β†’ dist/index.js... +(!) Unresolved dependencies +https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency +os-name (imported by dist-esm/utils/user-agent.js) +(!) Missing global variable name +Use output.globals to specify browser global variable names corresponding to external modules +os-name (guessing 'osName') created dist/index.js in ?s @azure/service-bus (? seconds) Warning: You have changed the public API signature for this project. Updating review/service-bus.api.md @@ -168,18 +163,21 @@ Warning: typings/src/receiver.d.ts:175:9 - (TS1086) An accessor cannot be declar Warning: typings/src/sender.d.ts:24:9 - (TS1086) An accessor cannot be declared in an ambient context. Warning: typings/src/serviceBusMessage.d.ts:453:9 - (TS1086) An accessor cannot be declared in an ambient context. ================================ -BLOCKED (11) +BLOCKED (14) ================================ -@azure/identity -@azure/core-amqp @azure/core-arm -@azure/event-hubs -@azure/app-configuration +@azure/identity @azure/core-lro -@azure/eventhubs-checkpointstore-blob -@azure/keyvault-certificates +@azure/core-amqp @azure/keyvault-keys @azure/keyvault-secrets +@azure/app-configuration +@azure/cognitiveservices-inkrecognizer +@azure/event-hubs +@azure/keyvault-certificates +@azure/storage-blob +@azure/storage-file-share +@azure/storage-queue @azure/template ================================ FAILURE (1) @@ -187,20 +185,20 @@ FAILURE (1) @azure/core-http ( ? seconds) npm ERR! code ELIFECYCLE npm ERR! errno 2 -npm ERR! @azure/core-http@X.X.X-preview.5 build:tsc: `tsc -p tsconfig.es.json` +npm ERR! @azure/core-http@X.X.X-preview.6 build:tsc: `tsc -p tsconfig.es.json` npm ERR! Exit status 2 npm ERR! -npm ERR! Failed at the @azure/core-http@X.X.X-preview.5 build:tsc script. +npm ERR! Failed at the @azure/core-http@X.X.X-preview.6 build:tsc script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/XXXX-XX-XXXXXXXXX-debug.log ERROR: "build:tsc" exited with 2. npm ERR! code ELIFECYCLE npm ERR! errno 1 -npm ERR! @azure/core-http@X.X.X-preview.5 build:lib: `run-s build:tsc build:rollup build:minify-browser` +npm ERR! @azure/core-http@X.X.X-preview.6 build:lib: `run-s build:tsc build:rollup build:minify-browser` npm ERR! Exit status 1 npm ERR! -npm ERR! Failed at the @azure/core-http@X.X.X-preview.5 build:lib script. +npm ERR! Failed at the @azure/core-http@X.X.X-preview.6 build:lib script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/XXXX-XX-XXXXXXXXX-debug.log @@ -215,15 +213,18 @@ Standard error: XX of XX: [@azure/core-http] failed to build! XX of XX: [@azure/app-configuration] blocked by [@azure/core-http]! +XX of XX: [@azure/cognitiveservices-inkrecognizer] blocked by [@azure/core-http]! XX of XX: [@azure/core-arm] blocked by [@azure/core-http]! XX of XX: [@azure/core-lro] blocked by [@azure/core-http]! +XX of XX: [@azure/keyvault-keys] blocked by [@azure/core-http]! XX of XX: [@azure/keyvault-certificates] blocked by [@azure/core-http]! +XX of XX: [@azure/keyvault-secrets] blocked by [@azure/core-http]! +XX of XX: [@azure/storage-blob] blocked by [@azure/core-http]! XX of XX: [@azure/identity] blocked by [@azure/core-http]! XX of XX: [@azure/core-amqp] blocked by [@azure/core-http]! XX of XX: [@azure/event-hubs] blocked by [@azure/core-http]! -XX of XX: [@azure/eventhubs-checkpointstore-blob] blocked by [@azure/core-http]! -XX of XX: [@azure/keyvault-keys] blocked by [@azure/core-http]! -XX of XX: [@azure/keyvault-secrets] blocked by [@azure/core-http]! +XX of XX: [@azure/storage-queue] blocked by [@azure/core-http]! +XX of XX: [@azure/storage-file-share] blocked by [@azure/core-http]! XX of XX: [@azure/template] blocked by [@azure/core-http]! XX of XX: [@azure/event-processor-host] completed with warnings in ? seconds XX of XX: [@azure/cosmos] completed with warnings in ? seconds diff --git a/tests/baselines/reference/docker/vscode.log b/tests/baselines/reference/docker/vscode.log index fdd7db9d713..c1a5c3eb6f9 100644 --- a/tests/baselines/reference/docker/vscode.log +++ b/tests/baselines/reference/docker/vscode.log @@ -4,21 +4,22 @@ yarn run vX.X.X $ gulp compile --max_old_space_size=4095 [XX:XX:XX] Node flags detected: --max_old_space_size=4095 [XX:XX:XX] Using gulpfile /vscode/gulpfile.js +[XX:XX:XX] Error: /vscode/extensions/typescript-language-features/src/features/fileConfigurationManager.ts(170,4): Type 'string | undefined' is not assignable to type 'SemicolonPreference | undefined'. + Type 'string' is not assignable to type 'SemicolonPreference | undefined'. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. Standard error: [XX:XX:XX] 'compile' errored after ?s -[XX:XX:XX] TypeError: Cannot read property 'text' of undefined - at DeclarationResolver._getDeclarationSourceFile (/vscode/build/monaco/api.js:519:75) - at DeclarationResolver.getDeclarationSourceFile (/vscode/build/monaco/api.js:493:52) - at sourceFileGetter (/vscode/build/monaco/api.js:525:53) - at lines.forEach.line (/vscode/build/monaco/api.js:330:32) - at Array.forEach () - at generateDeclarationFile (/vscode/build/monaco/api.js:319:11) - at _run (/vscode/build/monaco/api.js:438:15) - at Object.run3 (/vscode/build/monaco/api.js:526:12) - at MonacoGenerator._run (/vscode/build/lib/compilation.js:142:27) - at MonacoGenerator.execute (/vscode/build/lib/compilation.js:154:29) +[XX:XX:XX] Error: Found 1 errors + at Stream. (/vscode/build/lib/reporter.js:74:29) + at _end (/vscode/node_modules/through/index.js:65:9) + at Stream.stream.end (/vscode/node_modules/through/index.js:74:5) + at StreamFilter.onend (/vscode/node_modules/readable-stream/lib/_stream_readable.js:570:10) + at Object.onceWrapper (events.js:286:20) + at StreamFilter.emit (events.js:203:15) + at StreamFilter.EventEmitter.emit (domain.js:466:23) + at endReadableNT (/vscode/node_modules/readable-stream/lib/_stream_readable.js:992:12) + at process._tickCallback (internal/process/next_tick.js:63:19) error Command failed with exit code 1. diff --git a/tests/baselines/reference/emptyTypeArgumentList.errors.txt b/tests/baselines/reference/emptyTypeArgumentList.errors.txt index 395c990a3d9..4f970efb5f2 100644 --- a/tests/baselines/reference/emptyTypeArgumentList.errors.txt +++ b/tests/baselines/reference/emptyTypeArgumentList.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/emptyTypeArgumentList.ts(2,4): error TS1099: Type argument list cannot be empty. -tests/cases/compiler/emptyTypeArgumentList.ts(2,5): error TS2558: Expected 1 type arguments, but got 0. +tests/cases/compiler/emptyTypeArgumentList.ts(6,9): error TS1099: Type argument list cannot be empty. ==== tests/cases/compiler/emptyTypeArgumentList.ts (2 errors) ==== @@ -7,5 +7,9 @@ tests/cases/compiler/emptyTypeArgumentList.ts(2,5): error TS2558: Expected 1 typ foo<>(); ~~ !!! error TS1099: Type argument list cannot be empty. - -!!! error TS2558: Expected 1 type arguments, but got 0. \ No newline at end of file + + // https://github.com/microsoft/TypeScript/issues/33041 + function noParams() {} + noParams<>(); + ~~ +!!! error TS1099: Type argument list cannot be empty. \ No newline at end of file diff --git a/tests/baselines/reference/emptyTypeArgumentList.js b/tests/baselines/reference/emptyTypeArgumentList.js index 30093113be4..8662c255dc2 100644 --- a/tests/baselines/reference/emptyTypeArgumentList.js +++ b/tests/baselines/reference/emptyTypeArgumentList.js @@ -1,7 +1,14 @@ //// [emptyTypeArgumentList.ts] function foo() { } -foo<>(); +foo<>(); + +// https://github.com/microsoft/TypeScript/issues/33041 +function noParams() {} +noParams<>(); //// [emptyTypeArgumentList.js] function foo() { } foo(); +// https://github.com/microsoft/TypeScript/issues/33041 +function noParams() { } +noParams(); diff --git a/tests/baselines/reference/emptyTypeArgumentList.symbols b/tests/baselines/reference/emptyTypeArgumentList.symbols index efbe5705f4f..78573ea57c5 100644 --- a/tests/baselines/reference/emptyTypeArgumentList.symbols +++ b/tests/baselines/reference/emptyTypeArgumentList.symbols @@ -6,3 +6,10 @@ function foo() { } foo<>(); >foo : Symbol(foo, Decl(emptyTypeArgumentList.ts, 0, 0)) +// https://github.com/microsoft/TypeScript/issues/33041 +function noParams() {} +>noParams : Symbol(noParams, Decl(emptyTypeArgumentList.ts, 1, 8)) + +noParams<>(); +>noParams : Symbol(noParams, Decl(emptyTypeArgumentList.ts, 1, 8)) + diff --git a/tests/baselines/reference/emptyTypeArgumentList.types b/tests/baselines/reference/emptyTypeArgumentList.types index 94eb2d878c8..32f6f64d1dc 100644 --- a/tests/baselines/reference/emptyTypeArgumentList.types +++ b/tests/baselines/reference/emptyTypeArgumentList.types @@ -3,6 +3,14 @@ function foo() { } >foo : () => void foo<>(); ->foo<>() : any +>foo<>() : void >foo : () => void +// https://github.com/microsoft/TypeScript/issues/33041 +function noParams() {} +>noParams : () => void + +noParams<>(); +>noParams<>() : void +>noParams : () => void + diff --git a/tests/baselines/reference/emptyTypeArgumentListWithNew.errors.txt b/tests/baselines/reference/emptyTypeArgumentListWithNew.errors.txt index 92eb250291a..f0e756d8d93 100644 --- a/tests/baselines/reference/emptyTypeArgumentListWithNew.errors.txt +++ b/tests/baselines/reference/emptyTypeArgumentListWithNew.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/emptyTypeArgumentListWithNew.ts(2,8): error TS1099: Type argument list cannot be empty. -tests/cases/compiler/emptyTypeArgumentListWithNew.ts(2,9): error TS2558: Expected 1 type arguments, but got 0. +tests/cases/compiler/emptyTypeArgumentListWithNew.ts(6,13): error TS1099: Type argument list cannot be empty. ==== tests/cases/compiler/emptyTypeArgumentListWithNew.ts (2 errors) ==== @@ -7,5 +7,9 @@ tests/cases/compiler/emptyTypeArgumentListWithNew.ts(2,9): error TS2558: Expecte new foo<>(); ~~ !!! error TS1099: Type argument list cannot be empty. - -!!! error TS2558: Expected 1 type arguments, but got 0. \ No newline at end of file + + // https://github.com/microsoft/TypeScript/issues/33041 + class noParams {} + new noParams<>(); + ~~ +!!! error TS1099: Type argument list cannot be empty. \ No newline at end of file diff --git a/tests/baselines/reference/emptyTypeArgumentListWithNew.js b/tests/baselines/reference/emptyTypeArgumentListWithNew.js index c30fa31609a..bda839b5361 100644 --- a/tests/baselines/reference/emptyTypeArgumentListWithNew.js +++ b/tests/baselines/reference/emptyTypeArgumentListWithNew.js @@ -1,6 +1,10 @@ //// [emptyTypeArgumentListWithNew.ts] class foo { } -new foo<>(); +new foo<>(); + +// https://github.com/microsoft/TypeScript/issues/33041 +class noParams {} +new noParams<>(); //// [emptyTypeArgumentListWithNew.js] var foo = /** @class */ (function () { @@ -9,3 +13,10 @@ var foo = /** @class */ (function () { return foo; }()); new foo(); +// https://github.com/microsoft/TypeScript/issues/33041 +var noParams = /** @class */ (function () { + function noParams() { + } + return noParams; +}()); +new noParams(); diff --git a/tests/baselines/reference/emptyTypeArgumentListWithNew.symbols b/tests/baselines/reference/emptyTypeArgumentListWithNew.symbols index 34ce38aa478..9b2404960af 100644 --- a/tests/baselines/reference/emptyTypeArgumentListWithNew.symbols +++ b/tests/baselines/reference/emptyTypeArgumentListWithNew.symbols @@ -6,3 +6,10 @@ class foo { } new foo<>(); >foo : Symbol(foo, Decl(emptyTypeArgumentListWithNew.ts, 0, 0)) +// https://github.com/microsoft/TypeScript/issues/33041 +class noParams {} +>noParams : Symbol(noParams, Decl(emptyTypeArgumentListWithNew.ts, 1, 12)) + +new noParams<>(); +>noParams : Symbol(noParams, Decl(emptyTypeArgumentListWithNew.ts, 1, 12)) + diff --git a/tests/baselines/reference/emptyTypeArgumentListWithNew.types b/tests/baselines/reference/emptyTypeArgumentListWithNew.types index d89c3dd041f..57f1947c574 100644 --- a/tests/baselines/reference/emptyTypeArgumentListWithNew.types +++ b/tests/baselines/reference/emptyTypeArgumentListWithNew.types @@ -3,6 +3,14 @@ class foo { } >foo : foo new foo<>(); ->new foo<>() : any +>new foo<>() : foo >foo : typeof foo +// https://github.com/microsoft/TypeScript/issues/33041 +class noParams {} +>noParams : noParams + +new noParams<>(); +>new noParams<>() : noParams +>noParams : typeof noParams + diff --git a/tests/baselines/reference/exportsAndImports1-amd.errors.txt b/tests/baselines/reference/exportsAndImports1-amd.errors.txt deleted file mode 100644 index 713f464a608..00000000000 --- a/tests/baselines/reference/exportsAndImports1-amd.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -tests/cases/conformance/es6/modules/t1.ts(23,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. -tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - - -==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ==== - var v = 1; - function f() { } - class C { - } - interface I { - } - enum E { - A, B, C - } - const enum D { - A, B, C - } - module M { - export var x; - } - module N { - export interface I { - } - } - type T = number; - import a = M.x; - - export { v, f, C, I, E, D, M, N, T, a }; - ~ -!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - -==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== - export { v, f, C, I, E, D, M, N, T, a } from "./t1"; - -==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ==== - import { v, f, C, I, E, D, M, N, T, a } from "./t1"; - export { v, f, C, I, E, D, M, N, T, a }; - ~ -!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - \ No newline at end of file diff --git a/tests/baselines/reference/exportsAndImports1-es6.errors.txt b/tests/baselines/reference/exportsAndImports1-es6.errors.txt deleted file mode 100644 index 713f464a608..00000000000 --- a/tests/baselines/reference/exportsAndImports1-es6.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -tests/cases/conformance/es6/modules/t1.ts(23,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. -tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - - -==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ==== - var v = 1; - function f() { } - class C { - } - interface I { - } - enum E { - A, B, C - } - const enum D { - A, B, C - } - module M { - export var x; - } - module N { - export interface I { - } - } - type T = number; - import a = M.x; - - export { v, f, C, I, E, D, M, N, T, a }; - ~ -!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - -==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== - export { v, f, C, I, E, D, M, N, T, a } from "./t1"; - -==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ==== - import { v, f, C, I, E, D, M, N, T, a } from "./t1"; - export { v, f, C, I, E, D, M, N, T, a }; - ~ -!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - \ No newline at end of file diff --git a/tests/baselines/reference/exportsAndImports1.errors.txt b/tests/baselines/reference/exportsAndImports1.errors.txt deleted file mode 100644 index 713f464a608..00000000000 --- a/tests/baselines/reference/exportsAndImports1.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -tests/cases/conformance/es6/modules/t1.ts(23,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. -tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - - -==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ==== - var v = 1; - function f() { } - class C { - } - interface I { - } - enum E { - A, B, C - } - const enum D { - A, B, C - } - module M { - export var x; - } - module N { - export interface I { - } - } - type T = number; - import a = M.x; - - export { v, f, C, I, E, D, M, N, T, a }; - ~ -!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - -==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== - export { v, f, C, I, E, D, M, N, T, a } from "./t1"; - -==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ==== - import { v, f, C, I, E, D, M, N, T, a } from "./t1"; - export { v, f, C, I, E, D, M, N, T, a }; - ~ -!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - \ No newline at end of file diff --git a/tests/baselines/reference/exportsAndImports3-amd.errors.txt b/tests/baselines/reference/exportsAndImports3-amd.errors.txt deleted file mode 100644 index b084c1193f4..00000000000 --- a/tests/baselines/reference/exportsAndImports3-amd.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -tests/cases/conformance/es6/modules/t1.ts(23,55): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. -tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - - -==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ==== - export var v = 1; - export function f() { } - export class C { - } - export interface I { - } - export enum E { - A, B, C - } - export const enum D { - A, B, C - } - export module M { - export var x; - } - export module N { - export interface I { - } - } - export type T = number; - export import a = M.x; - - export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 }; - ~ -!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - -==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== - export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; - -==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ==== - import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; - export { v, f, C, I, E, D, M, N, T, a }; - ~ -!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - \ No newline at end of file diff --git a/tests/baselines/reference/exportsAndImports3-es6.errors.txt b/tests/baselines/reference/exportsAndImports3-es6.errors.txt deleted file mode 100644 index b084c1193f4..00000000000 --- a/tests/baselines/reference/exportsAndImports3-es6.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -tests/cases/conformance/es6/modules/t1.ts(23,55): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. -tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - - -==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ==== - export var v = 1; - export function f() { } - export class C { - } - export interface I { - } - export enum E { - A, B, C - } - export const enum D { - A, B, C - } - export module M { - export var x; - } - export module N { - export interface I { - } - } - export type T = number; - export import a = M.x; - - export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 }; - ~ -!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - -==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== - export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; - -==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ==== - import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; - export { v, f, C, I, E, D, M, N, T, a }; - ~ -!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - \ No newline at end of file diff --git a/tests/baselines/reference/exportsAndImports3.errors.txt b/tests/baselines/reference/exportsAndImports3.errors.txt deleted file mode 100644 index b084c1193f4..00000000000 --- a/tests/baselines/reference/exportsAndImports3.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -tests/cases/conformance/es6/modules/t1.ts(23,55): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. -tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - - -==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ==== - export var v = 1; - export function f() { } - export class C { - } - export interface I { - } - export enum E { - A, B, C - } - export const enum D { - A, B, C - } - export module M { - export var x; - } - export module N { - export interface I { - } - } - export type T = number; - export import a = M.x; - - export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 }; - ~ -!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - -==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== - export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; - -==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ==== - import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; - export { v, f, C, I, E, D, M, N, T, a }; - ~ -!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. - \ No newline at end of file diff --git a/tests/baselines/reference/extendGlobalThis.symbols b/tests/baselines/reference/extendGlobalThis.symbols index 944d7b23715..91cd0bf2530 100644 --- a/tests/baselines/reference/extendGlobalThis.symbols +++ b/tests/baselines/reference/extendGlobalThis.symbols @@ -3,7 +3,7 @@ declare global { >global : Symbol(global, Decl(extension.d.ts, 0, 0)) namespace globalThis { ->globalThis : Symbol(globalThis) +>globalThis : Symbol(globalThis, Decl(extension.d.ts, 0, 16)) var test: string; >test : Symbol(test, Decl(extension.d.ts, 2, 11)) @@ -16,7 +16,7 @@ export {} import "./extention"; globalThis.tests = "a-b"; ->globalThis : Symbol(globalThis) +>globalThis : Symbol(globalThis, Decl(extension.d.ts, 0, 16)) console.log(globalThis.test.split("-")); >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) @@ -24,7 +24,7 @@ console.log(globalThis.test.split("-")); >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >globalThis.test.split : Symbol(String.split, Decl(lib.es5.d.ts, --, --)) >globalThis.test : Symbol(test, Decl(extension.d.ts, 2, 11)) ->globalThis : Symbol(globalThis) +>globalThis : Symbol(globalThis, Decl(extension.d.ts, 0, 16)) >test : Symbol(test, Decl(extension.d.ts, 2, 11)) >split : Symbol(String.split, Decl(lib.es5.d.ts, --, --)) diff --git a/tests/baselines/reference/extendGlobalThis2.errors.txt b/tests/baselines/reference/extendGlobalThis2.errors.txt new file mode 100644 index 00000000000..09e78cba92d --- /dev/null +++ b/tests/baselines/reference/extendGlobalThis2.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/extendGlobalThis2.ts(1,11): error TS2397: Declaration name conflicts with built-in global identifier 'globalThis'. + + +==== tests/cases/compiler/extendGlobalThis2.ts (1 errors) ==== + namespace globalThis { + ~~~~~~~~~~ +!!! error TS2397: Declaration name conflicts with built-in global identifier 'globalThis'. + export function foo() { console.log("x"); } + } + \ No newline at end of file diff --git a/tests/baselines/reference/extendGlobalThis2.js b/tests/baselines/reference/extendGlobalThis2.js new file mode 100644 index 00000000000..63f06536ce5 --- /dev/null +++ b/tests/baselines/reference/extendGlobalThis2.js @@ -0,0 +1,12 @@ +//// [extendGlobalThis2.ts] +namespace globalThis { + export function foo() { console.log("x"); } +} + + +//// [extendGlobalThis2.js] +var globalThis; +(function (globalThis) { + function foo() { console.log("x"); } + globalThis.foo = foo; +})(globalThis || (globalThis = {})); diff --git a/tests/baselines/reference/extendGlobalThis2.symbols b/tests/baselines/reference/extendGlobalThis2.symbols new file mode 100644 index 00000000000..f16727a674b --- /dev/null +++ b/tests/baselines/reference/extendGlobalThis2.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/extendGlobalThis2.ts === +namespace globalThis { +>globalThis : Symbol(globalThis, Decl(extendGlobalThis2.ts, 0, 0)) + + export function foo() { console.log("x"); } +>foo : Symbol(foo, Decl(extendGlobalThis2.ts, 0, 22)) +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +} + diff --git a/tests/baselines/reference/extendGlobalThis2.types b/tests/baselines/reference/extendGlobalThis2.types new file mode 100644 index 00000000000..4a062194742 --- /dev/null +++ b/tests/baselines/reference/extendGlobalThis2.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/extendGlobalThis2.ts === +namespace globalThis { +>globalThis : typeof globalThis + + export function foo() { console.log("x"); } +>foo : () => void +>console.log("x") : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>"x" : "x" +} + diff --git a/tests/baselines/reference/genericObjectRest.js b/tests/baselines/reference/genericObjectRest.js index 33815e1bb98..0ef4859d341 100644 --- a/tests/baselines/reference/genericObjectRest.js +++ b/tests/baselines/reference/genericObjectRest.js @@ -48,16 +48,16 @@ function f1(obj) { let { a: a2, b: b2 } = obj, r2 = __rest(obj, ["a", "b"]); let { 'a': a3 } = obj, r3 = __rest(obj, ['a']); let { ['a']: a4 } = obj, r4 = __rest(obj, ['a']); - let _a = a, a5 = obj[_a], r5 = __rest(obj, [typeof _a === "symbol" ? _a : _a + ""]); + let _a = obj, _b = a, a5 = _a[_b], r5 = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]); } const sa = Symbol(); const sb = Symbol(); function f2(obj) { - let _a = sa, a1 = obj[_a], _b = sb, b1 = obj[_b], r1 = __rest(obj, [typeof _a === "symbol" ? _a : _a + "", typeof _b === "symbol" ? _b : _b + ""]); + let _a = obj, _b = sa, a1 = _a[_b], _c = sb, b1 = _a[_c], r1 = __rest(_a, [typeof _b === "symbol" ? _b : _b + "", typeof _c === "symbol" ? _c : _c + ""]); } function f3(obj, k1, k2) { - let _a = k1, a1 = obj[_a], _b = k2, a2 = obj[_b], r1 = __rest(obj, [typeof _a === "symbol" ? _a : _a + "", typeof _b === "symbol" ? _b : _b + ""]); + let _a = obj, _b = k1, a1 = _a[_b], _c = k2, a2 = _a[_c], r1 = __rest(_a, [typeof _b === "symbol" ? _b : _b + "", typeof _c === "symbol" ? _c : _c + ""]); } function f4(obj, k1, k2) { - let _a = k1, a1 = obj[_a], _b = k2, a2 = obj[_b], r1 = __rest(obj, [typeof _a === "symbol" ? _a : _a + "", typeof _b === "symbol" ? _b : _b + ""]); + let _a = obj, _b = k1, a1 = _a[_b], _c = k2, a2 = _a[_c], r1 = __rest(_a, [typeof _b === "symbol" ? _b : _b + "", typeof _c === "symbol" ? _c : _c + ""]); } diff --git a/tests/baselines/reference/globalThisPropertyAssignment.symbols b/tests/baselines/reference/globalThisPropertyAssignment.symbols index 1ae4dd5af63..3bc852cbba1 100644 --- a/tests/baselines/reference/globalThisPropertyAssignment.symbols +++ b/tests/baselines/reference/globalThisPropertyAssignment.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es2019/globalThisPropertyAssignment.js === this.x = 1 >this.x : Symbol(x, Decl(globalThisPropertyAssignment.js, 0, 0)) ->this : Symbol(globalThis) +>this : Symbol(globalThis, Decl(globalThisPropertyAssignment.js, 3, 12)) >x : Symbol(x, Decl(globalThisPropertyAssignment.js, 0, 0)) var y = 2 @@ -14,6 +14,6 @@ window.z = 3 // should work in JS (even though it's a secondary declaration) globalThis.alpha = 4 >globalThis.alpha : Symbol(alpha, Decl(globalThisPropertyAssignment.js, 3, 12)) ->globalThis : Symbol(globalThis) +>globalThis : Symbol(globalThis, Decl(globalThisPropertyAssignment.js, 3, 12)) >alpha : Symbol(alpha, Decl(globalThisPropertyAssignment.js, 3, 12)) diff --git a/tests/baselines/reference/importAliasModuleExports.errors.txt b/tests/baselines/reference/importAliasModuleExports.errors.txt index ea3dd9ef0e0..9cd2cd9768e 100644 --- a/tests/baselines/reference/importAliasModuleExports.errors.txt +++ b/tests/baselines/reference/importAliasModuleExports.errors.txt @@ -1,5 +1,8 @@ tests/cases/conformance/salsa/main.js(2,13): error TS2339: Property 'foo' does not exist on type 'Alias'. -tests/cases/conformance/salsa/main.js(4,9): error TS2339: Property 'foo' does not exist on type 'Alias'. +tests/cases/conformance/salsa/main.js(3,13): error TS2339: Property 'func' does not exist on type 'Alias'. +tests/cases/conformance/salsa/main.js(3,38): error TS2339: Property '_func' does not exist on type 'Alias'. +tests/cases/conformance/salsa/main.js(5,9): error TS2339: Property 'foo' does not exist on type 'Alias'. +tests/cases/conformance/salsa/main.js(6,9): error TS2339: Property 'func' does not exist on type 'Alias'. ==== tests/cases/conformance/salsa/mod1.js (0 errors) ==== @@ -8,13 +11,21 @@ tests/cases/conformance/salsa/main.js(4,9): error TS2339: Property 'foo' does no } module.exports = Alias; -==== tests/cases/conformance/salsa/main.js (2 errors) ==== +==== tests/cases/conformance/salsa/main.js (5 errors) ==== import A from './mod1' A.prototype.foo = 0 ~~~ !!! error TS2339: Property 'foo' does not exist on type 'Alias'. + A.prototype.func = function() { this._func = 0; } + ~~~~ +!!! error TS2339: Property 'func' does not exist on type 'Alias'. + ~~~~~ +!!! error TS2339: Property '_func' does not exist on type 'Alias'. new A().bar new A().foo ~~~ !!! error TS2339: Property 'foo' does not exist on type 'Alias'. + new A().func() + ~~~~ +!!! error TS2339: Property 'func' does not exist on type 'Alias'. \ No newline at end of file diff --git a/tests/baselines/reference/importAliasModuleExports.symbols b/tests/baselines/reference/importAliasModuleExports.symbols index 4ab081d608f..4d67eb8e197 100644 --- a/tests/baselines/reference/importAliasModuleExports.symbols +++ b/tests/baselines/reference/importAliasModuleExports.symbols @@ -20,6 +20,12 @@ A.prototype.foo = 0 >A : Symbol(A, Decl(main.js, 0, 6)) >prototype : Symbol(A.prototype) +A.prototype.func = function() { this._func = 0; } +>A.prototype : Symbol(A.prototype) +>A : Symbol(A, Decl(main.js, 0, 6)) +>prototype : Symbol(A.prototype) +>this : Symbol(A, Decl(mod1.js, 0, 0)) + new A().bar >new A().bar : Symbol(A.bar, Decl(mod1.js, 0, 13)) >A : Symbol(A, Decl(main.js, 0, 6)) @@ -28,3 +34,6 @@ new A().bar new A().foo >A : Symbol(A, Decl(main.js, 0, 6)) +new A().func() +>A : Symbol(A, Decl(main.js, 0, 6)) + diff --git a/tests/baselines/reference/importAliasModuleExports.types b/tests/baselines/reference/importAliasModuleExports.types index 1303ba6e8c4..6c9b0509549 100644 --- a/tests/baselines/reference/importAliasModuleExports.types +++ b/tests/baselines/reference/importAliasModuleExports.types @@ -26,6 +26,20 @@ A.prototype.foo = 0 >foo : any >0 : 0 +A.prototype.func = function() { this._func = 0; } +>A.prototype.func = function() { this._func = 0; } : () => void +>A.prototype.func : any +>A.prototype : A +>A : typeof A +>prototype : A +>func : any +>function() { this._func = 0; } : () => void +>this._func = 0 : 0 +>this._func : any +>this : A +>_func : any +>0 : 0 + new A().bar >new A().bar : () => number >new A() : A @@ -38,3 +52,10 @@ new A().foo >A : typeof A >foo : any +new A().func() +>new A().func() : any +>new A().func : any +>new A() : A +>A : typeof A +>func : any + diff --git a/tests/baselines/reference/intersectionAndUnionTypes.errors.txt b/tests/baselines/reference/intersectionAndUnionTypes.errors.txt index 4f3b1db01e3..7de8735f640 100644 --- a/tests/baselines/reference/intersectionAndUnionTypes.errors.txt +++ b/tests/baselines/reference/intersectionAndUnionTypes.errors.txt @@ -24,14 +24,14 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(29,1): e Property 'd' is missing in type 'A & B' but required in type 'D'. tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(31,1): error TS2322: Type 'A & B' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. Type 'A & B' is not assignable to type 'B & D'. - Type 'A & B' is not assignable to type 'D'. + Property 'd' is missing in type 'A & B' but required in type 'D'. tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(32,1): error TS2322: Type 'A | B' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. Type 'A' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. Type 'A' is not assignable to type 'A & D'. Property 'd' is missing in type 'A' but required in type 'D'. tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(33,1): error TS2322: Type 'C & D' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. Type 'C & D' is not assignable to type 'B & D'. - Type 'C & D' is not assignable to type 'B'. + Property 'b' is missing in type 'C & D' but required in type 'B'. tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(34,1): error TS2322: Type 'C | D' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. Type 'C' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. Type 'C' is not assignable to type 'B & C'. @@ -118,7 +118,8 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e ~ !!! error TS2322: Type 'A & B' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. !!! error TS2322: Type 'A & B' is not assignable to type 'B & D'. -!!! error TS2322: Type 'A & B' is not assignable to type 'D'. +!!! error TS2322: Property 'd' is missing in type 'A & B' but required in type 'D'. +!!! related TS2728 tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts:4:15: 'd' is declared here. y = aob; ~ !!! error TS2322: Type 'A | B' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. @@ -130,7 +131,8 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e ~ !!! error TS2322: Type 'C & D' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. !!! error TS2322: Type 'C & D' is not assignable to type 'B & D'. -!!! error TS2322: Type 'C & D' is not assignable to type 'B'. +!!! error TS2322: Property 'b' is missing in type 'C & D' but required in type 'B'. +!!! related TS2728 tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts:2:15: 'b' is declared here. y = cod; ~ !!! error TS2322: Type 'C | D' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. diff --git a/tests/baselines/reference/intersectionMemberOfUnionNarrowsCorrectly.js b/tests/baselines/reference/intersectionMemberOfUnionNarrowsCorrectly.js new file mode 100644 index 00000000000..059d182b1b2 --- /dev/null +++ b/tests/baselines/reference/intersectionMemberOfUnionNarrowsCorrectly.js @@ -0,0 +1,11 @@ +//// [intersectionMemberOfUnionNarrowsCorrectly.ts] +export type U = { kind?: 'A', a: string } | { kind?: 'B' } & { b: string }; +type Ex = T extends U ? T : never; +declare let x: Ex +x.a + + +//// [intersectionMemberOfUnionNarrowsCorrectly.js] +"use strict"; +exports.__esModule = true; +x.a; diff --git a/tests/baselines/reference/intersectionMemberOfUnionNarrowsCorrectly.symbols b/tests/baselines/reference/intersectionMemberOfUnionNarrowsCorrectly.symbols new file mode 100644 index 00000000000..d10772a93f5 --- /dev/null +++ b/tests/baselines/reference/intersectionMemberOfUnionNarrowsCorrectly.symbols @@ -0,0 +1,27 @@ +=== tests/cases/conformance/types/intersection/intersectionMemberOfUnionNarrowsCorrectly.ts === +export type U = { kind?: 'A', a: string } | { kind?: 'B' } & { b: string }; +>U : Symbol(U, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 0, 0)) +>kind : Symbol(kind, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 0, 17)) +>a : Symbol(a, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 0, 29)) +>kind : Symbol(kind, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 0, 45)) +>b : Symbol(b, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 0, 62)) + +type Ex = T extends U ? T : never; +>Ex : Symbol(Ex, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 0, 75)) +>T : Symbol(T, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 1, 8)) +>U : Symbol(U, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 1, 10)) +>T : Symbol(T, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 1, 8)) +>U : Symbol(U, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 1, 10)) +>T : Symbol(T, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 1, 8)) + +declare let x: Ex +>x : Symbol(x, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 2, 11)) +>Ex : Symbol(Ex, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 0, 75)) +>U : Symbol(U, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 0, 0)) +>kind : Symbol(kind, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 2, 22)) + +x.a +>x.a : Symbol(a, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 0, 29)) +>x : Symbol(x, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 2, 11)) +>a : Symbol(a, Decl(intersectionMemberOfUnionNarrowsCorrectly.ts, 0, 29)) + diff --git a/tests/baselines/reference/intersectionMemberOfUnionNarrowsCorrectly.types b/tests/baselines/reference/intersectionMemberOfUnionNarrowsCorrectly.types new file mode 100644 index 00000000000..77805ece13b --- /dev/null +++ b/tests/baselines/reference/intersectionMemberOfUnionNarrowsCorrectly.types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/types/intersection/intersectionMemberOfUnionNarrowsCorrectly.ts === +export type U = { kind?: 'A', a: string } | { kind?: 'B' } & { b: string }; +>U : U +>kind : "A" +>a : string +>kind : "B" +>b : string + +type Ex = T extends U ? T : never; +>Ex : Ex + +declare let x: Ex +>x : { kind?: "A"; a: string; } +>kind : "A" + +x.a +>x.a : string +>x : { kind?: "A"; a: string; } +>a : string + diff --git a/tests/baselines/reference/javascriptImportDefaultBadExport.errors.txt b/tests/baselines/reference/javascriptImportDefaultBadExport.errors.txt new file mode 100644 index 00000000000..71ff85e2155 --- /dev/null +++ b/tests/baselines/reference/javascriptImportDefaultBadExport.errors.txt @@ -0,0 +1,16 @@ +/b.js(1,8): error TS1259: Module '"/a"' can only be default-imported using the 'esModuleInterop' flag + + +==== /a.js (0 errors) ==== + // https://github.com/microsoft/TypeScript/issues/34481 + + + const alias = {}; + module.exports = alias; + +==== /b.js (1 errors) ==== + import a from "./a"; + ~ +!!! error TS1259: Module '"/a"' can only be default-imported using the 'esModuleInterop' flag +!!! related TS2594 /a.js:5:1: This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. + \ No newline at end of file diff --git a/tests/baselines/reference/javascriptImportDefaultBadExport.symbols b/tests/baselines/reference/javascriptImportDefaultBadExport.symbols new file mode 100644 index 00000000000..b5506996aff --- /dev/null +++ b/tests/baselines/reference/javascriptImportDefaultBadExport.symbols @@ -0,0 +1,17 @@ +=== /a.js === +// https://github.com/microsoft/TypeScript/issues/34481 + + +const alias = {}; +>alias : Symbol(alias, Decl(a.js, 3, 5)) + +module.exports = alias; +>module.exports : Symbol("/a", Decl(a.js, 0, 0)) +>module : Symbol(export=, Decl(a.js, 3, 17)) +>exports : Symbol(export=, Decl(a.js, 3, 17)) +>alias : Symbol(alias, Decl(a.js, 3, 5)) + +=== /b.js === +import a from "./a"; +>a : Symbol(a, Decl(b.js, 0, 6)) + diff --git a/tests/baselines/reference/javascriptImportDefaultBadExport.types b/tests/baselines/reference/javascriptImportDefaultBadExport.types new file mode 100644 index 00000000000..81d68cbdf96 --- /dev/null +++ b/tests/baselines/reference/javascriptImportDefaultBadExport.types @@ -0,0 +1,19 @@ +=== /a.js === +// https://github.com/microsoft/TypeScript/issues/34481 + + +const alias = {}; +>alias : {} +>{} : {} + +module.exports = alias; +>module.exports = alias : {} +>module.exports : {} +>module : { "/a": {}; } +>exports : {} +>alias : {} + +=== /b.js === +import a from "./a"; +>a : any + diff --git a/tests/baselines/reference/jsNegativeElementAccessNotBound.symbols b/tests/baselines/reference/jsNegativeElementAccessNotBound.symbols new file mode 100644 index 00000000000..d8ff3f52e23 --- /dev/null +++ b/tests/baselines/reference/jsNegativeElementAccessNotBound.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/jsNegativeELementAccessNotBound.js === +var indexMap = {}; +>indexMap : Symbol(indexMap, Decl(jsNegativeELementAccessNotBound.js, 0, 3)) + +indexMap[-1] = 0; +>indexMap : Symbol(indexMap, Decl(jsNegativeELementAccessNotBound.js, 0, 3)) + diff --git a/tests/baselines/reference/jsNegativeElementAccessNotBound.types b/tests/baselines/reference/jsNegativeElementAccessNotBound.types new file mode 100644 index 00000000000..dbd5d4c005d --- /dev/null +++ b/tests/baselines/reference/jsNegativeElementAccessNotBound.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/jsNegativeELementAccessNotBound.js === +var indexMap = {}; +>indexMap : {} +>{} : {} + +indexMap[-1] = 0; +>indexMap[-1] = 0 : 0 +>indexMap[-1] : any +>indexMap : {} +>-1 : -1 +>1 : 1 +>0 : 0 + diff --git a/tests/baselines/reference/jsdocImportTypeReferenceToClassAlias.symbols b/tests/baselines/reference/jsdocImportTypeReferenceToClassAlias.symbols new file mode 100644 index 00000000000..c62d8e0676f --- /dev/null +++ b/tests/baselines/reference/jsdocImportTypeReferenceToClassAlias.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsdoc/mod1.js === +class C { +>C : Symbol(C, Decl(mod1.js, 0, 0)) + + s() { } +>s : Symbol(C.s, Decl(mod1.js, 0, 9)) +} +module.exports.C = C +>module.exports.C : Symbol(C, Decl(mod1.js, 2, 1)) +>module.exports : Symbol(C, Decl(mod1.js, 2, 1)) +>module : Symbol(module, Decl(mod1.js, 2, 1)) +>exports : Symbol("tests/cases/conformance/jsdoc/mod1", Decl(mod1.js, 0, 0)) +>C : Symbol(C, Decl(mod1.js, 2, 1)) +>C : Symbol(C, Decl(mod1.js, 0, 0)) + +=== tests/cases/conformance/jsdoc/test.js === +/** @typedef {import('./mod1').C} X */ +/** @param {X} c */ +function demo(c) { +>demo : Symbol(demo, Decl(test.js, 0, 0)) +>c : Symbol(c, Decl(test.js, 2, 14)) + + c.s +>c.s : Symbol(C.s, Decl(mod1.js, 0, 9)) +>c : Symbol(c, Decl(test.js, 2, 14)) +>s : Symbol(C.s, Decl(mod1.js, 0, 9)) +} + diff --git a/tests/baselines/reference/jsdocImportTypeReferenceToClassAlias.types b/tests/baselines/reference/jsdocImportTypeReferenceToClassAlias.types new file mode 100644 index 00000000000..880288d7197 --- /dev/null +++ b/tests/baselines/reference/jsdocImportTypeReferenceToClassAlias.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/jsdoc/mod1.js === +class C { +>C : C + + s() { } +>s : () => void +} +module.exports.C = C +>module.exports.C = C : typeof C +>module.exports.C : typeof C +>module.exports : typeof import("tests/cases/conformance/jsdoc/mod1") +>module : { "tests/cases/conformance/jsdoc/mod1": typeof import("tests/cases/conformance/jsdoc/mod1"); } +>exports : typeof import("tests/cases/conformance/jsdoc/mod1") +>C : typeof C +>C : typeof C + +=== tests/cases/conformance/jsdoc/test.js === +/** @typedef {import('./mod1').C} X */ +/** @param {X} c */ +function demo(c) { +>demo : (c: C) => void +>c : C + + c.s +>c.s : () => void +>c : C +>s : () => void +} + diff --git a/tests/baselines/reference/jsdocTypeReferenceToImport.symbols b/tests/baselines/reference/jsdocTypeReferenceToImport.symbols new file mode 100644 index 00000000000..c7d04ff5a16 --- /dev/null +++ b/tests/baselines/reference/jsdocTypeReferenceToImport.symbols @@ -0,0 +1,58 @@ +=== tests/cases/conformance/jsdoc/jsdocTypeReferenceToImport.js === +// #34802 + +const C = require('./ex').C; +>C : Symbol(C, Decl(jsdocTypeReferenceToImport.js, 2, 5)) +>require('./ex').C : Symbol(C, Decl(ex.d.ts, 0, 0)) +>require : Symbol(require) +>'./ex' : Symbol("tests/cases/conformance/jsdoc/ex", Decl(ex.d.ts, 0, 0)) +>C : Symbol(C, Decl(ex.d.ts, 0, 0)) + +const D = require('./ex')?.C; +>D : Symbol(D, Decl(jsdocTypeReferenceToImport.js, 3, 5)) +>require('./ex')?.C : Symbol(C, Decl(ex.d.ts, 0, 0)) +>require : Symbol(require) +>'./ex' : Symbol("tests/cases/conformance/jsdoc/ex", Decl(ex.d.ts, 0, 0)) +>C : Symbol(C, Decl(ex.d.ts, 0, 0)) + +/** @type {C} c */ +var c = new C() +>c : Symbol(c, Decl(jsdocTypeReferenceToImport.js, 5, 3)) +>C : Symbol(C, Decl(jsdocTypeReferenceToImport.js, 2, 5)) + +c.start +>c.start : Symbol(C.start, Decl(ex.d.ts, 0, 16)) +>c : Symbol(c, Decl(jsdocTypeReferenceToImport.js, 5, 3)) +>start : Symbol(C.start, Decl(ex.d.ts, 0, 16)) + +c.end +>c.end : Symbol(C.end, Decl(ex.d.ts, 1, 17)) +>c : Symbol(c, Decl(jsdocTypeReferenceToImport.js, 5, 3)) +>end : Symbol(C.end, Decl(ex.d.ts, 1, 17)) + +/** @type {D} c */ +var d = new D() +>d : Symbol(d, Decl(jsdocTypeReferenceToImport.js, 10, 3)) +>D : Symbol(D, Decl(jsdocTypeReferenceToImport.js, 3, 5)) + +d.start +>d.start : Symbol(C.start, Decl(ex.d.ts, 0, 16)) +>d : Symbol(d, Decl(jsdocTypeReferenceToImport.js, 10, 3)) +>start : Symbol(C.start, Decl(ex.d.ts, 0, 16)) + +d.end +>d.end : Symbol(C.end, Decl(ex.d.ts, 1, 17)) +>d : Symbol(d, Decl(jsdocTypeReferenceToImport.js, 10, 3)) +>end : Symbol(C.end, Decl(ex.d.ts, 1, 17)) + +=== tests/cases/conformance/jsdoc/ex.d.ts === +export class C { +>C : Symbol(C, Decl(ex.d.ts, 0, 0)) + + start: number +>start : Symbol(C.start, Decl(ex.d.ts, 0, 16)) + + end: number +>end : Symbol(C.end, Decl(ex.d.ts, 1, 17)) +} + diff --git a/tests/baselines/reference/jsdocTypeReferenceToImport.types b/tests/baselines/reference/jsdocTypeReferenceToImport.types new file mode 100644 index 00000000000..4d4fe89ae02 --- /dev/null +++ b/tests/baselines/reference/jsdocTypeReferenceToImport.types @@ -0,0 +1,62 @@ +=== tests/cases/conformance/jsdoc/jsdocTypeReferenceToImport.js === +// #34802 + +const C = require('./ex').C; +>C : typeof import("tests/cases/conformance/jsdoc/ex").C +>require('./ex').C : typeof import("tests/cases/conformance/jsdoc/ex").C +>require('./ex') : typeof import("tests/cases/conformance/jsdoc/ex") +>require : any +>'./ex' : "./ex" +>C : typeof import("tests/cases/conformance/jsdoc/ex").C + +const D = require('./ex')?.C; +>D : typeof import("tests/cases/conformance/jsdoc/ex").C +>require('./ex')?.C : typeof import("tests/cases/conformance/jsdoc/ex").C +>require('./ex') : typeof import("tests/cases/conformance/jsdoc/ex") +>require : any +>'./ex' : "./ex" +>C : typeof import("tests/cases/conformance/jsdoc/ex").C + +/** @type {C} c */ +var c = new C() +>c : import("tests/cases/conformance/jsdoc/ex").C +>new C() : import("tests/cases/conformance/jsdoc/ex").C +>C : typeof import("tests/cases/conformance/jsdoc/ex").C + +c.start +>c.start : number +>c : import("tests/cases/conformance/jsdoc/ex").C +>start : number + +c.end +>c.end : number +>c : import("tests/cases/conformance/jsdoc/ex").C +>end : number + +/** @type {D} c */ +var d = new D() +>d : import("tests/cases/conformance/jsdoc/ex").C +>new D() : import("tests/cases/conformance/jsdoc/ex").C +>D : typeof import("tests/cases/conformance/jsdoc/ex").C + +d.start +>d.start : number +>d : import("tests/cases/conformance/jsdoc/ex").C +>start : number + +d.end +>d.end : number +>d : import("tests/cases/conformance/jsdoc/ex").C +>end : number + +=== tests/cases/conformance/jsdoc/ex.d.ts === +export class C { +>C : C + + start: number +>start : number + + end: number +>end : number +} + diff --git a/tests/baselines/reference/jsdocTypeReferenceToMergedClass.symbols b/tests/baselines/reference/jsdocTypeReferenceToMergedClass.symbols new file mode 100644 index 00000000000..86dcb536419 --- /dev/null +++ b/tests/baselines/reference/jsdocTypeReferenceToMergedClass.symbols @@ -0,0 +1,32 @@ +=== tests/cases/conformance/jsdoc/jsdocTypeReferenceToMergedClass.js === +// https://github.com/microsoft/TypeScript/issues/34685 + +var Workspace = {} +>Workspace : Symbol(Workspace, Decl(jsdocTypeReferenceToMergedClass.js, 2, 3), Decl(jsdocTypeReferenceToMergedClass.js, 5, 20), Decl(jsdocTypeReferenceToMergedClass.js, 7, 37)) + +/** @type {Workspace.Project} */ +var p; +>p : Symbol(p, Decl(jsdocTypeReferenceToMergedClass.js, 4, 3)) + +p.isServiceProject() +>p.isServiceProject : Symbol(isServiceProject, Decl(jsdocTypeReferenceToMergedClass.js, 8, 31)) +>p : Symbol(p, Decl(jsdocTypeReferenceToMergedClass.js, 4, 3)) +>isServiceProject : Symbol(isServiceProject, Decl(jsdocTypeReferenceToMergedClass.js, 8, 31)) + +Workspace.Project = function wp() { } +>Workspace.Project : Symbol(Workspace.Project, Decl(jsdocTypeReferenceToMergedClass.js, 5, 20), Decl(jsdocTypeReferenceToMergedClass.js, 8, 10)) +>Workspace : Symbol(Workspace, Decl(jsdocTypeReferenceToMergedClass.js, 2, 3), Decl(jsdocTypeReferenceToMergedClass.js, 5, 20), Decl(jsdocTypeReferenceToMergedClass.js, 7, 37)) +>Project : Symbol(Workspace.Project, Decl(jsdocTypeReferenceToMergedClass.js, 5, 20), Decl(jsdocTypeReferenceToMergedClass.js, 8, 10)) +>wp : Symbol(wp, Decl(jsdocTypeReferenceToMergedClass.js, 7, 19)) + +Workspace.Project.prototype = { +>Workspace.Project.prototype : Symbol(Workspace.Project.prototype, Decl(jsdocTypeReferenceToMergedClass.js, 7, 37)) +>Workspace.Project : Symbol(Workspace.Project, Decl(jsdocTypeReferenceToMergedClass.js, 5, 20), Decl(jsdocTypeReferenceToMergedClass.js, 8, 10)) +>Workspace : Symbol(Workspace, Decl(jsdocTypeReferenceToMergedClass.js, 2, 3), Decl(jsdocTypeReferenceToMergedClass.js, 5, 20), Decl(jsdocTypeReferenceToMergedClass.js, 7, 37)) +>Project : Symbol(Workspace.Project, Decl(jsdocTypeReferenceToMergedClass.js, 5, 20), Decl(jsdocTypeReferenceToMergedClass.js, 8, 10)) +>prototype : Symbol(Workspace.Project.prototype, Decl(jsdocTypeReferenceToMergedClass.js, 7, 37)) + + isServiceProject() {} +>isServiceProject : Symbol(isServiceProject, Decl(jsdocTypeReferenceToMergedClass.js, 8, 31)) +} + diff --git a/tests/baselines/reference/jsdocTypeReferenceToMergedClass.types b/tests/baselines/reference/jsdocTypeReferenceToMergedClass.types new file mode 100644 index 00000000000..3fd1661fa29 --- /dev/null +++ b/tests/baselines/reference/jsdocTypeReferenceToMergedClass.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/jsdoc/jsdocTypeReferenceToMergedClass.js === +// https://github.com/microsoft/TypeScript/issues/34685 + +var Workspace = {} +>Workspace : typeof Workspace +>{} : {} + +/** @type {Workspace.Project} */ +var p; +>p : wp + +p.isServiceProject() +>p.isServiceProject() : void +>p.isServiceProject : () => void +>p : wp +>isServiceProject : () => void + +Workspace.Project = function wp() { } +>Workspace.Project = function wp() { } : typeof wp +>Workspace.Project : typeof wp +>Workspace : typeof Workspace +>Project : typeof wp +>function wp() { } : typeof wp +>wp : typeof wp + +Workspace.Project.prototype = { +>Workspace.Project.prototype = { isServiceProject() {}} : { isServiceProject(): void; } +>Workspace.Project.prototype : { isServiceProject(): void; } +>Workspace.Project : typeof wp +>Workspace : typeof Workspace +>Project : typeof wp +>prototype : { isServiceProject(): void; } +>{ isServiceProject() {}} : { isServiceProject(): void; } + + isServiceProject() {} +>isServiceProject : () => void +} + diff --git a/tests/baselines/reference/lateBoundDestructuringImplicitAnyError.js b/tests/baselines/reference/lateBoundDestructuringImplicitAnyError.js index 61331a13564..0dac53806b8 100644 --- a/tests/baselines/reference/lateBoundDestructuringImplicitAnyError.js +++ b/tests/baselines/reference/lateBoundDestructuringImplicitAnyError.js @@ -30,26 +30,26 @@ void prop9; //// [lateBoundDestructuringImplicitAnyError.js] var named = "foo"; -var _a = named, prop = { prop: "foo" }[_a]; +var _a = { prop: "foo" }, _b = named, prop = _a[_b]; void prop; var numIndexed = null; var strIndexed = null; var numed = 6; var symed = Symbol(); var symed2 = Symbol(); -var _b = named, prop2 = numIndexed[_b]; +var _c = numIndexed, _d = named, prop2 = _c[_d]; void prop2; -var _c = numed, prop3 = numIndexed[_c]; +var _e = numIndexed, _f = numed, prop3 = _e[_f]; void prop3; -var _d = named, prop4 = strIndexed[_d]; +var _g = strIndexed, _h = named, prop4 = _g[_h]; void prop4; -var _e = numed, prop5 = strIndexed[_e]; +var _j = strIndexed, _k = numed, prop5 = _j[_k]; void prop5; -var _f = symed, prop6 = numIndexed[_f]; +var _l = numIndexed, _m = symed, prop6 = _l[_m]; void prop6; -var _g = symed, prop7 = strIndexed[_g]; +var _o = strIndexed, _p = symed, prop7 = _o[_p]; void prop7; -var _h = symed2, prop8 = numIndexed[_h]; +var _q = numIndexed, _r = symed2, prop8 = _q[_r]; void prop8; -var _j = symed2, prop9 = strIndexed[_j]; +var _s = strIndexed, _t = symed2, prop9 = _s[_t]; void prop9; diff --git a/tests/baselines/reference/mixedPropertyElementAccessAssignmentDeclaration.js b/tests/baselines/reference/mixedPropertyElementAccessAssignmentDeclaration.js new file mode 100644 index 00000000000..ee5b3d9e895 --- /dev/null +++ b/tests/baselines/reference/mixedPropertyElementAccessAssignmentDeclaration.js @@ -0,0 +1,10 @@ +//// [mixedPropertyElementAccessAssignmentDeclaration.ts] +// Should not crash: #34642 +var arr = []; +arr[0].prop[2] = {}; + + +//// [mixedPropertyElementAccessAssignmentDeclaration.js] +// Should not crash: #34642 +var arr = []; +arr[0].prop[2] = {}; diff --git a/tests/baselines/reference/mixedPropertyElementAccessAssignmentDeclaration.symbols b/tests/baselines/reference/mixedPropertyElementAccessAssignmentDeclaration.symbols new file mode 100644 index 00000000000..d414e979f17 --- /dev/null +++ b/tests/baselines/reference/mixedPropertyElementAccessAssignmentDeclaration.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/salsa/mixedPropertyElementAccessAssignmentDeclaration.ts === +// Should not crash: #34642 +var arr = []; +>arr : Symbol(arr, Decl(mixedPropertyElementAccessAssignmentDeclaration.ts, 1, 3)) + +arr[0].prop[2] = {}; +>arr : Symbol(arr, Decl(mixedPropertyElementAccessAssignmentDeclaration.ts, 1, 3)) + diff --git a/tests/baselines/reference/mixedPropertyElementAccessAssignmentDeclaration.types b/tests/baselines/reference/mixedPropertyElementAccessAssignmentDeclaration.types new file mode 100644 index 00000000000..18d20dfd936 --- /dev/null +++ b/tests/baselines/reference/mixedPropertyElementAccessAssignmentDeclaration.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/salsa/mixedPropertyElementAccessAssignmentDeclaration.ts === +// Should not crash: #34642 +var arr = []; +>arr : any[] +>[] : undefined[] + +arr[0].prop[2] = {}; +>arr[0].prop[2] = {} : {} +>arr[0].prop[2] : any +>arr[0].prop : any +>arr[0] : any +>arr : any[] +>0 : 0 +>prop : any +>2 : 2 +>{} : {} + diff --git a/tests/baselines/reference/nullishCoalescingOperator1.js b/tests/baselines/reference/nullishCoalescingOperator1.js index 87a149c1855..9b857a1473d 100644 --- a/tests/baselines/reference/nullishCoalescingOperator1.js +++ b/tests/baselines/reference/nullishCoalescingOperator1.js @@ -38,10 +38,36 @@ const cc4 = c4 ?? true; const dd1 = d1 ?? {b: 1}; const dd2 = d2 ?? {b: 1}; const dd3 = d3 ?? {b: 1}; -const dd4 = d4 ?? {b: 1}; +const dd4 = d4 ?? {b: 1}; + +// Repro from #34635 + +declare function foo(): void; + +const maybeBool = false; + +if (!(maybeBool ?? true)) { + foo(); +} + +if (maybeBool ?? true) { + foo(); +} +else { + foo(); +} + +if (false ?? true) { + foo(); +} +else { + foo(); +} + //// [nullishCoalescingOperator1.js] "use strict"; +var _a; var aa1 = (a1 !== null && a1 !== void 0 ? a1 : 'whatever'); var aa2 = (a2 !== null && a2 !== void 0 ? a2 : 'whatever'); var aa3 = (a3 !== null && a3 !== void 0 ? a3 : 'whatever'); @@ -58,3 +84,19 @@ var dd1 = (d1 !== null && d1 !== void 0 ? d1 : { b: 1 }); var dd2 = (d2 !== null && d2 !== void 0 ? d2 : { b: 1 }); var dd3 = (d3 !== null && d3 !== void 0 ? d3 : { b: 1 }); var dd4 = (d4 !== null && d4 !== void 0 ? d4 : { b: 1 }); +var maybeBool = false; +if (!((maybeBool !== null && maybeBool !== void 0 ? maybeBool : true))) { + foo(); +} +if ((maybeBool !== null && maybeBool !== void 0 ? maybeBool : true)) { + foo(); +} +else { + foo(); +} +if (_a = false, (_a !== null && _a !== void 0 ? _a : true)) { + foo(); +} +else { + foo(); +} diff --git a/tests/baselines/reference/nullishCoalescingOperator1.symbols b/tests/baselines/reference/nullishCoalescingOperator1.symbols index fb95dee5096..83bd5162280 100644 --- a/tests/baselines/reference/nullishCoalescingOperator1.symbols +++ b/tests/baselines/reference/nullishCoalescingOperator1.symbols @@ -123,3 +123,38 @@ const dd4 = d4 ?? {b: 1}; >d4 : Symbol(d4, Decl(nullishCoalescingOperator1.ts, 19, 13)) >b : Symbol(b, Decl(nullishCoalescingOperator1.ts, 39, 19)) +// Repro from #34635 + +declare function foo(): void; +>foo : Symbol(foo, Decl(nullishCoalescingOperator1.ts, 39, 25)) + +const maybeBool = false; +>maybeBool : Symbol(maybeBool, Decl(nullishCoalescingOperator1.ts, 45, 5)) + +if (!(maybeBool ?? true)) { +>maybeBool : Symbol(maybeBool, Decl(nullishCoalescingOperator1.ts, 45, 5)) + + foo(); +>foo : Symbol(foo, Decl(nullishCoalescingOperator1.ts, 39, 25)) +} + +if (maybeBool ?? true) { +>maybeBool : Symbol(maybeBool, Decl(nullishCoalescingOperator1.ts, 45, 5)) + + foo(); +>foo : Symbol(foo, Decl(nullishCoalescingOperator1.ts, 39, 25)) +} +else { + foo(); +>foo : Symbol(foo, Decl(nullishCoalescingOperator1.ts, 39, 25)) +} + +if (false ?? true) { + foo(); +>foo : Symbol(foo, Decl(nullishCoalescingOperator1.ts, 39, 25)) +} +else { + foo(); +>foo : Symbol(foo, Decl(nullishCoalescingOperator1.ts, 39, 25)) +} + diff --git a/tests/baselines/reference/nullishCoalescingOperator1.types b/tests/baselines/reference/nullishCoalescingOperator1.types index 0e800540ee8..81aa6a7404c 100644 --- a/tests/baselines/reference/nullishCoalescingOperator1.types +++ b/tests/baselines/reference/nullishCoalescingOperator1.types @@ -170,3 +170,54 @@ const dd4 = d4 ?? {b: 1}; >b : number >1 : 1 +// Repro from #34635 + +declare function foo(): void; +>foo : () => void + +const maybeBool = false; +>maybeBool : false +>false : false + +if (!(maybeBool ?? true)) { +>!(maybeBool ?? true) : true +>(maybeBool ?? true) : false +>maybeBool ?? true : false +>maybeBool : false +>true : true + + foo(); +>foo() : void +>foo : () => void +} + +if (maybeBool ?? true) { +>maybeBool ?? true : false +>maybeBool : false +>true : true + + foo(); +>foo() : void +>foo : () => void +} +else { + foo(); +>foo() : void +>foo : () => void +} + +if (false ?? true) { +>false ?? true : false +>false : false +>true : true + + foo(); +>foo() : void +>foo : () => void +} +else { + foo(); +>foo() : void +>foo : () => void +} + diff --git a/tests/baselines/reference/prototypePropertyAssignmentMergedTypeReference.symbols b/tests/baselines/reference/prototypePropertyAssignmentMergedTypeReference.symbols new file mode 100644 index 00000000000..7e3f503c7bc --- /dev/null +++ b/tests/baselines/reference/prototypePropertyAssignmentMergedTypeReference.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/salsa/prototypePropertyAssignmentMergedTypeReference.js === +// https://github.com/microsoft/TypeScript/issues/33993 +var f = function() { +>f : Symbol(f, Decl(prototypePropertyAssignmentMergedTypeReference.js, 1, 3)) + + return 12; +}; + +f.prototype.a = "a"; +>f.prototype : Symbol(f.a, Decl(prototypePropertyAssignmentMergedTypeReference.js, 3, 2)) +>f : Symbol(f, Decl(prototypePropertyAssignmentMergedTypeReference.js, 1, 3)) +>prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --)) +>a : Symbol(f.a, Decl(prototypePropertyAssignmentMergedTypeReference.js, 3, 2)) + +/** @type {new () => f} */ +var x = f; +>x : Symbol(x, Decl(prototypePropertyAssignmentMergedTypeReference.js, 8, 3)) +>f : Symbol(f, Decl(prototypePropertyAssignmentMergedTypeReference.js, 1, 3)) + + diff --git a/tests/baselines/reference/prototypePropertyAssignmentMergedTypeReference.types b/tests/baselines/reference/prototypePropertyAssignmentMergedTypeReference.types new file mode 100644 index 00000000000..2fa4bcee43b --- /dev/null +++ b/tests/baselines/reference/prototypePropertyAssignmentMergedTypeReference.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/salsa/prototypePropertyAssignmentMergedTypeReference.js === +// https://github.com/microsoft/TypeScript/issues/33993 +var f = function() { +>f : typeof f +>function() { return 12;} : typeof f + + return 12; +>12 : 12 + +}; + +f.prototype.a = "a"; +>f.prototype.a = "a" : "a" +>f.prototype.a : any +>f.prototype : any +>f : typeof f +>prototype : any +>a : any +>"a" : "a" + +/** @type {new () => f} */ +var x = f; +>x : new () => f +>f : typeof f + + diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.transformUpdateModuleMember.js b/tests/baselines/reference/transformApi/transformsCorrectly.transformUpdateModuleMember.js new file mode 100644 index 00000000000..4dad11f737c --- /dev/null +++ b/tests/baselines/reference/transformApi/transformsCorrectly.transformUpdateModuleMember.js @@ -0,0 +1,5 @@ +var MyModule; +(function (MyModule) { + const newName = 1; + function foo(param) { } +})(MyModule || (MyModule = {})); diff --git a/tests/baselines/reference/tsxTypeArgumentResolution.errors.txt b/tests/baselines/reference/tsxTypeArgumentResolution.errors.txt index 7b429f073dd..cf6dedd16dd 100644 --- a/tests/baselines/reference/tsxTypeArgumentResolution.errors.txt +++ b/tests/baselines/reference/tsxTypeArgumentResolution.errors.txt @@ -3,9 +3,7 @@ tests/cases/conformance/jsx/file.tsx(18,26): error TS2322: Type 'number' is not tests/cases/conformance/jsx/file.tsx(20,13): error TS2558: Expected 1 type arguments, but got 2. tests/cases/conformance/jsx/file.tsx(22,13): error TS2558: Expected 1 type arguments, but got 2. tests/cases/conformance/jsx/file.tsx(24,12): error TS1099: Type argument list cannot be empty. -tests/cases/conformance/jsx/file.tsx(24,13): error TS2558: Expected 1 type arguments, but got 0. tests/cases/conformance/jsx/file.tsx(26,12): error TS1099: Type argument list cannot be empty. -tests/cases/conformance/jsx/file.tsx(26,13): error TS2558: Expected 1 type arguments, but got 0. tests/cases/conformance/jsx/file.tsx(39,14): error TS2344: Type 'Prop' does not satisfy the constraint '{ a: string; }'. Types of property 'a' are incompatible. Type 'number' is not assignable to type 'string'. @@ -16,7 +14,7 @@ tests/cases/conformance/jsx/file.tsx(51,47): error TS2322: Type 'string' is not tests/cases/conformance/jsx/file.tsx(53,47): error TS2322: Type 'string' is not assignable to type 'number'. -==== tests/cases/conformance/jsx/file.tsx (14 errors) ==== +==== tests/cases/conformance/jsx/file.tsx (12 errors) ==== import React = require('react'); interface Prop { @@ -53,14 +51,10 @@ tests/cases/conformance/jsx/file.tsx(53,47): error TS2322: Type 'string' is not x = a={10} b="hi" />; // error ~~ !!! error TS1099: Type argument list cannot be empty. - -!!! error TS2558: Expected 1 type arguments, but got 0. x = a={10} b="hi">; // error ~~ !!! error TS1099: Type argument list cannot be empty. - -!!! error TS2558: Expected 1 type arguments, but got 0. x= /> // OK diff --git a/tests/baselines/reference/typeAssertionsWithIntersectionTypes01.errors.txt b/tests/baselines/reference/typeAssertionsWithIntersectionTypes01.errors.txt index 29a7f49d2db..d7df5037490 100644 --- a/tests/baselines/reference/typeAssertionsWithIntersectionTypes01.errors.txt +++ b/tests/baselines/reference/typeAssertionsWithIntersectionTypes01.errors.txt @@ -1,6 +1,7 @@ tests/cases/conformance/types/typeRelationships/comparable/typeAssertionsWithIntersectionTypes01.ts(17,9): error TS2352: Conversion of type 'I2' to type 'I1 & I3' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Property 'p3' is missing in type 'I2' but required in type 'I3'. tests/cases/conformance/types/typeRelationships/comparable/typeAssertionsWithIntersectionTypes01.ts(18,9): error TS2352: Conversion of type 'I2' to type 'I3' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'p3' is missing in type 'I2' but required in type 'I3'. ==== tests/cases/conformance/types/typeRelationships/comparable/typeAssertionsWithIntersectionTypes01.ts (2 errors) ==== @@ -28,6 +29,8 @@ tests/cases/conformance/types/typeRelationships/comparable/typeAssertionsWithInt var b = z; ~~~~~ !!! error TS2352: Conversion of type 'I2' to type 'I3' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: Property 'p3' is missing in type 'I2' but required in type 'I3'. +!!! related TS2728 tests/cases/conformance/types/typeRelationships/comparable/typeAssertionsWithIntersectionTypes01.ts:10:5: 'p3' is declared here. var c = z; var d = y; \ No newline at end of file diff --git a/tests/baselines/reference/unionAndIntersectionInference3.js b/tests/baselines/reference/unionAndIntersectionInference3.js index 415d98220a5..12ce5a9a19b 100644 --- a/tests/baselines/reference/unionAndIntersectionInference3.js +++ b/tests/baselines/reference/unionAndIntersectionInference3.js @@ -52,10 +52,43 @@ let y1 = foo1(sx); // string let x2 = foo2(sa); // unknown let y2 = foo2(sx); // { extra: number } + +// Repro from #33490 + +declare class Component

{ props: P } + +export type ComponentClass

= new (props: P) => Component

; +export type FunctionComponent

= (props: P) => null; + +export type ComponentType

= FunctionComponent

| ComponentClass

; + +export interface RouteComponentProps { route: string } + +declare function withRouter< + P extends RouteComponentProps, + C extends ComponentType

+>( + component: C & ComponentType

+): ComponentClass>; + +interface Props extends RouteComponentProps { username: string } + +declare const MyComponent: ComponentType; + +withRouter(MyComponent); + +// Repro from #33490 + +type AB = { a: T } | { b: T }; + +// T & AB normalizes to T & { a: U } | T & { b: U } below +declare function foo(obj: T & AB): [T, U]; +declare let ab: AB; + +let z = foo(ab); // [AB, string] //// [unionAndIntersectionInference3.js] -"use strict"; // Repro from #30720 concatMaybe([1, 2, 3], 4); // Repros from #32247 @@ -70,3 +103,5 @@ let x1 = foo1(sa); // string let y1 = foo1(sx); // string let x2 = foo2(sa); // unknown let y2 = foo2(sx); // { extra: number } +withRouter(MyComponent); +let z = foo(ab); // [AB, string] diff --git a/tests/baselines/reference/unionAndIntersectionInference3.symbols b/tests/baselines/reference/unionAndIntersectionInference3.symbols index 1d237951b4f..43079f9e8a9 100644 --- a/tests/baselines/reference/unionAndIntersectionInference3.symbols +++ b/tests/baselines/reference/unionAndIntersectionInference3.symbols @@ -205,3 +205,107 @@ let y2 = foo2(sx); // { extra: number } >foo2 : Symbol(foo2, Decl(unionAndIntersectionInference3.ts, 42, 57)) >sx : Symbol(sx, Decl(unionAndIntersectionInference3.ts, 46, 11)) +// Repro from #33490 + +declare class Component

{ props: P } +>Component : Symbol(Component, Decl(unionAndIntersectionInference3.ts, 52, 18)) +>P : Symbol(P, Decl(unionAndIntersectionInference3.ts, 56, 24)) +>props : Symbol(Component.props, Decl(unionAndIntersectionInference3.ts, 56, 28)) +>P : Symbol(P, Decl(unionAndIntersectionInference3.ts, 56, 24)) + +export type ComponentClass

= new (props: P) => Component

; +>ComponentClass : Symbol(ComponentClass, Decl(unionAndIntersectionInference3.ts, 56, 39)) +>P : Symbol(P, Decl(unionAndIntersectionInference3.ts, 58, 27)) +>props : Symbol(props, Decl(unionAndIntersectionInference3.ts, 58, 37)) +>P : Symbol(P, Decl(unionAndIntersectionInference3.ts, 58, 27)) +>Component : Symbol(Component, Decl(unionAndIntersectionInference3.ts, 52, 18)) +>P : Symbol(P, Decl(unionAndIntersectionInference3.ts, 58, 27)) + +export type FunctionComponent

= (props: P) => null; +>FunctionComponent : Symbol(FunctionComponent, Decl(unionAndIntersectionInference3.ts, 58, 63)) +>P : Symbol(P, Decl(unionAndIntersectionInference3.ts, 59, 30)) +>props : Symbol(props, Decl(unionAndIntersectionInference3.ts, 59, 36)) +>P : Symbol(P, Decl(unionAndIntersectionInference3.ts, 59, 30)) + +export type ComponentType

= FunctionComponent

| ComponentClass

; +>ComponentType : Symbol(ComponentType, Decl(unionAndIntersectionInference3.ts, 59, 54)) +>P : Symbol(P, Decl(unionAndIntersectionInference3.ts, 61, 26)) +>FunctionComponent : Symbol(FunctionComponent, Decl(unionAndIntersectionInference3.ts, 58, 63)) +>P : Symbol(P, Decl(unionAndIntersectionInference3.ts, 61, 26)) +>ComponentClass : Symbol(ComponentClass, Decl(unionAndIntersectionInference3.ts, 56, 39)) +>P : Symbol(P, Decl(unionAndIntersectionInference3.ts, 61, 26)) + +export interface RouteComponentProps { route: string } +>RouteComponentProps : Symbol(RouteComponentProps, Decl(unionAndIntersectionInference3.ts, 61, 72)) +>route : Symbol(RouteComponentProps.route, Decl(unionAndIntersectionInference3.ts, 63, 38)) + +declare function withRouter< +>withRouter : Symbol(withRouter, Decl(unionAndIntersectionInference3.ts, 63, 54)) + + P extends RouteComponentProps, +>P : Symbol(P, Decl(unionAndIntersectionInference3.ts, 65, 28)) +>RouteComponentProps : Symbol(RouteComponentProps, Decl(unionAndIntersectionInference3.ts, 61, 72)) + + C extends ComponentType

+>C : Symbol(C, Decl(unionAndIntersectionInference3.ts, 66, 32)) +>ComponentType : Symbol(ComponentType, Decl(unionAndIntersectionInference3.ts, 59, 54)) +>P : Symbol(P, Decl(unionAndIntersectionInference3.ts, 65, 28)) + +>( + component: C & ComponentType

+>component : Symbol(component, Decl(unionAndIntersectionInference3.ts, 68, 2)) +>C : Symbol(C, Decl(unionAndIntersectionInference3.ts, 66, 32)) +>ComponentType : Symbol(ComponentType, Decl(unionAndIntersectionInference3.ts, 59, 54)) +>P : Symbol(P, Decl(unionAndIntersectionInference3.ts, 65, 28)) + +): ComponentClass>; +>ComponentClass : Symbol(ComponentClass, Decl(unionAndIntersectionInference3.ts, 56, 39)) +>Omit : Symbol(Omit, Decl(lib.es5.d.ts, --, --)) +>P : Symbol(P, Decl(unionAndIntersectionInference3.ts, 65, 28)) +>RouteComponentProps : Symbol(RouteComponentProps, Decl(unionAndIntersectionInference3.ts, 61, 72)) + +interface Props extends RouteComponentProps { username: string } +>Props : Symbol(Props, Decl(unionAndIntersectionInference3.ts, 70, 54)) +>RouteComponentProps : Symbol(RouteComponentProps, Decl(unionAndIntersectionInference3.ts, 61, 72)) +>username : Symbol(Props.username, Decl(unionAndIntersectionInference3.ts, 72, 45)) + +declare const MyComponent: ComponentType; +>MyComponent : Symbol(MyComponent, Decl(unionAndIntersectionInference3.ts, 74, 13)) +>ComponentType : Symbol(ComponentType, Decl(unionAndIntersectionInference3.ts, 59, 54)) +>Props : Symbol(Props, Decl(unionAndIntersectionInference3.ts, 70, 54)) + +withRouter(MyComponent); +>withRouter : Symbol(withRouter, Decl(unionAndIntersectionInference3.ts, 63, 54)) +>MyComponent : Symbol(MyComponent, Decl(unionAndIntersectionInference3.ts, 74, 13)) + +// Repro from #33490 + +type AB = { a: T } | { b: T }; +>AB : Symbol(AB, Decl(unionAndIntersectionInference3.ts, 76, 24)) +>T : Symbol(T, Decl(unionAndIntersectionInference3.ts, 80, 8)) +>a : Symbol(a, Decl(unionAndIntersectionInference3.ts, 80, 14)) +>T : Symbol(T, Decl(unionAndIntersectionInference3.ts, 80, 8)) +>b : Symbol(b, Decl(unionAndIntersectionInference3.ts, 80, 25)) +>T : Symbol(T, Decl(unionAndIntersectionInference3.ts, 80, 8)) + +// T & AB normalizes to T & { a: U } | T & { b: U } below +declare function foo(obj: T & AB): [T, U]; +>foo : Symbol(foo, Decl(unionAndIntersectionInference3.ts, 80, 33)) +>T : Symbol(T, Decl(unionAndIntersectionInference3.ts, 83, 21)) +>U : Symbol(U, Decl(unionAndIntersectionInference3.ts, 83, 23)) +>obj : Symbol(obj, Decl(unionAndIntersectionInference3.ts, 83, 27)) +>T : Symbol(T, Decl(unionAndIntersectionInference3.ts, 83, 21)) +>AB : Symbol(AB, Decl(unionAndIntersectionInference3.ts, 76, 24)) +>U : Symbol(U, Decl(unionAndIntersectionInference3.ts, 83, 23)) +>T : Symbol(T, Decl(unionAndIntersectionInference3.ts, 83, 21)) +>U : Symbol(U, Decl(unionAndIntersectionInference3.ts, 83, 23)) + +declare let ab: AB; +>ab : Symbol(ab, Decl(unionAndIntersectionInference3.ts, 84, 11)) +>AB : Symbol(AB, Decl(unionAndIntersectionInference3.ts, 76, 24)) + +let z = foo(ab); // [AB, string] +>z : Symbol(z, Decl(unionAndIntersectionInference3.ts, 86, 3)) +>foo : Symbol(foo, Decl(unionAndIntersectionInference3.ts, 80, 33)) +>ab : Symbol(ab, Decl(unionAndIntersectionInference3.ts, 84, 11)) + diff --git a/tests/baselines/reference/unionAndIntersectionInference3.types b/tests/baselines/reference/unionAndIntersectionInference3.types index fb507474321..05cb9368f83 100644 --- a/tests/baselines/reference/unionAndIntersectionInference3.types +++ b/tests/baselines/reference/unionAndIntersectionInference3.types @@ -135,3 +135,67 @@ let y2 = foo2(sx); // { extra: number } >foo2 : (obj: string[] & T) => T >sx : string[] & { extra: number; } +// Repro from #33490 + +declare class Component

{ props: P } +>Component : Component

+>props : P + +export type ComponentClass

= new (props: P) => Component

; +>ComponentClass : ComponentClass

+>props : P + +export type FunctionComponent

= (props: P) => null; +>FunctionComponent : FunctionComponent

+>props : P +>null : null + +export type ComponentType

= FunctionComponent

| ComponentClass

; +>ComponentType : ComponentType

+ +export interface RouteComponentProps { route: string } +>route : string + +declare function withRouter< +>withRouter :

>(component: (C & FunctionComponent

) | (C & ComponentClass

)) => ComponentClass>> + + P extends RouteComponentProps, + C extends ComponentType

+>( + component: C & ComponentType

+>component : (C & FunctionComponent

) | (C & ComponentClass

) + +): ComponentClass>; + +interface Props extends RouteComponentProps { username: string } +>username : string + +declare const MyComponent: ComponentType; +>MyComponent : ComponentType + +withRouter(MyComponent); +>withRouter(MyComponent) : ComponentClass> +>withRouter :

>(component: (C & FunctionComponent

) | (C & ComponentClass

)) => ComponentClass>> +>MyComponent : ComponentType + +// Repro from #33490 + +type AB = { a: T } | { b: T }; +>AB : AB +>a : T +>b : T + +// T & AB normalizes to T & { a: U } | T & { b: U } below +declare function foo(obj: T & AB): [T, U]; +>foo : (obj: (T & { a: U; }) | (T & { b: U; })) => [T, U] +>obj : (T & { a: U; }) | (T & { b: U; }) + +declare let ab: AB; +>ab : AB + +let z = foo(ab); // [AB, string] +>z : [AB, string] +>foo(ab) : [AB, string] +>foo : (obj: (T & { a: U; }) | (T & { b: U; })) => [T, U] +>ab : AB + diff --git a/tests/baselines/reference/unionThisTypeInFunctions.errors.txt b/tests/baselines/reference/unionThisTypeInFunctions.errors.txt index db03a5426fb..f4f0377a087 100644 --- a/tests/baselines/reference/unionThisTypeInFunctions.errors.txt +++ b/tests/baselines/reference/unionThisTypeInFunctions.errors.txt @@ -5,8 +5,12 @@ tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts(10,5): error Type '(this: Real, n: number) => void' is not assignable to type '(this: Fake, n: number) => void'. The 'this' types of each signature are incompatible. Type 'Fake' is not assignable to type 'Real'. - Types of property 'data' are incompatible. - Type 'number' is not assignable to type 'string'. + Types of property 'method' are incompatible. + Type '(this: Fake, n: number) => void' is not assignable to type '(this: Real, n: number) => void'. + The 'this' types of each signature are incompatible. + Type 'Real' is not assignable to type 'Fake'. + Types of property 'data' are incompatible. + Type 'string' is not assignable to type 'number'. ==== tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts (1 errors) ==== @@ -28,7 +32,11 @@ tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts(10,5): error !!! error TS2684: Type '(this: Real, n: number) => void' is not assignable to type '(this: Fake, n: number) => void'. !!! error TS2684: The 'this' types of each signature are incompatible. !!! error TS2684: Type 'Fake' is not assignable to type 'Real'. -!!! error TS2684: Types of property 'data' are incompatible. -!!! error TS2684: Type 'number' is not assignable to type 'string'. +!!! error TS2684: Types of property 'method' are incompatible. +!!! error TS2684: Type '(this: Fake, n: number) => void' is not assignable to type '(this: Real, n: number) => void'. +!!! error TS2684: The 'this' types of each signature are incompatible. +!!! error TS2684: Type 'Real' is not assignable to type 'Fake'. +!!! error TS2684: Types of property 'data' are incompatible. +!!! error TS2684: Type 'string' is not assignable to type 'number'. } \ No newline at end of file diff --git a/tests/baselines/reference/user/TypeScript-React-Native-Starter.log b/tests/baselines/reference/user/TypeScript-React-Native-Starter.log index 7741454bfa0..b1e05a3af26 100644 --- a/tests/baselines/reference/user/TypeScript-React-Native-Starter.log +++ b/tests/baselines/reference/user/TypeScript-React-Native-Starter.log @@ -3,7 +3,7 @@ Standard output: node_modules/@types/react-native/index.d.ts(3425,42): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. node_modules/@types/react-native/index.d.ts(3438,42): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. node_modules/@types/react-native/index.d.ts(8745,18): error TS2717: Subsequent property declarations must have the same type. Property 'geolocation' must be of type 'Geolocation', but here has type 'GeolocationStatic'. -node_modules/@types/react/index.d.ts(373,23): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. +node_modules/@types/react/index.d.ts(386,23): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. diff --git a/tests/baselines/reference/user/axios-src.log b/tests/baselines/reference/user/axios-src.log index 472cb6dd8e9..b9c1388292a 100644 --- a/tests/baselines/reference/user/axios-src.log +++ b/tests/baselines/reference/user/axios-src.log @@ -14,8 +14,8 @@ lib/adapters/xhr.js(64,7): error TS2322: Type 'null' is not assignable to type ' lib/adapters/xhr.js(76,7): error TS2322: Type 'null' is not assignable to type 'XMLHttpRequest'. lib/adapters/xhr.js(83,51): error TS2345: Argument of type 'null' is not assignable to parameter of type 'string | undefined'. lib/adapters/xhr.js(86,7): error TS2322: Type 'null' is not assignable to type 'XMLHttpRequest'. -lib/adapters/xhr.js(95,7): error TS2322: Type 'null' is not assignable to type 'XMLHttpRequest'. -lib/adapters/xhr.js(165,9): error TS2322: Type 'null' is not assignable to type 'XMLHttpRequest'. +lib/adapters/xhr.js(99,7): error TS2322: Type 'null' is not assignable to type 'XMLHttpRequest'. +lib/adapters/xhr.js(169,9): error TS2322: Type 'null' is not assignable to type 'XMLHttpRequest'. lib/axios.js(23,9): error TS2554: Expected 3 arguments, but got 2. lib/axios.js(25,3): error TS2739: Type '(...args: any[]) => any' is missing the following properties from type 'Axios': defaults, interceptors, request, getUri lib/axios.js(32,7): error TS2339: Property 'Axios' does not exist on type 'Axios'. diff --git a/tests/baselines/reference/user/bluebird.log b/tests/baselines/reference/user/bluebird.log index 7f91d19ebd4..4026f5c7f0f 100644 --- a/tests/baselines/reference/user/bluebird.log +++ b/tests/baselines/reference/user/bluebird.log @@ -3,90 +3,23 @@ Standard output: node_modules/bluebird/js/release/assert.js(11,30): error TS2339: Property 'constructor$' does not exist on type 'Error'. node_modules/bluebird/js/release/bluebird.js(5,15): error TS2367: This condition will always return 'false' since the types 'PromiseConstructor' and 'typeof Promise' have no overlap. node_modules/bluebird/js/release/bluebird.js(10,10): error TS2339: Property 'noConflict' does not exist on type 'typeof Promise'. -node_modules/bluebird/js/release/call_get.js(11,24): error TS2339: Property 'canEvaluate' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/call_get.js(12,25): error TS2339: Property 'isIdentifier' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/call_get.js(73,40): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/call_get.js(74,27): error TS2554: Expected 0 arguments, but got 1. -node_modules/bluebird/js/release/cancel.js(4,21): error TS2339: Property 'tryCatch' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/cancel.js(5,21): error TS2339: Property 'errorObj' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/cancel.js(93,14): error TS2339: Property 'isArray' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/catch_filter.js(5,21): error TS2339: Property 'tryCatch' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/catch_filter.js(6,21): error TS2339: Property 'errorObj' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/catch_filter.js(26,29): error TS2339: Property 'isObject' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(8,27): error TS2339: Property 'canAttachTrace' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(19,25): error TS2339: Property 'env' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(21,31): error TS2339: Property 'env' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(22,31): error TS2339: Property 'env' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(24,24): error TS2339: Property 'env' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(25,24): error TS2339: Property 'env' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(27,31): error TS2339: Property 'env' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(28,24): error TS2339: Property 'env' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(30,29): error TS2339: Property 'env' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(31,25): error TS2339: Property 'env' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(156,39): error TS2339: Property 'contextBind' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(161,38): error TS2339: Property 'contextBind' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(199,28): error TS2339: Property 'global' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(200,18): error TS2339: Property 'global' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(204,18): error TS2339: Property 'global' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(209,28): error TS2339: Property 'global' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(210,18): error TS2339: Property 'global' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(214,18): error TS2339: Property 'global' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(225,30): error TS2339: Property 'global' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(230,26): error TS2339: Property 'global' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(236,18): error TS2339: Property 'global' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/debuggability.js(252,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'event' must be of type 'CustomEvent', but here has type 'Event'. -node_modules/bluebird/js/release/debuggability.js(253,18): error TS2339: Property 'global' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/debuggability.js(259,26): error TS2339: Property 'detail' does not exist on type 'Event'. -node_modules/bluebird/js/release/debuggability.js(267,18): error TS2339: Property 'global' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(283,14): error TS2339: Property 'isNode' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/debuggability.js(285,48): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '["multipleResolves", MultipleResolveListener]'. -node_modules/bluebird/js/release/debuggability.js(288,19): error TS2339: Property 'global' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(295,31): error TS2339: Property 'global' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(297,31): error TS2339: Property 'global' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/debuggability.js(328,56): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'any[]'. Type 'IArguments' is missing the following properties from type 'any[]': pop, push, concat, join, and 26 more. -node_modules/bluebird/js/release/debuggability.js(360,18): error TS2339: Property 'isObject' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(436,51): error TS2554: Expected 0 arguments, but got 1. -node_modules/bluebird/js/release/debuggability.js(450,18): error TS2339: Property 'isArray' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(522,18): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(524,18): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/debuggability.js(589,19): error TS2350: Only a void function can be called with the 'new' keyword. node_modules/bluebird/js/release/debuggability.js(660,59): error TS2554: Expected 0 arguments, but got 1. -node_modules/bluebird/js/release/debuggability.js(699,18): error TS2339: Property 'isObject' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(746,46): error TS2554: Expected 0 arguments, but got 1. node_modules/bluebird/js/release/debuggability.js(834,5): error TS2721: Cannot invoke an object which is possibly 'null'. -node_modules/bluebird/js/release/debuggability.js(837,6): error TS2339: Property 'inherits' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/debuggability.js(852,30): error TS2339: Property 'stack' does not exist on type 'CapturedTrace'. node_modules/bluebird/js/release/debuggability.js(858,37): error TS2339: Property 'stack' does not exist on type 'CapturedTrace'. node_modules/bluebird/js/release/debuggability.js(897,38): error TS2339: Property 'stack' does not exist on type 'CapturedTrace'. -node_modules/bluebird/js/release/debuggability.js(902,10): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(903,10): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/debuggability.js(977,4): error TS2554: Expected 0 arguments, but got 1. -node_modules/bluebird/js/release/debuggability.js(983,14): error TS2339: Property 'isNode' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(988,22): error TS2339: Property 'isNode' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/errors.js(5,21): error TS2339: Property 'inherits' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/errors.js(6,30): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/errors.js(10,49): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/finally.js(5,21): error TS2339: Property 'errorObj' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/finally.js(126,22): error TS2339: Property 'isObject' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/finally.js(131,61): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/generators.js(11,21): error TS2339: Property 'errorObj' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/generators.js(12,21): error TS2339: Property 'tryCatch' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/generators.js(55,6): error TS2339: Property 'inherits' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/generators.js(159,21): error TS2350: Only a void function can be called with the 'new' keyword. node_modules/bluebird/js/release/generators.js(190,15): error TS2350: Only a void function can be called with the 'new' keyword. node_modules/bluebird/js/release/generators.js(208,15): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/generators.js(208,68): error TS2339: Property 'classString' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/generators.js(220,16): error TS2554: Expected 0 arguments, but got 1. -node_modules/bluebird/js/release/join.js(5,24): error TS2339: Property 'canEvaluate' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/join.js(6,21): error TS2339: Property 'tryCatch' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/join.js(7,21): error TS2339: Property 'errorObj' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/join.js(150,42): error TS2339: Property 'contextBind' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/map.js(9,21): error TS2339: Property 'tryCatch' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/map.js(10,21): error TS2339: Property 'errorObj' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/map.js(17,27): error TS2339: Property 'contextBind' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/map.js(25,14): error TS2339: Property 'isArray' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/map.js(34,6): error TS2339: Property 'inherits' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/map.js(37,10): error TS2551: Property '_init$' does not exist on type 'MappingPromiseArray'. Did you mean '_init'? node_modules/bluebird/js/release/map.js(43,23): error TS2339: Property '_values' does not exist on type 'MappingPromiseArray'. node_modules/bluebird/js/release/map.js(44,23): error TS2339: Property 'length' does not exist on type 'MappingPromiseArray'. @@ -101,77 +34,40 @@ node_modules/bluebird/js/release/map.js(108,18): error TS2339: Property '_resolv node_modules/bluebird/js/release/map.js(118,23): error TS2339: Property '_values' does not exist on type 'MappingPromiseArray'. node_modules/bluebird/js/release/map.js(120,18): error TS2339: Property '_isResolved' does not exist on type 'MappingPromiseArray'. node_modules/bluebird/js/release/map.js(134,10): error TS2339: Property '_resolve' does not exist on type 'MappingPromiseArray'. -node_modules/bluebird/js/release/map.js(143,68): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/map.js(152,42): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/map.js(158,35): error TS2339: Property 'classString' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/map.js(163,66): error TS2339: Property 'promise' does not exist on type 'MappingPromiseArray'. -node_modules/bluebird/js/release/method.js(5,21): error TS2339: Property 'tryCatch' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/method.js(9,76): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/method.js(26,68): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/method.js(36,22): error TS2339: Property 'isArray' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/method.js(49,24): error TS2339: Property 'errorObj' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/nodeback.js(3,29): error TS2339: Property 'maybeWrapAsError' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/nodeback.js(30,10): error TS2339: Property 'markAsOriginatingFromRejection' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/nodeify.js(5,21): error TS2339: Property 'tryCatch' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/nodeify.js(6,21): error TS2339: Property 'errorObj' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/nodeify.js(10,15): error TS2339: Property 'isArray' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/nodeify.js(32,19): error TS2339: Property 'cause' does not exist on type 'Error'. node_modules/bluebird/js/release/promise.js(4,12): error TS2350: Only a void function can be called with the 'new' keyword. node_modules/bluebird/js/release/promise.js(7,24): error TS2339: Property 'PromiseInspection' does not exist on type 'typeof Promise'. node_modules/bluebird/js/release/promise.js(10,27): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/promise.js(15,6): error TS2339: Property 'setReflectHandler' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(33,26): error TS2339: Property 'isNode' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(38,20): error TS2531: Object is possibly 'null'. -node_modules/bluebird/js/release/promise.js(41,23): error TS2339: Property 'isNode' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(42,6): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(44,5): error TS2322: Type '() => { domain: Domain | null; async: AsyncResource; }' is not assignable to type '(() => null) | (() => { domain: Domain | null; async: null; })'. Type '() => { domain: Domain | null; async: AsyncResource; }' is not assignable to type '() => null'. Type '{ domain: NodeJS.Domain | null; async: AsyncResource; }' is not assignable to type 'null'. -node_modules/bluebird/js/release/promise.js(45,10): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(49,10): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(82,21): error TS2339: Property 'errorObj' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(83,21): error TS2339: Property 'tryCatch' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(86,15): error TS2350: Only a void function can be called with the 'new' keyword. node_modules/bluebird/js/release/promise.js(89,15): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/promise.js(89,68): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(119,22): error TS2339: Property 'isObject' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(123,59): error TS2339: Property 'classString' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(130,19): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/promise.js(131,60): error TS2554: Expected 0 arguments, but got 1. -node_modules/bluebird/js/release/promise.js(148,22): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(150,32): error TS2339: Property 'classString' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(152,14): error TS2339: Property '_warn' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(165,68): error TS2339: Property 'classString' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(177,14): error TS2551: Property 'isFulfilled' does not exist on type 'Promise'. Did you mean '_setFulfilled'? node_modules/bluebird/js/release/promise.js(178,37): error TS2339: Property 'value' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(180,21): error TS2551: Property 'isRejected' does not exist on type 'Promise'. Did you mean '_setRejected'? node_modules/bluebird/js/release/promise.js(181,36): error TS2339: Property 'reason' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(189,14): error TS2339: Property '_warn' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(195,29): error TS2339: Property 'originatesFromRejection' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(206,9): error TS2339: Property '_captureStackTrace' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(236,9): error TS2339: Property '_captureStackTrace' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(243,15): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/promise.js(243,68): error TS2339: Property 'classString' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(267,63): error TS2339: Property '_boundTo' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(270,14): error TS2339: Property '_fireEvent' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(282,20): error TS2339: Property '_unsetRejectionIsUnhandled' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(286,20): error TS2339: Property '_attachExtraTrace' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(291,27): error TS2339: Property 'contextBind' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(323,10): error TS2339: Property '_fireEvent' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(328,10): error TS2339: Property '_fireEvent' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(333,10): error TS2339: Property '_fireEvent' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(350,10): error TS2339: Property '_fireEvent' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(375,42): error TS2339: Property '_isBound' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(435,46): error TS2339: Property 'contextBind' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(438,44): error TS2339: Property 'contextBind' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(446,22): error TS2339: Property 'contextBind' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(450,22): error TS2339: Property 'contextBind' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(468,26): error TS2339: Property '_propagateFrom' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(489,31): error TS2339: Property '_value' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(491,30): error TS2339: Property '_reason' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(494,17): error TS2339: Property '_attachExtraTrace' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(501,22): error TS2339: Property 'ensureErrorObject' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(505,18): error TS2339: Property 'classString' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(506,14): error TS2339: Property '_warn' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(508,10): error TS2339: Property '_attachExtraTrace' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(515,10): error TS2339: Property '_captureStackTrace' does not exist on type 'Promise'. @@ -179,55 +75,25 @@ node_modules/bluebird/js/release/promise.js(516,10): error TS2339: Property '_pu node_modules/bluebird/js/release/promise.js(518,18): error TS2339: Property '_execute' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(524,10): error TS2339: Property '_popContext' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(541,19): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/promise.js(542,42): error TS2339: Property 'classString' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(593,22): error TS2339: Property '_promiseCancelled' does not exist on type '{}'. node_modules/bluebird/js/release/promise.js(607,23): error TS2339: Property '_isResolved' does not exist on type '{}'. node_modules/bluebird/js/release/promise.js(609,26): error TS2339: Property '_promiseFulfilled' does not exist on type '{}'. node_modules/bluebird/js/release/promise.js(611,26): error TS2339: Property '_promiseRejected' does not exist on type '{}'. node_modules/bluebird/js/release/promise.js(665,14): error TS2339: Property '_attachExtraTrace' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(677,14): error TS2339: Property '_dereferenceTrace' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(688,46): error TS2339: Property 'isNode' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(694,14): error TS2339: Property '_ensurePossibleRejectionHandled' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(734,10): error TS2339: Property '_clearCancellationData' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(767,6): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(797,10): error TS2339: Property 'toFastProperties' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(798,10): error TS2339: Property 'toFastProperties' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise_array.js(5,20): error TS2339: Property 'isArray' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise_array.js(27,6): error TS2339: Property 'inherits' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise_array.js(62,19): error TS2339: Property 'asArray' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise_array.js(65,72): error TS2339: Property 'classString' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise_array.js(72,18): error TS2339: Property '_resolveEmptyArray' does not exist on type 'PromiseArray'. node_modules/bluebird/js/release/promise_array.js(110,76): error TS2554: Expected 0-1 arguments, but got 2. node_modules/bluebird/js/release/promise_array.js(112,53): error TS2554: Expected 0 arguments, but got 1. -node_modules/bluebird/js/release/promisify.js(6,25): error TS2339: Property 'withAppended' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promisify.js(7,29): error TS2339: Property 'maybeWrapAsError' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promisify.js(8,24): error TS2339: Property 'canEvaluate' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promisify.js(24,17): error TS2339: Property 'isIdentifier' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promisify.js(43,20): error TS2339: Property 'getDataPropertyOrDefault' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promisify.js(54,27): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/promisify.js(63,21): error TS2339: Property 'inheritedDataKeys' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promisify.js(69,41): error TS2554: Expected 0-1 arguments, but got 3. node_modules/bluebird/js/release/promisify.js(93,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'number', but here has type 'any'. -node_modules/bluebird/js/release/promisify.js(100,17): error TS2339: Property 'filledRange' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promisify.js(104,17): error TS2339: Property 'filledRange' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promisify.js(201,26): error TS2339: Property 'tryCatch' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promisify.js(202,26): error TS2339: Property 'errorObj' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promisify.js(203,26): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promisify.js(230,10): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promisify.js(249,17): error TS2722: Cannot invoke an object which is possibly 'undefined'. node_modules/bluebird/js/release/promisify.js(252,24): error TS2722: Cannot invoke an object which is possibly 'undefined'. -node_modules/bluebird/js/release/promisify.js(255,18): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promisify.js(259,10): error TS2339: Property 'toFastProperties' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promisify.js(264,12): error TS2722: Cannot invoke an object which is possibly 'undefined'. node_modules/bluebird/js/release/promisify.js(270,15): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/promisify.js(270,68): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promisify.js(279,10): error TS2339: Property 'copyDescriptors' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promisify.js(285,15): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/promisify.js(296,15): error TS2339: Property 'isIdentifier' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promisify.js(300,21): error TS2339: Property 'inheritedDataKeys' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promisify.js(304,18): error TS2339: Property 'isClass' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/props.js(5,21): error TS2339: Property 'isObject' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/props.js(60,6): error TS2339: Property 'inherits' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/props.js(65,10): error TS2339: Property '_values' does not exist on type 'PropertiesPromiseArray'. node_modules/bluebird/js/release/props.js(66,32): error TS2339: Property '_totalResolved' does not exist on type 'PropertiesPromiseArray'. node_modules/bluebird/js/release/props.js(67,31): error TS2339: Property '_length' does not exist on type 'PropertiesPromiseArray'. @@ -238,23 +104,14 @@ node_modules/bluebird/js/release/props.js(75,26): error TS2339: Property '_value node_modules/bluebird/js/release/props.js(75,57): error TS2339: Property '_values' does not exist on type 'PropertiesPromiseArray'. node_modules/bluebird/js/release/props.js(78,14): error TS2339: Property '_resolve' does not exist on type 'PropertiesPromiseArray'. node_modules/bluebird/js/release/props.js(102,53): error TS2339: Property 'promise' does not exist on type 'PropertiesPromiseArray'. -node_modules/bluebird/js/release/race.js(18,25): error TS2339: Property 'asArray' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/race.js(20,92): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/reduce.js(9,21): error TS2339: Property 'tryCatch' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/reduce.js(14,21): error TS2339: Property 'contextBind' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/reduce.js(31,6): error TS2339: Property 'inherits' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/reduce.js(43,9): error TS2532: Object is possibly 'undefined'. node_modules/bluebird/js/release/reduce.js(60,10): error TS2339: Property '_promise' does not exist on type 'ReductionPromiseArray'. node_modules/bluebird/js/release/reduce.js(65,52): error TS2339: Property '_cancel' does not exist on type 'ReductionPromiseArray'. node_modules/bluebird/js/release/reduce.js(66,14): error TS2339: Property '_isResolved' does not exist on type 'ReductionPromiseArray'. node_modules/bluebird/js/release/reduce.js(67,10): error TS2551: Property '_resultCancelled$' does not exist on type 'ReductionPromiseArray'. Did you mean '_resultCancelled'? -node_modules/bluebird/js/release/reduce.js(141,68): error TS2339: Property 'classString' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/reduce.js(144,18): error TS2339: Property 'promise' does not exist on type 'ReductionPromiseArray'. -node_modules/bluebird/js/release/schedule.js(7,26): error TS2339: Property 'getNativePromise' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/schedule.js(8,10): error TS2339: Property 'isNode' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/schedule.js(23,31): error TS2339: Property 'standalone' does not exist on type 'Navigator'. node_modules/bluebird/js/release/schedule.js(23,52): error TS2339: Property 'cordova' does not exist on type 'Window & typeof globalThis'. -node_modules/bluebird/js/release/settle.js(10,6): error TS2339: Property 'inherits' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/settle.js(13,10): error TS2339: Property '_values' does not exist on type 'SettledPromiseArray'. node_modules/bluebird/js/release/settle.js(14,32): error TS2339: Property '_totalResolved' does not exist on type 'SettledPromiseArray'. node_modules/bluebird/js/release/settle.js(15,31): error TS2339: Property '_length' does not exist on type 'SettledPromiseArray'. @@ -262,8 +119,6 @@ node_modules/bluebird/js/release/settle.js(16,14): error TS2339: Property '_reso node_modules/bluebird/js/release/settle.js(16,28): error TS2339: Property '_values' does not exist on type 'SettledPromiseArray'. node_modules/bluebird/js/release/settle.js(37,46): error TS2339: Property 'promise' does not exist on type 'SettledPromiseArray'. node_modules/bluebird/js/release/settle.js(41,46): error TS2339: Property 'promise' does not exist on type 'SettledPromiseArray'. -node_modules/bluebird/js/release/some.js(7,20): error TS2339: Property 'isArray' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/some.js(17,6): error TS2339: Property 'inherits' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/some.js(24,14): error TS2339: Property '_resolve' does not exist on type 'SomePromiseArray'. node_modules/bluebird/js/release/some.js(27,10): error TS2551: Property '_init$' does not exist on type 'SomePromiseArray'. Did you mean '_init'? node_modules/bluebird/js/release/some.js(28,40): error TS2339: Property '_values' does not exist on type 'SomePromiseArray'. @@ -294,29 +149,15 @@ node_modules/bluebird/js/release/some.js(115,17): error TS2339: Property 'length node_modules/bluebird/js/release/some.js(121,12): error TS2350: Only a void function can be called with the 'new' keyword. node_modules/bluebird/js/release/some.js(125,10): error TS2551: Property '_reject' does not exist on type 'SomePromiseArray'. Did you mean '_rejected'? node_modules/bluebird/js/release/some.js(133,23): error TS2339: Property 'promise' does not exist on type 'SomePromiseArray'. -node_modules/bluebird/js/release/thenables.js(4,21): error TS2339: Property 'errorObj' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/thenables.js(5,21): error TS2339: Property 'isObject' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/thenables.js(63,23): error TS2339: Property 'tryCatch' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/timers.js(51,10): error TS2339: Property 'markAsOriginatingFromRejection' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/using.js(6,38): error TS2339: Property 'inherits' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/using.js(7,25): error TS2339: Property 'errorObj' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/using.js(8,25): error TS2339: Property 'tryCatch' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/using.js(78,20): error TS2339: Property 'doDispose' does not exist on type 'Disposer'. node_modules/bluebird/js/release/using.js(97,23): error TS2339: Property 'data' does not exist on type 'FunctionDisposer'. -node_modules/bluebird/js/release/using.js(131,72): error TS2339: Property 'classString' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/using.js(223,15): error TS2350: Only a void function can be called with the 'new' keyword. node_modules/bluebird/js/release/util.js(279,45): error TS2345: Argument of type 'PropertyDescriptor | { value: any; } | undefined' is not assignable to parameter of type 'PropertyDescriptor & ThisType'. Type 'undefined' is not assignable to type 'PropertyDescriptor & ThisType'. Type 'undefined' is not assignable to type 'PropertyDescriptor'. -node_modules/bluebird/js/release/util.js(362,5): error TS2322: Type '{ setReflectHandler: (fn: any) => void; isClass: (fn: any) => boolean; isIdentifier: (str: any) => boolean; inheritedDataKeys: (obj: any) => string[]; getDataPropertyOrDefault: (obj: any, key: any, defaultValue: any) => any; ... 27 more ...; contextBind: (ctx: any, cb: any) => any; }' is not assignable to type 'typeof ret'. - Object literal may only specify known properties, and 'setReflectHandler' does not exist in type 'typeof ret'. -node_modules/bluebird/js/release/util.js(398,24): error TS2339: Property 'isNode' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/util.js(405,13): error TS2532: Object is possibly 'undefined'. node_modules/bluebird/js/release/util.js(405,33): error TS2532: Object is possibly 'undefined'. node_modules/bluebird/js/release/util.js(405,54): error TS2532: Object is possibly 'undefined'. -node_modules/bluebird/js/release/util.js(407,37): error TS2339: Property 'isNode' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/util.js(418,9): error TS2339: Property 'isNode' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/util.js(418,21): error TS2339: Property 'toFastProperties' does not exist on type 'typeof ret'. diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index b0dabfddafc..b8d5f95285b 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -1,7 +1,7 @@ Exit Code: 1 Standard output: ../../../../built/local/lib.es5.d.ts(1433,11): error TS2300: Duplicate identifier 'ArrayLike'. -../../../../node_modules/@types/node/globals.d.ts(234,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'module' must be of type '{}', but here has type 'NodeModule'. +../../../../node_modules/@types/node/globals.d.ts(231,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'module' must be of type '{}', but here has type 'NodeModule'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(43,8): error TS2339: Property '_importScriptPathPrefix' does not exist on type 'Window & typeof globalThis'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(77,16): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/Runtime.js(78,16): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. @@ -269,10 +269,16 @@ node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(751, node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(778,24): error TS2694: Namespace 'Protocol' has no exported member 'Page'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(811,11): error TS2339: Property 'AnimationModel' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(7,11): error TS2339: Property 'AnimationScreenshotPopover' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. +node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(18,39): error TS2345: Argument of type 'new (width?: number, height?: number) => HTMLImageElement' is not assignable to parameter of type 'Node'. + Type 'new (width?: number, height?: number) => HTMLImageElement' is missing the following properties from type 'Node': baseURI, childNodes, firstChild, isConnected, and 47 more. +node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(19,13): error TS2339: Property 'style' does not exist on type 'new (width?: number, height?: number) => HTMLImageElement'. +node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(22,21): error TS2339: Property 'style' does not exist on type 'new (width?: number, height?: number) => HTMLImageElement'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(23,45): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(30,39): error TS2339: Property 'window' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(37,25): error TS2339: Property 'window' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(42,39): error TS2339: Property 'window' does not exist on type 'Element'. +node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(53,50): error TS2339: Property 'style' does not exist on type 'new (width?: number, height?: number) => HTMLImageElement'. +node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(55,52): error TS2339: Property 'style' does not exist on type 'new (width?: number, height?: number) => HTMLImageElement'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationTimeline.js(8,11): error TS2339: Property 'AnimationTimeline' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationTimeline.js(14,38): error TS2339: Property 'createSVGChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationTimeline.js(19,53): error TS2339: Property 'createChild' does not exist on type 'Element'. @@ -3863,7 +3869,7 @@ node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(119,47 node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(122,25): error TS2345: Argument of type 'Element' is not assignable to parameter of type 'Icon'. Type 'Element' is missing the following properties from type 'Icon': createdCallback, _descriptor, _spriteSheet, _iconType, and 117 more. node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(133,9): error TS2339: Property 'ConsoleSidebar' does not exist on type '{ new (): Console; prototype: Console; }'. -node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(147,27): error TS2740: Type 'Element' is missing the following properties from type 'Icon': createdCallback, _descriptor, _spriteSheet, _iconType, and 117 more. +node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(147,27): error TS2322: Type 'Element' is not assignable to type 'Icon'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(177,67): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(179,61): error TS2339: Property 'ConsoleSidebar' does not exist on type '{ new (): Console; prototype: Console; }'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(213,28): error TS2555: Expected at least 2 arguments, but got 1. @@ -5040,19 +5046,19 @@ node_modules/chrome-devtools-frontend/front_end/elements/ComputedStyleWidget.js( node_modules/chrome-devtools-frontend/front_end/elements/ComputedStyleWidget.js(73,12): error TS2339: Property '_filterRegex' does not exist on type 'ComputedStyleWidget'. node_modules/chrome-devtools-frontend/front_end/elements/ComputedStyleWidget.js(91,24): error TS2769: No overload matches this call. The last overload gave the following error. - Argument of type '(Promise | Promise)[]' is not assignable to parameter of type 'Iterable>'. + Argument of type '(Promise | Promise)[]' is not assignable to parameter of type 'Iterable>'. The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types. - Type 'IteratorResult | Promise, any>' is not assignable to type 'IteratorResult, any>'. - Type 'IteratorYieldResult | Promise>' is not assignable to type 'IteratorResult, any>'. - Type 'IteratorYieldResult | Promise>' is not assignable to type 'IteratorYieldResult>'. - Type 'Promise | Promise' is not assignable to type 'CSSMatchedStyles | PromiseLike'. - Type 'Promise' is not assignable to type 'CSSMatchedStyles | PromiseLike'. - Type 'Promise' is not assignable to type 'PromiseLike'. + Type 'IteratorResult | Promise, any>' is not assignable to type 'IteratorResult, any>'. + Type 'IteratorYieldResult | Promise>' is not assignable to type 'IteratorResult, any>'. + Type 'IteratorYieldResult | Promise>' is not assignable to type 'IteratorYieldResult>'. + Type 'Promise | Promise' is not assignable to type 'ComputedStyle | PromiseLike'. + Type 'Promise' is not assignable to type 'ComputedStyle | PromiseLike'. + Type 'Promise' is not assignable to type 'PromiseLike'. Types of property 'then' are incompatible. - Type '(onfulfilled?: (value: ComputedStyle) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike<...>) => Promise<...>' is not assignable to type '(onfulfilled?: (value: CSSMatchedStyles) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike<...>) => PromiseLike<...>'. + Type '(onfulfilled?: (value: CSSMatchedStyles) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike<...>) => Promise<...>' is not assignable to type '(onfulfilled?: (value: ComputedStyle) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike<...>) => PromiseLike<...>'. Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. Types of parameters 'value' and 'value' are incompatible. - Type 'ComputedStyle' is missing the following properties from type 'CSSMatchedStyles': _cssModel, _node, _nodeStyles, _nodeForStyle, and 22 more. + Property 'computedStyle' is missing in type 'CSSMatchedStyles' but required in type 'ComputedStyle'. node_modules/chrome-devtools-frontend/front_end/elements/ComputedStyleWidget.js(147,52): error TS2339: Property 'keysArray' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/elements/ComputedStyleWidget.js(179,50): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/ComputedStyleWidget.js(200,74): error TS2339: Property 'consume' does not exist on type 'Event'. @@ -9613,8 +9619,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(704,32): err node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(727,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(728,32): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(729,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(731,3): error TS2416: Property 'callFunctionJSON' in type 'RemoteObjectImpl' is not assignable to the same property in base type 'RemoteObject'. - Type '(functionDeclaration: (this: any) => any, args: any[], callback: (arg0: any) => any) => void' is not assignable to type '(functionDeclaration: (this: any, ...arg1: any[]) => T, args: any[], callback: (arg0: T) => any) => void'. node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(731,3): error TS2416: Property 'callFunctionJSON' in type 'RemoteObjectImpl' is not assignable to the same property in base type 'RemoteObject'. Type '(functionDeclaration: (this: any) => any, args: any[], callback: (arg0: any) => any) => void' is not assignable to type '(functionDeclaration: (this: any, ...arg1: any[]) => T, args: any[], callback: (arg0: T) => any) => void'. Types of parameters 'functionDeclaration' and 'functionDeclaration' are incompatible. @@ -9635,8 +9639,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(1153,31): er node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(1175,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(1176,31): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(1177,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(1179,3): error TS2416: Property 'callFunctionJSON' in type 'LocalJSONObject' is not assignable to the same property in base type 'RemoteObject'. - Type '(functionDeclaration: (this: any) => any, args: any[], callback: (arg0: any) => any) => void' is not assignable to type '(functionDeclaration: (this: any, ...arg1: any[]) => T, args: any[], callback: (arg0: T) => any) => void'. node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(1179,3): error TS2416: Property 'callFunctionJSON' in type 'LocalJSONObject' is not assignable to the same property in base type 'RemoteObject'. Type '(functionDeclaration: (this: any) => any, args: any[], callback: (arg0: any) => any) => void' is not assignable to type '(functionDeclaration: (this: any, ...arg1: any[]) => T, args: any[], callback: (arg0: T) => any) => void'. Types of parameters 'functionDeclaration' and 'functionDeclaration' are incompatible. @@ -11022,24 +11024,16 @@ node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1637,61): error TS2339: Property 'line' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1637,71): error TS2339: Property 'ch' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1647,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorUtils.js(57,53): error TS2345: Argument of type 'Pos' is not assignable to parameter of type 'Pos'. - Type 'Pos' is missing the following properties from type 'Pos': line, ch node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorUtils.js(146,15): error TS1345: An expression of type 'void' cannot be tested for truthiness node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorUtils.js(147,26): error TS2339: Property 'token' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorUtils.js(149,67): error TS2339: Property 'length' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(42,30): error TS2345: Argument of type 'void' is not assignable to parameter of type 'string'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(66,36): error TS2339: Property 'line' does not exist on type 'Pos'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(66,63): error TS2339: Property 'line' does not exist on type 'Pos'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(130,5): error TS2322: Type 'Promise<{ text: string; }[]>' is not assignable to type 'Promise<{ text: string; subtitle: string; iconType: string; priority: number; isSecondary: boolean; title: string; }[]>'. Type '{ text: string; }[]' is not assignable to type '{ text: string; subtitle: string; iconType: string; priority: number; isSecondary: boolean; title: string; }[]'. Type '{ text: string; }' is missing the following properties from type '{ text: string; subtitle: string; iconType: string; priority: number; isSecondary: boolean; title: string; }': subtitle, iconType, priority, isSecondary, title -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(163,27): error TS2339: Property 'line' does not exist on type 'Pos'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(163,43): error TS2339: Property 'line' does not exist on type 'void'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(163,67): error TS2339: Property 'ch' does not exist on type 'Pos'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(163,85): error TS2339: Property 'ch' does not exist on type 'void'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(168,67): error TS2339: Property 'line' does not exist on type 'Pos'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(168,83): error TS2339: Property 'line' does not exist on type 'void'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(169,27): error TS2339: Property 'ch' does not exist on type 'Pos'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(169,45): error TS2339: Property 'ch' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(199,20): error TS2339: Property 'length' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(202,36): error TS2339: Property 'length' does not exist on type 'void'. @@ -11187,6 +11181,9 @@ node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.j node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(204,36): error TS2339: Property '_overviewIndex' does not exist on type 'TimelineCategory'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(246,68): error TS2339: Property 'peekLast' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(248,81): error TS2339: Property '_overviewIndex' does not exist on type 'TimelineCategory'. +node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(384,7): error TS2322: Type 'Promise HTMLImageElement)>' is not assignable to type 'Promise'. + Type 'HTMLImageElement | (new (width?: number, height?: number) => HTMLImageElement)' is not assignable to type 'HTMLImageElement'. + Type 'new (width?: number, height?: number) => HTMLImageElement' is missing the following properties from type 'HTMLImageElement': align, alt, border, complete, and 261 more. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(457,17): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(483,31): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(524,28): error TS2339: Property 'peekLast' does not exist on type 'TimelineFrame[]'. @@ -11232,6 +11229,10 @@ node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataP node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(541,38): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(548,25): error TS2339: Property 'createChild' does not exist on type 'DocumentFragment'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(621,36): error TS2339: Property 'preciseMillisToString' does not exist on type 'NumberConstructor'. +node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(654,37): error TS2339: Property 'naturalHeight' does not exist on type 'new (width?: number, height?: number) => HTMLImageElement'. +node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(655,39): error TS2339: Property 'naturalWidth' does not exist on type 'new (width?: number, height?: number) => HTMLImageElement'. +node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(660,23): error TS2345: Argument of type 'new (width?: number, height?: number) => HTMLImageElement' is not assignable to parameter of type 'CanvasImageSource'. + Type 'new (width?: number, height?: number) => HTMLImageElement' is missing the following properties from type 'OffscreenCanvas': height, width, convertToBlob, getContext, and 4 more. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(862,44): error TS2339: Property 'id' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(865,63): error TS2339: Property 'id' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(866,44): error TS2339: Property 'id' does not exist on type 'Event'. @@ -11675,6 +11676,7 @@ node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1649 node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1651,40): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1652,40): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1652,69): error TS2339: Property 'millisToString' does not exist on type 'NumberConstructor'. +node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1657,64): error TS2345: Argument of type 'new (width?: number, height?: number) => HTMLImageElement' is not assignable to parameter of type 'Node'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1664,18): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1665,74): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1675,5): error TS2740: Type 'DocumentFragment' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 64 more. @@ -11958,7 +11960,6 @@ node_modules/chrome-devtools-frontend/front_end/ui/Geometry.js(272,13): error TS node_modules/chrome-devtools-frontend/front_end/ui/Geometry.js(316,13): error TS2304: Cannot find name 'CSSMatrix'. node_modules/chrome-devtools-frontend/front_end/ui/GlassPane.js(18,17): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/ui/GlassPane.js(72,15): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/chrome-devtools-frontend/front_end/ui/GlassPane.js(82,5): error TS2739: Type 'Size' is missing the following properties from type 'Size': isEqual, widthToMax, addWidth, heightToMax, addHeight node_modules/chrome-devtools-frontend/front_end/ui/GlassPane.js(125,5): error TS2322: Type 'boolean' is not assignable to type 'symbol'. node_modules/chrome-devtools-frontend/front_end/ui/GlassPane.js(126,51): error TS2367: This condition will always return 'true' since the types 'boolean' and 'symbol' have no overlap. node_modules/chrome-devtools-frontend/front_end/ui/GlassPane.js(136,18): error TS2339: Property 'style' does not exist on type 'Element'. @@ -12329,18 +12330,6 @@ node_modules/chrome-devtools-frontend/front_end/ui/SplitWidget.js(590,25): error node_modules/chrome-devtools-frontend/front_end/ui/SplitWidget.js(593,27): error TS2339: Property 'window' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/SplitWidget.js(647,21): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/ui/SplitWidget.js(654,21): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. -node_modules/chrome-devtools-frontend/front_end/ui/SplitWidget.js(704,41): error TS2339: Property 'widthToMax' does not exist on type 'Constraints | Constraints'. - Property 'widthToMax' does not exist on type 'Constraints'. -node_modules/chrome-devtools-frontend/front_end/ui/SplitWidget.js(705,47): error TS2339: Property 'widthToMax' does not exist on type 'Constraints | Constraints'. - Property 'widthToMax' does not exist on type 'Constraints'. -node_modules/chrome-devtools-frontend/front_end/ui/SplitWidget.js(706,30): error TS2339: Property 'addWidth' does not exist on type 'Constraints | Constraints'. - Property 'addWidth' does not exist on type 'Constraints'. -node_modules/chrome-devtools-frontend/front_end/ui/SplitWidget.js(708,41): error TS2339: Property 'heightToMax' does not exist on type 'Constraints | Constraints'. - Property 'heightToMax' does not exist on type 'Constraints'. -node_modules/chrome-devtools-frontend/front_end/ui/SplitWidget.js(709,47): error TS2339: Property 'heightToMax' does not exist on type 'Constraints | Constraints'. - Property 'heightToMax' does not exist on type 'Constraints'. -node_modules/chrome-devtools-frontend/front_end/ui/SplitWidget.js(710,30): error TS2339: Property 'widthToMax' does not exist on type 'Constraints | Constraints'. - Property 'widthToMax' does not exist on type 'Constraints'. node_modules/chrome-devtools-frontend/front_end/ui/SplitWidget.js(872,47): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/ui/SuggestBox.js(72,50): error TS2345: Argument of type 'this' is not assignable to parameter of type 'ListDelegate<{ text: string; subtitle: string; iconType: string; priority: number; isSecondary: boolean; title: string; }>'. Type 'SuggestBox' is not assignable to type 'ListDelegate<{ text: string; subtitle: string; iconType: string; priority: number; isSecondary: boolean; title: string; }>'. @@ -12366,10 +12355,6 @@ node_modules/chrome-devtools-frontend/front_end/ui/TabbedPane.js(41,47): error T node_modules/chrome-devtools-frontend/front_end/ui/TabbedPane.js(47,48): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/TabbedPane.js(159,27): error TS2339: Property 'focus' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/TabbedPane.js(314,56): error TS2339: Property 'getComponentRoot' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/ui/TabbedPane.js(487,31): error TS2339: Property 'widthToMax' does not exist on type 'Constraints'. -node_modules/chrome-devtools-frontend/front_end/ui/TabbedPane.js(489,33): error TS2339: Property 'addWidth' does not exist on type 'Constraints'. -node_modules/chrome-devtools-frontend/front_end/ui/TabbedPane.js(491,33): error TS2339: Property 'addHeight' does not exist on type 'Constraints'. -node_modules/chrome-devtools-frontend/front_end/ui/TabbedPane.js(492,5): error TS2739: Type 'Constraints' is missing the following properties from type 'Constraints': isEqual, widthToMax, addWidth, heightToMax, addHeight node_modules/chrome-devtools-frontend/front_end/ui/TabbedPane.js(568,15): error TS2339: Property 'which' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/ui/TabbedPane.js(671,27): error TS2339: Property '__tab' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/TabbedPane.js(679,31): error TS2339: Property '__tab' does not exist on type 'Element'. @@ -12640,6 +12625,8 @@ node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1910,22): error TS node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1911,22): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1912,22): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1913,22): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. +node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1943,50): error TS2345: Argument of type 'HTMLImageElement' is not assignable to parameter of type '(new (width?: number, height?: number) => HTMLImageElement) | PromiseLike HTMLImageElement>'. + Property 'then' is missing in type 'HTMLImageElement' but required in type 'PromiseLike HTMLImageElement>'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1961,12): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1966,23): error TS2339: Property 'type' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1967,23): error TS2339: Property 'style' does not exist on type 'Element'. @@ -12718,16 +12705,7 @@ node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(484,20): error TS23 node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(485,17): error TS2339: Property 'focus' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(498,39): error TS2339: Property 'traverseNextNode' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(513,25): error TS2339: Property 'hasFocus' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(583,17): error TS2339: Property 'isEqual' does not exist on type 'Constraints'. node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(593,55): error TS2339: Property 'removeChildren' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(621,44): error TS2345: Argument of type 'Constraints' is not assignable to parameter of type 'number | Constraints'. - Type 'Constraints' is not assignable to type 'Constraints'. Two different types with this name exist, but they are unrelated. -node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(622,43): error TS2345: Argument of type 'Constraints' is not assignable to parameter of type 'number | Constraints'. - Type 'Constraints' is not assignable to type 'Constraints'. Two different types with this name exist, but they are unrelated. -node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(655,42): error TS2345: Argument of type 'Constraints' is not assignable to parameter of type 'number | Constraints'. - Type 'Constraints' is not assignable to type 'Constraints'. Two different types with this name exist, but they are unrelated. -node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(656,45): error TS2345: Argument of type 'Constraints' is not assignable to parameter of type 'number | Constraints'. - Type 'Constraints' is not assignable to type 'Constraints'. Two different types with this name exist, but they are unrelated. node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(669,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(693,51): error TS2339: Property 'deepActiveElement' does not exist on type 'Document'. node_modules/chrome-devtools-frontend/front_end/ui/Widget.js(713,1): error TS2322: Type '(child: Node) => Node' is not assignable to type '(newChild: T) => T'. diff --git a/tests/baselines/reference/user/graceful-fs.log b/tests/baselines/reference/user/graceful-fs.log index 2a02c52d08d..1f60574df06 100644 --- a/tests/baselines/reference/user/graceful-fs.log +++ b/tests/baselines/reference/user/graceful-fs.log @@ -15,12 +15,10 @@ node_modules/graceful-fs/graceful-fs.js(199,5): error TS2539: Cannot assign to ' node_modules/graceful-fs/graceful-fs.js(200,5): error TS2539: Cannot assign to 'WriteStream' because it is not a variable. node_modules/graceful-fs/graceful-fs.js(220,7): error TS2539: Cannot assign to 'ReadStream' because it is not a variable. node_modules/graceful-fs/graceful-fs.js(230,7): error TS2539: Cannot assign to 'WriteStream' because it is not a variable. -node_modules/graceful-fs/graceful-fs.js(242,7): error TS2539: Cannot assign to 'ReadStream' because it is not a variable. -node_modules/graceful-fs/graceful-fs.js(252,7): error TS2539: Cannot assign to 'WriteStream' because it is not a variable. -node_modules/graceful-fs/graceful-fs.js(262,68): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[any?, any?, ...any[]]'. -node_modules/graceful-fs/graceful-fs.js(285,70): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[any?, any?, ...any[]]'. -node_modules/graceful-fs/graceful-fs.js(334,9): error TS2554: Expected 0 arguments, but got 3. -node_modules/graceful-fs/graceful-fs.js(341,11): error TS2554: Expected 0 arguments, but got 3. +node_modules/graceful-fs/graceful-fs.js(264,68): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[any?, any?, ...any[]]'. +node_modules/graceful-fs/graceful-fs.js(287,70): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[any?, any?, ...any[]]'. +node_modules/graceful-fs/graceful-fs.js(336,9): error TS2554: Expected 0 arguments, but got 3. +node_modules/graceful-fs/graceful-fs.js(343,11): error TS2554: Expected 0 arguments, but got 3. diff --git a/tests/baselines/reference/user/prettier.log b/tests/baselines/reference/user/prettier.log index 05342cae1e1..ac7d6fedeae 100644 --- a/tests/baselines/reference/user/prettier.log +++ b/tests/baselines/reference/user/prettier.log @@ -23,6 +23,7 @@ node_modules/@glimmer/util/dist/types/lib/destroy.d.ts(3,69): error TS2677: A ty Index signature is missing in type 'SymbolDestroyable'. node_modules/@glimmer/util/dist/types/lib/dom.d.ts(1,31): error TS2307: Cannot find module '@simple-dom/interface'. node_modules/@glimmer/util/dist/types/lib/is-serialization-first-node.d.ts(1,28): error TS2307: Cannot find module '@simple-dom/interface'. +node_modules/@typescript-eslint/typescript-estree/dist/create-program/createWatchProgram.d.ts(1,8): error TS1259: Module '"/prettier/prettier/node_modules/typescript/lib/typescript"' can only be default-imported using the 'esModuleInterop' flag src/cli/util.js(60,44): error TS2345: Argument of type 'null' is not assignable to parameter of type 'number | undefined'. src/cli/util.js(119,38): error TS2339: Property 'sync' does not exist on type '(...args: any[]) => any'. src/cli/util.js(413,36): error TS2345: Argument of type '{ dot: true; nodir: boolean; }' is not assignable to parameter of type 'GlobbyOptions'. @@ -36,6 +37,8 @@ src/cli/util.js(693,22): error TS2339: Property 'name' does not exist on type 'n src/cli/util.js(693,46): error TS2339: Property 'alias' does not exist on type 'never'. src/common/create-ignorer.js(34,19): error TS2349: This expression is not callable. Type 'typeof import("/prettier/prettier/node_modules/ignore/index")' has no call signatures. +src/common/get-file-info.js(36,27): error TS2339: Property 'resolveConfig' does not exist on type '{ ignorePath?: string | undefined; withNodeModules?: boolean | undefined; plugins: any; }'. +src/common/get-file-info.js(59,25): error TS2339: Property 'resolveConfig' does not exist on type '{ ignorePath?: string | undefined; withNodeModules?: boolean | undefined; plugins: any; }'. src/common/parser-create-error.js(8,9): error TS2339: Property 'loc' does not exist on type 'SyntaxError'. src/config/resolve-config.js(14,12): error TS2571: Object is of type 'unknown'. src/config/resolve-config.js(50,16): error TS2571: Object is of type 'unknown'. @@ -169,7 +172,7 @@ src/language-html/syntax-vue.js(14,27): error TS2339: Property 'right' does not src/language-html/utils.js(10,30): error TS2307: Cannot find module 'html-tag-names'. src/language-html/utils.js(11,39): error TS2307: Cannot find module 'html-element-attributes'. src/language-html/utils.js(444,17): error TS2554: Expected 0 arguments, but got 1. -src/language-js/comments.js(865,64): error TS2554: Expected 0 arguments, but got 1. +src/language-js/comments.js(867,64): error TS2554: Expected 0 arguments, but got 1. src/language-js/index.js(9,26): error TS2307: Cannot find module 'linguist-languages/data/JavaScript'. src/language-js/index.js(9,65): error TS2345: Argument of type '{ override: { since: string; parsers: string[]; vscodeLanguageIds: string[]; }; extend: { interpreters: string[]; }; }' is not assignable to parameter of type '{ extend: any; override: any; exclude: any; }'. Property 'exclude' is missing in type '{ override: { since: string; parsers: string[]; vscodeLanguageIds: string[]; }; extend: { interpreters: string[]; }; }' but required in type '{ extend: any; override: any; exclude: any; }'. @@ -197,7 +200,7 @@ src/language-js/index.js(71,73): error TS2345: Argument of type '{ override: { s src/language-js/index.js(81,26): error TS2307: Cannot find module 'linguist-languages/data/JSON5'. src/language-js/index.js(81,60): error TS2345: Argument of type '{ override: { since: string; parsers: string[]; vscodeLanguageIds: string[]; }; }' is not assignable to parameter of type '{ extend: any; override: any; exclude: any; }'. Type '{ override: { since: string; parsers: string[]; vscodeLanguageIds: string[]; }; }' is missing the following properties from type '{ extend: any; override: any; exclude: any; }': extend, exclude -src/language-js/needs-parens.js(880,14): error TS2769: No overload matches this call. +src/language-js/needs-parens.js(893,14): error TS2769: No overload matches this call. Overload 1 of 2, '(...items: ConcatArray<(childPath: any) => any>[]): ((childPath: any) => any)[]', gave the following error. Argument of type '(string | number)[]' is not assignable to parameter of type 'ConcatArray<(childPath: any) => any>'. The types returned by 'slice(...)' are incompatible between these types. @@ -211,36 +214,36 @@ src/language-js/printer-estree.js(263,36): error TS2304: Cannot find name 'Doc'. src/language-js/printer-estree.js(264,62): error TS2304: Cannot find name 'Doc'. src/language-js/printer-estree.js(271,12): error TS2304: Cannot find name 'FastPath'. src/language-js/printer-estree.js(272,12): error TS2304: Cannot find name 'Options'. -src/language-js/printer-estree.js(398,9): error TS2769: No overload matches this call. +src/language-js/printer-estree.js(401,9): error TS2769: No overload matches this call. Overload 1 of 2, '(...items: ConcatArray[]): never[]', gave the following error. Argument of type '{ type: string; parts: any; } | { type: string; contents: any; n: any; }' is not assignable to parameter of type 'ConcatArray'. Type '{ type: string; parts: any; }' is missing the following properties from type 'ConcatArray': length, join, slice Overload 2 of 2, '(...items: ConcatArray[]): never[]', gave the following error. Argument of type '{ type: string; parts: any; } | { type: string; contents: any; n: any; }' is not assignable to parameter of type 'ConcatArray'. Type '{ type: string; parts: any; }' is not assignable to type 'ConcatArray'. -src/language-js/printer-estree.js(1897,20): error TS2345: Argument of type '" "' is not assignable to parameter of type '{ type: string; id: any; contents: any; break: boolean; expandedStates: any; }'. -src/language-js/printer-estree.js(1899,20): error TS2345: Argument of type '{ type: string; parts: any; }' is not assignable to parameter of type '{ type: string; id: any; contents: any; break: boolean; expandedStates: any; }'. +src/language-js/printer-estree.js(1929,20): error TS2345: Argument of type '" "' is not assignable to parameter of type '{ type: string; id: any; contents: any; break: boolean; expandedStates: any; }'. +src/language-js/printer-estree.js(1931,20): error TS2345: Argument of type '{ type: string; parts: any; }' is not assignable to parameter of type '{ type: string; id: any; contents: any; break: boolean; expandedStates: any; }'. Type '{ type: string; parts: any; }' is missing the following properties from type '{ type: string; id: any; contents: any; break: boolean; expandedStates: any; }': id, contents, break, expandedStates -src/language-js/printer-estree.js(1901,18): error TS2345: Argument of type '"while ("' is not assignable to parameter of type '{ type: string; id: any; contents: any; break: boolean; expandedStates: any; }'. -src/language-js/printer-estree.js(1910,9): error TS2345: Argument of type '")"' is not assignable to parameter of type '{ type: string; id: any; contents: any; break: boolean; expandedStates: any; }'. -src/language-js/printer-estree.js(3430,11): error TS2769: No overload matches this call. +src/language-js/printer-estree.js(1933,18): error TS2345: Argument of type '"while ("' is not assignable to parameter of type '{ type: string; id: any; contents: any; break: boolean; expandedStates: any; }'. +src/language-js/printer-estree.js(1942,9): error TS2345: Argument of type '")"' is not assignable to parameter of type '{ type: string; id: any; contents: any; break: boolean; expandedStates: any; }'. +src/language-js/printer-estree.js(3467,11): error TS2769: No overload matches this call. Overload 1 of 2, '(...items: ConcatArray[]): never[]', gave the following error. Argument of type 'never[] | { type: string; parts: any; }' is not assignable to parameter of type 'ConcatArray'. Type '{ type: string; parts: any; }' is not assignable to type 'ConcatArray'. Overload 2 of 2, '(...items: ConcatArray[]): never[]', gave the following error. Argument of type 'never[] | { type: string; parts: any; }' is not assignable to parameter of type 'ConcatArray'. Type '{ type: string; parts: any; }' is not assignable to type 'ConcatArray'. -src/language-js/printer-estree.js(3782,22): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. -src/language-js/printer-estree.js(3990,23): error TS2532: Object is possibly 'undefined'. -src/language-js/printer-estree.js(3991,24): error TS2532: Object is possibly 'undefined'. -src/language-js/printer-estree.js(4312,5): error TS2345: Argument of type '"" | { type: string; parts: any; } | { type: string; contents: any; }' is not assignable to parameter of type 'string'. +src/language-js/printer-estree.js(3817,22): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. +src/language-js/printer-estree.js(4033,23): error TS2532: Object is possibly 'undefined'. +src/language-js/printer-estree.js(4034,24): error TS2532: Object is possibly 'undefined'. +src/language-js/printer-estree.js(4355,5): error TS2345: Argument of type '"" | { type: string; parts: any; } | { type: string; contents: any; }' is not assignable to parameter of type 'string'. Type '{ type: string; parts: any; }' is not assignable to type 'string'. -src/language-js/printer-estree.js(4316,16): error TS2345: Argument of type '{ type: string; parts: any; }' is not assignable to parameter of type 'string'. -src/language-js/printer-estree.js(4364,11): error TS2322: Type '{ type: string; id: any; contents: any; break: boolean; expandedStates: any; }' is not assignable to type 'string'. -src/language-js/printer-estree.js(4379,11): error TS2322: Type '{ type: string; parts: any; }' is not assignable to type 'string'. -src/language-js/printer-estree.js(4391,9): error TS2345: Argument of type '{ type: string; parts: any; }' is not assignable to parameter of type 'string'. -src/language-js/printer-estree.js(4664,9): error TS2554: Expected 0-2 arguments, but got 3. -src/language-js/printer-estree.js(5674,7): error TS2769: No overload matches this call. +src/language-js/printer-estree.js(4359,16): error TS2345: Argument of type '{ type: string; parts: any; }' is not assignable to parameter of type 'string'. +src/language-js/printer-estree.js(4407,11): error TS2322: Type '{ type: string; id: any; contents: any; break: boolean; expandedStates: any; }' is not assignable to type 'string'. +src/language-js/printer-estree.js(4422,11): error TS2322: Type '{ type: string; parts: any; }' is not assignable to type 'string'. +src/language-js/printer-estree.js(4434,9): error TS2345: Argument of type '{ type: string; parts: any; }' is not assignable to parameter of type 'string'. +src/language-js/printer-estree.js(4712,9): error TS2554: Expected 0-2 arguments, but got 3. +src/language-js/printer-estree.js(5728,7): error TS2769: No overload matches this call. Overload 1 of 2, '(...items: ConcatArray<(childPath: any) => any>[]): ((childPath: any) => any)[]', gave the following error. Argument of type '(string | number)[]' is not assignable to parameter of type 'ConcatArray<(childPath: any) => any>'. The types returned by 'slice(...)' are incompatible between these types. @@ -253,18 +256,22 @@ src/language-js/printer-estree.js(5674,7): error TS2769: No overload matches thi src/language-js/utils.js(118,55): error TS2554: Expected 0-1 arguments, but got 2. src/language-js/utils.js(417,14): error TS2339: Property 'comments' does not exist on type 'Expression'. Property 'comments' does not exist on type 'Identifier'. -src/language-js/utils.js(429,9): error TS2367: This condition will always return 'false' since the types '"FunctionExpression" | "ClassExpression" | "ObjectExpression" | "TaggedTemplateExpression" | "CallExpression" | "ConditionalExpression" | "UpdateExpression" | "SequenceExpression" | ... 11 more ... | "AwaitExpression"' and '"OptionalMemberExpression"' have no overlap. -src/language-js/utils.js(430,13): error TS2339: Property 'property' does not exist on type 'SimpleLiteral | RegExpLiteral | FunctionExpression | ArrowFunctionExpression | ArrayExpression | ... 16 more ... | AwaitExpression'. +src/language-js/utils.js(429,7): error TS2367: This condition will always return 'false' since the types '"FunctionExpression" | "ClassExpression" | "ObjectExpression" | "TaggedTemplateExpression" | "CallExpression" | "ConditionalExpression" | "UpdateExpression" | "SequenceExpression" | ... 11 more ... | "AwaitExpression"' and '"OptionalMemberExpression"' have no overlap. +src/language-js/utils.js(434,9): error TS2367: This condition will always return 'false' since the types '"FunctionExpression" | "ClassExpression" | "ObjectExpression" | "TaggedTemplateExpression" | "CallExpression" | "ConditionalExpression" | "UpdateExpression" | "SequenceExpression" | ... 11 more ... | "AwaitExpression"' and '"OptionalMemberExpression"' have no overlap. +src/language-js/utils.js(437,16): error TS2339: Property 'property' does not exist on type 'SimpleLiteral | RegExpLiteral | FunctionExpression | ArrowFunctionExpression | ArrayExpression | ... 16 more ... | AwaitExpression'. Property 'property' does not exist on type 'SimpleLiteral'. -src/language-js/utils.js(430,52): error TS2339: Property 'property' does not exist on type 'SimpleLiteral | RegExpLiteral | FunctionExpression | ArrowFunctionExpression | ArrayExpression | ... 16 more ... | AwaitExpression'. +src/language-js/utils.js(438,16): error TS2339: Property 'property' does not exist on type 'SimpleLiteral | RegExpLiteral | FunctionExpression | ArrowFunctionExpression | ArrayExpression | ... 16 more ... | AwaitExpression'. Property 'property' does not exist on type 'SimpleLiteral'. -src/language-js/utils.js(435,9): error TS2367: This condition will always return 'false' since the types '"FunctionExpression" | "ClassExpression" | "ObjectExpression" | "TaggedTemplateExpression" | "CallExpression" | "ConditionalExpression" | "UpdateExpression" | "SequenceExpression" | ... 11 more ... | "AwaitExpression"' and '"OptionalMemberExpression"' have no overlap. -src/language-js/utils.js(437,29): error TS2339: Property 'object' does not exist on type 'SimpleLiteral | RegExpLiteral | FunctionExpression | ArrowFunctionExpression | ArrayExpression | ... 16 more ... | AwaitExpression'. +src/language-js/utils.js(439,16): error TS2339: Property 'property' does not exist on type 'SimpleLiteral | RegExpLiteral | FunctionExpression | ArrowFunctionExpression | ArrayExpression | ... 16 more ... | AwaitExpression'. + Property 'property' does not exist on type 'SimpleLiteral'. +src/language-js/utils.js(440,16): error TS2339: Property 'property' does not exist on type 'SimpleLiteral | RegExpLiteral | FunctionExpression | ArrowFunctionExpression | ArrayExpression | ... 16 more ... | AwaitExpression'. + Property 'property' does not exist on type 'SimpleLiteral'. +src/language-js/utils.js(444,21): error TS2339: Property 'object' does not exist on type 'SimpleLiteral | RegExpLiteral | FunctionExpression | ArrowFunctionExpression | ArrayExpression | ... 16 more ... | AwaitExpression'. Property 'object' does not exist on type 'SimpleLiteral'. -src/language-js/utils.js(438,22): error TS2339: Property 'comments' does not exist on type 'SimpleLiteral | RegExpLiteral | FunctionExpression | ArrowFunctionExpression | ArrayExpression | ... 16 more ... | AwaitExpression'. +src/language-js/utils.js(445,18): error TS2339: Property 'comments' does not exist on type 'SimpleLiteral | RegExpLiteral | FunctionExpression | ArrowFunctionExpression | ArrayExpression | ... 16 more ... | AwaitExpression'. Property 'comments' does not exist on type 'SimpleLiteral'. -src/language-js/utils.js(444,9): error TS2367: This condition will always return 'false' since the types '"FunctionExpression" | "ClassExpression" | "ObjectExpression" | "TaggedTemplateExpression" | "CallExpression" | "ConditionalExpression" | "UpdateExpression" | "SequenceExpression" | ... 11 more ... | "AwaitExpression"' and '"Identifier"' have no overlap. -src/language-js/utils.js(445,9): error TS2367: This condition will always return 'false' since the types '"FunctionExpression" | "ClassExpression" | "ObjectExpression" | "TaggedTemplateExpression" | "CallExpression" | "ConditionalExpression" | "UpdateExpression" | "SequenceExpression" | ... 11 more ... | "AwaitExpression"' and '"ThisExpression"' have no overlap. +src/language-js/utils.js(450,11): error TS2367: This condition will always return 'false' since the types '"FunctionExpression" | "ClassExpression" | "ObjectExpression" | "TaggedTemplateExpression" | "CallExpression" | "ConditionalExpression" | "UpdateExpression" | "SequenceExpression" | ... 11 more ... | "AwaitExpression"' and '"Identifier"' have no overlap. +src/language-js/utils.js(450,41): error TS2367: This condition will always return 'false' since the types '"FunctionExpression" | "ClassExpression" | "ObjectExpression" | "TaggedTemplateExpression" | "CallExpression" | "ConditionalExpression" | "UpdateExpression" | "SequenceExpression" | ... 11 more ... | "AwaitExpression"' and '"ThisExpression"' have no overlap. src/language-markdown/index.js(8,26): error TS2307: Cannot find module 'linguist-languages/data/Markdown'. src/language-markdown/index.js(21,26): error TS2307: Cannot find module 'linguist-languages/data/Markdown'. src/language-markdown/index.js(21,63): error TS2345: Argument of type '{ override: { name: string; since: string; parsers: string[]; vscodeLanguageIds: string[]; filenames: never[]; extensions: string[]; }; }' is not assignable to parameter of type '{ extend: any; override: any; exclude: any; }'. @@ -284,39 +291,17 @@ src/language-yaml/printer-yaml.js(226,41): error TS2769: No overload matches thi Overload 2 of 2, '(...items: ConcatArray[]): never[]', gave the following error. Argument of type '"" | { type: string; parts: any; }' is not assignable to parameter of type 'ConcatArray'. Type '""' is not assignable to type 'ConcatArray'. -src/main/core-options.js(51,43): error TS1005: '}' expected. -src/main/core-options.js(63,5): error TS2322: Type '{ since: string; category: string; type: "int"; default: number; range: { start: number; end: number; step: number; }; description: any; cliCategory: string; }' is not assignable to type 'OptionInfo'. - Object literal may only specify known properties, and 'cliCategory' does not exist in type 'OptionInfo'. -src/main/core-options.js(71,5): error TS2740: Type '{ value: string; description: any; }[]' is missing the following properties from type 'OptionChoiceInfo': value, description, since, deprecated, and 4 more. -src/main/core-options.js(101,5): error TS2322: Type '{ since: string; category: string; type: "path"; description: string; cliName: string; cliCategory: string; cliDescription: string; }' is not assignable to type 'OptionInfo'. - Object literal may only specify known properties, and 'cliName' does not exist in type 'OptionInfo'. -src/main/core-options.js(111,5): error TS2322: Type '{ since: string; category: string; type: "boolean"; default: false; description: string; cliCategory: string; }' is not assignable to type 'OptionInfo'. - Object literal may only specify known properties, and 'cliCategory' does not exist in type 'OptionInfo'. -src/main/core-options.js(118,9): error TS2322: Type '[{ since: string; value: string; }, { since: string; value: undefined; }]' is not assignable to type 'string | number | boolean | { since: string; value: string | number | boolean; }[] | [{ value: (string | number | boolean)[]; }]'. +src/main/core-options.js(117,9): error TS2322: Type '[{ since: string; value: string; }, { since: string; value: undefined; }]' is not assignable to type 'string | number | boolean | { since: string; value: string | number | boolean; }[] | [{ value: (string | number | boolean)[]; }]'. Type '[{ since: string; value: string; }, { since: string; value: undefined; }]' is not assignable to type '[{ value: (string | number | boolean)[]; }]'. Types of property '0' are incompatible. Type '{ since: string; value: string; }' is not assignable to type '{ value: (string | number | boolean)[]; }'. Object literal may only specify known properties, and 'since' does not exist in type '{ value: (string | number | boolean)[]; }'. -src/main/core-options.js(124,5): error TS2740: Type '({ value: string; description: string; } | { value: string; description: string; deprecated: string; redirect: string; } | { value: string; since: string; description: string; } | { value: string; since: string; description: string; deprecated: string; redirect: string; } | { ...; })[]' is missing the following properties from type 'OptionChoiceInfo': value, description, since, deprecated, and 4 more. -src/main/core-options.js(176,5): error TS2322: Type '{ since: string; type: "path"; array: true; default: [{ value: never[]; }]; category: string; description: string; exception: (value: any) => boolean; cliName: string; cliCategory: string; }' is not assignable to type 'OptionInfo'. - Object literal may only specify known properties, and 'cliName' does not exist in type 'OptionInfo'. -src/main/core-options.js(191,5): error TS2322: Type '{ since: string; type: "path"; array: true; default: [{ value: never[]; }]; category: string; description: any; exception: (value: any) => boolean; cliName: string; cliCategory: string; }' is not assignable to type 'OptionInfo'. - Object literal may only specify known properties, and 'cliName' does not exist in type 'OptionInfo'. -src/main/core-options.js(194,3): error TS2740: Type '{ since: string; category: string; type: "int"; default: number; description: string; range: { start: number; end: number; step: number; }; }' is missing the following properties from type 'OptionInfo': array, deprecated, redirect, oppositeDescription, and 2 more. -src/main/core-options.js(213,5): error TS2322: Type '{ since: string; category: string; type: "int"; default: number; range: { start: number; end: number; step: number; }; description: any; cliCategory: string; }' is not assignable to type 'OptionInfo'. - Object literal may only specify known properties, and 'cliCategory' does not exist in type 'OptionInfo'. -src/main/core-options.js(226,5): error TS2322: Type '{ since: string; category: string; type: "int"; default: number; range: { start: number; end: number; step: number; }; description: any; cliCategory: string; }' is not assignable to type 'OptionInfo'. - Object literal may only specify known properties, and 'cliCategory' does not exist in type 'OptionInfo'. -src/main/core-options.js(237,5): error TS2322: Type '{ since: string; category: string; type: "boolean"; default: false; description: any; cliCategory: string; }' is not assignable to type 'OptionInfo'. - Object literal may only specify known properties, and 'cliCategory' does not exist in type 'OptionInfo'. -src/main/core-options.js(239,3): error TS2740: Type '{ type: "int"; category: string; default: number; description: string; range: { start: number; end: number; step: number; }; }' is missing the following properties from type 'OptionInfo': since, array, deprecated, redirect, and 3 more. -src/main/core-options.js(251,9): error TS2322: Type '[{ since: string; value: false; }, { since: string; value: undefined; }]' is not assignable to type 'string | number | boolean | { since: string; value: string | number | boolean; }[] | [{ value: (string | number | boolean)[]; }]'. +src/main/core-options.js(158,9): error TS2322: Type 'null' is not assignable to type 'string'. +src/main/core-options.js(250,9): error TS2322: Type '[{ since: string; value: false; }, { since: string; value: undefined; }]' is not assignable to type 'string | number | boolean | { since: string; value: string | number | boolean; }[] | [{ value: (string | number | boolean)[]; }]'. Type '[{ since: string; value: false; }, { since: string; value: undefined; }]' is not assignable to type '[{ value: (string | number | boolean)[]; }]'. Types of property '0' are incompatible. Type '{ since: string; value: false; }' is not assignable to type '{ value: (string | number | boolean)[]; }'. Object literal may only specify known properties, and 'since' does not exist in type '{ value: (string | number | boolean)[]; }'. -src/main/core-options.js(254,5): error TS2322: Type 'string' is not assignable to type 'boolean | null'. -src/main/core-options.js(259,3): error TS2740: Type '{ since: string; category: string; type: "boolean"; default: false; description: string; }' is missing the following properties from type 'OptionInfo': array, deprecated, redirect, oppositeDescription, and 3 more. src/main/core.js(303,34): error TS2538: Type 'false' cannot be used as an index type. src/main/core.js(303,47): error TS2538: Type 'false' cannot be used as an index type. src/main/core.js(308,28): error TS2538: Type 'false' cannot be used as an index type. diff --git a/tests/baselines/reference/user/puppeteer.log b/tests/baselines/reference/user/puppeteer.log index 06c9e50d505..f368b268259 100644 --- a/tests/baselines/reference/user/puppeteer.log +++ b/tests/baselines/reference/user/puppeteer.log @@ -1,17 +1,17 @@ Exit Code: 1 Standard output: lib/Accessibility.js(134,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Accessibility.js(341,7): error TS2322: Type 'string | number | boolean' is not assignable to type 'never'. +lib/Accessibility.js(344,7): error TS2322: Type 'string | number | boolean' is not assignable to type 'never'. Type 'string' is not assignable to type 'never'. -lib/Accessibility.js(364,7): error TS2322: Type 'string | number | true' is not assignable to type 'never'. +lib/Accessibility.js(367,7): error TS2322: Type 'string | number | true' is not assignable to type 'never'. Type 'string' is not assignable to type 'never'. -lib/Accessibility.js(376,7): error TS2322: Type 'boolean | "mixed"' is not assignable to type 'never'. +lib/Accessibility.js(379,7): error TS2322: Type 'boolean | "mixed"' is not assignable to type 'never'. Type 'false' is not assignable to type 'never'. -lib/Accessibility.js(387,7): error TS2322: Type 'string | number | boolean' is not assignable to type 'never'. +lib/Accessibility.js(390,7): error TS2322: Type 'string | number | boolean' is not assignable to type 'never'. Type 'string' is not assignable to type 'never'. -lib/Accessibility.js(400,7): error TS2322: Type 'string | number | true' is not assignable to type 'never'. +lib/Accessibility.js(403,7): error TS2322: Type 'string | number | true' is not assignable to type 'never'. Type 'string' is not assignable to type 'never'. -lib/Accessibility.js(406,22): error TS2503: Cannot find namespace 'Protocol'. +lib/Accessibility.js(409,22): error TS2503: Cannot find namespace 'Protocol'. lib/Browser.js(109,15): error TS2503: Cannot find namespace 'Protocol'. lib/Browser.js(116,58): error TS2322: Type 'Promise' is not assignable to type 'Promise'. Type 'CDPSession' is not assignable to type 'Puppeteer.CDPSession'. @@ -42,7 +42,7 @@ lib/NetworkManager.js(295,15): error TS2503: Cannot find namespace 'Protocol'. lib/NetworkManager.js(319,15): error TS2503: Cannot find namespace 'Protocol'. lib/NetworkManager.js(529,15): error TS2503: Cannot find namespace 'Protocol'. lib/NetworkManager.js(668,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(93,33): error TS2345: Argument of type 'CDPSession' is not assignable to parameter of type 'Puppeteer.CDPSession'. +lib/Page.js(94,33): error TS2345: Argument of type 'CDPSession' is not assignable to parameter of type 'Puppeteer.CDPSession'. Types of property 'on' are incompatible. Type '(event: string | symbol, listener: (...args: any[]) => void) => CDPSession' is not assignable to type '(event: T, listener: (arg: any) => void) => CDPSession'. Types of parameters 'event' and 'event' are incompatible. @@ -52,20 +52,20 @@ lib/Page.js(93,33): error TS2345: Argument of type 'CDPSession' is not assignabl Type 'T' is not assignable to type 'symbol'. Type 'string | number | symbol' is not assignable to type 'symbol'. Type 'string' is not assignable to type 'symbol'. -lib/Page.js(146,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(219,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(387,20): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(450,7): error TS2740: Type '(...args: any[]) => Promise' is missing the following properties from type 'Window': applicationCache, caches, clientInformation, closed, and 227 more. -lib/Page.js(460,9): error TS2349: This expression is not callable. +lib/Page.js(147,15): error TS2503: Cannot find namespace 'Protocol'. +lib/Page.js(220,15): error TS2503: Cannot find namespace 'Protocol'. +lib/Page.js(388,20): error TS2503: Cannot find namespace 'Protocol'. +lib/Page.js(451,7): error TS2740: Type '(...args: any[]) => Promise' is missing the following properties from type 'Window': applicationCache, caches, clientInformation, closed, and 227 more. +lib/Page.js(461,9): error TS2349: This expression is not callable. Type 'Window' has no call signatures. -lib/Page.js(496,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(506,22): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(519,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(529,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(554,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(607,14): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(914,19): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(1315,15): error TS2503: Cannot find namespace 'Protocol'. +lib/Page.js(497,15): error TS2503: Cannot find namespace 'Protocol'. +lib/Page.js(507,22): error TS2503: Cannot find namespace 'Protocol'. +lib/Page.js(520,15): error TS2503: Cannot find namespace 'Protocol'. +lib/Page.js(530,15): error TS2503: Cannot find namespace 'Protocol'. +lib/Page.js(555,15): error TS2503: Cannot find namespace 'Protocol'. +lib/Page.js(608,14): error TS2503: Cannot find namespace 'Protocol'. +lib/Page.js(944,19): error TS2503: Cannot find namespace 'Protocol'. +lib/Page.js(1354,15): error TS2503: Cannot find namespace 'Protocol'. lib/Target.js(23,15): error TS2503: Cannot find namespace 'Protocol'. lib/Target.js(87,7): error TS2322: Type 'Promise' is not assignable to type 'Promise'. Type 'Worker | Worker' is not assignable to type 'Worker'. diff --git a/tests/baselines/reference/user/uglify-js.log b/tests/baselines/reference/user/uglify-js.log index 79999aa8abd..2a892b5f50e 100644 --- a/tests/baselines/reference/user/uglify-js.log +++ b/tests/baselines/reference/user/uglify-js.log @@ -12,93 +12,92 @@ node_modules/uglify-js/lib/ast.js(989,29): error TS2339: Property 'parent' does node_modules/uglify-js/lib/compress.js(184,42): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/compress.js(535,41): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/compress.js(861,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1121,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1135,51): error TS2349: This expression is not callable. +node_modules/uglify-js/lib/compress.js(1122,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1136,51): error TS2349: This expression is not callable. Not all constituents of type 'true | ((node: any) => any)' are callable. Type 'true' has no call signatures. -node_modules/uglify-js/lib/compress.js(1199,53): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1240,112): error TS2454: Variable 'args' is used before being assigned. -node_modules/uglify-js/lib/compress.js(1241,29): error TS2532: Object is possibly 'undefined'. -node_modules/uglify-js/lib/compress.js(1250,87): error TS2322: Type 'false' is not assignable to type 'number'. -node_modules/uglify-js/lib/compress.js(1258,29): error TS2322: Type 'false' is not assignable to type 'never'. -node_modules/uglify-js/lib/compress.js(1367,53): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1468,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1578,42): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1610,41): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1722,49): error TS2345: Argument of type 'number[]' is not assignable to parameter of type '[number, number, ...never[]]'. +node_modules/uglify-js/lib/compress.js(1200,53): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1241,112): error TS2454: Variable 'args' is used before being assigned. +node_modules/uglify-js/lib/compress.js(1242,29): error TS2532: Object is possibly 'undefined'. +node_modules/uglify-js/lib/compress.js(1251,87): error TS2322: Type 'false' is not assignable to type 'number'. +node_modules/uglify-js/lib/compress.js(1259,29): error TS2322: Type 'false' is not assignable to type 'never'. +node_modules/uglify-js/lib/compress.js(1368,53): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1469,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1549,42): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1581,41): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1693,49): error TS2345: Argument of type 'number[]' is not assignable to parameter of type '[number, number, ...never[]]'. Type 'number[]' is missing the following properties from type '[number, number, ...never[]]': 0, 1 -node_modules/uglify-js/lib/compress.js(2045,59): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(2083,53): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[number, number, ...never[]]'. +node_modules/uglify-js/lib/compress.js(2016,59): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(2054,53): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[number, number, ...never[]]'. Type 'any[]' is missing the following properties from type '[number, number, ...never[]]': 0, 1 -node_modules/uglify-js/lib/compress.js(2231,34): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(2950,42): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3404,38): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3428,33): error TS2322: Type '"f"' is not assignable to type 'boolean'. -node_modules/uglify-js/lib/compress.js(3562,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3615,29): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3632,29): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(3657,75): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3731,63): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3852,12): error TS2339: Property 'push' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(3927,38): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3948,24): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(3958,28): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(4183,17): error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead. -node_modules/uglify-js/lib/compress.js(4246,45): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4357,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4655,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(4739,37): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4947,57): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[string | RegExp, (string | undefined)?]'. +node_modules/uglify-js/lib/compress.js(2202,34): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(2928,42): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3382,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3406,33): error TS2322: Type '"f"' is not assignable to type 'boolean'. +node_modules/uglify-js/lib/compress.js(3540,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3593,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3611,29): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(3636,75): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3711,63): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3838,12): error TS2339: Property 'push' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(3917,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3938,24): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(3948,28): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(4182,17): error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead. +node_modules/uglify-js/lib/compress.js(4245,45): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4356,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4654,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(4738,37): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4946,57): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[string | RegExp, (string | undefined)?]'. Property '0' is missing in type 'any[]' but required in type '[string | RegExp, (string | undefined)?]'. -node_modules/uglify-js/lib/compress.js(5111,45): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(5118,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'code' must be of type 'string', but here has type '{ get: () => string; toString: () => string; indent: () => void; indentation: () => number; current_width: () => number; should_break: () => boolean; has_parens: () => boolean; newline: () => void; print: (str: any) => void; ... 23 more ...; parent: (n: any) => any; }'. -node_modules/uglify-js/lib/compress.js(5122,36): error TS2532: Object is possibly 'undefined'. -node_modules/uglify-js/lib/compress.js(5127,41): error TS2339: Property 'get' does not exist on type 'string'. -node_modules/uglify-js/lib/compress.js(5642,18): error TS2454: Variable 'is_strict_comparison' is used before being assigned. -node_modules/uglify-js/lib/compress.js(6149,25): error TS2367: This condition will always return 'false' since the types 'boolean' and 'string' have no overlap. -node_modules/uglify-js/lib/compress.js(6176,47): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(6249,39): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(6321,39): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(6327,41): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(6772,43): error TS2454: Variable 'property' is used before being assigned. -node_modules/uglify-js/lib/compress.js(6787,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(6790,46): error TS2339: Property 'has_side_effects' does not exist on type 'number'. -node_modules/uglify-js/lib/compress.js(6796,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(6834,34): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5110,45): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5117,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'code' must be of type 'string', but here has type '{ get: () => string; toString: () => string; indent: () => void; indentation: () => number; current_width: () => number; should_break: () => boolean; has_parens: () => boolean; newline: () => void; print: (str: any) => void; ... 23 more ...; parent: (n: any) => any; }'. +node_modules/uglify-js/lib/compress.js(5121,36): error TS2532: Object is possibly 'undefined'. +node_modules/uglify-js/lib/compress.js(5126,41): error TS2339: Property 'get' does not exist on type 'string'. +node_modules/uglify-js/lib/compress.js(5643,18): error TS2454: Variable 'is_strict_comparison' is used before being assigned. +node_modules/uglify-js/lib/compress.js(6150,25): error TS2367: This condition will always return 'false' since the types 'boolean' and 'string' have no overlap. +node_modules/uglify-js/lib/compress.js(6178,47): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6253,39): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6325,39): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6331,41): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6776,43): error TS2454: Variable 'property' is used before being assigned. +node_modules/uglify-js/lib/compress.js(6791,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(6794,46): error TS2339: Property 'has_side_effects' does not exist on type 'number'. +node_modules/uglify-js/lib/compress.js(6800,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(6838,34): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/minify.js(186,75): error TS2339: Property 'compress' does not exist on type 'Compressor'. node_modules/uglify-js/lib/mozilla-ast.js(566,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/output.js(234,25): error TS2554: Expected 0 arguments, but got 2. -node_modules/uglify-js/lib/output.js(458,37): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/output.js(762,38): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/output.js(1158,44): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/output.js(1459,58): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. -node_modules/uglify-js/lib/parse.js(361,20): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. +node_modules/uglify-js/lib/output.js(232,25): error TS2554: Expected 0 arguments, but got 2. +node_modules/uglify-js/lib/output.js(456,37): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/output.js(759,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/output.js(1153,44): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/output.js(1454,58): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. +node_modules/uglify-js/lib/parse.js(358,20): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. Type 'undefined' is not assignable to type 'number'. -node_modules/uglify-js/lib/parse.js(443,32): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. -node_modules/uglify-js/lib/parse.js(454,32): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. -node_modules/uglify-js/lib/parse.js(505,20): error TS2339: Property 'raw_source' does not exist on type 'RegExp'. -node_modules/uglify-js/lib/parse.js(616,57): error TS2339: Property 'push' does not exist on type 'never'. -node_modules/uglify-js/lib/parse.js(626,32): error TS2345: Argument of type 'never[]' is not assignable to parameter of type 'never'. -node_modules/uglify-js/lib/parse.js(632,40): error TS2339: Property 'length' does not exist on type 'never'. -node_modules/uglify-js/lib/parse.js(733,13): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(769,69): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(769,83): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(813,31): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(819,17): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(823,21): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(828,43): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(847,21): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(866,21): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(981,23): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. -node_modules/uglify-js/lib/parse.js(1095,9): error TS2322: Type 'any[]' is not assignable to type 'never[]'. +node_modules/uglify-js/lib/parse.js(437,32): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. +node_modules/uglify-js/lib/parse.js(448,32): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. +node_modules/uglify-js/lib/parse.js(498,20): error TS2339: Property 'raw_source' does not exist on type 'RegExp'. +node_modules/uglify-js/lib/parse.js(606,57): error TS2339: Property 'push' does not exist on type 'never'. +node_modules/uglify-js/lib/parse.js(612,32): error TS2345: Argument of type 'never[]' is not assignable to parameter of type 'never'. +node_modules/uglify-js/lib/parse.js(705,13): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(738,69): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(738,83): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(782,31): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(788,17): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(792,21): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(797,43): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(816,21): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(835,21): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(950,23): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. +node_modules/uglify-js/lib/parse.js(1064,9): error TS2322: Type 'any[]' is not assignable to type 'never[]'. Type 'any' is not assignable to type 'never'. -node_modules/uglify-js/lib/parse.js(1152,17): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(1320,32): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(1420,20): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(1426,20): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(1512,48): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(1538,35): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(1583,52): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(1121,17): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(1289,32): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(1389,20): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(1395,20): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(1481,48): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(1507,35): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(1552,52): error TS2531: Object is possibly 'null'. node_modules/uglify-js/lib/propmangle.js(69,18): error TS2339: Property 'prototype' does not exist on type 'ObjectConstructor | FunctionConstructor | StringConstructor | BooleanConstructor | NumberConstructor | ... 4 more ... | ArrayConstructor'. Property 'prototype' does not exist on type 'Math'. node_modules/uglify-js/lib/propmangle.js(70,45): error TS2339: Property 'prototype' does not exist on type 'ObjectConstructor | FunctionConstructor | StringConstructor | BooleanConstructor | NumberConstructor | ... 4 more ... | ArrayConstructor'. @@ -106,14 +105,14 @@ node_modules/uglify-js/lib/propmangle.js(70,45): error TS2339: Property 'prototy node_modules/uglify-js/lib/propmangle.js(80,29): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/propmangle.js(94,30): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/propmangle.js(146,29): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(88,21): error TS2339: Property 'defun' does not exist on type 'SymbolDef'. -node_modules/uglify-js/lib/scope.js(88,35): error TS2339: Property 'defun' does not exist on type 'SymbolDef'. -node_modules/uglify-js/lib/scope.js(102,29): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(157,29): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(192,47): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(403,29): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(460,30): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(485,30): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(89,21): error TS2339: Property 'defun' does not exist on type 'SymbolDef'. +node_modules/uglify-js/lib/scope.js(89,35): error TS2339: Property 'defun' does not exist on type 'SymbolDef'. +node_modules/uglify-js/lib/scope.js(103,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(158,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(193,47): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(412,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(475,30): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(500,30): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/sourcemap.js(55,25): error TS2304: Cannot find name 'MOZ_SourceMap'. node_modules/uglify-js/lib/sourcemap.js(61,23): error TS2304: Cannot find name 'MOZ_SourceMap'. node_modules/uglify-js/tools/exit.js(10,37): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[(number | undefined)?]'. diff --git a/tests/baselines/reference/user/webpack.log b/tests/baselines/reference/user/webpack.log index a660ffbad3f..d1af5e0c5f7 100644 --- a/tests/baselines/reference/user/webpack.log +++ b/tests/baselines/reference/user/webpack.log @@ -1,33 +1,44 @@ Exit Code: 1 Standard output: -lib/BannerPlugin.js(34,27): error TS2345: Argument of type 'BannerPluginArgument' is not assignable to parameter of type 'object | object[]'. - Type 'string' is not assignable to type 'object | object[]'. -lib/logging/Logger.js(49,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(53,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(57,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(61,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(65,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(70,21): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(75,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(79,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(83,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(87,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(91,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(95,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(99,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(103,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(117,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/logging/Logger.js(127,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "log" | "info" | "warn" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. -lib/util/registerExternalSerializer.js(253,14): error TS2339: Property 'line' does not exist on type 'Position'. -lib/util/registerExternalSerializer.js(254,14): error TS2339: Property 'column' does not exist on type 'Position'. -lib/validateSchema.js(15,11): error TS2339: Property 'children' does not exist on type 'ErrorObject'. -lib/validateSchema.js(16,11): error TS2339: Property 'children' does not exist on type 'ErrorObject'. -lib/validateSchema.js(26,22): error TS2339: Property 'additionalProperty' does not exist on type 'ErrorParameters'. - Property 'additionalProperty' does not exist on type 'RefParams'. -lib/validateSchema.js(40,22): error TS2339: Property 'additionalProperty' does not exist on type 'ErrorParameters'. - Property 'additionalProperty' does not exist on type 'RefParams'. -lib/validateSchema.js(51,31): error TS2339: Property 'additionalProperty' does not exist on type 'ErrorParameters'. - Property 'additionalProperty' does not exist on type 'RefParams'. +lib/MultiCompiler.js(15,65): error TS2300: Duplicate identifier 'AsyncSeriesHook'. +lib/MultiCompiler.js(16,77): error TS2300: Duplicate identifier 'SyncBailHook'. +lib/MultiCompiler.js(17,70): error TS2300: Duplicate identifier 'WatchOptions'. +lib/MultiCompiler.js(18,37): error TS2300: Duplicate identifier 'Compiler'. +lib/MultiCompiler.js(19,34): error TS2300: Duplicate identifier 'Stats'. +lib/MultiCompiler.js(20,37): error TS2300: Duplicate identifier 'Watching'. +lib/MultiCompiler.js(21,52): error TS2300: Duplicate identifier 'InputFileSystem'. +lib/MultiCompiler.js(22,59): error TS2300: Duplicate identifier 'IntermediateFileSystem'. +lib/MultiCompiler.js(23,53): error TS2300: Duplicate identifier 'OutputFileSystem'. +lib/MultiCompiler.js(25,23): error TS2300: Duplicate identifier 'CompilerStatus'. +lib/MultiCompiler.js(33,14): error TS2300: Duplicate identifier 'Callback'. +lib/MultiCompiler.js(39,14): error TS2300: Duplicate identifier 'RunWithDependenciesHandler'. +lib/MultiCompiler.js(105,6): error TS2300: Duplicate identifier 'outputPath'. +lib/MultiCompiler.js(120,6): error TS2300: Duplicate identifier 'inputFileSystem'. +lib/MultiCompiler.js(124,6): error TS2300: Duplicate identifier 'outputFileSystem'. +lib/MultiCompiler.js(128,6): error TS2300: Duplicate identifier 'intermediateFileSystem'. +lib/MultiCompiler.js(135,6): error TS2300: Duplicate identifier 'inputFileSystem'. +lib/MultiCompiler.js(144,6): error TS2300: Duplicate identifier 'outputFileSystem'. +lib/MultiCompiler.js(153,6): error TS2300: Duplicate identifier 'intermediateFileSystem'. +lib/logging/Logger.js(49,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(53,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(57,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(61,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(65,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(70,21): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(75,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(79,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(83,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(87,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(91,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(95,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(99,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(103,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(117,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/logging/Logger.js(127,20): error TS2345: Argument of type 'string' is not assignable to parameter of type '"error" | "time" | "group" | "debug" | "info" | "warn" | "log" | "trace" | "groupCollapsed" | "groupEnd" | "profile" | "profileEnd" | "clear" | "status"'. +lib/util/registerExternalSerializer.js(218,14): error TS2339: Property 'start' does not exist on type 'typeof SourceLocation'. +lib/util/registerExternalSerializer.js(219,14): error TS2339: Property 'start' does not exist on type 'typeof SourceLocation'. +lib/util/registerExternalSerializer.js(220,14): error TS2339: Property 'end' does not exist on type 'typeof SourceLocation'. +lib/util/registerExternalSerializer.js(221,14): error TS2339: Property 'end' does not exist on type 'typeof SourceLocation'. diff --git a/tests/cases/compiler/anonClassDeclarationEmitIsAnon.ts b/tests/cases/compiler/anonClassDeclarationEmitIsAnon.ts new file mode 100644 index 00000000000..e7718e5c01b --- /dev/null +++ b/tests/cases/compiler/anonClassDeclarationEmitIsAnon.ts @@ -0,0 +1,34 @@ +// @declaration: true +// @filename: wrapClass.ts +export function wrapClass(param: any) { + return class Wrapped { + foo() { + return param; + } + } +} + +export type Constructor = new (...args: any[]) => T; + +export function Timestamped(Base: TBase) { + return class extends Base { + timestamp = Date.now(); + }; +} + +// @filename: index.ts +import { wrapClass, Timestamped } from "./wrapClass"; + +export default wrapClass(0); + +// Simple class +export class User { + name = ''; +} + +// User that is Timestamped +export class TimestampedUser extends Timestamped(User) { + constructor() { + super(); + } +} \ No newline at end of file diff --git a/tests/cases/compiler/constEnumNoEmitReexport.ts b/tests/cases/compiler/constEnumNoEmitReexport.ts new file mode 100644 index 00000000000..9ef57f12550 --- /dev/null +++ b/tests/cases/compiler/constEnumNoEmitReexport.ts @@ -0,0 +1,26 @@ +// @filename: ConstEnum.ts +export const enum MyConstEnum { + Foo, + Bar +}; +// @filename: ImportExport.ts +import { MyConstEnum } from './ConstEnum'; +export { MyConstEnum }; +// @filename: ImportExportDefault.ts +import { MyConstEnum } from './ConstEnum'; +export default MyConstEnum; +// @filename: ReExportDefault.ts +export { MyConstEnum as default } from './ConstEnum'; +// @filename: ReExport.ts +export { MyConstEnum } from './ConstEnum'; +// @filename: Usage1.ts +import MyConstEnum1 from './ImportExportDefault'; +import MyConstEnum2 from './ReExportDefault'; +MyConstEnum1.Foo; +MyConstEnum2.Foo; +// @filename: Usage2.ts +import { MyConstEnum } from './ImportExport'; +MyConstEnum.Foo; +// @filename: Usage3.ts +import { MyConstEnum } from './ReExport'; +MyConstEnum.Foo; diff --git a/tests/cases/compiler/emptyTypeArgumentList.ts b/tests/cases/compiler/emptyTypeArgumentList.ts index f06bbc3afd2..8089b3ed2b1 100644 --- a/tests/cases/compiler/emptyTypeArgumentList.ts +++ b/tests/cases/compiler/emptyTypeArgumentList.ts @@ -1,2 +1,6 @@ function foo() { } -foo<>(); \ No newline at end of file +foo<>(); + +// https://github.com/microsoft/TypeScript/issues/33041 +function noParams() {} +noParams<>(); \ No newline at end of file diff --git a/tests/cases/compiler/emptyTypeArgumentListWithNew.ts b/tests/cases/compiler/emptyTypeArgumentListWithNew.ts index 3a4926f5a8a..f7350ac8017 100644 --- a/tests/cases/compiler/emptyTypeArgumentListWithNew.ts +++ b/tests/cases/compiler/emptyTypeArgumentListWithNew.ts @@ -1,2 +1,6 @@ class foo { } -new foo<>(); \ No newline at end of file +new foo<>(); + +// https://github.com/microsoft/TypeScript/issues/33041 +class noParams {} +new noParams<>(); \ No newline at end of file diff --git a/tests/cases/compiler/extendGlobalThis2.ts b/tests/cases/compiler/extendGlobalThis2.ts new file mode 100644 index 00000000000..4949c91cf22 --- /dev/null +++ b/tests/cases/compiler/extendGlobalThis2.ts @@ -0,0 +1,3 @@ +namespace globalThis { + export function foo() { console.log("x"); } +} diff --git a/tests/cases/compiler/javascriptImportDefaultBadExport.ts b/tests/cases/compiler/javascriptImportDefaultBadExport.ts new file mode 100644 index 00000000000..c1f2455e11d --- /dev/null +++ b/tests/cases/compiler/javascriptImportDefaultBadExport.ts @@ -0,0 +1,12 @@ +// https://github.com/microsoft/TypeScript/issues/34481 + +// @allowJs: true +// @checkJs: true +// @noEmit: true + +// @Filename: /a.js +const alias = {}; +module.exports = alias; + +// @Filename: /b.js +import a from "./a"; diff --git a/tests/cases/compiler/jsNegativeElementAccessNotBound.ts b/tests/cases/compiler/jsNegativeElementAccessNotBound.ts new file mode 100644 index 00000000000..c7a204e578f --- /dev/null +++ b/tests/cases/compiler/jsNegativeElementAccessNotBound.ts @@ -0,0 +1,6 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true +// @filename: jsNegativeELementAccessNotBound.js +var indexMap = {}; +indexMap[-1] = 0; diff --git a/tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts b/tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts index f54275f309c..49ebd3807db 100644 --- a/tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts +++ b/tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts @@ -302,6 +302,60 @@ function f14(o: Thing | null) { } } +function f15(o: Thing | undefined, value: number) { + if (o?.foo === value) { + o.foo; + } + else { + o.foo; // Error + } + if (o?.foo !== value) { + o.foo; // Error + } + else { + o.foo; + } + if (o?.foo == value) { + o.foo; + } + else { + o.foo; // Error + } + if (o?.foo != value) { + o.foo; // Error + } + else { + o.foo; + } +} + +function f16(o: Thing | undefined) { + if (o?.foo === undefined) { + o.foo; // Error + } + else { + o.foo; + } + if (o?.foo !== undefined) { + o.foo; + } + else { + o.foo; // Error + } + if (o?.foo == undefined) { + o.foo; // Error + } + else { + o.foo; + } + if (o?.foo != undefined) { + o.foo; + } + else { + o.foo; // Error + } +} + function f20(o: Thing | undefined) { if (typeof o?.foo === "number") { o.foo; @@ -331,3 +385,146 @@ function f21(o: Thing | null) { o.baz; } } + +function f22(o: Thing | undefined) { + if (typeof o?.foo === "number") { + o.foo; + } + else { + o.foo; // Error + } + if (typeof o?.foo !== "number") { + o.foo; // Error + } + else { + o.foo; + } + if (typeof o?.foo == "number") { + o.foo; + } + else { + o.foo; // Error + } + if (typeof o?.foo != "number") { + o.foo; // Error + } + else { + o.foo; + } +} + +function f23(o: Thing | undefined) { + if (typeof o?.foo === "undefined") { + o.foo; // Error + } + else { + o.foo; + } + if (typeof o?.foo !== "undefined") { + o.foo; + } + else { + o.foo; // Error + } + if (typeof o?.foo == "undefined") { + o.foo; // Error + } + else { + o.foo; + } + if (typeof o?.foo != "undefined") { + o.foo; + } + else { + o.foo; // Error + } +} + +declare function assert(x: unknown): asserts x; +declare function assertNonNull(x: T): asserts x is NonNullable; + +function f30(o: Thing | undefined) { + if (!!true) { + assert(o?.foo); + o.foo; + } + if (!!true) { + assert(o?.foo === 42); + o.foo; + } + if (!!true) { + assert(typeof o?.foo === "number"); + o.foo; + } + if (!!true) { + assertNonNull(o?.foo); + o.foo; + } +} + +function f40(o: Thing | undefined) { + switch (o?.foo) { + case "abc": + o.foo; + break; + case 42: + o.foo; + break; + case undefined: + o.foo; // Error + break; + default: + o.foo; // Error + break; + } +} + +function f41(o: Thing | undefined) { + switch (typeof o?.foo) { + case "string": + o.foo; + break; + case "number": + o.foo; + break; + case "undefined": + o.foo; // Error + break; + default: + o.foo; // Error + break; + } +} + +// Repros from #34570 + +type Shape = + | { type: 'rectangle', width: number, height: number } + | { type: 'circle', radius: number } + +function getArea(shape?: Shape) { + switch (shape?.type) { + case 'circle': + return Math.PI * shape.radius ** 2 + case 'rectangle': + return shape.width * shape.height + default: + return 0 + } +} + +type Feature = { + id: string; + geometry?: { + type: string; + coordinates: number[]; + }; +}; + + +function extractCoordinates(f: Feature): number[] { + if (f.geometry?.type !== 'test') { + return []; + } + return f.geometry.coordinates; +} diff --git a/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperator1.ts b/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperator1.ts index 80f0c64e7d9..f7024fd8292 100644 --- a/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperator1.ts +++ b/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperator1.ts @@ -1,4 +1,5 @@ // @strict: true +// @allowUnreachableCode: false declare const a1: string | undefined | null declare const a2: string | undefined | null @@ -39,4 +40,28 @@ const cc4 = c4 ?? true; const dd1 = d1 ?? {b: 1}; const dd2 = d2 ?? {b: 1}; const dd3 = d3 ?? {b: 1}; -const dd4 = d4 ?? {b: 1}; \ No newline at end of file +const dd4 = d4 ?? {b: 1}; + +// Repro from #34635 + +declare function foo(): void; + +const maybeBool = false; + +if (!(maybeBool ?? true)) { + foo(); +} + +if (maybeBool ?? true) { + foo(); +} +else { + foo(); +} + +if (false ?? true) { + foo(); +} +else { + foo(); +} diff --git a/tests/cases/conformance/jsdoc/checkJsdocTypedefOnlySourceFile.ts b/tests/cases/conformance/jsdoc/checkJsdocTypedefOnlySourceFile.ts new file mode 100644 index 00000000000..d991d2f6e16 --- /dev/null +++ b/tests/cases/conformance/jsdoc/checkJsdocTypedefOnlySourceFile.ts @@ -0,0 +1,15 @@ +// @allowJS: true +// @suppressOutputPathCheck: true + +// @filename: 0.js +// @ts-check + +var exports = {}; + +/** + * @typedef {string} + */ +exports.SomeName; + +/** @type {exports.SomeName} */ +const myString = 'str'; diff --git a/tests/cases/conformance/jsdoc/jsdocImportTypeReferenceToClassAlias.ts b/tests/cases/conformance/jsdoc/jsdocImportTypeReferenceToClassAlias.ts new file mode 100644 index 00000000000..d53da960035 --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocImportTypeReferenceToClassAlias.ts @@ -0,0 +1,15 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: mod1.js +class C { + s() { } +} +module.exports.C = C + +// @Filename: test.js +/** @typedef {import('./mod1').C} X */ +/** @param {X} c */ +function demo(c) { + c.s +} diff --git a/tests/cases/conformance/jsdoc/jsdocTypeReferenceToImport.ts b/tests/cases/conformance/jsdoc/jsdocTypeReferenceToImport.ts new file mode 100644 index 00000000000..8163988fc0c --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocTypeReferenceToImport.ts @@ -0,0 +1,23 @@ +// #34802 +// @Filename: jsdocTypeReferenceToImport.js +// @noEmit: true +// @allowJs: true +// @checkJs: true + +const C = require('./ex').C; +const D = require('./ex')?.C; +/** @type {C} c */ +var c = new C() +c.start +c.end + +/** @type {D} c */ +var d = new D() +d.start +d.end + +// @Filename: ex.d.ts +export class C { + start: number + end: number +} diff --git a/tests/cases/conformance/jsdoc/jsdocTypeReferenceToMergedClass.ts b/tests/cases/conformance/jsdoc/jsdocTypeReferenceToMergedClass.ts new file mode 100644 index 00000000000..931ad69cfb0 --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocTypeReferenceToMergedClass.ts @@ -0,0 +1,15 @@ +// https://github.com/microsoft/TypeScript/issues/34685 +// @noEmit: true +// @allowJs: true +// @checkJs: true + +// @Filename: jsdocTypeReferenceToMergedClass.js +var Workspace = {} +/** @type {Workspace.Project} */ +var p; +p.isServiceProject() + +Workspace.Project = function wp() { } +Workspace.Project.prototype = { + isServiceProject() {} +} diff --git a/tests/cases/conformance/salsa/importAliasModuleExports.ts b/tests/cases/conformance/salsa/importAliasModuleExports.ts index 5e850206676..691dde20269 100644 --- a/tests/cases/conformance/salsa/importAliasModuleExports.ts +++ b/tests/cases/conformance/salsa/importAliasModuleExports.ts @@ -11,5 +11,7 @@ module.exports = Alias; // @filename: main.js import A from './mod1' A.prototype.foo = 0 +A.prototype.func = function() { this._func = 0; } new A().bar new A().foo +new A().func() diff --git a/tests/cases/conformance/salsa/mixedPropertyElementAccessAssignmentDeclaration.ts b/tests/cases/conformance/salsa/mixedPropertyElementAccessAssignmentDeclaration.ts new file mode 100644 index 00000000000..8dd13383df0 --- /dev/null +++ b/tests/cases/conformance/salsa/mixedPropertyElementAccessAssignmentDeclaration.ts @@ -0,0 +1,3 @@ +// Should not crash: #34642 +var arr = []; +arr[0].prop[2] = {}; diff --git a/tests/cases/conformance/salsa/prototypePropertyAssignmentMergedTypeReference.ts b/tests/cases/conformance/salsa/prototypePropertyAssignmentMergedTypeReference.ts new file mode 100644 index 00000000000..f79b9e01b5f --- /dev/null +++ b/tests/cases/conformance/salsa/prototypePropertyAssignmentMergedTypeReference.ts @@ -0,0 +1,14 @@ +// https://github.com/microsoft/TypeScript/issues/33993 +// @noEmit: true +// @allowJs: true +// @checkJS: true +// @filename: prototypePropertyAssignmentMergedTypeReference.js +var f = function() { + return 12; +}; + +f.prototype.a = "a"; + +/** @type {new () => f} */ +var x = f; + diff --git a/tests/cases/conformance/types/intersection/commonTypeIntersection.ts b/tests/cases/conformance/types/intersection/commonTypeIntersection.ts new file mode 100644 index 00000000000..1b4ce3746bc --- /dev/null +++ b/tests/cases/conformance/types/intersection/commonTypeIntersection.ts @@ -0,0 +1,4 @@ +declare let x1: { __typename?: 'TypeTwo' } & { a: boolean }; +let y1: { __typename?: 'TypeOne' } & { a: boolean} = x1; // should error here +declare let x2: { __typename?: 'TypeTwo' } & string; +let y2: { __typename?: 'TypeOne' } & string = x2; // should error here diff --git a/tests/cases/conformance/types/intersection/intersectionMemberOfUnionNarrowsCorrectly.ts b/tests/cases/conformance/types/intersection/intersectionMemberOfUnionNarrowsCorrectly.ts new file mode 100644 index 00000000000..d2657011dae --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionMemberOfUnionNarrowsCorrectly.ts @@ -0,0 +1,4 @@ +export type U = { kind?: 'A', a: string } | { kind?: 'B' } & { b: string }; +type Ex = T extends U ? T : never; +declare let x: Ex +x.a diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference3.ts b/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference3.ts index d64b1973695..12a5e8b17cb 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference3.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference3.ts @@ -54,3 +54,37 @@ let y1 = foo1(sx); // string let x2 = foo2(sa); // unknown let y2 = foo2(sx); // { extra: number } + +// Repro from #33490 + +declare class Component

{ props: P } + +export type ComponentClass

= new (props: P) => Component

; +export type FunctionComponent

= (props: P) => null; + +export type ComponentType

= FunctionComponent

| ComponentClass

; + +export interface RouteComponentProps { route: string } + +declare function withRouter< + P extends RouteComponentProps, + C extends ComponentType

+>( + component: C & ComponentType

+): ComponentClass>; + +interface Props extends RouteComponentProps { username: string } + +declare const MyComponent: ComponentType; + +withRouter(MyComponent); + +// Repro from #33490 + +type AB = { a: T } | { b: T }; + +// T & AB normalizes to T & { a: U } | T & { b: U } below +declare function foo(obj: T & AB): [T, U]; +declare let ab: AB; + +let z = foo(ab); // [AB, string] diff --git a/tests/cases/fourslash/completionNoAutoInsertQuestionDotWithUserPreferencesOff.ts b/tests/cases/fourslash/completionNoAutoInsertQuestionDotWithUserPreferencesOff.ts new file mode 100644 index 00000000000..a1071a37f93 --- /dev/null +++ b/tests/cases/fourslash/completionNoAutoInsertQuestionDotWithUserPreferencesOff.ts @@ -0,0 +1,20 @@ +/// +// @strict: true + +//// interface User { +//// address?: { +//// city: string; +//// "postal code": string; +//// } +//// }; +//// declare const user: User; +//// user.address[|./**/|] + +verify.completions({ + marker: "", + exact: [], + preferences: { + includeInsertTextCompletions: true, + includeAutomaticOptionalChainCompletions: false + }, +}); diff --git a/tests/cases/fourslash/findAllRefsGlobalThisKeywordInModule.ts b/tests/cases/fourslash/findAllRefsGlobalThisKeywordInModule.ts new file mode 100644 index 00000000000..40222b2530b --- /dev/null +++ b/tests/cases/fourslash/findAllRefsGlobalThisKeywordInModule.ts @@ -0,0 +1,8 @@ +/// +// @noLib: true + +////[|this|]; +////export const c = 1; + +const [glob] = test.ranges(); +verify.referenceGroups(glob, undefined); diff --git a/tests/cases/fourslash/formatTypeArgumentOnNewLine.ts b/tests/cases/fourslash/formatTypeArgumentOnNewLine.ts new file mode 100644 index 00000000000..8567a5ff06d --- /dev/null +++ b/tests/cases/fourslash/formatTypeArgumentOnNewLine.ts @@ -0,0 +1,18 @@ +/// + +////const genericObject = new GenericObject< +//// /*1*/{} +////>(); +////const genericObject2 = new GenericObject2< +//// /*2*/{}, +//// /*3*/{} +////>(); + +format.document(); + +goTo.marker("1"); +verify.currentLineContentIs(" {}"); +goTo.marker("2"); +verify.currentLineContentIs(" {},"); +goTo.marker("3"); +verify.currentLineContentIs(" {}"); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 5672f430434..cd184df3bed 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -583,6 +583,7 @@ declare namespace FourSlashInterface { readonly quotePreference?: "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; readonly includeInsertTextCompletions?: boolean; + readonly includeAutomaticOptionalChainCompletions?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly importModuleSpecifierEnding?: "minimal" | "index" | "js"; } diff --git a/tests/cases/fourslash/navigationBarComputedPropertyName.ts b/tests/cases/fourslash/navigationBarComputedPropertyName.ts new file mode 100644 index 00000000000..fc6fb808f74 --- /dev/null +++ b/tests/cases/fourslash/navigationBarComputedPropertyName.ts @@ -0,0 +1,57 @@ +/// + +////function F(key, value) { +//// return { +//// [key]: value, +//// "prop": true +//// } +////} + +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "F", + "kind": "function", + "childItems": [ + { + "text": "[key]", + "kind": "property" + }, + { + "text": "\"prop\"", + "kind": "property" + } + ] + } + ] +}); + +verify.navigationBar([ + { + "text": "", + "kind": "script", + "childItems": [ + { + "text": "F", + "kind": "function" + } + ] + }, + { + "text": "F", + "kind": "function", + "childItems": [ + { + "text": "[key]", + "kind": "property" + }, + { + "text": "\"prop\"", + "kind": "property" + } + ], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/refactorExtractType_js7.ts b/tests/cases/fourslash/refactorExtractType_js7.ts new file mode 100644 index 00000000000..c3543ef36e2 --- /dev/null +++ b/tests/cases/fourslash/refactorExtractType_js7.ts @@ -0,0 +1,18 @@ +/// + +// @allowJs: true +// @Filename: a.js +////function a(/** @type {/*a*/string/*b*/} */ b) {} + +goTo.file('a.js') +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract type", + actionName: "Extract to typedef", + actionDescription: "Extract to typedef", + newContent: `/** + * @typedef {string} /*RENAME*/NewType + */ + +function a(/** @type {NewType} */ b) {}`, +});