Skip to content

Commit 8545211

Browse files
committed
Merge branch 'master' of https://github.com/microsoft/TypeScript into fix/42519
2 parents f463824 + d7d7b88 commit 8545211

File tree

42 files changed

+1102
-99
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1102
-99
lines changed

.travis.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

Gulpfile.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const log = require("fancy-log");
55
const newer = require("gulp-newer");
66
const sourcemaps = require("gulp-sourcemaps");
77
const del = require("del");
8-
const fold = require("travis-fold");
98
const rename = require("gulp-rename");
109
const concat = require("gulp-concat");
1110
const merge2 = require("merge2");
@@ -346,9 +345,6 @@ const runEslintRulesTests = () => runConsoleTests("scripts/eslint/built/tests",
346345
task("run-eslint-rules-tests", series(buildEslintRules, runEslintRulesTests));
347346
task("run-eslint-rules-tests").description = "Runs the eslint rule tests";
348347

349-
const lintFoldStart = async () => { if (fold.isTravis()) console.log(fold.start("lint")); };
350-
const lintFoldEnd = async () => { if (fold.isTravis()) console.log(fold.end("lint")); };
351-
352348
/** @type { (folder: string) => { (): Promise<any>; displayName?: string } } */
353349
const eslint = (folder) => async () => {
354350

@@ -374,20 +370,20 @@ const eslint = (folder) => async () => {
374370

375371
const lintScripts = eslint("scripts");
376372
lintScripts.displayName = "lint-scripts";
377-
task("lint-scripts", series([buildEslintRules, lintFoldStart, lintScripts, lintFoldEnd]));
373+
task("lint-scripts", series([buildEslintRules, lintScripts]));
378374
task("lint-scripts").description = "Runs eslint on the scripts sources.";
379375

380376
const lintCompiler = eslint("src");
381377
lintCompiler.displayName = "lint-compiler";
382-
task("lint-compiler", series([buildEslintRules, lintFoldStart, lintCompiler, lintFoldEnd]));
378+
task("lint-compiler", series([buildEslintRules, lintCompiler]));
383379
task("lint-compiler").description = "Runs eslint on the compiler sources.";
384380
task("lint-compiler").flags = {
385381
" --ci": "Runs eslint additional rules",
386382
};
387383

388-
const lint = series([buildEslintRules, lintFoldStart, lintScripts, lintCompiler, lintFoldEnd]);
384+
const lint = series([buildEslintRules, lintScripts, lintCompiler]);
389385
lint.displayName = "lint";
390-
task("lint", series([buildEslintRules, lintFoldStart, lint, lintFoldEnd]));
386+
task("lint", series([buildEslintRules, lint]));
391387
task("lint").description = "Runs eslint on the compiler and scripts sources.";
392388
task("lint").flags = {
393389
" --ci": "Runs eslint additional rules",
@@ -429,9 +425,7 @@ const buildOtherOutputs = parallel(buildCancellationToken, buildTypingsInstaller
429425
task("other-outputs", series(preBuild, buildOtherOutputs));
430426
task("other-outputs").description = "Builds miscelaneous scripts and documents distributed with the LKG";
431427

432-
const buildFoldStart = async () => { if (fold.isTravis()) console.log(fold.start("build")); };
433-
const buildFoldEnd = async () => { if (fold.isTravis()) console.log(fold.end("build")); };
434-
task("local", series(buildFoldStart, preBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl, buildOtherOutputs), buildFoldEnd));
428+
task("local", series(preBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl, buildOtherOutputs)));
435429
task("local").description = "Builds the full compiler and services";
436430
task("local").flags = {
437431
" --built": "Compile using the built version of the compiler."

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# TypeScript
33

4-
[![Build Status](https://travis-ci.org/microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/microsoft/TypeScript)
4+
[![GitHub Actions CI](https://github.com/microsoft/TypeScript/workflows/CI/badge.svg)](https://github.com/microsoft/TypeScript/actions?query=workflow%3ACI)
55
[![Devops Build Status](https://dev.azure.com/typescript/TypeScript/_apis/build/status/Typescript/node10)](https://dev.azure.com/typescript/TypeScript/_build?definitionId=7)
66
[![npm version](https://badge.fury.io/js/typescript.svg)](https://www.npmjs.com/package/typescript)
77
[![Downloads](https://img.shields.io/npm/dm/typescript.svg)](https://www.npmjs.com/package/typescript)

package-lock.json

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"@types/q": "latest",
5353
"@types/source-map-support": "latest",
5454
"@types/through2": "latest",
55-
"@types/travis-fold": "latest",
5655
"@types/xml2js": "^0.4.0",
5756
"@typescript-eslint/eslint-plugin": "4.5.0",
5857
"@typescript-eslint/experimental-utils": "4.5.0",
@@ -95,7 +94,6 @@
9594
"remove-internal": "^2.9.2",
9695
"source-map-support": "latest",
9796
"through2": "latest",
98-
"travis-fold": "latest",
9997
"typescript": "^4.0.0-dev.20200624",
10098
"vinyl": "latest",
10199
"vinyl-sourcemaps-apply": "latest",

src/compiler/binder.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,6 +2540,11 @@ namespace ts {
25402540
node.flowNode = currentFlow;
25412541
}
25422542
return checkContextualIdentifier(<Identifier>node);
2543+
case SyntaxKind.QualifiedName:
2544+
if (currentFlow && parent.kind === SyntaxKind.TypeQuery) {
2545+
node.flowNode = currentFlow;
2546+
}
2547+
break;
25432548
case SyntaxKind.SuperKeyword:
25442549
node.flowNode = currentFlow;
25452550
break;

src/compiler/checker.ts

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4183,7 +4183,8 @@ namespace ts {
41834183
return {
41844184
accessibility: SymbolAccessibility.CannotBeNamed,
41854185
errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
4186-
errorModuleName: symbolToString(symbolExternalModule)
4186+
errorModuleName: symbolToString(symbolExternalModule),
4187+
errorNode: isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined,
41874188
};
41884189
}
41894190
}
@@ -4699,7 +4700,7 @@ namespace ts {
46994700

47004701
function createMappedTypeNodeFromType(type: MappedType) {
47014702
Debug.assert(!!(type.flags & TypeFlags.Object));
4702-
const readonlyToken = type.declaration.readonlyToken ? <ReadonlyToken | PlusToken | MinusToken>factory.createToken(type.declaration.readonlyToken.kind) : undefined;
4703+
const readonlyToken = type.declaration.readonlyToken ? <ReadonlyKeyword | PlusToken | MinusToken>factory.createToken(type.declaration.readonlyToken.kind) : undefined;
47034704
const questionToken = type.declaration.questionToken ? <QuestionToken | PlusToken | MinusToken>factory.createToken(type.declaration.questionToken.kind) : undefined;
47044705
let appropriateConstraintTypeNode: TypeNode;
47054706
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
@@ -6183,7 +6184,7 @@ namespace ts {
61836184
tracker: {
61846185
...oldcontext.tracker,
61856186
trackSymbol: (sym, decl, meaning) => {
6186-
const accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeALiases*/ false);
6187+
const accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false);
61876188
if (accessibleResult.accessibility === SymbolAccessibility.Accessible) {
61886189
// Lookup the root symbol of the chain of refs we'll use to access it and serialize it
61896190
const chain = lookupSymbolChainWorker(sym, context, meaning);
@@ -6625,16 +6626,17 @@ namespace ts {
66256626
function addResult(node: Statement, additionalModifierFlags: ModifierFlags) {
66266627
if (canHaveModifiers(node)) {
66276628
let newModifierFlags: ModifierFlags = ModifierFlags.None;
6629+
const enclosingDeclaration = context.enclosingDeclaration &&
6630+
(isJSDocTypeAlias(context.enclosingDeclaration) ? getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
66286631
if (additionalModifierFlags & ModifierFlags.Export &&
6629-
context.enclosingDeclaration &&
6630-
(isExportingScope(context.enclosingDeclaration) || isModuleDeclaration(context.enclosingDeclaration)) &&
6632+
enclosingDeclaration && (isExportingScope(enclosingDeclaration) || isModuleDeclaration(enclosingDeclaration)) &&
66316633
canHaveExportModifier(node)
66326634
) {
66336635
// Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private
66346636
newModifierFlags |= ModifierFlags.Export;
66356637
}
66366638
if (addingDeclare && !(newModifierFlags & ModifierFlags.Export) &&
6637-
(!context.enclosingDeclaration || !(context.enclosingDeclaration.flags & NodeFlags.Ambient)) &&
6639+
(!enclosingDeclaration || !(enclosingDeclaration.flags & NodeFlags.Ambient)) &&
66386640
(isEnumDeclaration(node) || isVariableStatement(node) || isFunctionDeclaration(node) || isClassDeclaration(node) || isModuleDeclaration(node))) {
66396641
// Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope
66406642
newModifierFlags |= ModifierFlags.Ambient;
@@ -6657,6 +6659,8 @@ namespace ts {
66576659
const commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined;
66586660
const oldFlags = context.flags;
66596661
context.flags |= NodeBuilderFlags.InTypeAlias;
6662+
const oldEnclosingDecl = context.enclosingDeclaration;
6663+
context.enclosingDeclaration = jsdocAliasDecl;
66606664
const typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression
66616665
&& isJSDocTypeExpression(jsdocAliasDecl.typeExpression)
66626666
&& serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled)
@@ -6666,6 +6670,7 @@ namespace ts {
66666670
!commentText ? [] : [{ kind: SyntaxKind.MultiLineCommentTrivia, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]
66676671
), modifierFlags);
66686672
context.flags = oldFlags;
6673+
context.enclosingDeclaration = oldEnclosingDecl;
66696674
}
66706675

66716676
function serializeInterface(symbol: Symbol, symbolName: string, modifierFlags: ModifierFlags) {
@@ -14642,6 +14647,7 @@ namespace ts {
1464214647
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
1464314648
// purposes of resolution. This means such types aren't subject to the instatiation depth limiter.
1464414649
while (true) {
14650+
const isUnwrapped = isTypicalNondistributiveConditional(root);
1464514651
const checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.checkType), mapper);
1464614652
const checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
1464714653
const extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
@@ -14667,9 +14673,9 @@ namespace ts {
1466714673
// types with type parameters mapped to the wildcard type, the most permissive instantiations
1466814674
// possible (the wildcard type is assignable to and from all types). If those are not related,
1466914675
// then no instantiations will be and we can just return the false branch type.
14670-
if (!(inferredExtendsType.flags & TypeFlags.AnyOrUnknown) && ((checkType.flags & TypeFlags.Any && root.isDistributive) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
14676+
if (!(inferredExtendsType.flags & TypeFlags.AnyOrUnknown) && ((checkType.flags & TypeFlags.Any && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
1467114677
// Return union of trueType and falseType for 'any' since it matches anything
14672-
if (checkType.flags & TypeFlags.Any && root.isDistributive) {
14678+
if (checkType.flags & TypeFlags.Any && !isUnwrapped) {
1467314679
(extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
1467414680
}
1467514681
// If falseType is an immediately nested conditional type that isn't distributive or has an
@@ -21284,8 +21290,12 @@ namespace ts {
2128421290
case SyntaxKind.PropertyAccessExpression:
2128521291
case SyntaxKind.ElementAccessExpression:
2128621292
return isAccessExpression(target) &&
21287-
getAccessedPropertyName(<AccessExpression>source) === getAccessedPropertyName(target) &&
21288-
isMatchingReference((<AccessExpression>source).expression, target.expression);
21293+
getAccessedPropertyName(source as AccessExpression) === getAccessedPropertyName(target) &&
21294+
isMatchingReference((source as AccessExpression).expression, target.expression);
21295+
case SyntaxKind.QualifiedName:
21296+
return isAccessExpression(target) &&
21297+
(source as QualifiedName).right.escapedText === getAccessedPropertyName(target) &&
21298+
isMatchingReference((source as QualifiedName).left, target.expression);
2128921299
case SyntaxKind.BinaryExpression:
2129021300
return (isBinaryExpression(source) && source.operatorToken.kind === SyntaxKind.CommaToken && isMatchingReference(source.right, target));
2129121301
}
@@ -22631,13 +22641,13 @@ namespace ts {
2263122641
if (propName === undefined) {
2263222642
return type;
2263322643
}
22634-
const includesUndefined = strictNullChecks && maybeTypeOfKind(type, TypeFlags.Undefined);
22635-
const removeOptional = includesUndefined && isOptionalChain(access);
22636-
let propType = getTypeOfPropertyOfType(removeOptional ? getTypeWithFacts(type, TypeFacts.NEUndefined) : type, propName);
22644+
const includesNullable = strictNullChecks && maybeTypeOfKind(type, TypeFlags.Nullable);
22645+
const removeNullable = includesNullable && isOptionalChain(access);
22646+
let propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull) : type, propName);
2263722647
if (!propType) {
2263822648
return type;
2263922649
}
22640-
propType = removeOptional ? getOptionalType(propType) : propType;
22650+
propType = removeNullable ? getOptionalType(propType) : propType;
2264122651
const narrowedPropType = narrowType(propType);
2264222652
return filterType(type, t => {
2264322653
const discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
@@ -24752,6 +24762,8 @@ namespace ts {
2475224762
const tag = isInJSFile(parent) ? getJSDocTypeTag(parent) : undefined;
2475324763
return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(<ParenthesizedExpression>parent, contextFlags);
2475424764
}
24765+
case SyntaxKind.NonNullExpression:
24766+
return getContextualType(parent as NonNullExpression, contextFlags);
2475524767
case SyntaxKind.JsxExpression:
2475624768
return getContextualTypeForJsxExpression(<JsxExpression>parent);
2475724769
case SyntaxKind.JsxAttribute:
@@ -26414,8 +26426,7 @@ namespace ts {
2641426426
// assignment target, and the referenced property was declared as a variable, property,
2641526427
// accessor, or optional method.
2641626428
const assignmentKind = getAssignmentTargetKind(node);
26417-
if (!isAccessExpression(node) ||
26418-
assignmentKind === AssignmentKind.Definite ||
26429+
if (assignmentKind === AssignmentKind.Definite ||
2641926430
prop && !(prop.flags & (SymbolFlags.Variable | SymbolFlags.Property | SymbolFlags.Accessor)) && !(prop.flags & SymbolFlags.Method && propType.flags & TypeFlags.Union)) {
2642026431
return propType;
2642126432
}
@@ -26427,7 +26438,7 @@ namespace ts {
2642726438
// and if we are in a constructor of the same class as the property declaration, assume that
2642826439
// the property is uninitialized at the top of the control flow.
2642926440
let assumeUninitialized = false;
26430-
if (strictNullChecks && strictPropertyInitialization && node.expression.kind === SyntaxKind.ThisKeyword) {
26441+
if (strictNullChecks && strictPropertyInitialization && isAccessExpression(node) && node.expression.kind === SyntaxKind.ThisKeyword) {
2643126442
const declaration = prop && prop.valueDeclaration;
2643226443
if (declaration && isInstancePropertyWithoutInitializer(declaration)) {
2643326444
const flowContainer = getControlFlowContainer(node);

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3537,6 +3537,10 @@
35373537
"category": "Error",
35383538
"code": 4083
35393539
},
3540+
"Exported type alias '{0}' has or is using private name '{1}' from module {2}.": {
3541+
"category": "Error",
3542+
"code": 4084
3543+
},
35403544
"Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict.": {
35413545
"category": "Error",
35423546
"code": 4090

src/compiler/transformers/declarations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,12 @@ namespace ts {
217217

218218
function transformDeclarationsForJS(sourceFile: SourceFile, bundled?: boolean) {
219219
const oldDiag = getSymbolAccessibilityDiagnostic;
220-
getSymbolAccessibilityDiagnostic = (s) => ({
220+
getSymbolAccessibilityDiagnostic = (s) => (s.errorNode && canProduceDiagnostics(s.errorNode) ? createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({
221221
diagnosticMessage: s.errorModuleName
222222
? Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit
223223
: Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit,
224224
errorNode: s.errorNode || sourceFile
225-
});
225+
}));
226226
const result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled);
227227
getSymbolAccessibilityDiagnostic = oldDiag;
228228
return result;

0 commit comments

Comments
 (0)