Merge branch 'master' into fix34579

# Conflicts:
#	src/compiler/utilities.ts
This commit is contained in:
Ron Buckton
2019-10-29 18:22:36 -07:00
156 changed files with 5155 additions and 1176 deletions
+44 -41
View File
@@ -1,41 +1,44 @@
---
name: Bug report
about: Create a report to help us improve
---
<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨
Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section!
Please help us by doing the following steps before logging an issue:
* Search: https://github.com/Microsoft/TypeScript/search?type=Issues
* Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ
Please fill in the *entire* template below.
-->
<!--
Please try to reproduce the issue with the latest published version. It may have already been fixed.
For npm: `typescript@next`
This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly
-->
**TypeScript Version:** 3.7.x-dev.201xxxxx
<!-- Search terms you tried before logging this (so others can find this issue more easily) -->
**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:** <!-- A link to a TypeScript Playground "Share" link which demonstrates this behavior -->
**Related Issues:** <!-- Did you find other bugs that looked similar? -->
---
name: Bug
about: Create a report to help us improve TypeScript
title: ''
labels: ''
assignees: ''
---
<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨
Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section!
Please help us by doing the following steps before logging an issue:
* Search: https://github.com/Microsoft/TypeScript/search?type=Issues
* Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ
Please fill in the *entire* template below.
-->
<!--
Please try to reproduce the issue with the latest published version. It may have already been fixed.
For npm: `typescript@next`
This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly
-->
**TypeScript Version:** 3.7.x-dev.201xxxxx
<!-- Search terms you tried before logging this (so others can find this issue more easily) -->
**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:** <!-- A link to a TypeScript Playground "Share" link which demonstrates this behavior -->
**Related Issues:** <!-- Did you find other bugs that looked similar? -->
+47 -45
View File
@@ -1,45 +1,47 @@
---
name: Feature request
about: Suggest an idea for this project
---
<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨
Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker.
Please help us by doing the following steps before logging an issue:
* Search: https://github.com/Microsoft/TypeScript/search?type=Issues
* Read the FAQ, especially the "Common Feature Requests" section: https://github.com/Microsoft/TypeScript/wiki/FAQ
-->
## Search Terms
<!-- List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily -->
## Suggestion
<!-- A summary of what you'd like to see added or changed -->
## Use Cases
<!--
What do you want to use this for?
What shortcomings exist with current approaches?
-->
## Examples
<!-- Show how this would be used and what the behavior would be -->
## 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: ''
---
<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨
Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker.
Please help us by doing the following steps before logging an issue:
* Search: https://github.com/Microsoft/TypeScript/search?type=Issues
* Read the FAQ, especially the "Common Feature Requests" section: https://github.com/Microsoft/TypeScript/wiki/FAQ
-->
## Search Terms
<!-- List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily -->
## Suggestion
<!-- A summary of what you'd like to see added or changed -->
## Use Cases
<!--
What do you want to use this for?
What shortcomings exist with current approaches?
-->
## Examples
<!-- Show how this would be used and what the behavior would be -->
## 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).
-15
View File
@@ -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.
+8
View File
@@ -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
+37
View File
@@ -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
+25 -4
View File
@@ -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}"
}
]
}
}
+2 -2
View File
@@ -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.
+3 -3
View File
@@ -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),
+1 -1
View File
@@ -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": [
+2 -1
View File
@@ -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 => {
+17 -9
View File
@@ -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
+129 -92
View File
@@ -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(<IntersectionType>source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true);
result = someTypeRelatedToType(<IntersectionType>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<RelationComparisonResult>) {
function getRelationKey(source: Type, target: Type, isIntersectionConstituent: boolean, relation: Map<RelationComparisonResult>) {
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(<TypeReference>source, typeParameters) + "," + getTypeReferenceId(<TypeReference>target, typeParameters);
return getTypeReferenceId(<TypeReference>source, typeParameters) + "," + getTypeReferenceId(<TypeReference>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((<IntersectionType>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> | 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, <IndexType>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 = <Block | ModuleBlock | SourceFile>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 && (<StringLiteralType>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, <AccessExpression>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 && (<ElementAccessExpression>node.parent).expression === node) ||
((node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName) && isInRightSideOfImportOrExportAssignment(<Identifier>node) ||
(node.parent.kind === SyntaxKind.TypeQuery && (<TypeQueryNode>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);
+1 -1
View File
@@ -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`;
}
+6 -4
View File
@@ -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) {
+6 -2
View File
@@ -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 {
+43 -37
View File
@@ -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<OutputFingerprint>;
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<OutputFingerprint>();
}
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) :
+8 -18
View File
@@ -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*/
+17 -2
View File
@@ -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);
+6 -1
View File
@@ -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);
}
+1
View File
@@ -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" */
+51 -11
View File
@@ -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 && (<BinaryExpression>node).operatorToken.kind === SyntaxKind.QuestionQuestionToken;
}
export function isNewExpression(node: Node): node is NewExpression {
return node.kind === SyntaxKind.NewExpression;
}
+10 -10
View File
@@ -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");
+118 -19
View File
@@ -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<true> | undefined;
private symlinkedDirectories: Map<SymlinkedDirectory | false> | undefined;
private symlinkedFiles: Map<string> | 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();
}
+6
View File
@@ -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;
+24 -5
View File
@@ -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<UserPreferences, "includeCompletionsForModuleExports" | "includeCompletionsWithInsertText">,
preferences: Pick<UserPreferences, "includeCompletionsForModuleExports" | "includeCompletionsWithInsertText" | "includeAutomaticOptionalChainCompletions">,
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);
}
+1 -1
View File
@@ -584,7 +584,7 @@ namespace ts.FindAllReferences.Core {
}
function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol: Symbol, program: Program, sourceFiles: readonly SourceFile[], cancellationToken: CancellationToken, options: Options, sourceFilesSet: ReadonlyMap<true>) {
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.
+3 -2
View File
@@ -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
+2 -1
View File
@@ -648,7 +648,8 @@ namespace ts.NavigationBar {
const declName = getNameOfDeclaration(<Declaration>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:
+1 -5
View File
@@ -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);
}
+1 -3
View File
@@ -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;
@@ -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("'"),
+29
View File
@@ -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<T extends Node>(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);
@@ -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
@@ -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: []
}]
});
});
});
}
@@ -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
};
}
});
});
}
+2 -5
View File
@@ -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 }
]
@@ -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<T = {}> = new (...args: any[]) => T;
export function Timestamped<TBase extends Constructor>(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<T = {}> = new (...args: any[]) => T;
export declare function Timestamped<TBase extends Constructor>(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();
}
@@ -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<T = {}> = 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<TBase extends Constructor>(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();
}
}
@@ -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<T = {}> = new (...args: any[]) => T;
>Constructor : Constructor<T>
>args : any[]
export function Timestamped<TBase extends Constructor>(Base: TBase) {
>Timestamped : <TBase extends Constructor<{}>>(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped<any>.(Anonymous class); } & TBase
>Base : TBase
return class extends Base {
>class extends Base { timestamp = Date.now(); } : { new (...args: any[]): (Anonymous class); prototype: Timestamped<any>.(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 : <TBase extends import("tests/cases/compiler/wrapClass").Constructor<{}>>(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped<any>.(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<typeof User>.(Anonymous class) & User
>Timestamped : <TBase extends import("tests/cases/compiler/wrapClass").Constructor<{}>>(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped<any>.(Anonymous class); } & TBase
>User : typeof User
constructor() {
super();
>super() : void
>super : { new (...args: any[]): Timestamped<typeof User>.(Anonymous class); prototype: Timestamped<any>.(Anonymous class); } & typeof User
}
}
+17 -1
View File
@@ -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.
+3 -1
View File
@@ -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;
@@ -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];
@@ -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';
@@ -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';
@@ -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))
@@ -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"
@@ -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"'.
@@ -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
@@ -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))
@@ -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
@@ -5,20 +5,23 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t
Type '"text" | "email"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"] & ChannelOfType<T, EmailChannel>["type"]'.
Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"] & ChannelOfType<T, EmailChannel>["type"]'.
Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
Type 'T' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
Type '"text" | "email"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["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<T, TextChannel>["type"]'.
Type '"text" | "email"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["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<T, TextChannel>["type"] & ChannelOfType<T, EmailChannel>["type"]'.
!!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"] & ChannelOfType<T, EmailChannel>["type"]'.
!!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
!!! error TS2322: Type 'T' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
!!! error TS2322: Type '"text" | "email"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
!!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["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<T, TextChannel>["type"]'.
!!! error TS2322: Type '"text" | "email"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
!!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["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');
@@ -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];
@@ -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];
@@ -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 */;
@@ -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))
@@ -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
@@ -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<T>(x: T): asserts x is NonNullable<T>;
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;
}
@@ -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<T>(x: T): asserts x is NonNullable<T>;
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;
}
@@ -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<T>(x: T): asserts x is NonNullable<T>;
>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))
}
@@ -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<T>(x: T): asserts x is NonNullable<T>;
>assertNonNull : <T>(x: T) => asserts x is NonNullable<T>
>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 : <T>(x: T) => asserts x is NonNullable<T>
>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[]
}
@@ -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:
@@ -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;
@@ -9,7 +9,7 @@ function foo<T extends string>(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];
@@ -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);
@@ -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
+46 -45
View File
@@ -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
+12 -11
View File
@@ -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 (<anonymous>)
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.<anonymous> (/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.
@@ -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.
// https://github.com/microsoft/TypeScript/issues/33041
function noParams() {}
noParams<>();
~~
!!! error TS1099: Type argument list cannot be empty.
@@ -1,7 +1,14 @@
//// [emptyTypeArgumentList.ts]
function foo<T>() { }
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();
@@ -6,3 +6,10 @@ function foo<T>() { }
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))
@@ -3,6 +3,14 @@ function foo<T>() { }
>foo : <T>() => void
foo<>();
>foo<>() : any
>foo<>() : void
>foo : <T>() => void
// https://github.com/microsoft/TypeScript/issues/33041
function noParams() {}
>noParams : () => void
noParams<>();
>noParams<>() : void
>noParams : () => void
@@ -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.
// https://github.com/microsoft/TypeScript/issues/33041
class noParams {}
new noParams<>();
~~
!!! error TS1099: Type argument list cannot be empty.
@@ -1,6 +1,10 @@
//// [emptyTypeArgumentListWithNew.ts]
class foo<T> { }
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();
@@ -6,3 +6,10 @@ class foo<T> { }
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))
@@ -3,6 +3,14 @@ class foo<T> { }
>foo : foo<T>
new foo<>();
>new foo<>() : any
>new foo<>() : foo<unknown>
>foo : typeof foo
// https://github.com/microsoft/TypeScript/issues/33041
class noParams {}
>noParams : noParams
new noParams<>();
>new noParams<>() : noParams
>noParams : typeof noParams
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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, --, --))
@@ -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"); }
}
@@ -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 = {}));
@@ -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, --, --))
}
@@ -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"
}
@@ -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 + ""]);
}
@@ -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))
@@ -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'.
@@ -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))
@@ -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
@@ -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)'.
@@ -0,0 +1,11 @@
//// [intersectionMemberOfUnionNarrowsCorrectly.ts]
export type U = { kind?: 'A', a: string } | { kind?: 'B' } & { b: string };
type Ex<T, U> = T extends U ? T : never;
declare let x: Ex<U, { kind?: 'A' }>
x.a
//// [intersectionMemberOfUnionNarrowsCorrectly.js]
"use strict";
exports.__esModule = true;
x.a;
@@ -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, U> = 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<U, { kind?: 'A' }>
>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))
@@ -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, U> = T extends U ? T : never;
>Ex : Ex<T, U>
declare let x: Ex<U, { kind?: 'A' }>
>x : { kind?: "A"; a: string; }
>kind : "A"
x.a
>x.a : string
>x : { kind?: "A"; a: string; }
>a : string
@@ -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.
@@ -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))
@@ -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
@@ -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))
@@ -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

Some files were not shown because too many files have changed in this diff Show More