diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6245f14a117b9..59d7269a7faec 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -490,6 +490,7 @@ import { isCatchClauseVariableDeclarationOrBindingElement, isCheckJsEnabledForFile, isClassDeclaration, + isClassElement, isClassExpression, isClassInstanceProperty, isClassLike, @@ -836,6 +837,7 @@ import { LateBoundDeclaration, LateBoundName, LateVisibilityPaintedStatement, + LazyNodeCheckFlags, length, LiteralExpression, LiteralType, @@ -4254,6 +4256,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return undefined; } const links = getSymbolLinks(symbol); + if (links.typeOnlyDeclaration === undefined) { + // We need to set a WIP value here to prevent reentrancy during `getImmediateAliasedSymbol` which, paradoxically, can depend on this + links.typeOnlyDeclaration = false; + const resolved = resolveSymbol(symbol); // do this before the `resolveImmediate` below, as it uses a different circularity cache and we might hide a circularity error if we blindly get the immediate alias first + // While usually the alias will have been marked during the pass by the full typecheck, we may still need to calculate the alias declaration now + markSymbolOfAliasDeclarationIfTypeOnly(symbol.declarations?.[0], getDeclarationOfAliasSymbol(symbol) && getImmediateAliasedSymbol(symbol), resolved, /*overwriteEmpty*/ true); + } if (include === undefined) { return links.typeOnlyDeclaration || undefined; } @@ -29265,9 +29274,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (isJsxOpeningLikeElement(location) || isJsxOpeningFragment(location)) { return markJsxAliasReferenced(location); } - if (isFunctionLikeDeclaration(location) || isMethodSignature(location)) { - return markAsyncFunctionAliasReferenced(location); - } if (isImportEqualsDeclaration(location)) { if (isInternalModuleImportEqualsDeclaration(location) || checkExternalImportOrExportDeclaration(location)) { return markImportEqualsAliasReferenced(location); @@ -29277,6 +29283,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (isExportSpecifier(location)) { return markExportSpecifierAliasReferenced(location); } + if (isFunctionLikeDeclaration(location) || isMethodSignature(location)) { + markAsyncFunctionAliasReferenced(location); + // Might be decorated, fall through to decorator final case + } if (!compilerOptions.emitDecoratorMetadata) { return; } @@ -29672,15 +29682,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return type; } - function checkIdentifier(node: Identifier, checkMode: CheckMode | undefined): Type { - if (isThisInTypeQuery(node)) { - return checkThisExpression(node); - } - - const symbol = getResolvedSymbol(node); - if (symbol === unknownSymbol) { - return errorType; - } + /** + * This part of `checkIdentifier` is kept seperate from the rest, so `NodeCheckFlags` (and related diagnostics) can be lazily calculated + * without calculating the flow type of the identifier. + */ + function checkIdentifierCalculateNodeCheckFlags(node: Identifier, symbol: Symbol) { + if (isThisInTypeQuery(node)) return; // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. // Although in down-level emit of arrow function, we emit it using function expression which means that @@ -29691,7 +29698,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (symbol === argumentsSymbol) { if (isInPropertyInitializerOrClassStaticBlock(node)) { error(node, Diagnostics.arguments_cannot_be_referenced_in_property_initializers); - return errorType; + return; } let container = getContainingFunction(node); @@ -29713,11 +29720,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } } - return getTypeOfSymbol(symbol); - } - - if (shouldMarkIdentifierAliasReferenced(node)) { - markLinkedReferences(node, ReferenceHint.Identifier); + return; } const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); @@ -29726,7 +29729,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText as string); } - let declaration = localOrExportSymbol.valueDeclaration; + const declaration = localOrExportSymbol.valueDeclaration; if (declaration && localOrExportSymbol.flags & SymbolFlags.Class) { // When we downlevel classes we may emit some code outside of the class body. Due to the fact the // class name is double-bound, we must ensure we mark references to the class name so that we can @@ -29746,6 +29749,33 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } checkNestedBlockScopedBinding(node, symbol); + } + + function checkIdentifier(node: Identifier, checkMode: CheckMode | undefined): Type { + if (isThisInTypeQuery(node)) { + return checkThisExpression(node); + } + + const symbol = getResolvedSymbol(node); + if (symbol === unknownSymbol) { + return errorType; + } + + checkIdentifierCalculateNodeCheckFlags(node, symbol); + + if (symbol === argumentsSymbol) { + if (isInPropertyInitializerOrClassStaticBlock(node)) { + return errorType; + } + return getTypeOfSymbol(symbol); + } + + if (shouldMarkIdentifierAliasReferenced(node)) { + markLinkedReferences(node, ReferenceHint.Identifier); + } + + const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); + let declaration = localOrExportSymbol.valueDeclaration; let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode); const assignmentKind = getAssignmentTargetKind(node); @@ -48442,12 +48472,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (links.isDeclarationWithCollidingName === undefined) { const container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { - const nodeLinks = getNodeLinks(symbol.valueDeclaration); if (resolveName(container.parent, symbol.escapedName, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } - else if (nodeLinks.flags & NodeCheckFlags.CapturedBlockScopedBinding) { + else if (hasNodeCheckFlag(symbol.valueDeclaration, NodeCheckFlags.CapturedBlockScopedBinding)) { // binding is captured in the function // should be renamed if: // - binding is not top level - top level bindings never collide with anything @@ -48463,7 +48492,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly // * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus // they will not collide with anything - const isDeclaredInLoop = nodeLinks.flags & NodeCheckFlags.BlockScopedBindingInLoop; + const isDeclaredInLoop = hasNodeCheckFlag(symbol.valueDeclaration, NodeCheckFlags.BlockScopedBindingInLoop); const inLoopInitializer = isIterationStatement(container, /*lookInLabeledStatements*/ false); const inLoopBodyBlock = container.kind === SyntaxKind.Block && isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); @@ -48550,6 +48579,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (!symbol) { return false; } + const container = getSourceFileOfNode(symbol.valueDeclaration); + const fileSymbol = container && getSymbolOfDeclaration(container); + // Ensures cjs export assignment is setup, since this symbol may point at, and merge with, the file itself. + // If we don't, the merge may not have yet occured, and the flags check below will be missing flags that + // are added as a result of the merge. + void resolveExternalModuleSymbol(fileSymbol); const target = getExportSymbolOfValueSymbolIfExported(resolveAlias(symbol)); if (target === unknownSymbol) { return !excludeTypeOnlyValues || !getTypeOnlyAliasDeclaration(symbol); @@ -48676,6 +48711,129 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return nodeLinks[nodeId]?.flags || 0; } + function hasNodeCheckFlag(node: Node, flag: LazyNodeCheckFlags) { + calculateNodeCheckFlagWorker(node, flag); + return !!(getNodeCheckFlags(node) & flag); + } + + function calculateNodeCheckFlagWorker(node: Node, flag: LazyNodeCheckFlags) { + if (!compilerOptions.noCheck) { + // Unless noCheck is passed, assume calculation of node check flags has been done eagerly. + // This saves needing to mark up where in the eager traversal certain results are "done", + // just to reconcile the eager and lazy results. This wouldn't be hard if an eager typecheck + // was actually an in-order traversal, but it isn't - some nodes are deferred, and so don't + // have these node check flags calculated until that deferral is completed. As an example, + // in concept, we could consider a class that we've called `checkSourceElement` on as having had + // these flags calculated, but since the method bodies are deferred, we actually can't set the + // flags as having been calculated until that deferral is completed. + // The downside to this either/or approach to eager or lazy calculation is that we can't combine + // a partial eager traversal and lazy calculation for the missing bits, and there's a bit of + // overlap in functionality. This isn't a huge loss for any usecases today, but would be nice + // alongside language service partial file checking and editor-triggered emit. + return; + } + const links = getNodeLinks(node); + if (links.calculatedFlags & flag) { + return; + } + // This is only the set of `NodeCheckFlags` our emitter actually looks for, not all of them + switch (flag) { + case NodeCheckFlags.SuperInstance: + case NodeCheckFlags.SuperStatic: + return checkSingleSuperExpression(node); + case NodeCheckFlags.MethodWithSuperPropertyAccessInAsync: + case NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync: + case NodeCheckFlags.ContainsSuperPropertyInStaticInitializer: + return checkChildSuperExpressions(node); + case NodeCheckFlags.CaptureArguments: + case NodeCheckFlags.ContainsCapturedBlockScopeBinding: + case NodeCheckFlags.NeedsLoopOutParameter: + case NodeCheckFlags.ContainsConstructorReference: + return checkChildIdentifiers(node); + case NodeCheckFlags.ConstructorReference: + return checkSingleIdentifier(node); + case NodeCheckFlags.LoopWithCapturedBlockScopedBinding: + case NodeCheckFlags.BlockScopedBindingInLoop: + case NodeCheckFlags.CapturedBlockScopedBinding: + return checkContainingBlockScopeBindingUses(node); + default: + return Debug.assertNever(flag, `Unhandled node check flag calculation: ${Debug.formatNodeCheckFlags(flag)}`); + } + + function forEachNodeRecursively(root: Node, cb: (node: Node, parent: Node) => T | "skip" | undefined): T | undefined { + const rootResult = cb(root, root.parent); + if (rootResult === "skip") return undefined; + if (rootResult) return rootResult; + return forEachChildRecursively(root, cb); + } + + function checkSuperExpressions(node: Node) { + const links = getNodeLinks(node); + if (links.calculatedFlags & flag) return "skip"; + links.calculatedFlags |= NodeCheckFlags.MethodWithSuperPropertyAccessInAsync | NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync | NodeCheckFlags.ContainsSuperPropertyInStaticInitializer; + checkSingleSuperExpression(node); + return undefined; + } + + function checkChildSuperExpressions(node: Node) { + forEachNodeRecursively(node, checkSuperExpressions); + } + + function checkSingleSuperExpression(node: Node) { + const nodeLinks = getNodeLinks(node); // This is called on sub-nodes of the original input, make sure we set `calculatedFlags` on the correct node + nodeLinks.calculatedFlags |= NodeCheckFlags.SuperInstance | NodeCheckFlags.SuperStatic; // Yes, we set this on non-applicable nodes, so we can entirely skip the traversal on future calls + if (node.kind === SyntaxKind.SuperKeyword) { + checkSuperExpression(node); + } + } + + function checkIdentifiers(node: Node) { + const links = getNodeLinks(node); + if (links.calculatedFlags & flag) return "skip"; + links.calculatedFlags |= NodeCheckFlags.CaptureArguments | NodeCheckFlags.ContainsCapturedBlockScopeBinding | NodeCheckFlags.NeedsLoopOutParameter | NodeCheckFlags.ContainsConstructorReference; + checkSingleIdentifier(node); + return undefined; + } + + function checkChildIdentifiers(node: Node) { + forEachNodeRecursively(node, checkIdentifiers); + } + + function checkSingleIdentifier(node: Node) { + const nodeLinks = getNodeLinks(node); + nodeLinks.calculatedFlags |= NodeCheckFlags.ConstructorReference | NodeCheckFlags.CapturedBlockScopedBinding | NodeCheckFlags.BlockScopedBindingInLoop; + if (isIdentifier(node) && isExpressionNode(node) && !(isPropertyAccessExpression(node.parent) && node.parent.name === node)) { + const s = getSymbolAtLocation(node, /*ignoreErrors*/ true); + if (s && s !== unknownSymbol) { + checkIdentifierCalculateNodeCheckFlags(node, s); + } + } + } + + function checkBlockScopeBindings(node: Node) { + const links = getNodeLinks(node); + if (links.calculatedFlags & flag) return "skip"; + links.calculatedFlags |= NodeCheckFlags.LoopWithCapturedBlockScopedBinding | NodeCheckFlags.BlockScopedBindingInLoop | NodeCheckFlags.CapturedBlockScopedBinding; + checkSingleBlockScopeBinding(node); + return undefined; + } + + function checkContainingBlockScopeBindingUses(node: Node) { + const scope = getEnclosingBlockScopeContainer(isDeclarationName(node) ? node.parent : node); + forEachNodeRecursively(scope, checkBlockScopeBindings); + } + + function checkSingleBlockScopeBinding(node: Node) { + checkSingleIdentifier(node); + if (isComputedPropertyName(node)) { + checkComputedPropertyName(node); + } + if (isPrivateIdentifier(node) && isClassElement(node.parent)) { + setNodeLinksForPrivateIdentifierScope(node.parent as PropertyDeclaration | PropertySignature | MethodDeclaration | MethodSignature | AccessorDeclaration); + } + } + } + function getEnumMemberValue(node: EnumMember): EvaluatorResult { computeEnumMemberValues(node.parent); return getNodeLinks(node).enumMemberValue ?? evaluatorResult(/*value*/ undefined); @@ -48696,7 +48854,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return getEnumMemberValue(node).value; } - const symbol = getNodeLinks(node).resolvedSymbol; + if (!getNodeLinks(node).resolvedSymbol) { + void checkExpressionCached(node); // ensure cached resolved symbol is set + } + const symbol = getNodeLinks(node).resolvedSymbol || (isEntityNameExpression(node) ? resolveEntityName(node, SymbolFlags.Value, /*ignoreErrors*/ true) : undefined); if (symbol && (symbol.flags & SymbolFlags.EnumMember)) { // inline property\index accesses only for const enums const member = symbol.valueDeclaration as EnumMember; @@ -49101,9 +49262,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Synthesized nodes are always treated as referenced. return node && canCollectSymbolAliasAccessabilityData ? isReferencedAliasDeclaration(node, checkChildren) : true; }, - getNodeCheckFlags: nodeIn => { + hasNodeCheckFlag: (nodeIn, flag) => { const node = getParseTreeNode(nodeIn); - return node ? getNodeCheckFlags(node) : 0; + if (!node) return false; + return hasNodeCheckFlag(node, flag); }, isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible, @@ -49126,6 +49288,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return node ? getEnumMemberValue(node) : undefined; }, collectLinkedAliases, + markLinkedReferences: nodeIn => { + const node = getParseTreeNode(nodeIn); + return node && markLinkedReferences(node, ReferenceHint.Unspecified); + }, getReferencedValueDeclaration, getReferencedValueDeclarations, getTypeReferenceSerializationKind, diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 52db793b070a8..4a9918c9671e9 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -778,7 +778,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [ showInSimplifiedHelpView: false, category: Diagnostics.Compiler_Diagnostics, description: Diagnostics.Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported, - transpileOptionValue: undefined, + transpileOptionValue: true, defaultValueDescription: false, affectsSemanticDiagnostics: true, affectsBuildInfo: true, diff --git a/src/compiler/debug.ts b/src/compiler/debug.ts index 13f199b927174..baa8ce61a90f2 100644 --- a/src/compiler/debug.ts +++ b/src/compiler/debug.ts @@ -64,6 +64,7 @@ import { ModifierFlags, Node, NodeArray, + NodeCheckFlags, NodeFlags, nodeIsSynthesized, noop, @@ -455,6 +456,10 @@ export namespace Debug { return formatEnum(flags, (ts as any).NodeFlags, /*isFlags*/ true); } + export function formatNodeCheckFlags(flags: NodeCheckFlags | undefined): string { + return formatEnum(flags, (ts as any).NodeCheckFlags, /*isFlags*/ true); + } + export function formatModifierFlags(flags: ModifierFlags | undefined): string { return formatEnum(flags, (ts as any).ModifierFlags, /*isFlags*/ true); } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 03fe0e5e3859e..8f86f2be69074 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -207,6 +207,7 @@ import { isGeneratedPrivateIdentifier, isIdentifier, isImportAttributes, + isImportEqualsDeclaration, isIncrementalCompilation, isInJsonFile, isJSDocLikeText, @@ -793,6 +794,11 @@ export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFi emitSkipped = true; return; } + + if (compilerOptions.noCheck) { + (isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : filter(sourceFileOrBundle.sourceFiles, isSourceFileNotJson)).forEach(markLinkedReferences); + } + // Transform the source files const transform = transformNodes(resolver, host, factory, compilerOptions, [sourceFileOrBundle], scriptTransformers, /*allowDtsFiles*/ false); @@ -924,6 +930,14 @@ export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFi forEachChild(node, collectLinkedAliases); } + function markLinkedReferences(file: SourceFile) { + ts.forEachChildRecursively(file, n => { + if (isImportEqualsDeclaration(n) && !(ts.getSyntacticModifierFlags(n) & ts.ModifierFlags.Export)) return "skip"; // These are deferred and marked in a chain when referenced + if (ts.isImportDeclaration(n)) return "skip"; // likewise, these are ultimately what get marked by calls on other nodes - we want to skip them + resolver.markLinkedReferences(n); + }); + } + function printSourceFileOrBundle(jsFilePath: string, sourceMapFilePath: string | undefined, transform: TransformationResult, printer: Printer, mapOptions: SourceMapOptions) { const sourceFileOrBundle = transform.transformed[0]; const bundle = sourceFileOrBundle.kind === SyntaxKind.Bundle ? sourceFileOrBundle : undefined; @@ -1090,10 +1104,11 @@ export const notImplementedResolver: EmitResolver = { isValueAliasDeclaration: notImplemented, isReferencedAliasDeclaration: notImplemented, isTopLevelValueImportEqualsWithEntityName: notImplemented, - getNodeCheckFlags: notImplemented, + hasNodeCheckFlag: notImplemented, isDeclarationVisible: notImplemented, isLateBound: (_node): _node is LateBoundDeclaration => false, collectLinkedAliases: notImplemented, + markLinkedReferences: notImplemented, isImplementationOfOverload: notImplemented, requiresAddingImplicitUndefined: notImplemented, isExpandoFunctionDeclaration: notImplemented, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 51a5a2e727502..a95b1d079c056 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -4454,9 +4454,6 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg if (options.noEmit) { createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noCheck", "noEmit"); } - if (!options.emitDeclarationOnly) { - createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "noCheck", "emitDeclarationOnly"); - } } if ( diff --git a/src/compiler/transformers/classFields.ts b/src/compiler/transformers/classFields.ts index 2f32839d1bb86..adc960e552ea0 100644 --- a/src/compiler/transformers/classFields.ts +++ b/src/compiler/transformers/classFields.ts @@ -1755,7 +1755,7 @@ export function transformClassFields(context: TransformationContext): (x: Source } else if (isPrivateIdentifierClassElementDeclaration(member)) { containsInstancePrivateElements = true; - if (resolver.getNodeCheckFlags(member) & NodeCheckFlags.ContainsConstructorReference) { + if (resolver.hasNodeCheckFlag(member, NodeCheckFlags.ContainsConstructorReference)) { facts |= ClassFacts.NeedsClassConstructorReference; } } @@ -1889,7 +1889,7 @@ export function transformClassFields(context: TransformationContext): (x: Source getClassLexicalEnvironment().classThis = node.emitNode.classThis; } - const isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & NodeCheckFlags.ContainsConstructorReference; + const isClassWithConstructorReference = resolver.hasNodeCheckFlag(node, NodeCheckFlags.ContainsConstructorReference); const isExport = hasSyntacticModifier(node, ModifierFlags.Export); const isDefault = hasSyntacticModifier(node, ModifierFlags.Default); let modifiers = visitNodes(node.modifiers, modifierVisitor, isModifier); @@ -1965,8 +1965,8 @@ export function transformClassFields(context: TransformationContext): (x: Source // these statements after the class expression variable statement. const isDecoratedClassDeclaration = !!(facts & ClassFacts.ClassWasDecorated); const staticPropertiesOrClassStaticBlocks = getStaticPropertiesAndClassStaticBlock(node); - const classCheckFlags = resolver.getNodeCheckFlags(node); - const isClassWithConstructorReference = classCheckFlags & NodeCheckFlags.ContainsConstructorReference; + const isClassWithConstructorReference = resolver.hasNodeCheckFlag(node, NodeCheckFlags.ContainsConstructorReference); + const requiresBlockScopedVar = resolver.hasNodeCheckFlag(node, NodeCheckFlags.BlockScopedBindingInLoop); let temp: Identifier | undefined; function createClassTempVar() { @@ -1983,7 +1983,6 @@ export function transformClassFields(context: TransformationContext): (x: Source return getClassLexicalEnvironment().classConstructor = node.emitNode.classThis; } - const requiresBlockScopedVar = classCheckFlags & NodeCheckFlags.BlockScopedBindingInLoop; const temp = factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, /*reservedInNestedScopes*/ true); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); return temp; @@ -2712,7 +2711,7 @@ export function transformClassFields(context: TransformationContext): (x: Source const alreadyTransformed = !!cacheAssignment || isAssignmentExpression(innerExpression) && isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { const generatedName = factory.getGeneratedNameForNode(name); - if (resolver.getNodeCheckFlags(name) & NodeCheckFlags.BlockScopedBindingInLoop) { + if (resolver.hasNodeCheckFlag(name, NodeCheckFlags.BlockScopedBindingInLoop)) { addBlockScopedVariable(generatedName); } else { @@ -2960,7 +2959,7 @@ export function transformClassFields(context: TransformationContext): (x: Source typeof name === "string" ? factory.createUniqueName(name, GeneratedIdentifierFlags.Optimistic, prefix, suffix) : factory.createTempVariable(/*recordTempVariable*/ undefined, /*reservedInNestedScopes*/ true, prefix, suffix); - if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.BlockScopedBindingInLoop) { + if (resolver.hasNodeCheckFlag(node, NodeCheckFlags.BlockScopedBindingInLoop)) { addBlockScopedVariable(identifier); } else { @@ -3295,7 +3294,7 @@ export function transformClassFields(context: TransformationContext): (x: Source function trySubstituteClassAlias(node: Identifier): Expression | undefined { if (enabledSubstitutions & ClassPropertySubstitutionFlags.ClassAliases) { - if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.ConstructorReference) { + if (resolver.hasNodeCheckFlag(node, NodeCheckFlags.ConstructorReference)) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 3b21f019f49e6..6973b1aef26e0 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -2867,9 +2867,8 @@ export function transformES2015(context: TransformationContext): (x: SourceFile // * Why loop initializer is excluded? // - Since we've introduced a fresh name it already will be undefined. - const flags = resolver.getNodeCheckFlags(node); - const isCapturedInFunction = flags & NodeCheckFlags.CapturedBlockScopedBinding; - const isDeclaredInLoop = flags & NodeCheckFlags.BlockScopedBindingInLoop; + const isCapturedInFunction = resolver.hasNodeCheckFlag(node, NodeCheckFlags.CapturedBlockScopedBinding); + const isDeclaredInLoop = resolver.hasNodeCheckFlag(node, NodeCheckFlags.BlockScopedBindingInLoop); const emittedAsTopLevel = (hierarchyFacts & HierarchyFacts.TopLevel) !== 0 || (isCapturedInFunction && isDeclaredInLoop @@ -3373,7 +3372,7 @@ export function transformES2015(context: TransformationContext): (x: SourceFile } function shouldConvertPartOfIterationStatement(node: Node) { - return (resolver.getNodeCheckFlags(node) & NodeCheckFlags.ContainsCapturedBlockScopeBinding) !== 0; + return resolver.hasNodeCheckFlag(node, NodeCheckFlags.ContainsCapturedBlockScopeBinding); } function shouldConvertInitializerOfForStatement(node: IterationStatement): node is ForStatementWithConvertibleInitializer { @@ -3394,7 +3393,7 @@ export function transformES2015(context: TransformationContext): (x: SourceFile } function shouldConvertBodyOfIterationStatement(node: IterationStatement): boolean { - return (resolver.getNodeCheckFlags(node) & NodeCheckFlags.LoopWithCapturedBlockScopedBinding) !== 0; + return resolver.hasNodeCheckFlag(node, NodeCheckFlags.LoopWithCapturedBlockScopedBinding); } /** @@ -4057,11 +4056,11 @@ export function transformES2015(context: TransformationContext): (x: SourceFile } else { loopParameters.push(factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); - const checkFlags = resolver.getNodeCheckFlags(decl); - if (checkFlags & NodeCheckFlags.NeedsLoopOutParameter || hasCapturedBindingsInForHead) { + const needsOutParam = resolver.hasNodeCheckFlag(decl, NodeCheckFlags.NeedsLoopOutParameter); + if (needsOutParam || hasCapturedBindingsInForHead) { const outParamName = factory.createUniqueName("out_" + idText(name)); let flags = LoopOutParameterFlags.None; - if (checkFlags & NodeCheckFlags.NeedsLoopOutParameter) { + if (needsOutParam) { flags |= LoopOutParameterFlags.Body; } if (isForStatement(container)) { diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index df0a34c29209b..e1f0c9756b242 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -659,7 +659,7 @@ export function transformES2017(context: TransformationContext): (x: SourceFile // This step isn't needed if we eventually transform this to ES5. const originalMethod = getOriginalNode(node, isFunctionLikeDeclaration); const emitSuperHelpers = languageVersion >= ScriptTarget.ES2015 && - resolver.getNodeCheckFlags(node) & (NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync | NodeCheckFlags.MethodWithSuperPropertyAccessInAsync) && + (resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync) || resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAccessInAsync)) && (getFunctionFlags(originalMethod) & FunctionFlags.AsyncGenerator) !== FunctionFlags.AsyncGenerator; if (emitSuperHelpers) { @@ -675,10 +675,10 @@ export function transformES2017(context: TransformationContext): (x: SourceFile if (hasSuperElementAccess) { // Emit helpers for super element access expressions (`super[x]`). - if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync) { + if (resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync)) { addEmitHelper(updated, advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.MethodWithSuperPropertyAccessInAsync) { + else if (resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAccessInAsync)) { addEmitHelper(updated, asyncSuperHelper); } } @@ -743,7 +743,7 @@ export function transformES2017(context: TransformationContext): (x: SourceFile const promiseConstructor = languageVersion < ScriptTarget.ES2015 ? getPromiseConstructor(nodeType) : undefined; const isArrowFunction = node.kind === SyntaxKind.ArrowFunction; const savedLexicalArgumentsBinding = lexicalArgumentsBinding; - const hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0; + const hasLexicalArguments = resolver.hasNodeCheckFlag(node, NodeCheckFlags.CaptureArguments); const captureLexicalArguments = hasLexicalArguments && !lexicalArgumentsBinding; if (captureLexicalArguments) { lexicalArgumentsBinding = factory.createUniqueName("arguments"); @@ -816,7 +816,7 @@ export function transformES2017(context: TransformationContext): (x: SourceFile // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - const emitSuperHelpers = languageVersion >= ScriptTarget.ES2015 && resolver.getNodeCheckFlags(node) & (NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync | NodeCheckFlags.MethodWithSuperPropertyAccessInAsync); + const emitSuperHelpers = languageVersion >= ScriptTarget.ES2015 && (resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync) || resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAccessInAsync)); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); @@ -836,10 +836,10 @@ export function transformES2017(context: TransformationContext): (x: SourceFile if (emitSuperHelpers && hasSuperElementAccess) { // Emit helpers for super element access expressions (`super[x]`). - if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync) { + if (resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync)) { addEmitHelper(block, advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.MethodWithSuperPropertyAccessInAsync) { + else if (resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAccessInAsync)) { addEmitHelper(block, asyncSuperHelper); } } @@ -926,7 +926,7 @@ export function transformES2017(context: TransformationContext): (x: SourceFile // If we need to support substitutions for `super` in an async method, // we should track it here. if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && isSuperContainer(node)) { - const superContainerFlags = resolver.getNodeCheckFlags(node) & (NodeCheckFlags.MethodWithSuperPropertyAccessInAsync | NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync); + const superContainerFlags = (resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAccessInAsync) ? NodeCheckFlags.MethodWithSuperPropertyAccessInAsync : 0) | (resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync) ? NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync : 0); if (superContainerFlags !== enclosingSuperContainerFlags) { const savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -1058,7 +1058,7 @@ export function transformES2017(context: TransformationContext): (x: SourceFile export function createSuperAccessVariableStatement(factory: NodeFactory, resolver: EmitResolver, node: FunctionLikeDeclaration, names: Set<__String>) { // Create a variable declaration with a getter/setter (if binding) definition for each name: // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... }); - const hasBinding = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync) !== 0; + const hasBinding = resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync); const accessors: PropertyAssignment[] = []; names.forEach((_, key) => { const name = unescapeLeadingUnderscores(key); diff --git a/src/compiler/transformers/es2018.ts b/src/compiler/transformers/es2018.ts index 9328d83b1a39b..4eff61428d9fd 100644 --- a/src/compiler/transformers/es2018.ts +++ b/src/compiler/transformers/es2018.ts @@ -1190,7 +1190,7 @@ export function transformES2018(context: TransformationContext): (x: SourceFile // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - const emitSuperHelpers = languageVersion >= ScriptTarget.ES2015 && resolver.getNodeCheckFlags(node) & (NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync | NodeCheckFlags.MethodWithSuperPropertyAccessInAsync); + const emitSuperHelpers = languageVersion >= ScriptTarget.ES2015 && (resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync) || resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAccessInAsync)); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); const variableStatement = createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties); @@ -1202,10 +1202,10 @@ export function transformES2018(context: TransformationContext): (x: SourceFile const block = factory.updateBlock(node.body!, outerStatements); if (emitSuperHelpers && hasSuperElementAccess) { - if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync) { + if (resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync)) { addEmitHelper(block, advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.MethodWithSuperPropertyAccessInAsync) { + else if (resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAccessInAsync)) { addEmitHelper(block, asyncSuperHelper); } } @@ -1360,7 +1360,7 @@ export function transformES2018(context: TransformationContext): (x: SourceFile // If we need to support substitutions for `super` in an async method, // we should track it here. if (enabledSubstitutions & ESNextSubstitutionFlags.AsyncMethodsWithSuper && isSuperContainer(node)) { - const superContainerFlags = resolver.getNodeCheckFlags(node) & (NodeCheckFlags.MethodWithSuperPropertyAccessInAsync | NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync); + const superContainerFlags = (resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAccessInAsync) ? NodeCheckFlags.MethodWithSuperPropertyAccessInAsync : 0) | (resolver.hasNodeCheckFlag(node, NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync) ? NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync : 0); if (superContainerFlags !== enclosingSuperContainerFlags) { const savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; diff --git a/src/compiler/transformers/legacyDecorators.ts b/src/compiler/transformers/legacyDecorators.ts index e3112ed53a241..6ef7745dfd301 100644 --- a/src/compiler/transformers/legacyDecorators.ts +++ b/src/compiler/transformers/legacyDecorators.ts @@ -773,7 +773,7 @@ export function transformLegacyDecorators(context: TransformationContext): (x: S * double-binding semantics for the class name. */ function getClassAliasIfNeeded(node: ClassDeclaration) { - if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.ContainsConstructorReference) { + if (resolver.hasNodeCheckFlag(node, NodeCheckFlags.ContainsConstructorReference)) { enableSubstitutionForClassAliases(); const classAlias = factory.createUniqueName(node.name && !isGeneratedIdentifier(node.name) ? idText(node.name) : "default"); classAliases[getOriginalNodeId(node)] = classAlias; @@ -822,7 +822,7 @@ export function transformLegacyDecorators(context: TransformationContext): (x: S function trySubstituteClassAlias(node: Identifier): Expression | undefined { if (classAliases) { - if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.ConstructorReference) { + if (resolver.hasNodeCheckFlag(node, NodeCheckFlags.ConstructorReference)) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. diff --git a/src/compiler/types.ts b/src/compiler/types.ts index aae7c5494a17d..7a9cd97e8cb7c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5750,6 +5750,22 @@ export enum TypeReferenceSerializationKind { ObjectType, } +/** @internal */ +export type LazyNodeCheckFlags = + | NodeCheckFlags.SuperInstance + | NodeCheckFlags.SuperStatic + | NodeCheckFlags.MethodWithSuperPropertyAccessInAsync + | NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync + | NodeCheckFlags.ContainsSuperPropertyInStaticInitializer + | NodeCheckFlags.CaptureArguments + | NodeCheckFlags.ContainsCapturedBlockScopeBinding + | NodeCheckFlags.NeedsLoopOutParameter + | NodeCheckFlags.ContainsConstructorReference + | NodeCheckFlags.ConstructorReference + | NodeCheckFlags.CapturedBlockScopedBinding + | NodeCheckFlags.BlockScopedBindingInLoop + | NodeCheckFlags.LoopWithCapturedBlockScopedBinding; + /** @internal */ export interface EmitResolver { isNonNarrowedBindableName(node: ComputedPropertyName): boolean; @@ -5761,10 +5777,11 @@ export interface EmitResolver { isValueAliasDeclaration(node: Node): boolean; isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; - getNodeCheckFlags(node: Node): NodeCheckFlags; + hasNodeCheckFlag(node: Node, flags: LazyNodeCheckFlags): boolean; isDeclarationVisible(node: Declaration | AnyImportSyntax): boolean; isLateBound(node: Declaration): node is LateBoundDeclaration; collectLinkedAliases(node: Identifier, setVisibility?: boolean): Node[] | undefined; + markLinkedReferences(node: Node): void; isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined; requiresAddingImplicitUndefined(node: ParameterDeclaration): boolean; isExpandoFunctionDeclaration(node: FunctionDeclaration | VariableDeclaration): boolean; @@ -6095,6 +6112,21 @@ export const enum NodeCheckFlags { ContainsClassWithPrivateIdentifiers = 1 << 20, // Marked on all block-scoped containers containing a class with private identifiers. ContainsSuperPropertyInStaticInitializer = 1 << 21, // Marked on all block-scoped containers containing a static initializer with 'super.x' or 'super[x]'. InCheckIdentifier = 1 << 22, + + /** These flags are LazyNodeCheckFlags and can be calculated lazily by `hasNodeCheckFlag` */ + LazyFlags = SuperInstance + | SuperStatic + | MethodWithSuperPropertyAccessInAsync + | MethodWithSuperPropertyAssignmentInAsync + | ContainsSuperPropertyInStaticInitializer + | CaptureArguments + | ContainsCapturedBlockScopeBinding + | NeedsLoopOutParameter + | ContainsConstructorReference + | ConstructorReference + | CapturedBlockScopedBinding + | BlockScopedBindingInLoop + | LoopWithCapturedBlockScopedBinding, } /** @internal */ @@ -6109,6 +6141,7 @@ export interface EvaluatorResult | m.g | (() => c); declare var y: g | m.g | (() => c); + + +!!!! File declFileTypeAnnotationUnionType.d.ts differs from original emit in noCheck emit +//// [declFileTypeAnnotationUnionType.d.ts] +=================================================================== +--- Expected The full check baseline ++++ Actual with noCheck set +@@ -12,7 +12,7 @@ + declare class g { + private s; + } + declare var k: c | m.c; +-declare var l: c | m.c; ++declare var l: m.c | c; + declare var x: g | m.g | (() => c); + declare var y: g | m.g | (() => c); diff --git a/tests/baselines/reference/importDeclWithDeclareModifier.js b/tests/baselines/reference/importDeclWithDeclareModifier.js index add1aca76d814..6abdc61fb9584 100644 --- a/tests/baselines/reference/importDeclWithDeclareModifier.js +++ b/tests/baselines/reference/importDeclWithDeclareModifier.js @@ -15,3 +15,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.a = void 0; exports.a = x.c; var b; + + +!!!! File importDeclWithDeclareModifier.js differs from original emit in noCheck emit +//// [importDeclWithDeclareModifier.js] +=================================================================== +--- Expected The full check baseline ++++ Actual with noCheck set +@@ -1,5 +1,3 @@ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); +-exports.a = void 0; +-exports.a = x.c; + var b; diff --git a/tests/baselines/reference/isolatedModulesNoEmitOnError.js b/tests/baselines/reference/isolatedModulesNoEmitOnError.js new file mode 100644 index 0000000000000..80851e5cff8cd --- /dev/null +++ b/tests/baselines/reference/isolatedModulesNoEmitOnError.js @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/isolatedModulesNoEmitOnError.ts] //// + +//// [file1.ts] +export const x: string = 3; + + + +!!!! File file1.js missing from original emit, but present in noCheck emit +//// [file1.js] +export const x = 3; diff --git a/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.errors.txt b/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.errors.txt index dbe8496dc4b35..6ed52a9dfe7b9 100644 --- a/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.errors.txt +++ b/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.errors.txt @@ -1,6 +1,13 @@ +error TS-1: Pre-emit (1) and post-emit (5) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! multiLinePropertyAccessAndArrowFunctionIndent1.ts(1,1): error TS1108: A 'return' statement can only be used within a function body. +!!! error TS-1: Pre-emit (1) and post-emit (5) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! +!!! related TS-1: The excess diagnostics are: +!!! related TS2304 multiLinePropertyAccessAndArrowFunctionIndent1.ts:1:18: Cannot find name 'role'. +!!! related TS2304 multiLinePropertyAccessAndArrowFunctionIndent1.ts:2:18: Cannot find name 'Role'. +!!! related TS2503 multiLinePropertyAccessAndArrowFunctionIndent1.ts:4:26: Cannot find namespace 'ng'. +!!! related TS2304 multiLinePropertyAccessAndArrowFunctionIndent1.ts:4:53: Cannot find name 'Role'. ==== multiLinePropertyAccessAndArrowFunctionIndent1.ts (1 errors) ==== return this.edit(role) ~~~~~~ diff --git a/tests/baselines/reference/noCheckRequiresEmitDeclarationOnly.errors.txt b/tests/baselines/reference/noCheckRequiresEmitDeclarationOnly.errors.txt deleted file mode 100644 index 1256c80887fe2..0000000000000 --- a/tests/baselines/reference/noCheckRequiresEmitDeclarationOnly.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -error TS5052: Option 'noCheck' cannot be specified without specifying option 'emitDeclarationOnly'. - - -!!! error TS5052: Option 'noCheck' cannot be specified without specifying option 'emitDeclarationOnly'. -==== noCheckRequiresEmitDeclarationOnly.ts (0 errors) ==== - export const a: number = "not ok"; - \ No newline at end of file diff --git a/tests/baselines/reference/noEmitOnError.js b/tests/baselines/reference/noEmitOnError.js index d6e53fb9d4662..844d502f03530 100644 --- a/tests/baselines/reference/noEmitOnError.js +++ b/tests/baselines/reference/noEmitOnError.js @@ -9,3 +9,9 @@ var x: number = ""; !!!! File noEmitOnError.d.ts missing from original emit, but present in noCheck emit //// [noEmitOnError.d.ts] declare var x: number; + + +!!!! File noEmitOnError.js missing from original emit, but present in noCheck emit +//// [noEmitOnError.js] +var x = ""; +//# sourceMappingURL=noEmitOnError.js.map \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatCommonjs.js b/tests/baselines/reference/outModuleConcatCommonjs.js deleted file mode 100644 index c6da7cf3337ea..0000000000000 --- a/tests/baselines/reference/outModuleConcatCommonjs.js +++ /dev/null @@ -1,23 +0,0 @@ -//// [tests/cases/compiler/outModuleConcatCommonjs.ts] //// - -//// [a.ts] -export class A { } - -//// [b.ts] -import {A} from "./ref/a"; -export class B extends A { } - - - - -!!!! File all.d.ts missing from original emit, but present in noCheck emit -//// [all.d.ts] -declare module "ref/a" { - export class A { - } -} -declare module "b" { - import { A } from "ref/a"; - export class B extends A { - } -} diff --git a/tests/baselines/reference/outModuleConcatES6.js b/tests/baselines/reference/outModuleConcatES6.js deleted file mode 100644 index f747cc7e351cb..0000000000000 --- a/tests/baselines/reference/outModuleConcatES6.js +++ /dev/null @@ -1,22 +0,0 @@ -//// [tests/cases/compiler/outModuleConcatES6.ts] //// - -//// [a.ts] -export class A { } - -//// [b.ts] -import {A} from "./ref/a"; -export class B extends A { } - - - -!!!! File all.d.ts missing from original emit, but present in noCheck emit -//// [all.d.ts] -declare module "ref/a" { - export class A { - } -} -declare module "b" { - import { A } from "ref/a"; - export class B extends A { - } -} diff --git a/tests/baselines/reference/outModuleConcatUmd.js b/tests/baselines/reference/outModuleConcatUmd.js deleted file mode 100644 index 44bf3ae850709..0000000000000 --- a/tests/baselines/reference/outModuleConcatUmd.js +++ /dev/null @@ -1,22 +0,0 @@ -//// [tests/cases/compiler/outModuleConcatUmd.ts] //// - -//// [a.ts] -export class A { } - -//// [b.ts] -import {A} from "./ref/a"; -export class B extends A { } - - - -!!!! File all.d.ts missing from original emit, but present in noCheck emit -//// [all.d.ts] -declare module "ref/a" { - export class A { - } -} -declare module "b" { - import { A } from "ref/a"; - export class B extends A { - } -} diff --git a/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt b/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt index da6d517a345ae..915d1abde77f1 100644 --- a/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt +++ b/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt @@ -1,3 +1,4 @@ +error TS-1: Pre-emit (7) and post-emit (8) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! parseErrorIncorrectReturnToken.ts(2,17): error TS1005: ':' expected. parseErrorIncorrectReturnToken.ts(4,22): error TS1005: '=>' expected. parseErrorIncorrectReturnToken.ts(4,24): error TS2693: 'string' only refers to a type, but is being used as a value here. @@ -7,6 +8,9 @@ parseErrorIncorrectReturnToken.ts(9,21): error TS2693: 'string' only refers to a parseErrorIncorrectReturnToken.ts(12,1): error TS1128: Declaration or statement expected. +!!! error TS-1: Pre-emit (7) and post-emit (8) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! +!!! related TS-1: The excess diagnostics are: +!!! related TS2304 parseErrorIncorrectReturnToken.ts:10:16: Cannot find name 'n'. ==== parseErrorIncorrectReturnToken.ts (7 errors) ==== type F1 = { (n: number) => string; // should be : not => diff --git a/tests/baselines/reference/parserStatementIsNotAMemberVariableDeclaration1.errors.txt b/tests/baselines/reference/parserStatementIsNotAMemberVariableDeclaration1.errors.txt index 678d49a6ccfc4..0550c53d433f5 100644 --- a/tests/baselines/reference/parserStatementIsNotAMemberVariableDeclaration1.errors.txt +++ b/tests/baselines/reference/parserStatementIsNotAMemberVariableDeclaration1.errors.txt @@ -1,6 +1,10 @@ +error TS-1: Pre-emit (1) and post-emit (2) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! parserStatementIsNotAMemberVariableDeclaration1.ts(1,1): error TS1108: A 'return' statement can only be used within a function body. +!!! error TS-1: Pre-emit (1) and post-emit (2) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! +!!! related TS-1: The excess diagnostics are: +!!! related TS2304 parserStatementIsNotAMemberVariableDeclaration1.ts:6:5: Cannot find name 'private'. ==== parserStatementIsNotAMemberVariableDeclaration1.ts (1 errors) ==== return { ~~~~~~ diff --git a/tests/baselines/reference/typeReferenceDirectives11.js b/tests/baselines/reference/typeReferenceDirectives11.js deleted file mode 100644 index 5853619bf733b..0000000000000 --- a/tests/baselines/reference/typeReferenceDirectives11.js +++ /dev/null @@ -1,23 +0,0 @@ -//// [tests/cases/compiler/typeReferenceDirectives11.ts] //// - -//// [index.d.ts] -interface Lib { x } - -//// [mod1.ts] -export function foo(): Lib { return {x: 1} } - -//// [mod2.ts] -import {foo} from "./mod1"; -export const bar = foo(); - - - - -!!!! File /output.d.ts missing from original emit, but present in noCheck emit -//// [output.d.ts] -declare module "mod1" { - export function foo(): Lib; -} -declare module "mod2" { - export const bar: Lib; -} diff --git a/tests/baselines/reference/typeReferenceDirectives12.js b/tests/baselines/reference/typeReferenceDirectives12.js deleted file mode 100644 index dd06ed073a709..0000000000000 --- a/tests/baselines/reference/typeReferenceDirectives12.js +++ /dev/null @@ -1,60 +0,0 @@ -//// [tests/cases/compiler/typeReferenceDirectives12.ts] //// - -//// [index.d.ts] -interface Lib { x } - -//// [main.ts] -export class Cls { - x -} - -//// [mod1.ts] -/// - -import {Cls} from "./main"; -Cls.prototype.foo = function() { return undefined; } - -declare module "./main" { - interface Cls { - foo(): Lib; - } - namespace Cls { - function bar(): Lib; - } -} - -//// [mod2.ts] -import { Cls } from "./main"; -import "./mod1"; - -export const cls = Cls; -export const foo = new Cls().foo(); -export const bar = Cls.bar(); - - - - -!!!! File /output.d.ts missing from original emit, but present in noCheck emit -//// [output.d.ts] -declare module "main" { - export class Cls { - x: any; - } -} -declare module "mod1" { - module "main" { - interface Cls { - foo(): Lib; - } - namespace Cls { - function bar(): Lib; - } - } -} -declare module "mod2" { - import { Cls } from "main"; - import "mod1"; - export const cls: typeof Cls; - export const foo: Lib; - export const bar: Lib; -} diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).errors.txt b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).errors.txt index 249a5d65f7415..d0482948aa891 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).errors.txt +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).errors.txt @@ -1,3 +1,4 @@ +error TS-1: Pre-emit (44) and post-emit (45) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! astralAsSurrogatePair.ts(1,11): error TS1127: Invalid character. astralAsSurrogatePair.ts(1,14): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'as'. astralAsSurrogatePair.ts(1,17): error TS1127: Invalid character. @@ -44,6 +45,9 @@ extendedEscapesForAstralsInVarsAndClasses.ts(24,8): error TS1351: An identifier extendedEscapesForAstralsInVarsAndClasses.ts(24,12): error TS1128: Declaration or statement expected. +!!! error TS-1: Pre-emit (44) and post-emit (45) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! +!!! related TS-1: The excess diagnostics are: +!!! related TS2532 extendedEscapesForAstralsInVarsAndClasses.ts:18:16: Object is possibly 'undefined'. ==== extendedEscapesForAstralsInVarsAndClasses.ts (38 errors) ==== // U+102A7 CARIAN LETTER A2 var 𐊧: string; diff --git a/tests/baselines/reference/variadicTuples1.js b/tests/baselines/reference/variadicTuples1.js index cf327f771e2b8..57bab837e1d11 100644 --- a/tests/baselines/reference/variadicTuples1.js +++ b/tests/baselines/reference/variadicTuples1.js @@ -846,7 +846,7 @@ type AnyArr = [...any]; declare const tc4: [...string[], number, number, number]; declare function concat2(t: T, u: U): (T[number] | U[number])[]; -declare const tc5: (2 | 4 | 1 | 3 | 6 | 5)[]; -+declare const tc5: (1 | 2 | 3 | 6 | 4 | 5)[]; ++declare const tc5: (3 | 2 | 1 | 6 | 4 | 5)[]; declare function foo1(a: number, b: string, c: boolean, ...d: number[]): void; declare function foo2(t1: [number, string], t2: [boolean], a1: number[]): void; declare function foo3(x: number, ...args: [...T, number]): T;