Enable JS emit for noCheck and noCheck for transpileModule (#58364)

This commit is contained in:
Wesley Wigham 2024-05-30 13:38:37 -07:00 committed by GitHub
parent b7d8809150
commit bbfc1aa281
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 528 additions and 223 deletions

View File

@ -490,6 +490,7 @@ import {
isCatchClauseVariableDeclarationOrBindingElement,
isCheckJsEnabledForFile,
isClassDeclaration,
isClassElement,
isClassExpression,
isClassInstanceProperty,
isClassLike,
@ -837,6 +838,7 @@ import {
LateBoundDeclaration,
LateBoundName,
LateVisibilityPaintedStatement,
LazyNodeCheckFlags,
length,
LiteralExpression,
LiteralType,
@ -4264,6 +4266,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;
}
@ -29460,9 +29469,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);
@ -29472,6 +29478,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;
}
@ -29867,15 +29877,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
@ -29886,7 +29893,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);
@ -29908,11 +29915,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
}
}
return getTypeOfSymbol(symbol);
}
if (shouldMarkIdentifierAliasReferenced(node)) {
markLinkedReferences(node, ReferenceHint.Identifier);
return;
}
const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
@ -29921,7 +29924,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
@ -29941,6 +29944,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);
@ -48644,12 +48674,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
@ -48665,7 +48694,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);
@ -48752,6 +48781,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);
@ -48878,6 +48913,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<T>(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);
@ -48898,7 +49056,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;
@ -49285,9 +49446,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,
@ -49310,6 +49472,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,

View File

@ -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,

View File

@ -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);
}

View File

@ -207,6 +207,7 @@ import {
isGeneratedPrivateIdentifier,
isIdentifier,
isImportAttributes,
isImportEqualsDeclaration,
isIncrementalCompilation,
isInJsonFile,
isJSDocLikeText,
@ -798,6 +799,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);
@ -933,6 +939,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<SourceFile | Bundle>, printer: Printer, mapOptions: SourceMapOptions) {
const sourceFileOrBundle = transform.transformed[0];
const bundle = sourceFileOrBundle.kind === SyntaxKind.Bundle ? sourceFileOrBundle : undefined;
@ -1099,10 +1113,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,

View File

@ -4464,9 +4464,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 (

View File

@ -1754,7 +1754,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;
}
}
@ -1888,7 +1888,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);
@ -1964,8 +1964,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() {
@ -1982,7 +1982,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;
@ -2711,7 +2710,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 {
@ -2959,7 +2958,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 {
@ -3294,7 +3293,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.

View File

@ -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)) {

View File

@ -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);

View File

@ -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;

View File

@ -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.

View File

@ -5752,6 +5752,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 {
hasGlobalName(name: string): boolean;
@ -5762,10 +5778,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;
@ -6097,6 +6114,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 */
@ -6111,6 +6143,7 @@ export interface EvaluatorResult<T extends string | number | undefined = string
/** @internal */
export interface NodeLinks {
flags: NodeCheckFlags; // Set of flags specific to Node
calculatedFlags: NodeCheckFlags; // Set of flags which have definitely been calculated already
resolvedType?: Type; // Cached type of type node
resolvedSignature?: Signature; // Cached signature of signature node or call expression
resolvedSymbol?: Symbol; // Cached name resolution result

View File

@ -1001,9 +1001,10 @@ export namespace Compiler {
jsCode += "\r\n\r\n";
jsCode += getErrorBaseline(tsConfigFiles.concat(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.diagnostics);
}
else if (!options.noCheck && !options.noEmit && (options.composite || options.declaration || options.emitDeclarationOnly)) {
const withoutChecking = result.repeat({ noCheck: "true", emitDeclarationOnly: "true" });
else if (!options.noCheck && !options.noEmit) {
const withoutChecking = result.repeat({ noCheck: "true" });
compareResultFileSets(withoutChecking.dts, result.dts);
compareResultFileSets(withoutChecking.js, result.js);
}
// eslint-disable-next-line no-restricted-syntax

View File

@ -59,6 +59,7 @@ const optionsRedundantWithVerbatimModuleSyntax = new Set([
* - noLib = true
* - noResolve = true
* - declaration = false
* - noCheck = true
*/
export function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput {
return transpileWorker(input, transpileOptions, /*declaration*/ false);
@ -142,7 +143,6 @@ function transpileWorker(input: string, transpileOptions: TranspileOptions, decl
options.declaration = true;
options.emitDeclarationOnly = true;
options.isolatedDeclarations = true;
options.noCheck = true;
}
else {
options.declaration = false;

View File

@ -0,0 +1,61 @@
//// [tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor1.ts] ////
//// [autoAccessor1.ts]
class C1 {
accessor a: any;
accessor b = 1;
static accessor c: any;
static accessor d = 2;
}
!!!! File autoAccessor1.js missing from original emit, but present in noCheck emit
//// [autoAccessor1.js]
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var C1 = /** @class */ (function () {
function C1() {
_C1_a_accessor_storage.set(this, void 0);
_C1_b_accessor_storage.set(this, 1);
}
Object.defineProperty(C1.prototype, "a", {
get: function () { return __classPrivateFieldGet(this, _C1_a_accessor_storage, "f"); },
set: function (value) { __classPrivateFieldSet(this, _C1_a_accessor_storage, value, "f"); },
enumerable: false,
configurable: true
});
Object.defineProperty(C1.prototype, "b", {
get: function () { return __classPrivateFieldGet(this, _C1_b_accessor_storage, "f"); },
set: function (value) { __classPrivateFieldSet(this, _C1_b_accessor_storage, value, "f"); },
enumerable: false,
configurable: true
});
Object.defineProperty(C1, "c", {
get: function () { return __classPrivateFieldGet(_a, _a, "f", _C1_c_accessor_storage); },
set: function (value) { __classPrivateFieldSet(_a, _a, value, "f", _C1_c_accessor_storage); },
enumerable: false,
configurable: true
});
Object.defineProperty(C1, "d", {
get: function () { return __classPrivateFieldGet(_a, _a, "f", _C1_d_accessor_storage); },
set: function (value) { __classPrivateFieldSet(_a, _a, value, "f", _C1_d_accessor_storage); },
enumerable: false,
configurable: true
});
var _a, _C1_a_accessor_storage, _C1_b_accessor_storage, _C1_c_accessor_storage, _C1_d_accessor_storage;
_a = C1, _C1_a_accessor_storage = new WeakMap(), _C1_b_accessor_storage = new WeakMap();
_C1_c_accessor_storage = { value: void 0 };
_C1_d_accessor_storage = { value: 2 };
return C1;
}());

View File

@ -0,0 +1,61 @@
//// [tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor3.ts] ////
//// [autoAccessor3.ts]
class C1 {
accessor "w": any;
accessor "x" = 1;
static accessor "y": any;
static accessor "z" = 2;
}
!!!! File autoAccessor3.js missing from original emit, but present in noCheck emit
//// [autoAccessor3.js]
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var C1 = /** @class */ (function () {
function C1() {
_C1__a_accessor_storage.set(this, void 0);
_C1__b_accessor_storage.set(this, 1);
}
Object.defineProperty(C1.prototype, "w", {
get: function () { return __classPrivateFieldGet(this, _C1__a_accessor_storage, "f"); },
set: function (value) { __classPrivateFieldSet(this, _C1__a_accessor_storage, value, "f"); },
enumerable: false,
configurable: true
});
Object.defineProperty(C1.prototype, "x", {
get: function () { return __classPrivateFieldGet(this, _C1__b_accessor_storage, "f"); },
set: function (value) { __classPrivateFieldSet(this, _C1__b_accessor_storage, value, "f"); },
enumerable: false,
configurable: true
});
Object.defineProperty(C1, "y", {
get: function () { return __classPrivateFieldGet(_a, _a, "f", _C1__c_accessor_storage); },
set: function (value) { __classPrivateFieldSet(_a, _a, value, "f", _C1__c_accessor_storage); },
enumerable: false,
configurable: true
});
Object.defineProperty(C1, "z", {
get: function () { return __classPrivateFieldGet(_a, _a, "f", _C1__d_accessor_storage); },
set: function (value) { __classPrivateFieldSet(_a, _a, value, "f", _C1__d_accessor_storage); },
enumerable: false,
configurable: true
});
var _a, _C1__a_accessor_storage, _C1__b_accessor_storage, _C1__c_accessor_storage, _C1__d_accessor_storage;
_a = C1, _C1__a_accessor_storage = new WeakMap(), _C1__b_accessor_storage = new WeakMap();
_C1__c_accessor_storage = { value: void 0 };
_C1__d_accessor_storage = { value: 2 };
return C1;
}());

View File

@ -0,0 +1,61 @@
//// [tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor4.ts] ////
//// [autoAccessor4.ts]
class C1 {
accessor 0: any;
accessor 1 = 1;
static accessor 2: any;
static accessor 3 = 2;
}
!!!! File autoAccessor4.js missing from original emit, but present in noCheck emit
//// [autoAccessor4.js]
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var C1 = /** @class */ (function () {
function C1() {
_C1__a_accessor_storage.set(this, void 0);
_C1__b_accessor_storage.set(this, 1);
}
Object.defineProperty(C1.prototype, 0, {
get: function () { return __classPrivateFieldGet(this, _C1__a_accessor_storage, "f"); },
set: function (value) { __classPrivateFieldSet(this, _C1__a_accessor_storage, value, "f"); },
enumerable: false,
configurable: true
});
Object.defineProperty(C1.prototype, 1, {
get: function () { return __classPrivateFieldGet(this, _C1__b_accessor_storage, "f"); },
set: function (value) { __classPrivateFieldSet(this, _C1__b_accessor_storage, value, "f"); },
enumerable: false,
configurable: true
});
Object.defineProperty(C1, 2, {
get: function () { return __classPrivateFieldGet(_a, _a, "f", _C1__c_accessor_storage); },
set: function (value) { __classPrivateFieldSet(_a, _a, value, "f", _C1__c_accessor_storage); },
enumerable: false,
configurable: true
});
Object.defineProperty(C1, 3, {
get: function () { return __classPrivateFieldGet(_a, _a, "f", _C1__d_accessor_storage); },
set: function (value) { __classPrivateFieldSet(_a, _a, value, "f", _C1__d_accessor_storage); },
enumerable: false,
configurable: true
});
var _a, _C1__a_accessor_storage, _C1__b_accessor_storage, _C1__c_accessor_storage, _C1__d_accessor_storage;
_a = C1, _C1__a_accessor_storage = new WeakMap(), _C1__b_accessor_storage = new WeakMap();
_C1__c_accessor_storage = { value: void 0 };
_C1__d_accessor_storage = { value: 2 };
return C1;
}());

View File

@ -75,3 +75,19 @@ declare var k: c | m.c;
declare var l: c | m.c;
declare var x: g<string> | m.g<number> | (() => c);
declare var y: g<string> | m.g<number> | (() => 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<T> {
private s;
}
declare var k: c | m.c;
-declare var l: c | m.c;
+declare var l: m.c | c;
declare var x: g<string> | m.g<number> | (() => c);
declare var y: g<string> | m.g<number> | (() => c);

View File

@ -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;

View File

@ -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;

View File

@ -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)
~~~~~~

View File

@ -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";

View File

@ -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

View File

@ -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 {
}
}

View File

@ -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 {
}
}

View File

@ -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 {
}
}

View File

@ -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 =>

View File

@ -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 {
~~~~~~

View File

@ -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;
}

View File

@ -1,60 +0,0 @@
//// [tests/cases/compiler/typeReferenceDirectives12.ts] ////
//// [index.d.ts]
interface Lib { x }
//// [main.ts]
export class Cls {
x
}
//// [mod1.ts]
/// <reference types="lib" />
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;
}

View File

@ -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;

View File

@ -846,7 +846,7 @@ type AnyArr = [...any];
declare const tc4: [...string[], number, number, number];
declare function concat2<T extends readonly unknown[], U extends readonly unknown[]>(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<T extends unknown[]>(x: number, ...args: [...T, number]): T;