Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master: (78 commits)
  LEGO: check in for master to temporary branch.
  Skip default when initially iterating exports in __importStar, same as __exportStar (microsoft#38808)
  fix line endings
  Improve error range for ts2657 (jsx expr must have parent element), add code fix for it (microsoft#37917)
  fix(32341): add prefix name for module exports properties (microsoft#38541)
  fix(19385): add space after brace in the multiline string template (microsoft#38742)
  fix(38815): dive in arrow functions to check only this usage instead of checking all statements (microsoft#38865)
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  Convert HTML tags in doc-comments into markdown
  fix linting error
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  fix(38722): change error message for use-before-declaration on const enum (microsoft#38728)
  ...
  • Loading branch information
cangSDARM committed Jun 2, 2020
2 parents 7e748f4 + 1d1c167 commit 59a3320
Show file tree
Hide file tree
Showing 363 changed files with 3,773 additions and 1,474 deletions.
Empty file removed .gitmodules
Empty file.
58 changes: 45 additions & 13 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2290,7 +2290,7 @@ namespace ts {
else {
Debug.assert(!!(result.flags & SymbolFlags.ConstEnum));
if (compilerOptions.preserveConstEnums) {
diagnosticMessage = error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName);
diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
}
}

Expand Down Expand Up @@ -4142,12 +4142,16 @@ namespace ts {
let leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left);
let rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right);
if (leftStr === rightStr) {
leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType);
rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType);
leftStr = getTypeNameForErrorDisplay(left);
rightStr = getTypeNameForErrorDisplay(right);
}
return [leftStr, rightStr];
}

function getTypeNameForErrorDisplay(type: Type) {
return typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType);
}

function symbolValueDeclarationIsContextSensitive(symbol: Symbol): boolean {
return symbol && symbol.valueDeclaration && isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration);
}
Expand Down Expand Up @@ -15729,23 +15733,30 @@ namespace ts {
function reportRelationError(message: DiagnosticMessage | undefined, source: Type, target: Type) {
if (incompatibleStack.length) reportIncompatibleStack();
const [sourceType, targetType] = getTypeNamesForErrorDisplay(source, target);
let generalizedSource = source;
let generalizedSourceType = sourceType;

if (isLiteralType(source) && !typeCouldHaveTopLevelSingletonTypes(target)) {
generalizedSource = getBaseTypeOfLiteralType(source);
generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource);
}

if (target.flags & TypeFlags.TypeParameter) {
const constraint = getBaseConstraintOfType(target);
const constraintElab = constraint && isTypeAssignableTo(source, constraint);
if (constraintElab) {
let needsOriginalSource;
if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) {
reportError(
Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2,
sourceType,
needsOriginalSource ? sourceType : generalizedSourceType,
targetType,
typeToString(constraint!),
typeToString(constraint),
);
}
else {
reportError(
Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1,
targetType,
sourceType
generalizedSourceType
);
}
}
Expand All @@ -15762,7 +15773,7 @@ namespace ts {
}
}

reportError(message, sourceType, targetType);
reportError(message, generalizedSourceType, targetType);
}

function tryElaborateErrorsForPrimitivesAndObjects(source: Type, target: Type) {
Expand Down Expand Up @@ -17360,6 +17371,21 @@ namespace ts {
}
}

function typeCouldHaveTopLevelSingletonTypes(type: Type): boolean {
if (type.flags & TypeFlags.UnionOrIntersection) {
return !!forEach((type as IntersectionType).types, typeCouldHaveTopLevelSingletonTypes);
}

if (type.flags & TypeFlags.Instantiable) {
const constraint = getConstraintOfType(type);
if (constraint) {
return typeCouldHaveTopLevelSingletonTypes(constraint);
}
}

return isUnitType(type);
}

function getBestMatchingType(source: Type, target: UnionOrIntersectionType, isRelatedTo = compareTypesAssignable) {
return findMatchingDiscriminantType(source, target, isRelatedTo, /*skipPartial*/ true) ||
findMatchingTypeReferenceOrTypeAliasReference(source, target) ||
Expand Down Expand Up @@ -28746,7 +28772,14 @@ namespace ts {
}
case SyntaxKind.CommaToken:
if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) {
error(left, Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
const sf = getSourceFileOfNode(left);
const sourceText = sf.text;
const start = skipTrivia(sourceText, left.pos);
const isInDiag2657 = sf.parseDiagnostics.some(diag => {
if (diag.code !== Diagnostics.JSX_expressions_must_have_one_parent_element.code) return false;
return textSpanContainsPosition(diag, start);
});
if (!isInDiag2657) error(left, Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
}
return rightType;

Expand Down Expand Up @@ -33827,8 +33860,7 @@ namespace ts {
const derivedPropertyFlags = derived.flags & SymbolFlags.PropertyOrAccessor;
if (basePropertyFlags && derivedPropertyFlags) {
// property/accessor is overridden with property/accessor
if (!compilerOptions.useDefineForClassFields
|| baseDeclarationFlags & ModifierFlags.Abstract && !(base.valueDeclaration && isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
if (baseDeclarationFlags & ModifierFlags.Abstract && !(base.valueDeclaration && isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
|| base.valueDeclaration && base.valueDeclaration.parent.kind === SyntaxKind.InterfaceDeclaration
|| derived.valueDeclaration && isBinaryExpression(derived.valueDeclaration)) {
// when the base property is abstract or from an interface, base/derived flags don't need to match
Expand All @@ -33844,7 +33876,7 @@ namespace ts {
Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor;
error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, symbolToString(base), typeToString(baseType), typeToString(type));
}
else {
else if (compilerOptions.useDefineForClassFields) {
const uninitialized = find(derived.declarations, d => d.kind === SyntaxKind.PropertyDeclaration && !(d as PropertyDeclaration).initializer);
if (uninitialized
&& !(derived.flags & SymbolFlags.Transient)
Expand Down
28 changes: 28 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5705,6 +5705,34 @@
"category": "Message",
"code": 95118
},
"Generate 'get' and 'set' accessors for all overriding properties": {
"category": "Message",
"code": 95119
},
"Wrap in JSX fragment": {
"category": "Message",
"code": 95120
},
"Wrap all unparented JSX in JSX fragment": {
"category": "Message",
"code": 95121
},
"Convert arrow function or function expression": {
"category": "Message",
"code": 95122
},
"Convert to anonymous function": {
"category": "Message",
"code": 95123
},
"Convert to named function": {
"category": "Message",
"code": 95124
},
"Convert to arrow function": {
"category": "Message",
"code": 95125
},

"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
"category": "Error",
Expand Down
7 changes: 4 additions & 3 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4519,7 +4519,7 @@ namespace ts {
return finishNode(node);
}

function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext: boolean): JsxElement | JsxSelfClosingElement | JsxFragment {
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext: boolean, topInvalidNodePosition?: number): JsxElement | JsxSelfClosingElement | JsxFragment {
const opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
let result: JsxElement | JsxSelfClosingElement | JsxFragment;
if (opening.kind === SyntaxKind.JsxOpeningElement) {
Expand Down Expand Up @@ -4557,15 +4557,16 @@ namespace ts {
// Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios
// of one sort or another.
if (inExpressionContext && token() === SyntaxKind.LessThanToken) {
const invalidElement = tryParse(() => parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true));
const topBadPos = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition;
const invalidElement = tryParse(() => parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true, topBadPos));
if (invalidElement) {
parseErrorAtCurrentToken(Diagnostics.JSX_expressions_must_have_one_parent_element);
const badNode = <BinaryExpression>createNode(SyntaxKind.BinaryExpression, result.pos);
badNode.end = invalidElement.end;
badNode.left = result;
badNode.right = invalidElement;
badNode.operatorToken = createMissingNode(SyntaxKind.CommaToken, /*reportAtCurrentPosition*/ false);
badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos;
parseErrorAt(skipTrivia(sourceText, topBadPos), invalidElement.end, Diagnostics.JSX_expressions_must_have_one_parent_element);
return <JsxElement><Node>badNode;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/transformers/module/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};`
Expand Down
28 changes: 14 additions & 14 deletions src/lib/es2015.core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,48 +434,48 @@ interface String {
startsWith(searchString: string, position?: number): boolean;

/**
* Returns an <a> HTML anchor element and sets the name attribute to the text value
* Returns an `<a>` HTML anchor element and sets the name attribute to the text value
* @param name
*/
anchor(name: string): string;

/** Returns a <big> HTML element */
/** Returns a `<big>` HTML element */
big(): string;

/** Returns a <blink> HTML element */
/** Returns a `<blink>` HTML element */
blink(): string;

/** Returns a <b> HTML element */
/** Returns a `<b>` HTML element */
bold(): string;

/** Returns a <tt> HTML element */
/** Returns a `<tt>` HTML element */
fixed(): string;

/** Returns a <font> HTML element and sets the color attribute value */
/** Returns a `<font>` HTML element and sets the color attribute value */
fontcolor(color: string): string;

/** Returns a <font> HTML element and sets the size attribute value */
/** Returns a `<font>` HTML element and sets the size attribute value */
fontsize(size: number): string;

/** Returns a <font> HTML element and sets the size attribute value */
/** Returns a `<font>` HTML element and sets the size attribute value */
fontsize(size: string): string;

/** Returns an <i> HTML element */
/** Returns an `<i>` HTML element */
italics(): string;

/** Returns an <a> HTML element and sets the href attribute value */
/** Returns an `<a>` HTML element and sets the href attribute value */
link(url: string): string;

/** Returns a <small> HTML element */
/** Returns a `<small>` HTML element */
small(): string;

/** Returns a <strike> HTML element */
/** Returns a `<strike>` HTML element */
strike(): string;

/** Returns a <sub> HTML element */
/** Returns a `<sub>` HTML element */
sub(): string;

/** Returns a <sup> HTML element */
/** Returns a `<sup>` HTML element */
sup(): string;
}

Expand Down
Loading

0 comments on commit 59a3320

Please sign in to comment.