Skip to content

Commit

Permalink
Merge branch 'master' into named-tuple-members
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed May 14, 2020
2 parents 71a587f + 7fc456f commit a7aa566
Show file tree
Hide file tree
Showing 159 changed files with 1,722 additions and 554 deletions.
46 changes: 23 additions & 23 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace ts {
// 3. non-exported import declarations
case SyntaxKind.ImportDeclaration:
case SyntaxKind.ImportEqualsDeclaration:
if (!(hasModifier(node, ModifierFlags.Export))) {
if (!(hasSyntacticModifier(node, ModifierFlags.Export))) {
return ModuleInstanceState.NonInstantiated;
}
break;
Expand Down Expand Up @@ -413,7 +413,7 @@ namespace ts {
function declareSymbol(symbolTable: SymbolTable, parent: Symbol | undefined, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags, isReplaceableByMethod?: boolean): Symbol {
Debug.assert(!hasDynamicName(node));

const isDefaultExport = hasModifier(node, ModifierFlags.Default) || isExportSpecifier(node) && node.name.escapedText === "default";
const isDefaultExport = hasSyntacticModifier(node, ModifierFlags.Default) || isExportSpecifier(node) && node.name.escapedText === "default";

// The exported symbol for an export default function/class node is always named "default"
const name = isDefaultExport && parent ? InternalSymbolName.Default : getDeclarationName(node);
Expand Down Expand Up @@ -508,7 +508,7 @@ namespace ts {
}

const relatedInformation: DiagnosticRelatedInformation[] = [];
if (isTypeAliasDeclaration(node) && nodeIsMissing(node.type) && hasModifier(node, ModifierFlags.Export) && symbol.flags & (SymbolFlags.Alias | SymbolFlags.Type | SymbolFlags.Namespace)) {
if (isTypeAliasDeclaration(node) && nodeIsMissing(node.type) && hasSyntacticModifier(node, ModifierFlags.Export) && symbol.flags & (SymbolFlags.Alias | SymbolFlags.Type | SymbolFlags.Namespace)) {
// export type T; - may have meant export type { T }?
relatedInformation.push(createDiagnosticForNode(node, Diagnostics.Did_you_mean_0, `export type { ${unescapeLeadingUnderscores(node.name.escapedText)} }`));
}
Expand Down Expand Up @@ -572,7 +572,7 @@ namespace ts {
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
if (isJSDocTypeAlias(node)) Debug.assert(isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file.
if ((!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) || isJSDocTypeAlias(node)) {
if (!container.locals || (hasModifier(node, ModifierFlags.Default) && !getDeclarationName(node))) {
if (!container.locals || (hasSyntacticModifier(node, ModifierFlags.Default) && !getDeclarationName(node))) {
return declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default!
}
const exportKind = symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0;
Expand Down Expand Up @@ -637,7 +637,7 @@ namespace ts {
const saveExceptionTarget = currentExceptionTarget;
const saveActiveLabelList = activeLabelList;
const saveHasExplicitReturn = hasExplicitReturn;
const isIIFE = containerFlags & ContainerFlags.IsFunctionExpression && !hasModifier(node, ModifierFlags.Async) &&
const isIIFE = containerFlags & ContainerFlags.IsFunctionExpression && !hasSyntacticModifier(node, ModifierFlags.Async) &&
!(<FunctionLikeDeclaration>node).asteriskToken && !!getImmediatelyInvokedFunctionExpression(node);
// A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave
// similarly to break statements that exit to a label just past the statement body.
Expand Down Expand Up @@ -1906,7 +1906,7 @@ namespace ts {
}

function declareClassMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
return hasModifier(node, ModifierFlags.Static)
return hasSyntacticModifier(node, ModifierFlags.Static)
? declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes)
: declareSymbol(container.symbol.members!, container.symbol, node, symbolFlags, symbolExcludes);
}
Expand Down Expand Up @@ -1936,7 +1936,7 @@ namespace ts {
function bindModuleDeclaration(node: ModuleDeclaration) {
setExportContextFlag(node);
if (isAmbientModule(node)) {
if (hasModifier(node, ModifierFlags.Export)) {
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
}
if (isModuleAugmentationExternal(node)) {
Expand Down Expand Up @@ -2869,7 +2869,7 @@ namespace ts {
// this.foo assignment in a JavaScript class
// Bind this property to the containing class
const containingClass = thisContainer.parent;
const symbolTable = hasModifier(thisContainer, ModifierFlags.Static) ? containingClass.symbol.exports! : containingClass.symbol.members!;
const symbolTable = hasSyntacticModifier(thisContainer, ModifierFlags.Static) ? containingClass.symbol.exports! : containingClass.symbol.members!;
if (hasDynamicName(node)) {
bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol);
}
Expand Down Expand Up @@ -3402,7 +3402,7 @@ namespace ts {
case SyntaxKind.ModuleDeclaration:
return getModuleInstanceState(s as ModuleDeclaration) !== ModuleInstanceState.Instantiated;
case SyntaxKind.EnumDeclaration:
return hasModifier(s, ModifierFlags.Const);
return hasSyntacticModifier(s, ModifierFlags.Const);
default:
return false;
}
Expand Down Expand Up @@ -3636,7 +3636,7 @@ namespace ts {
}

// If a parameter has an accessibility modifier, then it is TypeScript syntax.
if (hasModifier(node, ModifierFlags.ParameterPropertyModifier)) {
if (hasSyntacticModifier(node, ModifierFlags.ParameterPropertyModifier)) {
transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.ContainsTypeScriptClassSyntax;
}

Expand Down Expand Up @@ -3675,7 +3675,7 @@ namespace ts {
function computeClassDeclaration(node: ClassDeclaration, subtreeFlags: TransformFlags) {
let transformFlags: TransformFlags;

if (hasModifier(node, ModifierFlags.Ambient)) {
if (hasSyntacticModifier(node, ModifierFlags.Ambient)) {
// An ambient declaration is TypeScript syntax.
transformFlags = TransformFlags.AssertTypeScript;
}
Expand Down Expand Up @@ -3766,7 +3766,7 @@ namespace ts {
let transformFlags = subtreeFlags;

// TypeScript-specific modifiers and overloads are TypeScript syntax
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
if (hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|| !node.body) {
transformFlags |= TransformFlags.AssertTypeScript;
}
Expand All @@ -3787,7 +3787,7 @@ namespace ts {
// Decorators, TypeScript-specific modifiers, type parameters, type annotations, and
// overloads are TypeScript syntax.
if (node.decorators
|| hasModifier(node, ModifierFlags.TypeScriptModifier)
|| hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|| node.typeParameters
|| node.type
|| !node.body
Expand All @@ -3801,7 +3801,7 @@ namespace ts {
}

// An async method declaration is ES2017 syntax.
if (hasModifier(node, ModifierFlags.Async)) {
if (hasSyntacticModifier(node, ModifierFlags.Async)) {
transformFlags |= node.asteriskToken ? TransformFlags.AssertES2018 : TransformFlags.AssertES2017;
}

Expand All @@ -3819,7 +3819,7 @@ namespace ts {
// Decorators, TypeScript-specific modifiers, type annotations, and overloads are
// TypeScript syntax.
if (node.decorators
|| hasModifier(node, ModifierFlags.TypeScriptModifier)
|| hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|| node.type
|| !node.body) {
transformFlags |= TransformFlags.AssertTypeScript;
Expand All @@ -3838,7 +3838,7 @@ namespace ts {
let transformFlags = subtreeFlags | TransformFlags.ContainsClassFields;

// Decorators, TypeScript-specific modifiers, and type annotations are TypeScript syntax.
if (some(node.decorators) || hasModifier(node, ModifierFlags.TypeScriptModifier) || node.type || node.questionToken || node.exclamationToken) {
if (some(node.decorators) || hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier) || node.type || node.questionToken || node.exclamationToken) {
transformFlags |= TransformFlags.AssertTypeScript;
}

Expand All @@ -3853,7 +3853,7 @@ namespace ts {

function computeFunctionDeclaration(node: FunctionDeclaration, subtreeFlags: TransformFlags) {
let transformFlags: TransformFlags;
const modifierFlags = getModifierFlags(node);
const modifierFlags = getSyntacticModifierFlags(node);
const body = node.body;

if (!body || (modifierFlags & ModifierFlags.Ambient)) {
Expand Down Expand Up @@ -3901,14 +3901,14 @@ namespace ts {

// TypeScript-specific modifiers, type parameters, and type annotations are TypeScript
// syntax.
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
if (hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|| node.typeParameters
|| node.type) {
transformFlags |= TransformFlags.AssertTypeScript;
}

// An async function expression is ES2017 syntax.
if (hasModifier(node, ModifierFlags.Async)) {
if (hasSyntacticModifier(node, ModifierFlags.Async)) {
transformFlags |= node.asteriskToken ? TransformFlags.AssertES2018 : TransformFlags.AssertES2017;
}

Expand All @@ -3934,14 +3934,14 @@ namespace ts {

// TypeScript-specific modifiers, type parameters, and type annotations are TypeScript
// syntax.
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
if (hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|| node.typeParameters
|| node.type) {
transformFlags |= TransformFlags.AssertTypeScript;
}

// An async arrow function is ES2017 syntax.
if (hasModifier(node, ModifierFlags.Async)) {
if (hasSyntacticModifier(node, ModifierFlags.Async)) {
transformFlags |= TransformFlags.AssertES2017;
}

Expand Down Expand Up @@ -4015,7 +4015,7 @@ namespace ts {
const declarationListTransformFlags = node.declarationList.transformFlags;

// An ambient declaration is TypeScript syntax.
if (hasModifier(node, ModifierFlags.Ambient)) {
if (hasSyntacticModifier(node, ModifierFlags.Ambient)) {
transformFlags = TransformFlags.AssertTypeScript;
}
else {
Expand Down Expand Up @@ -4063,7 +4063,7 @@ namespace ts {

function computeModuleDeclaration(node: ModuleDeclaration, subtreeFlags: TransformFlags) {
let transformFlags = TransformFlags.AssertTypeScript;
const modifierFlags = getModifierFlags(node);
const modifierFlags = getSyntacticModifierFlags(node);

if ((modifierFlags & ModifierFlags.Ambient) === 0) {
transformFlags |= subtreeFlags;
Expand Down
Loading

0 comments on commit a7aa566

Please sign in to comment.