diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 13e90241ab5bc..1003b23b455ec 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -3209,7 +3209,10 @@ namespace ts { } if (!isBindingPattern(node.name)) { - if (isBlockOrCatchScoped(node)) { + if (isInJSFile(node) && isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) && !getJSDocTypeTag(node)) { + declareSymbolAndAddToSymbolTable(node as Declaration, SymbolFlags.Alias, SymbolFlags.AliasExcludes); + } + else if (isBlockOrCatchScoped(node)) { bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes); } else if (isParameterDeclaration(node)) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cf64d3908c80f..52b3494002cb7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1919,11 +1919,8 @@ namespace ts { if (lastLocation && ( lastLocation === (location as BindingElement).initializer || lastLocation === (location as BindingElement).name && isBindingPattern(lastLocation))) { - const root = getRootDeclaration(location); - if (root.kind === SyntaxKind.Parameter) { - if (!associatedDeclarationForContainingInitializerOrBindingName) { - associatedDeclarationForContainingInitializerOrBindingName = location as BindingElement; - } + if (isParameterDeclaration(location as BindingElement) && !associatedDeclarationForContainingInitializerOrBindingName) { + associatedDeclarationForContainingInitializerOrBindingName = location as BindingElement; } } break; @@ -2372,32 +2369,41 @@ namespace ts { * {name: } */ function isAliasSymbolDeclaration(node: Node): boolean { - return node.kind === SyntaxKind.ImportEqualsDeclaration || - node.kind === SyntaxKind.NamespaceExportDeclaration || - node.kind === SyntaxKind.ImportClause && !!(node).name || - node.kind === SyntaxKind.NamespaceImport || - node.kind === SyntaxKind.NamespaceExport || - node.kind === SyntaxKind.ImportSpecifier || - node.kind === SyntaxKind.ExportSpecifier || - node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(node) || - isBinaryExpression(node) && getAssignmentDeclarationKind(node) === AssignmentDeclarationKind.ModuleExports && exportAssignmentIsAlias(node) || - isPropertyAccessExpression(node) + return node.kind === SyntaxKind.ImportEqualsDeclaration + || node.kind === SyntaxKind.NamespaceExportDeclaration + || node.kind === SyntaxKind.ImportClause && !!(node).name + || node.kind === SyntaxKind.NamespaceImport + || node.kind === SyntaxKind.NamespaceExport + || node.kind === SyntaxKind.ImportSpecifier + || node.kind === SyntaxKind.ExportSpecifier + || node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(node) + || isBinaryExpression(node) && getAssignmentDeclarationKind(node) === AssignmentDeclarationKind.ModuleExports && exportAssignmentIsAlias(node) + || isPropertyAccessExpression(node) && isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === SyntaxKind.EqualsToken - && isAliasableOrJsExpression(node.parent.right) || - node.kind === SyntaxKind.ShorthandPropertyAssignment || - node.kind === SyntaxKind.PropertyAssignment && isAliasableOrJsExpression((node as PropertyAssignment).initializer); + && isAliasableOrJsExpression(node.parent.right) + || node.kind === SyntaxKind.ShorthandPropertyAssignment + || node.kind === SyntaxKind.PropertyAssignment && isAliasableOrJsExpression((node as PropertyAssignment).initializer) + || isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true); } function isAliasableOrJsExpression(e: Expression) { return isAliasableExpression(e) || isFunctionExpression(e) && isJSConstructor(e); } - function getTargetOfImportEqualsDeclaration(node: ImportEqualsDeclaration, dontResolveAlias: boolean): Symbol | undefined { - if (node.moduleReference.kind === SyntaxKind.ExternalModuleReference) { - const immediate = resolveExternalModuleName(node, getExternalModuleImportEqualsDeclarationExpression(node)); - const resolved = resolveExternalModuleSymbol(immediate); + function getTargetOfImportEqualsDeclaration(node: ImportEqualsDeclaration | VariableDeclaration, dontResolveAlias: boolean): Symbol | undefined { + if (isVariableDeclaration(node) && node.initializer && isPropertyAccessExpression(node.initializer)) { + const name = (node.initializer.expression as CallExpression).arguments[0] as StringLiteral; + return isIdentifier(node.initializer.name) + ? getPropertyOfType(resolveExternalModuleTypeByLiteral(name), node.initializer.name.escapedText) + : undefined; + } + if (isVariableDeclaration(node) || node.moduleReference.kind === SyntaxKind.ExternalModuleReference) { + const immediate = resolveExternalModuleName( + node, + getExternalModuleRequireArgument(node) || getExternalModuleImportEqualsDeclarationExpression(node)); + const resolved = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, /*overwriteEmpty*/ false); return resolved; } @@ -2585,10 +2591,13 @@ namespace ts { return result; } - function getExportOfModule(symbol: Symbol, specifier: ImportOrExportSpecifier, dontResolveAlias: boolean): Symbol | undefined { + function getExportOfModule(symbol: Symbol, specifier: ImportOrExportSpecifier | BindingElement, dontResolveAlias: boolean): Symbol | undefined { if (symbol.flags & SymbolFlags.Module) { - const name = (specifier.propertyName ?? specifier.name).escapedText; - const exportSymbol = getExportsOfSymbol(symbol).get(name); + const name = specifier.propertyName ?? specifier.name; + if (!isIdentifier(name)) { + return undefined; + } + const exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText); const resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false); return resolved; @@ -2604,11 +2613,15 @@ namespace ts { } } - function getExternalModuleMember(node: ImportDeclaration | ExportDeclaration, specifier: ImportOrExportSpecifier, dontResolveAlias = false): Symbol | undefined { - const moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier!)!; + function getExternalModuleMember(node: ImportDeclaration | ExportDeclaration | VariableDeclaration, specifier: ImportOrExportSpecifier | BindingElement, dontResolveAlias = false): Symbol | undefined { + const moduleSpecifier = getExternalModuleRequireArgument(node) || (node as ImportDeclaration | ExportDeclaration).moduleSpecifier!; + const moduleSymbol = resolveExternalModuleName(node, moduleSpecifier)!; // TODO: GH#18217 const name = specifier.propertyName || specifier.name; + if (!isIdentifier(name)) { + return undefined; + } const suppressInteropError = name.escapedText === InternalSymbolName.Default && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); - const targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier!, dontResolveAlias, suppressInteropError); + const targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, dontResolveAlias, suppressInteropError); if (targetSymbol) { if (name.escapedText) { if (isShorthandAmbientModuleSymbol(moduleSymbol)) { @@ -2669,7 +2682,7 @@ namespace ts { } } - function reportNonExportedMember(node: ImportDeclaration | ExportDeclaration, name: Identifier, declarationName: string, moduleSymbol: Symbol, moduleName: string): void { + function reportNonExportedMember(node: ImportDeclaration | ExportDeclaration | VariableDeclaration, name: Identifier, declarationName: string, moduleSymbol: Symbol, moduleName: string): void { const localSymbol = moduleSymbol.valueDeclaration.locals?.get(name.escapedText); const exports = moduleSymbol.exports; if (localSymbol) { @@ -2693,7 +2706,7 @@ namespace ts { } } - function reportInvalidImportEqualsExportMember(node: ImportDeclaration | ExportDeclaration, name: Identifier, declarationName: string, moduleName: string) { + function reportInvalidImportEqualsExportMember(node: ImportDeclaration | ExportDeclaration | VariableDeclaration, name: Identifier, declarationName: string, moduleName: string) { if (moduleKind >= ModuleKind.ES2015) { const message = compilerOptions.esModuleInterop ? Diagnostics._0_can_only_be_imported_by_using_a_default_import : Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import; @@ -2713,8 +2726,8 @@ namespace ts { } } - function getTargetOfImportSpecifier(node: ImportSpecifier, dontResolveAlias: boolean): Symbol | undefined { - const resolved = getExternalModuleMember(node.parent.parent.parent, node, dontResolveAlias); + function getTargetOfImportSpecifier(node: ImportSpecifier | BindingElement, dontResolveAlias: boolean): Symbol | undefined { + const resolved = getExternalModuleMember(isBindingElement(node) ? getRootDeclaration(node) as VariableDeclaration : node.parent.parent.parent, node, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false); return resolved; } @@ -2771,15 +2784,17 @@ namespace ts { function getTargetOfAliasDeclaration(node: Declaration, dontRecursivelyResolve = false): Symbol | undefined { switch (node.kind) { case SyntaxKind.ImportEqualsDeclaration: - return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); + case SyntaxKind.VariableDeclaration: + return getTargetOfImportEqualsDeclaration(node as ImportEqualsDeclaration | VariableDeclaration, dontRecursivelyResolve); case SyntaxKind.ImportClause: - return getTargetOfImportClause(node, dontRecursivelyResolve); + return getTargetOfImportClause(node as ImportClause, dontRecursivelyResolve); case SyntaxKind.NamespaceImport: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); case SyntaxKind.NamespaceExport: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); case SyntaxKind.ImportSpecifier: - return getTargetOfImportSpecifier(node, dontRecursivelyResolve); + case SyntaxKind.BindingElement: + return getTargetOfImportSpecifier(node as ImportSpecifier | BindingElement, dontRecursivelyResolve); case SyntaxKind.ExportSpecifier: return getTargetOfExportSpecifier(node, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, dontRecursivelyResolve); case SyntaxKind.ExportAssignment: @@ -6217,43 +6232,60 @@ namespace ts { if (textRange && isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; } - const statement = setTextRange(factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) - ], flags)), textRange); - addResult(statement, name !== localName ? modifierFlags & ~ModifierFlags.Export : modifierFlags); - if (name !== localName && !isPrivate) { - // We rename the variable declaration we generate for Property symbols since they may have a name which - // conflicts with a local declaration. For example, given input: - // ``` - // function g() {} - // module.exports.g = g - // ``` - // In such a situation, we have a local variable named `g`, and a separate exported variable named `g`. - // Naively, we would emit - // ``` - // function g() {} - // export const g: typeof g; - // ``` - // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but - // the export declaration shadows it. - // To work around that, we instead write - // ``` - // function g() {} - // const g_1: typeof g; - // export { g_1 as g }; - // ``` - // To create an export named `g` that does _not_ shadow the local `g` + const propertyAccessRequire = find(symbol.declarations, isPropertyAccessExpression); + if (propertyAccessRequire && isBinaryExpression(propertyAccessRequire.parent) && isIdentifier(propertyAccessRequire.parent.right) + && type.symbol && isSourceFile(type.symbol.valueDeclaration)) { + const alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult( factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, - factory.createNamedExports([factory.createExportSpecifier(name, localName)]) + factory.createNamedExports([factory.createExportSpecifier(alias, localName)]) ), ModifierFlags.None ); - needsExportDeclaration = false; - needsPostExportDefault = false; + context.tracker.trackSymbol!(type.symbol, context.enclosingDeclaration, SymbolFlags.Value); + } + else { + const statement = setTextRange(factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([ + factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~ModifierFlags.Export : modifierFlags); + if (name !== localName && !isPrivate) { + // We rename the variable declaration we generate for Property symbols since they may have a name which + // conflicts with a local declaration. For example, given input: + // ``` + // function g() {} + // module.exports.g = g + // ``` + // In such a situation, we have a local variable named `g`, and a separate exported variable named `g`. + // Naively, we would emit + // ``` + // function g() {} + // export const g: typeof g; + // ``` + // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but + // the export declaration shadows it. + // To work around that, we instead write + // ``` + // function g() {} + // const g_1: typeof g; + // export { g_1 as g }; + // ``` + // To create an export named `g` that does _not_ shadow the local `g` + addResult( + factory.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*isTypeOnly*/ false, + factory.createNamedExports([factory.createExportSpecifier(name, localName)]) + ), + ModifierFlags.None + ); + needsExportDeclaration = false; + needsPostExportDefault = false; + } } } } @@ -6630,17 +6662,45 @@ namespace ts { const targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { + case SyntaxKind.VariableDeclaration: + // commonjs require: const x = require('y') + if (isPropertyAccessExpression((node as VariableDeclaration).initializer!)) { + // const x = require('y').z + const initializer = (node as VariableDeclaration).initializer! as PropertyAccessExpression; // require('y').z + const uniqueName = factory.createUniqueName((getExternalModuleRequireArgument(node) as StringLiteral).text); // _y + const specifier = getSpecifierForModuleSymbol(target.parent || target, context); // 'y' + // import _y = require('y'); + addResult(factory.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + uniqueName, + factory.createExternalModuleReference(factory.createStringLiteral(specifier)) + ), ModifierFlags.None); + // import x = _y.z + addResult(factory.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + factory.createIdentifier(localName), + factory.createQualifiedName(uniqueName, initializer.name as Identifier), + ), modifierFlags); + break; + } + // else fall through and treat commonjs require just like import= case SyntaxKind.ImportEqualsDeclaration: + if (target.escapedName === InternalSymbolName.ExportEquals) { + serializeMaybeAliasAssignment(symbol); + break; + } // Could be a local `import localName = ns.member` or // an external `import localName = require("whatever")` - const isLocalImport = !(target.flags & SymbolFlags.ValueModule); + const isLocalImport = !(target.flags & SymbolFlags.ValueModule) && !isVariableDeclaration(node); addResult(factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, factory.createIdentifier(localName), isLocalImport ? symbolToName(target, context, SymbolFlags.All, /*expectsIdentifier*/ false) - : factory.createExternalModuleReference(factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context))) + : factory.createExternalModuleReference(factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))) ), isLocalImport ? modifierFlags : ModifierFlags.None); break; case SyntaxKind.NamespaceExportDeclaration: @@ -6816,7 +6876,12 @@ namespace ts { const statement = factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(varName, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], NodeFlags.Const)); - addResult(statement, name === varName ? ModifierFlags.Export : ModifierFlags.None); + // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. + // Otherwise, the type itself should be exported. + addResult(statement, + target && target.flags & SymbolFlags.Property && target.escapedName === InternalSymbolName.ExportEquals ? ModifierFlags.Ambient + : name === varName ? ModifierFlags.Export + : ModifierFlags.None); } if (isExportAssignment) { results.push(factory.createExportAssignment( @@ -12062,8 +12127,7 @@ namespace ts { /** * A JSdoc TypeReference may be to a value, but resolve it as a type anyway. - * Note: If the value is imported from commonjs, it should really be an alias, - * but this function's special-case code fakes alias resolution as well. + * Example: import('./b').ConstructorFunction */ function getTypeFromJSDocValueReference(node: NodeWithTypeArguments, symbol: Symbol): Type | undefined { const links = getNodeLinks(node); @@ -12071,19 +12135,9 @@ namespace ts { const valueType = getTypeOfSymbol(symbol); let typeType = valueType; if (symbol.valueDeclaration) { - const decl = getRootDeclaration(symbol.valueDeclaration); - let isRequireAlias = false; - if (isVariableDeclaration(decl) && decl.initializer) { - let expr = decl.initializer; - // skip past entity names, eg `require("x").a.b.c` - while (isPropertyAccessExpression(expr)) { - expr = expr.expression; - } - isRequireAlias = isCallExpression(expr) && isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol; - } const isImportTypeWithQualifier = node.kind === SyntaxKind.ImportType && (node as ImportTypeNode).qualifier; // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL} - if (valueType.symbol && (isRequireAlias || isImportTypeWithQualifier)) { + if (valueType.symbol && isImportTypeWithQualifier) { typeType = getTypeReferenceType(node, valueType.symbol); } } @@ -32822,7 +32876,7 @@ namespace ts { forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && getRootDeclaration(node).kind === SyntaxKind.Parameter && nodeIsMissing((getContainingFunction(node) as FunctionLikeDeclaration).body)) { + if (node.initializer && isParameterDeclaration(node) && nodeIsMissing((getContainingFunction(node) as FunctionLikeDeclaration).body)) { error(node, Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -32854,7 +32908,13 @@ namespace ts { } return; } + // For a commonjs `const x = require`, validate the alias and exit const symbol = getSymbolOfNode(node); + if (symbol.flags & SymbolFlags.Alias && isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true)) { + checkAliasSymbol(node); + return; + } + const type = convertAutoToAny(getTypeOfSymbol(symbol)); if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer @@ -35300,7 +35360,7 @@ namespace ts { return true; } - function checkAliasSymbol(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier | ExportSpecifier | NamespaceExport) { + function checkAliasSymbol(node: ImportEqualsDeclaration | VariableDeclaration | ImportClause | NamespaceImport | ImportSpecifier | ExportSpecifier | NamespaceExport) { let symbol = getSymbolOfNode(node); const target = resolveAlias(symbol); @@ -36584,10 +36644,15 @@ namespace ts { } /** Returns the target of an export specifier without following aliases */ - function getExportSpecifierLocalTargetSymbol(node: ExportSpecifier): Symbol | undefined { - return node.parent.parent.moduleSpecifier ? - getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); + function getExportSpecifierLocalTargetSymbol(node: ExportSpecifier | Identifier): Symbol | undefined { + if (isExportSpecifier(node)) { + return node.parent.parent.moduleSpecifier ? + getExternalModuleMember(node.parent.parent, node) : + resolveEntityName(node.propertyName || node.name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); + } + else { + return resolveEntityName(node, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); + } } function getTypeOfNode(node: Node): Type { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 881daeb8cb406..40f43b3ad6bbc 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3937,7 +3937,8 @@ namespace ts { * This is necessary as an identifier in short-hand property assignment can contains two meaning: property name and property value. */ getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined; - getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined; + + getExportSpecifierLocalTargetSymbol(location: ExportSpecifier | Identifier): Symbol | undefined; /** * If a symbol is a local symbol with an associated exported symbol, returns the exported symbol. * Otherwise returns its input. diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 33d38853ec2ea..6b58a9aafd6d3 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1856,6 +1856,11 @@ namespace ts { return ((node).moduleReference).expression; } + export function getExternalModuleRequireArgument(node: Node) { + return isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) + && (getLeftmostPropertyAccessExpression(node.initializer) as CallExpression).arguments[0] as StringLiteral; + } + export function isInternalModuleImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration { return node.kind === SyntaxKind.ImportEqualsDeclaration && (node).moduleReference.kind !== SyntaxKind.ExternalModuleReference; } @@ -1923,7 +1928,8 @@ namespace ts { export function isRequireVariableDeclaration(node: Node, requireStringLiteralLikeArgument: true): node is RequireVariableDeclaration; export function isRequireVariableDeclaration(node: Node, requireStringLiteralLikeArgument: boolean): node is VariableDeclaration; export function isRequireVariableDeclaration(node: Node, requireStringLiteralLikeArgument: boolean): node is VariableDeclaration { - return isVariableDeclaration(node) && !!node.initializer && isRequireCall(node.initializer, requireStringLiteralLikeArgument); + node = getRootDeclaration(node); + return isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostPropertyAccessExpression(node.initializer), requireStringLiteralLikeArgument); } export function isRequireVariableStatement(node: Node, requireStringLiteralLikeArgument = true): node is RequireVariableStatement { @@ -5446,6 +5452,13 @@ namespace ts { return node.kind === SyntaxKind.NamedImports || node.kind === SyntaxKind.NamedExports; } + export function getLeftmostPropertyAccessExpression(expr: Expression): Expression { + while (isPropertyAccessExpression(expr)) { + expr = expr.expression; + } + return expr; + } + export function getLeftmostExpression(node: Expression, stopAtCallExpressions: boolean) { while (true) { switch (node.kind) { diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 4b39a90c880c7..f0ec33c88842b 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -34,9 +34,7 @@ namespace ts.GoToDefinition { const sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. - if (typeChecker.getRootSymbols(symbol).some(s => symbolMatchesSignature(s, calledDeclaration)) || - // TODO: GH#25533 Following check shouldn't be necessary if 'require' is an alias - symbol.declarations && symbol.declarations.some(d => isVariableDeclaration(d) && !!d.initializer && isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ false))) { + if (typeChecker.getRootSymbols(symbol).some(s => symbolMatchesSignature(s, calledDeclaration))) { return [sigInfo]; } else { @@ -210,15 +208,6 @@ namespace ts.GoToDefinition { return aliased; } } - if (symbol && isInJSFile(node)) { - const requireCall = forEach(symbol.declarations, d => isVariableDeclaration(d) && !!d.initializer && isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true) ? d.initializer : undefined); - if (requireCall) { - const moduleSymbol = checker.getSymbolAtLocation(requireCall.arguments[0]); - if (moduleSymbol) { - return checker.resolveExternalModuleSymbol(moduleSymbol); - } - } - } return symbol; } @@ -240,6 +229,9 @@ namespace ts.GoToDefinition { return true; case SyntaxKind.ImportSpecifier: return declaration.parent.kind === SyntaxKind.NamedImports; + case SyntaxKind.BindingElement: + case SyntaxKind.VariableDeclaration: + return isInJSFile(declaration) && isRequireVariableDeclaration(declaration, /*requireStringLiteralLikeArgument*/ true); default: return false; } diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 59c7e8c2745ac..41df9bcd5836b 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -93,9 +93,6 @@ namespace ts.FindAllReferences { break; } } - - // Don't support re-exporting 'require()' calls, so just add a single indirect user. - addIndirectUser(direct.getSourceFile()); } break; @@ -607,6 +604,8 @@ namespace ts.FindAllReferences { case SyntaxKind.NamespaceImport: Debug.assert((parent as ImportClause | NamespaceImport).name === node); return true; + case SyntaxKind.BindingElement: + return isInJSFile(node) && isRequireVariableDeclaration(parent, /*requireStringLiteralLikeArgument*/ true); default: return false; } @@ -628,6 +627,14 @@ namespace ts.FindAllReferences { if (isExportSpecifier(declaration) && !declaration.propertyName && !declaration.parent.parent.moduleSpecifier) { return checker.getExportSpecifierLocalTargetSymbol(declaration)!; } + else if (isPropertyAccessExpression(declaration) && isModuleExportsAccessExpression(declaration.expression) && !isPrivateIdentifier(declaration.name)) { + return checker.getExportSpecifierLocalTargetSymbol(declaration.name)!; + } + else if (isShorthandPropertyAssignment(declaration) + && isBinaryExpression(declaration.parent.parent) + && getAssignmentDeclarationKind(declaration.parent.parent) === AssignmentDeclarationKind.ModuleExports) { + return checker.getExportSpecifierLocalTargetSymbol(declaration.name)!; + } } } return symbol; diff --git a/tests/baselines/reference/ambientRequireFunction.symbols b/tests/baselines/reference/ambientRequireFunction.symbols index b2e94e89a2cb9..3fb2c754805c6 100644 --- a/tests/baselines/reference/ambientRequireFunction.symbols +++ b/tests/baselines/reference/ambientRequireFunction.symbols @@ -4,13 +4,13 @@ const fs = require("fs"); >fs : Symbol(fs, Decl(app.js, 2, 5)) >require : Symbol(require, Decl(node.d.ts, 0, 0)) ->"fs" : Symbol("fs", Decl(node.d.ts, 0, 50)) +>"fs" : Symbol(fs, Decl(node.d.ts, 0, 50)) const text = fs.readFileSync("/a/b/c"); >text : Symbol(text, Decl(app.js, 3, 5)) ->fs.readFileSync : Symbol(readFileSync, Decl(node.d.ts, 2, 21)) +>fs.readFileSync : Symbol(fs.readFileSync, Decl(node.d.ts, 2, 21)) >fs : Symbol(fs, Decl(app.js, 2, 5)) ->readFileSync : Symbol(readFileSync, Decl(node.d.ts, 2, 21)) +>readFileSync : Symbol(fs.readFileSync, Decl(node.d.ts, 2, 21)) === tests/cases/compiler/node.d.ts === declare function require(moduleName: string): any; diff --git a/tests/baselines/reference/ambientRequireFunction.types b/tests/baselines/reference/ambientRequireFunction.types index d8d47964cfdfd..487305a139a33 100644 --- a/tests/baselines/reference/ambientRequireFunction.types +++ b/tests/baselines/reference/ambientRequireFunction.types @@ -2,8 +2,8 @@ /// const fs = require("fs"); ->fs : typeof import("fs") ->require("fs") : typeof import("fs") +>fs : typeof fs +>require("fs") : typeof fs >require : (moduleName: string) => any >"fs" : "fs" @@ -11,7 +11,7 @@ const text = fs.readFileSync("/a/b/c"); >text : string >fs.readFileSync("/a/b/c") : string >fs.readFileSync : (s: string) => string ->fs : typeof import("fs") +>fs : typeof fs >readFileSync : (s: string) => string >"/a/b/c" : "/a/b/c" diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 116073c7d11fa..142dc3a9e7d29 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2159,7 +2159,7 @@ declare namespace ts { * This is necessary as an identifier in short-hand property assignment can contains two meaning: property name and property value. */ getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined; - getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined; + getExportSpecifierLocalTargetSymbol(location: ExportSpecifier | Identifier): Symbol | undefined; /** * If a symbol is a local symbol with an associated exported symbol, returns the exported symbol. * Otherwise returns its input. diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 1a76b249ed143..86432ff0efad4 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2159,7 +2159,7 @@ declare namespace ts { * This is necessary as an identifier in short-hand property assignment can contains two meaning: property name and property value. */ getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined; - getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined; + getExportSpecifierLocalTargetSymbol(location: ExportSpecifier | Identifier): Symbol | undefined; /** * If a symbol is a local symbol with an associated exported symbol, returns the exported symbol. * Otherwise returns its input. diff --git a/tests/baselines/reference/chainedPrototypeAssignment.symbols b/tests/baselines/reference/chainedPrototypeAssignment.symbols index 64211c83d0206..bd31b70bc87f1 100644 --- a/tests/baselines/reference/chainedPrototypeAssignment.symbols +++ b/tests/baselines/reference/chainedPrototypeAssignment.symbols @@ -3,19 +3,19 @@ var mod = require('./mod'); >mod : Symbol(mod, Decl(use.js, 1, 3)) >require : Symbol(require, Decl(types.d.ts, 0, 0)) ->'./mod' : Symbol("tests/cases/conformance/salsa/mod", Decl(mod.js, 0, 0)) +>'./mod' : Symbol(mod, Decl(mod.js, 0, 0)) var a = new mod.A() >a : Symbol(a, Decl(use.js, 2, 3)) ->mod.A : Symbol(A, Decl(mod.js, 6, 1)) +>mod.A : Symbol(mod.A, Decl(mod.js, 6, 1)) >mod : Symbol(mod, Decl(use.js, 1, 3)) ->A : Symbol(A, Decl(mod.js, 6, 1)) +>A : Symbol(mod.A, Decl(mod.js, 6, 1)) var b = new mod.B() >b : Symbol(b, Decl(use.js, 3, 3)) ->mod.B : Symbol(B, Decl(mod.js, 7, 13)) +>mod.B : Symbol(mod.B, Decl(mod.js, 7, 13)) >mod : Symbol(mod, Decl(use.js, 1, 3)) ->B : Symbol(B, Decl(mod.js, 7, 13)) +>B : Symbol(mod.B, Decl(mod.js, 7, 13)) a.m('nope') >a.m : Symbol(m, Decl(mod.js, 9, 29)) diff --git a/tests/baselines/reference/chainedPrototypeAssignment.types b/tests/baselines/reference/chainedPrototypeAssignment.types index d3754807da6ae..ccd81fa038096 100644 --- a/tests/baselines/reference/chainedPrototypeAssignment.types +++ b/tests/baselines/reference/chainedPrototypeAssignment.types @@ -1,8 +1,8 @@ === tests/cases/conformance/salsa/use.js === /// var mod = require('./mod'); ->mod : typeof import("tests/cases/conformance/salsa/mod") ->require('./mod') : typeof import("tests/cases/conformance/salsa/mod") +>mod : typeof mod +>require('./mod') : typeof mod >require : (name: string) => any >'./mod' : "./mod" @@ -10,14 +10,14 @@ var a = new mod.A() >a : A >new mod.A() : A >mod.A : typeof A ->mod : typeof import("tests/cases/conformance/salsa/mod") +>mod : typeof mod >A : typeof A var b = new mod.B() >b : B >new mod.B() : B >mod.B : typeof B ->mod : typeof import("tests/cases/conformance/salsa/mod") +>mod : typeof mod >B : typeof B a.m('nope') diff --git a/tests/baselines/reference/checkOtherObjectAssignProperty.symbols b/tests/baselines/reference/checkOtherObjectAssignProperty.symbols index 33e8560261950..10ff1067b34ce 100644 --- a/tests/baselines/reference/checkOtherObjectAssignProperty.symbols +++ b/tests/baselines/reference/checkOtherObjectAssignProperty.symbols @@ -1,61 +1,61 @@ === tests/cases/conformance/jsdoc/importer.js === const mod = require("./mod1"); ->mod : Symbol(mod, Decl(importer.js, 0, 5), Decl(importer.js, 6, 9), Decl(importer.js, 9, 14), Decl(importer.js, 10, 14), Decl(importer.js, 11, 13) ... and 2 more) +>mod : Symbol(mod, Decl(importer.js, 0, 5)) >require : Symbol(require) ->"./mod1" : Symbol("tests/cases/conformance/jsdoc/mod1", Decl(mod1.js, 0, 0)) +>"./mod1" : Symbol(mod, Decl(mod1.js, 0, 0)) mod.thing; ->mod.thing : Symbol(thing, Decl(mod1.js, 0, 42)) ->mod : Symbol(mod, Decl(importer.js, 0, 5), Decl(importer.js, 6, 9), Decl(importer.js, 9, 14), Decl(importer.js, 10, 14), Decl(importer.js, 11, 13) ... and 2 more) ->thing : Symbol(thing, Decl(mod1.js, 0, 42)) +>mod.thing : Symbol(mod.thing, Decl(mod1.js, 0, 42)) +>mod : Symbol(mod, Decl(importer.js, 0, 5)) +>thing : Symbol(mod.thing, Decl(mod1.js, 0, 42)) mod.other; ->mod : Symbol(mod, Decl(importer.js, 0, 5), Decl(importer.js, 6, 9), Decl(importer.js, 9, 14), Decl(importer.js, 10, 14), Decl(importer.js, 11, 13) ... and 2 more) +>mod : Symbol(mod, Decl(importer.js, 0, 5)) mod.prop; ->mod : Symbol(mod, Decl(importer.js, 0, 5), Decl(importer.js, 6, 9), Decl(importer.js, 9, 14), Decl(importer.js, 10, 14), Decl(importer.js, 11, 13) ... and 2 more) +>mod : Symbol(mod, Decl(importer.js, 0, 5)) mod.bad1; ->mod.bad1 : Symbol(bad1, Decl(mod1.js, 10, 72)) ->mod : Symbol(mod, Decl(importer.js, 0, 5), Decl(importer.js, 6, 9), Decl(importer.js, 9, 14), Decl(importer.js, 10, 14), Decl(importer.js, 11, 13) ... and 2 more) ->bad1 : Symbol(bad1, Decl(mod1.js, 10, 72)) +>mod.bad1 : Symbol(mod.bad1, Decl(mod1.js, 10, 72)) +>mod : Symbol(mod, Decl(importer.js, 0, 5)) +>bad1 : Symbol(mod.bad1, Decl(mod1.js, 10, 72)) mod.bad2; ->mod.bad2 : Symbol(bad2, Decl(mod1.js, 13, 44)) ->mod : Symbol(mod, Decl(importer.js, 0, 5), Decl(importer.js, 6, 9), Decl(importer.js, 9, 14), Decl(importer.js, 10, 14), Decl(importer.js, 11, 13) ... and 2 more) ->bad2 : Symbol(bad2, Decl(mod1.js, 13, 44)) +>mod.bad2 : Symbol(mod.bad2, Decl(mod1.js, 13, 44)) +>mod : Symbol(mod, Decl(importer.js, 0, 5)) +>bad2 : Symbol(mod.bad2, Decl(mod1.js, 13, 44)) mod.bad3; ->mod.bad3 : Symbol(bad3, Decl(mod1.js, 14, 77)) ->mod : Symbol(mod, Decl(importer.js, 0, 5), Decl(importer.js, 6, 9), Decl(importer.js, 9, 14), Decl(importer.js, 10, 14), Decl(importer.js, 11, 13) ... and 2 more) ->bad3 : Symbol(bad3, Decl(mod1.js, 14, 77)) +>mod.bad3 : Symbol(mod.bad3, Decl(mod1.js, 14, 77)) +>mod : Symbol(mod, Decl(importer.js, 0, 5)) +>bad3 : Symbol(mod.bad3, Decl(mod1.js, 14, 77)) mod.thing = 0; ->mod.thing : Symbol(thing, Decl(mod1.js, 0, 42)) ->mod : Symbol(mod, Decl(importer.js, 0, 5), Decl(importer.js, 6, 9), Decl(importer.js, 9, 14), Decl(importer.js, 10, 14), Decl(importer.js, 11, 13) ... and 2 more) ->thing : Symbol(thing, Decl(mod1.js, 0, 42)) +>mod.thing : Symbol(mod.thing, Decl(mod1.js, 0, 42)) +>mod : Symbol(mod, Decl(importer.js, 0, 5)) +>thing : Symbol(mod.thing, Decl(mod1.js, 0, 42)) mod.other = 0; ->mod : Symbol(mod, Decl(importer.js, 0, 5), Decl(importer.js, 6, 9), Decl(importer.js, 9, 14), Decl(importer.js, 10, 14), Decl(importer.js, 11, 13) ... and 2 more) +>mod : Symbol(mod, Decl(importer.js, 0, 5)) mod.prop = 0; ->mod : Symbol(mod, Decl(importer.js, 0, 5), Decl(importer.js, 6, 9), Decl(importer.js, 9, 14), Decl(importer.js, 10, 14), Decl(importer.js, 11, 13) ... and 2 more) +>mod : Symbol(mod, Decl(importer.js, 0, 5)) mod.bad1 = 0; ->mod.bad1 : Symbol(bad1, Decl(mod1.js, 10, 72)) ->mod : Symbol(mod, Decl(importer.js, 0, 5), Decl(importer.js, 6, 9), Decl(importer.js, 9, 14), Decl(importer.js, 10, 14), Decl(importer.js, 11, 13) ... and 2 more) ->bad1 : Symbol(bad1, Decl(mod1.js, 10, 72)) +>mod.bad1 : Symbol(mod.bad1, Decl(mod1.js, 10, 72)) +>mod : Symbol(mod, Decl(importer.js, 0, 5)) +>bad1 : Symbol(mod.bad1, Decl(mod1.js, 10, 72)) mod.bad2 = 0; ->mod.bad2 : Symbol(bad2, Decl(mod1.js, 13, 44)) ->mod : Symbol(mod, Decl(importer.js, 0, 5), Decl(importer.js, 6, 9), Decl(importer.js, 9, 14), Decl(importer.js, 10, 14), Decl(importer.js, 11, 13) ... and 2 more) ->bad2 : Symbol(bad2, Decl(mod1.js, 13, 44)) +>mod.bad2 : Symbol(mod.bad2, Decl(mod1.js, 13, 44)) +>mod : Symbol(mod, Decl(importer.js, 0, 5)) +>bad2 : Symbol(mod.bad2, Decl(mod1.js, 13, 44)) mod.bad3 = 0; ->mod.bad3 : Symbol(bad3, Decl(mod1.js, 14, 77)) ->mod : Symbol(mod, Decl(importer.js, 0, 5), Decl(importer.js, 6, 9), Decl(importer.js, 9, 14), Decl(importer.js, 10, 14), Decl(importer.js, 11, 13) ... and 2 more) ->bad3 : Symbol(bad3, Decl(mod1.js, 14, 77)) +>mod.bad3 : Symbol(mod.bad3, Decl(mod1.js, 14, 77)) +>mod : Symbol(mod, Decl(importer.js, 0, 5)) +>bad3 : Symbol(mod.bad3, Decl(mod1.js, 14, 77)) === tests/cases/conformance/jsdoc/mod1.js === const obj = { value: 42, writable: true }; diff --git a/tests/baselines/reference/checkOtherObjectAssignProperty.types b/tests/baselines/reference/checkOtherObjectAssignProperty.types index d9b68d71745e8..950e1266154e2 100644 --- a/tests/baselines/reference/checkOtherObjectAssignProperty.types +++ b/tests/baselines/reference/checkOtherObjectAssignProperty.types @@ -1,80 +1,80 @@ === tests/cases/conformance/jsdoc/importer.js === const mod = require("./mod1"); ->mod : typeof import("tests/cases/conformance/jsdoc/mod1") ->require("./mod1") : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod : typeof mod +>require("./mod1") : typeof mod >require : any >"./mod1" : "./mod1" mod.thing; >mod.thing : number ->mod : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod : typeof mod >thing : number mod.other; >mod.other : any ->mod : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod : typeof mod >other : any mod.prop; >mod.prop : any ->mod : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod : typeof mod >prop : any mod.bad1; >mod.bad1 : any ->mod : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod : typeof mod >bad1 : any mod.bad2; >mod.bad2 : string ->mod : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod : typeof mod >bad2 : string mod.bad3; >mod.bad3 : any ->mod : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod : typeof mod >bad3 : any mod.thing = 0; >mod.thing = 0 : 0 >mod.thing : number ->mod : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod : typeof mod >thing : number >0 : 0 mod.other = 0; >mod.other = 0 : 0 >mod.other : any ->mod : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod : typeof mod >other : any >0 : 0 mod.prop = 0; >mod.prop = 0 : 0 >mod.prop : any ->mod : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod : typeof mod >prop : any >0 : 0 mod.bad1 = 0; >mod.bad1 = 0 : 0 >mod.bad1 : any ->mod : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod : typeof mod >bad1 : any >0 : 0 mod.bad2 = 0; >mod.bad2 = 0 : 0 >mod.bad2 : any ->mod : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod : typeof mod >bad2 : any >0 : 0 mod.bad3 = 0; >mod.bad3 = 0 : 0 >mod.bad3 : any ->mod : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod : typeof mod >bad3 : any >0 : 0 diff --git a/tests/baselines/reference/constructorFunctions2.types b/tests/baselines/reference/constructorFunctions2.types index 0f5933e04f4be..8b1f3711770aa 100644 --- a/tests/baselines/reference/constructorFunctions2.types +++ b/tests/baselines/reference/constructorFunctions2.types @@ -9,16 +9,16 @@ declare var module: any, exports: any; === tests/cases/conformance/salsa/index.js === const A = require("./other"); ->A : typeof import("tests/cases/conformance/salsa/other") ->require("./other") : typeof import("tests/cases/conformance/salsa/other") +>A : typeof A +>require("./other") : typeof A >require : (id: string) => any >"./other" : "./other" const a = new A().id; >a : number >new A().id : number ->new A() : import("tests/cases/conformance/salsa/other") ->A : typeof import("tests/cases/conformance/salsa/other") +>new A() : A +>A : typeof A >id : number const B = function() { this.id = 1; } diff --git a/tests/baselines/reference/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.types b/tests/baselines/reference/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.types index 95ac66a27c838..cb026f00735df 100644 --- a/tests/baselines/reference/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.types +++ b/tests/baselines/reference/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.types @@ -1,7 +1,7 @@ === tests/cases/compiler/index.js === const _item = require("./namespacer"); ->_item : typeof B ->require("./namespacer") : typeof B +>_item : typeof _item +>require("./namespacer") : typeof _item >require : any >"./namespacer" : "./namespacer" diff --git a/tests/baselines/reference/findAllRefsCommonJsRequire.baseline.jsonc b/tests/baselines/reference/findAllRefsCommonJsRequire.baseline.jsonc new file mode 100644 index 0000000000000..675238f9655e0 --- /dev/null +++ b/tests/baselines/reference/findAllRefsCommonJsRequire.baseline.jsonc @@ -0,0 +1,196 @@ +// === /b.js === +// const { [|f|]/*FIND ALL REFS*/ } = require('./a') +// [|f|] + +// === /a.js === +// function [|f|]() { } +// export { [|f|] } + +[ + { + "definition": { + "containerKind": "", + "containerName": "", + "fileName": "/b.js", + "kind": "alias", + "name": "(alias) function f(): void\nimport f", + "textSpan": { + "start": 8, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "aliasName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "aliasName" + } + ], + "contextSpan": { + "start": 0, + "length": 28 + } + }, + "references": [ + { + "textSpan": { + "start": 8, + "length": 1 + }, + "fileName": "/b.js", + "contextSpan": { + "start": 0, + "length": 28 + }, + "isWriteAccess": true, + "isDefinition": true + }, + { + "textSpan": { + "start": 29, + "length": 1 + }, + "fileName": "/b.js", + "isWriteAccess": false, + "isDefinition": false + } + ] + }, + { + "definition": { + "containerKind": "", + "containerName": "", + "fileName": "/a.js", + "kind": "function", + "name": "function f(): void", + "textSpan": { + "start": 9, + "length": 1 + }, + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ], + "contextSpan": { + "start": 0, + "length": 16 + } + }, + "references": [ + { + "textSpan": { + "start": 9, + "length": 1 + }, + "fileName": "/a.js", + "contextSpan": { + "start": 0, + "length": 16 + }, + "isWriteAccess": true, + "isDefinition": true + }, + { + "textSpan": { + "start": 26, + "length": 1 + }, + "fileName": "/a.js", + "contextSpan": { + "start": 17, + "length": 12 + }, + "isWriteAccess": true, + "isDefinition": true + } + ] + } +] \ No newline at end of file diff --git a/tests/baselines/reference/findAllRefsCommonJsRequire2.baseline.jsonc b/tests/baselines/reference/findAllRefsCommonJsRequire2.baseline.jsonc new file mode 100644 index 0000000000000..f7b3b0ca60b74 --- /dev/null +++ b/tests/baselines/reference/findAllRefsCommonJsRequire2.baseline.jsonc @@ -0,0 +1,216 @@ +// === /b.js === +// const { [|f|]/*FIND ALL REFS*/ } = require('./a') +// [|f|] + +// === /a.js === +// function [|f|]() { } +// module.exports.f = [|f|] + +[ + { + "definition": { + "containerKind": "", + "containerName": "", + "fileName": "/b.js", + "kind": "alias", + "name": "(alias) (property) f: () => void\nimport f", + "textSpan": { + "start": 8, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "aliasName" + } + ], + "contextSpan": { + "start": 0, + "length": 28 + } + }, + "references": [ + { + "textSpan": { + "start": 8, + "length": 1 + }, + "fileName": "/b.js", + "contextSpan": { + "start": 0, + "length": 28 + }, + "isWriteAccess": true, + "isDefinition": true + }, + { + "textSpan": { + "start": 29, + "length": 1 + }, + "fileName": "/b.js", + "isWriteAccess": false, + "isDefinition": false + } + ] + }, + { + "definition": { + "containerKind": "", + "containerName": "", + "fileName": "/a.js", + "kind": "function", + "name": "function f(): void", + "textSpan": { + "start": 9, + "length": 1 + }, + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ], + "contextSpan": { + "start": 0, + "length": 16 + } + }, + "references": [ + { + "textSpan": { + "start": 9, + "length": 1 + }, + "fileName": "/a.js", + "contextSpan": { + "start": 0, + "length": 16 + }, + "isWriteAccess": true, + "isDefinition": true + }, + { + "textSpan": { + "start": 36, + "length": 1 + }, + "fileName": "/a.js", + "contextSpan": { + "start": 17, + "length": 20 + }, + "isWriteAccess": false, + "isDefinition": false + } + ] + } +] \ No newline at end of file diff --git a/tests/baselines/reference/findAllRefsCommonJsRequire3.baseline.jsonc b/tests/baselines/reference/findAllRefsCommonJsRequire3.baseline.jsonc new file mode 100644 index 0000000000000..bb4c2c66ec641 --- /dev/null +++ b/tests/baselines/reference/findAllRefsCommonJsRequire3.baseline.jsonc @@ -0,0 +1,212 @@ +// === /b.js === +// const { [|f|]/*FIND ALL REFS*/ } = require('./a') +// [|f|] + +// === /a.js === +// function [|f|]() { } +// module.exports = { [|f|] } + +[ + { + "definition": { + "containerKind": "", + "containerName": "", + "fileName": "/b.js", + "kind": "alias", + "name": "(alias) (property) f: () => void\nimport f", + "textSpan": { + "start": 8, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "aliasName" + } + ], + "contextSpan": { + "start": 0, + "length": 28 + } + }, + "references": [ + { + "textSpan": { + "start": 8, + "length": 1 + }, + "fileName": "/b.js", + "contextSpan": { + "start": 0, + "length": 28 + }, + "isWriteAccess": true, + "isDefinition": true + }, + { + "textSpan": { + "start": 29, + "length": 1 + }, + "fileName": "/b.js", + "isWriteAccess": false, + "isDefinition": false + } + ] + }, + { + "definition": { + "containerKind": "", + "containerName": "", + "fileName": "/a.js", + "kind": "function", + "name": "function f(): void", + "textSpan": { + "start": 9, + "length": 1 + }, + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ], + "contextSpan": { + "start": 0, + "length": 16 + } + }, + "references": [ + { + "textSpan": { + "start": 9, + "length": 1 + }, + "fileName": "/a.js", + "contextSpan": { + "start": 0, + "length": 16 + }, + "isWriteAccess": true, + "isDefinition": true + }, + { + "textSpan": { + "start": 36, + "length": 1 + }, + "fileName": "/a.js", + "isWriteAccess": true, + "isDefinition": true + } + ] + } +] \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.js b/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.js index 653fed447c485..1e270f2231b7b 100644 --- a/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.js +++ b/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.js @@ -56,12 +56,12 @@ declare class Bar { } //// [cls.d.ts] export = Foo; -declare const Foo_base: typeof import("./bar"); -declare class Foo extends Foo_base { +declare class Foo extends Bar { } declare namespace Foo { export { Strings }; } +import Bar = require("./bar"); declare namespace Strings { const a: string; const b: string; diff --git a/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.types b/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.types index ff1086ebd2de1..b73577a1133b1 100644 --- a/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.types +++ b/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.types @@ -1,7 +1,7 @@ === tests/cases/conformance/jsdoc/declarations/cls.js === const Bar = require("./bar"); ->Bar : typeof import("tests/cases/conformance/jsdoc/declarations/bar") ->require("./bar") : typeof import("tests/cases/conformance/jsdoc/declarations/bar") +>Bar : typeof Bar +>require("./bar") : typeof Bar >require : any >"./bar" : "./bar" @@ -20,7 +20,7 @@ const Strings = { }; class Foo extends Bar {} >Foo : Foo ->Bar : import("tests/cases/conformance/jsdoc/declarations/bar") +>Bar : Bar module.exports = Foo; >module.exports = Foo : typeof Foo diff --git a/tests/baselines/reference/jsDeclarationsCrossfileMerge.js b/tests/baselines/reference/jsDeclarationsCrossfileMerge.js index 9e99ba43fc55e..f4b06e5eaa883 100644 --- a/tests/baselines/reference/jsDeclarationsCrossfileMerge.js +++ b/tests/baselines/reference/jsDeclarationsCrossfileMerge.js @@ -24,5 +24,6 @@ module.exports.memberName = "thing"; //// [index.d.ts] -declare const _exports: typeof import("./exporter").default; +declare const _exports: typeof m.default; export = _exports; +import m = require("./exporter"); diff --git a/tests/baselines/reference/jsDeclarationsCrossfileMerge.symbols b/tests/baselines/reference/jsDeclarationsCrossfileMerge.symbols index 64753e212bef9..859c94328a408 100644 --- a/tests/baselines/reference/jsDeclarationsCrossfileMerge.symbols +++ b/tests/baselines/reference/jsDeclarationsCrossfileMerge.symbols @@ -2,15 +2,15 @@ const m = require("./exporter"); >m : Symbol(m, Decl(index.js, 0, 5)) >require : Symbol(require) ->"./exporter" : Symbol("tests/cases/conformance/jsdoc/declarations/exporter", Decl(exporter.js, 0, 0)) +>"./exporter" : Symbol(m, Decl(exporter.js, 0, 0)) module.exports = m.default; >module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) >module : Symbol(export=, Decl(index.js, 0, 32)) >exports : Symbol(export=, Decl(index.js, 0, 32)) ->m.default : Symbol(default, Decl(exporter.js, 0, 22)) +>m.default : Symbol(m.default, Decl(exporter.js, 0, 22)) >m : Symbol(m, Decl(index.js, 0, 5)) ->default : Symbol(default, Decl(exporter.js, 0, 22)) +>default : Symbol(m.default, Decl(exporter.js, 0, 22)) module.exports.memberName = "thing"; >module.exports.memberName : Symbol(memberName, Decl(index.js, 2, 27)) diff --git a/tests/baselines/reference/jsDeclarationsCrossfileMerge.types b/tests/baselines/reference/jsDeclarationsCrossfileMerge.types index 8de95cf8567eb..83e978857ee34 100644 --- a/tests/baselines/reference/jsDeclarationsCrossfileMerge.types +++ b/tests/baselines/reference/jsDeclarationsCrossfileMerge.types @@ -1,25 +1,25 @@ === tests/cases/conformance/jsdoc/declarations/index.js === const m = require("./exporter"); ->m : typeof import("tests/cases/conformance/jsdoc/declarations/exporter") ->require("./exporter") : typeof import("tests/cases/conformance/jsdoc/declarations/exporter") +>m : typeof m +>require("./exporter") : typeof m >require : any >"./exporter" : "./exporter" module.exports = m.default; ->module.exports = m.default : typeof import("tests/cases/conformance/jsdoc/declarations/exporter").default ->module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/exporter").default ->module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": typeof import("tests/cases/conformance/jsdoc/declarations/exporter").default; } ->exports : typeof import("tests/cases/conformance/jsdoc/declarations/exporter").default +>module.exports = m.default : typeof m.default +>module.exports : typeof m.default +>module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": typeof m.default; } +>exports : typeof m.default >m.default : { (): void; memberName: string; } ->m : typeof import("tests/cases/conformance/jsdoc/declarations/exporter") +>m : typeof m >default : { (): void; memberName: string; } module.exports.memberName = "thing"; >module.exports.memberName = "thing" : "thing" >module.exports.memberName : string ->module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/exporter").default ->module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": typeof import("tests/cases/conformance/jsdoc/declarations/exporter").default; } ->exports : typeof import("tests/cases/conformance/jsdoc/declarations/exporter").default +>module.exports : typeof m.default +>module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": typeof m.default; } +>exports : typeof m.default >memberName : string >"thing" : "thing" diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.js b/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.js index c900f28602e57..018aebdfec9cf 100644 --- a/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.js +++ b/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.js @@ -43,5 +43,6 @@ declare class Obj { //// [index.d.ts] export = Container; declare class Container { - usage: import("./obj"); + usage: Obj; } +import Obj = require("./obj"); diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.types b/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.types index a76835e3105a6..179947956bee7 100644 --- a/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.types +++ b/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.types @@ -1,7 +1,7 @@ === tests/cases/conformance/jsdoc/declarations/index.js === const Obj = require("./obj"); ->Obj : typeof import("tests/cases/conformance/jsdoc/declarations/obj") ->require("./obj") : typeof import("tests/cases/conformance/jsdoc/declarations/obj") +>Obj : typeof Obj +>require("./obj") : typeof Obj >require : any >"./obj" : "./obj" @@ -10,12 +10,12 @@ class Container { constructor() { this.usage = new Obj(); ->this.usage = new Obj() : import("tests/cases/conformance/jsdoc/declarations/obj") +>this.usage = new Obj() : Obj >this.usage : any >this : this >usage : any ->new Obj() : import("tests/cases/conformance/jsdoc/declarations/obj") ->Obj : typeof import("tests/cases/conformance/jsdoc/declarations/obj") +>new Obj() : Obj +>Obj : typeof Obj } } diff --git a/tests/baselines/reference/jsDeclarationsExportForms.js b/tests/baselines/reference/jsDeclarationsExportForms.js index d39e44d875c0f..eb6fd8ee81f5a 100644 --- a/tests/baselines/reference/jsDeclarationsExportForms.js +++ b/tests/baselines/reference/jsDeclarationsExportForms.js @@ -176,13 +176,16 @@ import * as ns from "./cls"; export { ns as classContainer }; import * as ns from "./cls"; //// [cjs.d.ts] -export const ns: typeof import("./cls"); +import ns = require("./cls"); +export { ns }; //// [cjs2.d.ts] export = ns; -declare const ns: typeof import("./cls"); +import ns = require("./cls"); //// [cjs3.d.ts] -export var ns: typeof import("./cls"); +export { ns }; +import ns = require("./cls"); //// [cjs4.d.ts] -export var names: typeof import("./cls"); +export { ns as names }; +import ns = require("./cls"); //// [includeAll.d.ts] export {}; diff --git a/tests/baselines/reference/jsDeclarationsExportForms.symbols b/tests/baselines/reference/jsDeclarationsExportForms.symbols index 300425b5c96e9..b42d528f92626 100644 --- a/tests/baselines/reference/jsDeclarationsExportForms.symbols +++ b/tests/baselines/reference/jsDeclarationsExportForms.symbols @@ -46,7 +46,7 @@ export { ns as classContainer }; const ns = require("./cls"); >ns : Symbol(ns, Decl(cjs.js, 0, 5)) >require : Symbol(require) ->"./cls" : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) +>"./cls" : Symbol(ns, Decl(cls.js, 0, 0)) module.exports = { ns }; >module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/cjs", Decl(cjs.js, 0, 0)) @@ -58,7 +58,7 @@ module.exports = { ns }; const ns = require("./cls"); >ns : Symbol(ns, Decl(cjs2.js, 0, 5)) >require : Symbol(require) ->"./cls" : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) +>"./cls" : Symbol(ns, Decl(cls.js, 0, 0)) module.exports = ns; >module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/cjs2", Decl(cjs2.js, 0, 0)) @@ -70,7 +70,7 @@ module.exports = ns; const ns = require("./cls"); >ns : Symbol(ns, Decl(cjs3.js, 0, 5)) >require : Symbol(require) ->"./cls" : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) +>"./cls" : Symbol(ns, Decl(cls.js, 0, 0)) module.exports.ns = ns; >module.exports.ns : Symbol(ns, Decl(cjs3.js, 0, 28)) @@ -84,7 +84,7 @@ module.exports.ns = ns; const ns = require("./cls"); >ns : Symbol(ns, Decl(cjs4.js, 0, 5)) >require : Symbol(require) ->"./cls" : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) +>"./cls" : Symbol(ns, Decl(cls.js, 0, 0)) module.exports.names = ns; >module.exports.names : Symbol(names, Decl(cjs4.js, 0, 28)) diff --git a/tests/baselines/reference/jsDeclarationsExportForms.types b/tests/baselines/reference/jsDeclarationsExportForms.types index c850d4b8a2323..496a58e9ac8a9 100644 --- a/tests/baselines/reference/jsDeclarationsExportForms.types +++ b/tests/baselines/reference/jsDeclarationsExportForms.types @@ -44,64 +44,64 @@ export { ns as classContainer }; === tests/cases/conformance/jsdoc/declarations/cjs.js === const ns = require("./cls"); ->ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") ->require("./cls") : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>ns : typeof ns +>require("./cls") : typeof ns >require : any >"./cls" : "./cls" module.exports = { ns }; ->module.exports = { ns } : { ns: typeof import("tests/cases/conformance/jsdoc/declarations/cls"); } ->module.exports : { ns: typeof import("tests/cases/conformance/jsdoc/declarations/cls"); } ->module : { "\"tests/cases/conformance/jsdoc/declarations/cjs\"": { ns: typeof import("tests/cases/conformance/jsdoc/declarations/cls"); }; } ->exports : { ns: typeof import("tests/cases/conformance/jsdoc/declarations/cls"); } ->{ ns } : { ns: typeof import("tests/cases/conformance/jsdoc/declarations/cls"); } ->ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>module.exports = { ns } : { ns: typeof ns; } +>module.exports : { ns: typeof ns; } +>module : { "\"tests/cases/conformance/jsdoc/declarations/cjs\"": { ns: typeof ns; }; } +>exports : { ns: typeof ns; } +>{ ns } : { ns: typeof ns; } +>ns : typeof ns === tests/cases/conformance/jsdoc/declarations/cjs2.js === const ns = require("./cls"); ->ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") ->require("./cls") : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>ns : typeof ns +>require("./cls") : typeof ns >require : any >"./cls" : "./cls" module.exports = ns; ->module.exports = ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") ->module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/cls") ->module : { "\"tests/cases/conformance/jsdoc/declarations/cjs2\"": typeof import("tests/cases/conformance/jsdoc/declarations/cls"); } ->exports : typeof import("tests/cases/conformance/jsdoc/declarations/cls") ->ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>module.exports = ns : typeof ns +>module.exports : typeof ns +>module : { "\"tests/cases/conformance/jsdoc/declarations/cjs2\"": typeof ns; } +>exports : typeof ns +>ns : typeof ns === tests/cases/conformance/jsdoc/declarations/cjs3.js === const ns = require("./cls"); ->ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") ->require("./cls") : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>ns : typeof ns +>require("./cls") : typeof ns >require : any >"./cls" : "./cls" module.exports.ns = ns; ->module.exports.ns = ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") ->module.exports.ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>module.exports.ns = ns : typeof ns +>module.exports.ns : typeof ns >module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/cjs3") >module : { "\"tests/cases/conformance/jsdoc/declarations/cjs3\"": typeof import("tests/cases/conformance/jsdoc/declarations/cjs3"); } >exports : typeof import("tests/cases/conformance/jsdoc/declarations/cjs3") ->ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") ->ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>ns : typeof ns +>ns : typeof ns === tests/cases/conformance/jsdoc/declarations/cjs4.js === const ns = require("./cls"); ->ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") ->require("./cls") : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>ns : typeof ns +>require("./cls") : typeof ns >require : any >"./cls" : "./cls" module.exports.names = ns; ->module.exports.names = ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") ->module.exports.names : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>module.exports.names = ns : typeof ns +>module.exports.names : typeof ns >module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/cjs4") >module : { "\"tests/cases/conformance/jsdoc/declarations/cjs4\"": typeof import("tests/cases/conformance/jsdoc/declarations/cjs4"); } >exports : typeof import("tests/cases/conformance/jsdoc/declarations/cjs4") ->names : typeof import("tests/cases/conformance/jsdoc/declarations/cls") ->ns : typeof import("tests/cases/conformance/jsdoc/declarations/cls") +>names : typeof ns +>ns : typeof ns === tests/cases/conformance/jsdoc/declarations/includeAll.js === import "./cjs4"; diff --git a/tests/baselines/reference/jsDeclarationsExportFormsErr.js b/tests/baselines/reference/jsDeclarationsExportFormsErr.js index 14c94dd65dcce..3146597117146 100644 --- a/tests/baselines/reference/jsDeclarationsExportFormsErr.js +++ b/tests/baselines/reference/jsDeclarationsExportFormsErr.js @@ -67,7 +67,7 @@ export class Foo { } //// [bar.d.ts] export = ns; -import ns = require("./bar"); +import ns = require("./cls"); //// [bin.d.ts] export {}; //// [globalNs.d.ts] diff --git a/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt b/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt index af5809b27023f..c771f9c9d664d 100644 --- a/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt +++ b/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsdoc/declarations/file2.js(12,31): error TS2694: Namespace 'myTypes' has no exported member 'typeC'. +tests/cases/conformance/jsdoc/declarations/file2.js(12,31): error TS2694: Namespace '"tests/cases/conformance/jsdoc/declarations/file".myTypes' has no exported member 'typeC'. ==== tests/cases/conformance/jsdoc/declarations/file2.js (1 errors) ==== @@ -15,7 +15,7 @@ tests/cases/conformance/jsdoc/declarations/file2.js(12,31): error TS2694: Namesp /** @typedef {boolean|myTypes.typeC} testFnTypes.input */ ~~~~~ -!!! error TS2694: Namespace 'myTypes' has no exported member 'typeC'. +!!! error TS2694: Namespace '"tests/cases/conformance/jsdoc/declarations/file".myTypes' has no exported member 'typeC'. /** * @function testFn diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences.js b/tests/baselines/reference/jsDeclarationsTypeReferences.js index 9e6a95d32e190..d302fc8a5ef61 100644 --- a/tests/baselines/reference/jsDeclarationsTypeReferences.js +++ b/tests/baselines/reference/jsDeclarationsTypeReferences.js @@ -13,7 +13,8 @@ const thing = new Something(); module.exports = { thing -}; +}; + //// [index.js] /// @@ -26,4 +27,6 @@ module.exports = { //// [index.d.ts] /// -export const thing: import("fs").Something; +export const thing: Something; +import fs_1 = require("fs"); +import Something = fs_1.Something; diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences.symbols b/tests/baselines/reference/jsDeclarationsTypeReferences.symbols index 258b4d224a807..d0bf2caa029ba 100644 --- a/tests/baselines/reference/jsDeclarationsTypeReferences.symbols +++ b/tests/baselines/reference/jsDeclarationsTypeReferences.symbols @@ -21,6 +21,7 @@ module.exports = { >thing : Symbol(thing, Decl(index.js, 6, 18)) }; + === tests/cases/conformance/jsdoc/declarations/node_modules/@types/node/index.d.ts === declare module "fs" { >"fs" : Symbol("fs", Decl(index.d.ts, 0, 0)) diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences.types b/tests/baselines/reference/jsDeclarationsTypeReferences.types index 59f515e400072..8cadeb608f611 100644 --- a/tests/baselines/reference/jsDeclarationsTypeReferences.types +++ b/tests/baselines/reference/jsDeclarationsTypeReferences.types @@ -2,29 +2,30 @@ /// const Something = require("fs").Something; ->Something : typeof import("fs").Something ->require("fs").Something : typeof import("fs").Something +>Something : typeof Something +>require("fs").Something : typeof Something >require("fs") : typeof import("fs") >require : any >"fs" : "fs" ->Something : typeof import("fs").Something +>Something : typeof Something const thing = new Something(); ->thing : import("fs").Something ->new Something() : import("fs").Something ->Something : typeof import("fs").Something +>thing : Something +>new Something() : Something +>Something : typeof Something module.exports = { ->module.exports = { thing} : { thing: import("fs").Something; } ->module.exports : { thing: import("fs").Something; } ->module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": { thing: import("fs").Something; }; } ->exports : { thing: import("fs").Something; } ->{ thing} : { thing: import("fs").Something; } +>module.exports = { thing} : { thing: Something; } +>module.exports : { thing: Something; } +>module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": { thing: Something; }; } +>exports : { thing: Something; } +>{ thing} : { thing: Something; } thing ->thing : import("fs").Something +>thing : Something }; + === tests/cases/conformance/jsdoc/declarations/node_modules/@types/node/index.d.ts === declare module "fs" { >"fs" : typeof import("fs") diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences2.errors.txt b/tests/baselines/reference/jsDeclarationsTypeReferences2.errors.txt new file mode 100644 index 0000000000000..e16b5cca80bab --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReferences2.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/jsdoc/declarations/index.js(1,8): error TS2305: Module '"./something"' has no exported member 'a'. +tests/cases/conformance/jsdoc/declarations/index.js(1,11): error TS2305: Module '"./something"' has no exported member 'm'. + + +==== tests/cases/conformance/jsdoc/declarations/index.js (2 errors) ==== + const{ a, m } = require("./something").o; + ~ +!!! error TS2305: Module '"./something"' has no exported member 'a'. + ~ +!!! error TS2305: Module '"./something"' has no exported member 'm'. + + const thing = a + m + + module.exports = { + thing + }; + +==== tests/cases/conformance/jsdoc/declarations/something.ts (0 errors) ==== + export const o = { + a: 1, + m: 1 + } + \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences2.js b/tests/baselines/reference/jsDeclarationsTypeReferences2.js new file mode 100644 index 0000000000000..a38563cf374b8 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReferences2.js @@ -0,0 +1,41 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences2.ts] //// + +//// [something.ts] +export const o = { + a: 1, + m: 1 +} + +//// [index.js] +const{ a, m } = require("./something").o; + +const thing = a + m + +module.exports = { + thing +}; + + +//// [something.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.o = void 0; +exports.o = { + a: 1, + m: 1 +}; +//// [index.js] +var _a = require("./something").o, a = _a.a, m = _a.m; +var thing = a + m; +module.exports = { + thing: thing +}; + + +//// [something.d.ts] +export declare const o: { + a: number; + m: number; +}; +//// [index.d.ts] +export const thing: any; diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences2.symbols b/tests/baselines/reference/jsDeclarationsTypeReferences2.symbols new file mode 100644 index 0000000000000..ecab617947465 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReferences2.symbols @@ -0,0 +1,35 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const{ a, m } = require("./something").o; +>a : Symbol(a, Decl(index.js, 0, 6)) +>m : Symbol(m, Decl(index.js, 0, 9)) +>require("./something").o : Symbol(o, Decl(something.ts, 0, 12)) +>require : Symbol(require) +>"./something" : Symbol("tests/cases/conformance/jsdoc/declarations/something", Decl(something.ts, 0, 0)) +>o : Symbol(o, Decl(something.ts, 0, 12)) + +const thing = a + m +>thing : Symbol(thing, Decl(index.js, 2, 5)) +>a : Symbol(a, Decl(index.js, 0, 6)) +>m : Symbol(m, Decl(index.js, 0, 9)) + +module.exports = { +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 2, 19)) +>exports : Symbol(export=, Decl(index.js, 2, 19)) + + thing +>thing : Symbol(thing, Decl(index.js, 4, 18)) + +}; + +=== tests/cases/conformance/jsdoc/declarations/something.ts === +export const o = { +>o : Symbol(o, Decl(something.ts, 0, 12)) + + a: 1, +>a : Symbol(a, Decl(something.ts, 0, 18)) + + m: 1 +>m : Symbol(m, Decl(something.ts, 1, 9)) +} + diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences2.types b/tests/baselines/reference/jsDeclarationsTypeReferences2.types new file mode 100644 index 0000000000000..e57c2b57c6511 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReferences2.types @@ -0,0 +1,42 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const{ a, m } = require("./something").o; +>a : any +>m : any +>require("./something").o : { a: number; m: number; } +>require("./something") : typeof import("tests/cases/conformance/jsdoc/declarations/something") +>require : any +>"./something" : "./something" +>o : { a: number; m: number; } + +const thing = a + m +>thing : any +>a + m : any +>a : any +>m : any + +module.exports = { +>module.exports = { thing} : { thing: any; } +>module.exports : { thing: any; } +>module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": { thing: any; }; } +>exports : { thing: any; } +>{ thing} : { thing: any; } + + thing +>thing : any + +}; + +=== tests/cases/conformance/jsdoc/declarations/something.ts === +export const o = { +>o : { a: number; m: number; } +>{ a: 1, m: 1} : { a: number; m: number; } + + a: 1, +>a : number +>1 : 1 + + m: 1 +>m : number +>1 : 1 +} + diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences3.js b/tests/baselines/reference/jsDeclarationsTypeReferences3.js new file mode 100644 index 0000000000000..e765cc6164325 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReferences3.js @@ -0,0 +1,34 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences3.ts] //// + +//// [index.d.ts] +declare module "fs" { + export class Something {} +} +//// [index.js] +/// + +const Something = require("fs").Something; +module.exports.A = {} +module.exports.A.B = { + thing: new Something() +} + + +//// [index.js] +/// +var Something = require("fs").Something; +module.exports.A = {}; +module.exports.A.B = { + thing: new Something() +}; + + +//// [index.d.ts] +/// +export namespace A { + namespace B { + const thing: Something; + } +} +import fs_1 = require("fs"); +import Something = fs_1.Something; diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences3.symbols b/tests/baselines/reference/jsDeclarationsTypeReferences3.symbols new file mode 100644 index 0000000000000..018debbe2277f --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReferences3.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +/// + +const Something = require("fs").Something; +>Something : Symbol(Something, Decl(index.js, 2, 5)) +>require("fs").Something : Symbol(Something, Decl(index.d.ts, 0, 21)) +>require : Symbol(require) +>"fs" : Symbol("fs", Decl(index.d.ts, 0, 0)) +>Something : Symbol(Something, Decl(index.d.ts, 0, 21)) + +module.exports.A = {} +>module.exports.A : Symbol(A, Decl(index.js, 2, 42), Decl(index.js, 4, 15)) +>module.exports : Symbol(A, Decl(index.js, 2, 42), Decl(index.js, 4, 15)) +>module : Symbol(module, Decl(index.js, 2, 42)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>A : Symbol(A, Decl(index.js, 2, 42), Decl(index.js, 4, 15)) + +module.exports.A.B = { +>module.exports.A.B : Symbol(A.B, Decl(index.js, 3, 21)) +>module.exports.A : Symbol(A.B, Decl(index.js, 3, 21)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(module, Decl(index.js, 2, 42)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>A : Symbol(A, Decl(index.js, 2, 42), Decl(index.js, 4, 15)) +>B : Symbol(A.B, Decl(index.js, 3, 21)) + + thing: new Something() +>thing : Symbol(thing, Decl(index.js, 4, 22)) +>Something : Symbol(Something, Decl(index.js, 2, 5)) +} + +=== tests/cases/conformance/jsdoc/declarations/node_modules/@types/node/index.d.ts === +declare module "fs" { +>"fs" : Symbol("fs", Decl(index.d.ts, 0, 0)) + + export class Something {} +>Something : Symbol(Something, Decl(index.d.ts, 0, 21)) +} diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences3.types b/tests/baselines/reference/jsDeclarationsTypeReferences3.types new file mode 100644 index 0000000000000..bb41517417b59 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReferences3.types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +/// + +const Something = require("fs").Something; +>Something : typeof Something +>require("fs").Something : typeof Something +>require("fs") : typeof import("fs") +>require : any +>"fs" : "fs" +>Something : typeof Something + +module.exports.A = {} +>module.exports.A = {} : typeof A +>module.exports.A : typeof A +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>A : typeof A +>{} : {} + +module.exports.A.B = { +>module.exports.A.B = { thing: new Something()} : { thing: Something; } +>module.exports.A.B : { thing: Something; } +>module.exports.A : typeof A +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") +>A : typeof A +>B : { thing: Something; } +>{ thing: new Something()} : { thing: Something; } + + thing: new Something() +>thing : Something +>new Something() : Something +>Something : typeof Something +} + +=== tests/cases/conformance/jsdoc/declarations/node_modules/@types/node/index.d.ts === +declare module "fs" { +>"fs" : typeof import("fs") + + export class Something {} +>Something : Something +} diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences4.errors.txt b/tests/baselines/reference/jsDeclarationsTypeReferences4.errors.txt new file mode 100644 index 0000000000000..1d04247967531 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReferences4.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/jsdoc/declarations/index.js(4,18): error TS8006: 'namespace' declarations can only be used in TypeScript files. + + +==== tests/cases/conformance/jsdoc/declarations/index.js (1 errors) ==== + /// + export const Something = 2; // to show conflict that can occur + // @ts-ignore + export namespace A { + ~ +!!! error TS8006: 'namespace' declarations can only be used in TypeScript files. + // @ts-ignore + export namespace B { + const Something = require("fs").Something; + const thing = new Something(); + // @ts-ignore + export { thing }; + } + } + +==== tests/cases/conformance/jsdoc/declarations/node_modules/@types/node/index.d.ts (0 errors) ==== + declare module "fs" { + export class Something {} + } \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences4.js b/tests/baselines/reference/jsDeclarationsTypeReferences4.js new file mode 100644 index 0000000000000..063aca33d76f0 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReferences4.js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences4.ts] //// + +//// [index.d.ts] +declare module "fs" { + export class Something {} +} +//// [index.js] +/// +export const Something = 2; // to show conflict that can occur +// @ts-ignore +export namespace A { + // @ts-ignore + export namespace B { + const Something = require("fs").Something; + const thing = new Something(); + // @ts-ignore + export { thing }; + } +} + + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.A = exports.Something = void 0; +/// +exports.Something = 2; // to show conflict that can occur +// @ts-ignore +var A; +(function (A) { + // @ts-ignore + var B; + (function (B) { + var Something = require("fs").Something; + var thing = new Something(); + })(B = A.B || (A.B = {})); +})(A = exports.A || (exports.A = {})); + + +//// [index.d.ts] +/// +export const Something: 2; +export namespace A { + namespace B { + export { thing }; + export const thing: import("fs").Something; + } +} diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences4.symbols b/tests/baselines/reference/jsDeclarationsTypeReferences4.symbols new file mode 100644 index 0000000000000..0f30ae0d30f8b --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReferences4.symbols @@ -0,0 +1,37 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +/// +export const Something = 2; // to show conflict that can occur +>Something : Symbol(Something, Decl(index.js, 1, 12)) + +// @ts-ignore +export namespace A { +>A : Symbol(A, Decl(index.js, 1, 27)) + + // @ts-ignore + export namespace B { +>B : Symbol(B, Decl(index.js, 3, 20)) + + const Something = require("fs").Something; +>Something : Symbol(Something, Decl(index.js, 6, 13)) +>require("fs").Something : Symbol(Something, Decl(index.d.ts, 0, 21)) +>require : Symbol(require) +>"fs" : Symbol("fs", Decl(index.d.ts, 0, 0)) +>Something : Symbol(Something, Decl(index.d.ts, 0, 21)) + + const thing = new Something(); +>thing : Symbol(thing, Decl(index.js, 7, 13)) +>Something : Symbol(Something, Decl(index.js, 6, 13)) + + // @ts-ignore + export { thing }; +>thing : Symbol(thing, Decl(index.js, 9, 16)) + } +} + +=== tests/cases/conformance/jsdoc/declarations/node_modules/@types/node/index.d.ts === +declare module "fs" { +>"fs" : Symbol("fs", Decl(index.d.ts, 0, 0)) + + export class Something {} +>Something : Symbol(Something, Decl(index.d.ts, 0, 21)) +} diff --git a/tests/baselines/reference/jsDeclarationsTypeReferences4.types b/tests/baselines/reference/jsDeclarationsTypeReferences4.types new file mode 100644 index 0000000000000..33de92f8e60a4 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsTypeReferences4.types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +/// +export const Something = 2; // to show conflict that can occur +>Something : 2 +>2 : 2 + +// @ts-ignore +export namespace A { +>A : typeof A + + // @ts-ignore + export namespace B { +>B : typeof B + + const Something = require("fs").Something; +>Something : typeof Something +>require("fs").Something : typeof Something +>require("fs") : typeof import("fs") +>require : any +>"fs" : "fs" +>Something : typeof Something + + const thing = new Something(); +>thing : Something +>new Something() : Something +>Something : typeof Something + + // @ts-ignore + export { thing }; +>thing : Something + } +} + +=== tests/cases/conformance/jsdoc/declarations/node_modules/@types/node/index.d.ts === +declare module "fs" { +>"fs" : typeof import("fs") + + export class Something {} +>Something : Something +} diff --git a/tests/baselines/reference/jsdocImportType.symbols b/tests/baselines/reference/jsdocImportType.symbols index dbe46e966e315..aeb548cd84fea 100644 --- a/tests/baselines/reference/jsdocImportType.symbols +++ b/tests/baselines/reference/jsdocImportType.symbols @@ -6,9 +6,9 @@ var c; >c : Symbol(c, Decl(use.js, 3, 3)) c.chunk; ->c.chunk : Symbol(Chunk.chunk, Decl(mod1.js, 2, 19)) +>c.chunk : Symbol(D.chunk, Decl(mod1.js, 2, 19)) >c : Symbol(c, Decl(use.js, 3, 3)) ->chunk : Symbol(Chunk.chunk, Decl(mod1.js, 2, 19)) +>chunk : Symbol(D.chunk, Decl(mod1.js, 2, 19)) const D = require("./mod1"); >D : Symbol(D, Decl(use.js, 6, 5)) @@ -20,9 +20,9 @@ var d; >d : Symbol(d, Decl(use.js, 8, 3)) d.chunk; ->d.chunk : Symbol(Chunk.chunk, Decl(mod1.js, 2, 19)) +>d.chunk : Symbol(D.chunk, Decl(mod1.js, 2, 19)) >d : Symbol(d, Decl(use.js, 8, 3)) ->chunk : Symbol(Chunk.chunk, Decl(mod1.js, 2, 19)) +>chunk : Symbol(D.chunk, Decl(mod1.js, 2, 19)) === tests/cases/conformance/jsdoc/types.d.ts === declare function require(name: string): any; diff --git a/tests/baselines/reference/jsdocImportType.types b/tests/baselines/reference/jsdocImportType.types index b1d7542475079..b5703459955c3 100644 --- a/tests/baselines/reference/jsdocImportType.types +++ b/tests/baselines/reference/jsdocImportType.types @@ -3,26 +3,26 @@ /** @typedef {import("./mod1")} C * @type {C} */ var c; ->c : import("tests/cases/conformance/jsdoc/mod1") +>c : D c.chunk; >c.chunk : number ->c : import("tests/cases/conformance/jsdoc/mod1") +>c : D >chunk : number const D = require("./mod1"); ->D : typeof import("tests/cases/conformance/jsdoc/mod1") ->require("./mod1") : typeof import("tests/cases/conformance/jsdoc/mod1") +>D : typeof D +>require("./mod1") : typeof D >require : (name: string) => any >"./mod1" : "./mod1" /** @type {D} */ var d; ->d : import("tests/cases/conformance/jsdoc/mod1") +>d : D d.chunk; >d.chunk : number ->d : import("tests/cases/conformance/jsdoc/mod1") +>d : D >chunk : number === tests/cases/conformance/jsdoc/types.d.ts === diff --git a/tests/baselines/reference/jsdocImportType2.symbols b/tests/baselines/reference/jsdocImportType2.symbols index a7ed5cc3d41c5..cecfd006ea89c 100644 --- a/tests/baselines/reference/jsdocImportType2.symbols +++ b/tests/baselines/reference/jsdocImportType2.symbols @@ -6,9 +6,9 @@ var c; >c : Symbol(c, Decl(use.js, 3, 3)) c.chunk; ->c.chunk : Symbol(Chunk.chunk, Decl(mod1.js, 2, 19)) +>c.chunk : Symbol(D.chunk, Decl(mod1.js, 2, 19)) >c : Symbol(c, Decl(use.js, 3, 3)) ->chunk : Symbol(Chunk.chunk, Decl(mod1.js, 2, 19)) +>chunk : Symbol(D.chunk, Decl(mod1.js, 2, 19)) const D = require("./mod1"); >D : Symbol(D, Decl(use.js, 6, 5)) @@ -20,9 +20,9 @@ var d; >d : Symbol(d, Decl(use.js, 8, 3)) d.chunk; ->d.chunk : Symbol(Chunk.chunk, Decl(mod1.js, 2, 19)) +>d.chunk : Symbol(D.chunk, Decl(mod1.js, 2, 19)) >d : Symbol(d, Decl(use.js, 8, 3)) ->chunk : Symbol(Chunk.chunk, Decl(mod1.js, 2, 19)) +>chunk : Symbol(D.chunk, Decl(mod1.js, 2, 19)) === tests/cases/conformance/jsdoc/types.d.ts === declare function require(name: string): any; diff --git a/tests/baselines/reference/jsdocImportType2.types b/tests/baselines/reference/jsdocImportType2.types index f4386faf5a695..b966871b9eff3 100644 --- a/tests/baselines/reference/jsdocImportType2.types +++ b/tests/baselines/reference/jsdocImportType2.types @@ -3,26 +3,26 @@ /** @typedef {import("./mod1")} C * @type {C} */ var c; ->c : import("tests/cases/conformance/jsdoc/mod1") +>c : D c.chunk; >c.chunk : number ->c : import("tests/cases/conformance/jsdoc/mod1") +>c : D >chunk : number const D = require("./mod1"); ->D : typeof import("tests/cases/conformance/jsdoc/mod1") ->require("./mod1") : typeof import("tests/cases/conformance/jsdoc/mod1") +>D : typeof D +>require("./mod1") : typeof D >require : (name: string) => any >"./mod1" : "./mod1" /** @type {D} */ var d; ->d : import("tests/cases/conformance/jsdoc/mod1") +>d : D d.chunk; >d.chunk : number ->d : import("tests/cases/conformance/jsdoc/mod1") +>d : D >chunk : number === tests/cases/conformance/jsdoc/types.d.ts === diff --git a/tests/baselines/reference/jsdocTypeFromChainedAssignment2.symbols b/tests/baselines/reference/jsdocTypeFromChainedAssignment2.symbols index ae7236a015641..646159ed41957 100644 --- a/tests/baselines/reference/jsdocTypeFromChainedAssignment2.symbols +++ b/tests/baselines/reference/jsdocTypeFromChainedAssignment2.symbols @@ -2,27 +2,27 @@ var mod = require('./mod'); >mod : Symbol(mod, Decl(use.js, 0, 3)) >require : Symbol(require) ->'./mod' : Symbol("tests/cases/conformance/jsdoc/mod", Decl(mod.js, 0, 0)) +>'./mod' : Symbol(mod, Decl(mod.js, 0, 0)) mod.f('no') ->mod.f : Symbol(f, Decl(mod.js, 0, 0)) +>mod.f : Symbol(mod.f, Decl(mod.js, 0, 0)) >mod : Symbol(mod, Decl(use.js, 0, 3)) ->f : Symbol(f, Decl(mod.js, 0, 0)) +>f : Symbol(mod.f, Decl(mod.js, 0, 0)) mod.g('also no') ->mod.g : Symbol(g, Decl(mod.js, 1, 11)) +>mod.g : Symbol(mod.g, Decl(mod.js, 1, 11)) >mod : Symbol(mod, Decl(use.js, 0, 3)) ->g : Symbol(g, Decl(mod.js, 1, 11)) +>g : Symbol(mod.g, Decl(mod.js, 1, 11)) mod.h(0) ->mod.h : Symbol(h, Decl(mod.js, 3, 1)) +>mod.h : Symbol(mod.h, Decl(mod.js, 3, 1)) >mod : Symbol(mod, Decl(use.js, 0, 3)) ->h : Symbol(h, Decl(mod.js, 3, 1)) +>h : Symbol(mod.h, Decl(mod.js, 3, 1)) mod.i(1) ->mod.i : Symbol(i, Decl(mod.js, 5, 18)) +>mod.i : Symbol(mod.i, Decl(mod.js, 5, 18)) >mod : Symbol(mod, Decl(use.js, 0, 3)) ->i : Symbol(i, Decl(mod.js, 5, 18)) +>i : Symbol(mod.i, Decl(mod.js, 5, 18)) === tests/cases/conformance/jsdoc/mod.js === /** @param {number} n */ diff --git a/tests/baselines/reference/jsdocTypeFromChainedAssignment2.types b/tests/baselines/reference/jsdocTypeFromChainedAssignment2.types index 75e198978f4d4..7bbcb5becabcb 100644 --- a/tests/baselines/reference/jsdocTypeFromChainedAssignment2.types +++ b/tests/baselines/reference/jsdocTypeFromChainedAssignment2.types @@ -1,35 +1,35 @@ === tests/cases/conformance/jsdoc/use.js === var mod = require('./mod'); ->mod : typeof import("tests/cases/conformance/jsdoc/mod") ->require('./mod') : typeof import("tests/cases/conformance/jsdoc/mod") +>mod : typeof mod +>require('./mod') : typeof mod >require : any >'./mod' : "./mod" mod.f('no') >mod.f('no') : number >mod.f : (n: number) => number ->mod : typeof import("tests/cases/conformance/jsdoc/mod") +>mod : typeof mod >f : (n: number) => number >'no' : "no" mod.g('also no') >mod.g('also no') : number >mod.g : (n: number) => number ->mod : typeof import("tests/cases/conformance/jsdoc/mod") +>mod : typeof mod >g : (n: number) => number >'also no' : "also no" mod.h(0) >mod.h(0) : string >mod.h : (mom: string) => string ->mod : typeof import("tests/cases/conformance/jsdoc/mod") +>mod : typeof mod >h : (mom: string) => string >0 : 0 mod.i(1) >mod.i(1) : string >mod.i : (mom: string) => string ->mod : typeof import("tests/cases/conformance/jsdoc/mod") +>mod : typeof mod >i : (mom: string) => string >1 : 1 diff --git a/tests/baselines/reference/jsdocTypeReferenceToImport.types b/tests/baselines/reference/jsdocTypeReferenceToImport.types index 4d4fe89ae02a5..7002b8d5bdc03 100644 --- a/tests/baselines/reference/jsdocTypeReferenceToImport.types +++ b/tests/baselines/reference/jsdocTypeReferenceToImport.types @@ -2,51 +2,51 @@ // #34802 const C = require('./ex').C; ->C : typeof import("tests/cases/conformance/jsdoc/ex").C ->require('./ex').C : typeof import("tests/cases/conformance/jsdoc/ex").C +>C : typeof C +>require('./ex').C : typeof C >require('./ex') : typeof import("tests/cases/conformance/jsdoc/ex") >require : any >'./ex' : "./ex" ->C : typeof import("tests/cases/conformance/jsdoc/ex").C +>C : typeof C const D = require('./ex')?.C; ->D : typeof import("tests/cases/conformance/jsdoc/ex").C ->require('./ex')?.C : typeof import("tests/cases/conformance/jsdoc/ex").C +>D : typeof C +>require('./ex')?.C : typeof C >require('./ex') : typeof import("tests/cases/conformance/jsdoc/ex") >require : any >'./ex' : "./ex" ->C : typeof import("tests/cases/conformance/jsdoc/ex").C +>C : typeof C /** @type {C} c */ var c = new C() ->c : import("tests/cases/conformance/jsdoc/ex").C ->new C() : import("tests/cases/conformance/jsdoc/ex").C ->C : typeof import("tests/cases/conformance/jsdoc/ex").C +>c : C +>new C() : C +>C : typeof C c.start >c.start : number ->c : import("tests/cases/conformance/jsdoc/ex").C +>c : C >start : number c.end >c.end : number ->c : import("tests/cases/conformance/jsdoc/ex").C +>c : C >end : number /** @type {D} c */ var d = new D() ->d : import("tests/cases/conformance/jsdoc/ex").C ->new D() : import("tests/cases/conformance/jsdoc/ex").C ->D : typeof import("tests/cases/conformance/jsdoc/ex").C +>d : C +>new D() : C +>D : typeof C d.start >d.start : number ->d : import("tests/cases/conformance/jsdoc/ex").C +>d : C >start : number d.end >d.end : number ->d : import("tests/cases/conformance/jsdoc/ex").C +>d : C >end : number === tests/cases/conformance/jsdoc/ex.d.ts === diff --git a/tests/baselines/reference/jsdocTypeReferenceToImportOfClassExpression.types b/tests/baselines/reference/jsdocTypeReferenceToImportOfClassExpression.types index 0645f6adfda1f..144cd81db37f2 100644 --- a/tests/baselines/reference/jsdocTypeReferenceToImportOfClassExpression.types +++ b/tests/baselines/reference/jsdocTypeReferenceToImportOfClassExpression.types @@ -1,7 +1,7 @@ === tests/cases/conformance/jsdoc/MC.js === const MW = require("./MW"); ->MW : typeof import("tests/cases/conformance/jsdoc/MW") ->require("./MW") : typeof import("tests/cases/conformance/jsdoc/MW") +>MW : typeof MW +>require("./MW") : typeof MW >require : any >"./MW" : "./MW" @@ -16,11 +16,11 @@ module.exports = class MC { >MC : typeof import("tests/cases/conformance/jsdoc/MC") watch() { ->watch : () => import("tests/cases/conformance/jsdoc/MW") +>watch : () => MW return new MW(this); ->new MW(this) : import("tests/cases/conformance/jsdoc/MW") ->MW : typeof import("tests/cases/conformance/jsdoc/MW") +>new MW(this) : MW +>MW : typeof MW >this : this } }; diff --git a/tests/baselines/reference/jsdocTypeReferenceToImportOfFunctionExpression.types b/tests/baselines/reference/jsdocTypeReferenceToImportOfFunctionExpression.types index 81422f0c76c9d..a6956b2bb558a 100644 --- a/tests/baselines/reference/jsdocTypeReferenceToImportOfFunctionExpression.types +++ b/tests/baselines/reference/jsdocTypeReferenceToImportOfFunctionExpression.types @@ -1,7 +1,7 @@ === tests/cases/conformance/jsdoc/MC.js === const MW = require("./MW"); ->MW : typeof import("tests/cases/conformance/jsdoc/MW") ->require("./MW") : typeof import("tests/cases/conformance/jsdoc/MW") +>MW : typeof MW +>require("./MW") : typeof MW >require : any >"./MW" : "./MW" @@ -22,8 +22,8 @@ module.exports = function MC() { >{} : {} return new MW(x); ->new MW(x) : import("tests/cases/conformance/jsdoc/MW") ->MW : typeof import("tests/cases/conformance/jsdoc/MW") +>new MW(x) : MW +>MW : typeof MW >x : any }; diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport1.symbols b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport1.symbols index ee7bd17cb08df..c290fc349bb09 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport1.symbols +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport1.symbols @@ -2,7 +2,7 @@ const x = require("./lateBoundAssignmentDeclarationSupport1.js"); >x : Symbol(x, Decl(usage.js, 0, 5)) >require : Symbol(require) ->"./lateBoundAssignmentDeclarationSupport1.js" : Symbol("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport1", Decl(lateBoundAssignmentDeclarationSupport1.js, 0, 0)) +>"./lateBoundAssignmentDeclarationSupport1.js" : Symbol(x, Decl(lateBoundAssignmentDeclarationSupport1.js, 0, 0)) const y = x["my-fake-sym"]; >y : Symbol(y, Decl(usage.js, 1, 5)) @@ -11,9 +11,9 @@ const y = x["my-fake-sym"]; const z = x[x.S]; >z : Symbol(z, Decl(usage.js, 2, 5)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->x.S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport1.js, 5, 21)) +>x.S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport1.js, 5, 21)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport1.js, 5, 21)) +>S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport1.js, 5, 21)) === tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport1.js === // currently unsupported diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport1.types b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport1.types index e81eca01ae515..8b31cce2543f7 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport1.types +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport1.types @@ -1,22 +1,22 @@ === tests/cases/conformance/salsa/usage.js === const x = require("./lateBoundAssignmentDeclarationSupport1.js"); ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport1") ->require("./lateBoundAssignmentDeclarationSupport1.js") : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport1") +>x : typeof x +>require("./lateBoundAssignmentDeclarationSupport1.js") : typeof x >require : any >"./lateBoundAssignmentDeclarationSupport1.js" : "./lateBoundAssignmentDeclarationSupport1.js" const y = x["my-fake-sym"]; >y : any >x["my-fake-sym"] : any ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport1") +>x : typeof x >"my-fake-sym" : "my-fake-sym" const z = x[x.S]; >z : any >x[x.S] : any ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport1") +>x : typeof x >x.S : unique symbol ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport1") +>x : typeof x >S : unique symbol === tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport1.js === diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport2.symbols b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport2.symbols index 54b247eb10822..5c252fe3db692 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport2.symbols +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport2.symbols @@ -2,7 +2,7 @@ const x = require("./lateBoundAssignmentDeclarationSupport2.js"); >x : Symbol(x, Decl(usage.js, 0, 5)) >require : Symbol(require) ->"./lateBoundAssignmentDeclarationSupport2.js" : Symbol("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport2", Decl(lateBoundAssignmentDeclarationSupport2.js, 0, 0)) +>"./lateBoundAssignmentDeclarationSupport2.js" : Symbol(x, Decl(lateBoundAssignmentDeclarationSupport2.js, 0, 0)) const y = x["my-fake-sym"]; >y : Symbol(y, Decl(usage.js, 1, 5)) @@ -11,9 +11,9 @@ const y = x["my-fake-sym"]; const z = x[x.S]; >z : Symbol(z, Decl(usage.js, 2, 5)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->x.S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport2.js, 5, 28)) +>x.S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport2.js, 5, 28)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport2.js, 5, 28)) +>S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport2.js, 5, 28)) === tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport2.js === // currently unsupported diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport2.types b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport2.types index 1c0090329d92c..818a0ab212ed8 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport2.types +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport2.types @@ -1,22 +1,22 @@ === tests/cases/conformance/salsa/usage.js === const x = require("./lateBoundAssignmentDeclarationSupport2.js"); ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport2") ->require("./lateBoundAssignmentDeclarationSupport2.js") : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport2") +>x : typeof x +>require("./lateBoundAssignmentDeclarationSupport2.js") : typeof x >require : any >"./lateBoundAssignmentDeclarationSupport2.js" : "./lateBoundAssignmentDeclarationSupport2.js" const y = x["my-fake-sym"]; >y : any >x["my-fake-sym"] : any ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport2") +>x : typeof x >"my-fake-sym" : "my-fake-sym" const z = x[x.S]; >z : any >x[x.S] : any ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport2") +>x : typeof x >x.S : unique symbol ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport2") +>x : typeof x >S : unique symbol === tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport2.js === diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport3.symbols b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport3.symbols index 412faa1164a22..3a9c558d36042 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport3.symbols +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport3.symbols @@ -2,7 +2,7 @@ const x = require("./lateBoundAssignmentDeclarationSupport3.js"); >x : Symbol(x, Decl(usage.js, 0, 5)) >require : Symbol(require) ->"./lateBoundAssignmentDeclarationSupport3.js" : Symbol("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport3", Decl(lateBoundAssignmentDeclarationSupport3.js, 0, 0)) +>"./lateBoundAssignmentDeclarationSupport3.js" : Symbol(x, Decl(lateBoundAssignmentDeclarationSupport3.js, 0, 0)) const y = x["my-fake-sym"]; >y : Symbol(y, Decl(usage.js, 1, 5)) @@ -11,9 +11,9 @@ const y = x["my-fake-sym"]; const z = x[x.S]; >z : Symbol(z, Decl(usage.js, 2, 5)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->x.S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport3.js, 5, 61)) +>x.S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport3.js, 5, 61)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport3.js, 5, 61)) +>S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport3.js, 5, 61)) === tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport3.js === // currently unsupported diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport3.types b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport3.types index 5811c9a4c33c5..511f2e6153e9f 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport3.types +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport3.types @@ -1,22 +1,22 @@ === tests/cases/conformance/salsa/usage.js === const x = require("./lateBoundAssignmentDeclarationSupport3.js"); ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport3") ->require("./lateBoundAssignmentDeclarationSupport3.js") : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport3") +>x : typeof x +>require("./lateBoundAssignmentDeclarationSupport3.js") : typeof x >require : any >"./lateBoundAssignmentDeclarationSupport3.js" : "./lateBoundAssignmentDeclarationSupport3.js" const y = x["my-fake-sym"]; >y : any >x["my-fake-sym"] : any ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport3") +>x : typeof x >"my-fake-sym" : "my-fake-sym" const z = x[x.S]; >z : any >x[x.S] : any ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport3") +>x : typeof x >x.S : unique symbol ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport3") +>x : typeof x >S : unique symbol === tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport3.js === diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport4.symbols b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport4.symbols index a6c3f2cacfbc1..fd52892f5a509 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport4.symbols +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport4.symbols @@ -2,13 +2,13 @@ const x = require("./lateBoundAssignmentDeclarationSupport4.js"); >x : Symbol(x, Decl(usage.js, 0, 5)) >require : Symbol(require) ->"./lateBoundAssignmentDeclarationSupport4.js" : Symbol("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport4", Decl(lateBoundAssignmentDeclarationSupport4.js, 0, 0)) +>"./lateBoundAssignmentDeclarationSupport4.js" : Symbol(x, Decl(lateBoundAssignmentDeclarationSupport4.js, 0, 0)) const inst = new x.F(); >inst : Symbol(inst, Decl(usage.js, 1, 5)) ->x.F : Symbol(F, Decl(lateBoundAssignmentDeclarationSupport4.js, 10, 22)) +>x.F : Symbol(x.F, Decl(lateBoundAssignmentDeclarationSupport4.js, 10, 22)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->F : Symbol(F, Decl(lateBoundAssignmentDeclarationSupport4.js, 10, 22)) +>F : Symbol(x.F, Decl(lateBoundAssignmentDeclarationSupport4.js, 10, 22)) const y = inst["my-fake-sym"]; >y : Symbol(y, Decl(usage.js, 2, 5)) @@ -17,9 +17,9 @@ const y = inst["my-fake-sym"]; const z = inst[x.S]; >z : Symbol(z, Decl(usage.js, 3, 5)) >inst : Symbol(inst, Decl(usage.js, 1, 5)) ->x.S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport4.js, 11, 21)) +>x.S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport4.js, 11, 21)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport4.js, 11, 21)) +>S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport4.js, 11, 21)) === tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport4.js === // currently unsupported diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport4.types b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport4.types index 5d5d8bd4bef41..0c8199d0fcbab 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport4.types +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport4.types @@ -1,7 +1,7 @@ === tests/cases/conformance/salsa/usage.js === const x = require("./lateBoundAssignmentDeclarationSupport4.js"); ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport4") ->require("./lateBoundAssignmentDeclarationSupport4.js") : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport4") +>x : typeof x +>require("./lateBoundAssignmentDeclarationSupport4.js") : typeof x >require : any >"./lateBoundAssignmentDeclarationSupport4.js" : "./lateBoundAssignmentDeclarationSupport4.js" @@ -9,7 +9,7 @@ const inst = new x.F(); >inst : F >new x.F() : F >x.F : typeof F ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport4") +>x : typeof x >F : typeof F const y = inst["my-fake-sym"]; @@ -23,7 +23,7 @@ const z = inst[x.S]; >inst[x.S] : any >inst : F >x.S : unique symbol ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport4") +>x : typeof x >S : unique symbol === tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport4.js === diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport5.symbols b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport5.symbols index 3d4cde8385d6b..90a1f464648ca 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport5.symbols +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport5.symbols @@ -2,13 +2,13 @@ const x = require("./lateBoundAssignmentDeclarationSupport5.js"); >x : Symbol(x, Decl(usage.js, 0, 5)) >require : Symbol(require) ->"./lateBoundAssignmentDeclarationSupport5.js" : Symbol("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport5", Decl(lateBoundAssignmentDeclarationSupport5.js, 0, 0)) +>"./lateBoundAssignmentDeclarationSupport5.js" : Symbol(x, Decl(lateBoundAssignmentDeclarationSupport5.js, 0, 0)) const inst = new x.F(); >inst : Symbol(inst, Decl(usage.js, 1, 5)) ->x.F : Symbol(F, Decl(lateBoundAssignmentDeclarationSupport5.js, 12, 22)) +>x.F : Symbol(x.F, Decl(lateBoundAssignmentDeclarationSupport5.js, 12, 22)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->F : Symbol(F, Decl(lateBoundAssignmentDeclarationSupport5.js, 12, 22)) +>F : Symbol(x.F, Decl(lateBoundAssignmentDeclarationSupport5.js, 12, 22)) const y = inst["my-fake-sym"]; >y : Symbol(y, Decl(usage.js, 2, 5)) @@ -17,9 +17,9 @@ const y = inst["my-fake-sym"]; const z = inst[x.S]; >z : Symbol(z, Decl(usage.js, 3, 5)) >inst : Symbol(inst, Decl(usage.js, 1, 5)) ->x.S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport5.js, 13, 21)) +>x.S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport5.js, 13, 21)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport5.js, 13, 21)) +>S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport5.js, 13, 21)) === tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport5.js === // currently unsupported diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport5.types b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport5.types index 5c73c112a78a1..d5b65354374ca 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport5.types +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport5.types @@ -1,7 +1,7 @@ === tests/cases/conformance/salsa/usage.js === const x = require("./lateBoundAssignmentDeclarationSupport5.js"); ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport5") ->require("./lateBoundAssignmentDeclarationSupport5.js") : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport5") +>x : typeof x +>require("./lateBoundAssignmentDeclarationSupport5.js") : typeof x >require : any >"./lateBoundAssignmentDeclarationSupport5.js" : "./lateBoundAssignmentDeclarationSupport5.js" @@ -9,7 +9,7 @@ const inst = new x.F(); >inst : F >new x.F() : F >x.F : typeof F ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport5") +>x : typeof x >F : typeof F const y = inst["my-fake-sym"]; @@ -23,7 +23,7 @@ const z = inst[x.S]; >inst[x.S] : any >inst : F >x.S : unique symbol ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport5") +>x : typeof x >S : unique symbol === tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport5.js === diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport6.symbols b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport6.symbols index a77cac27638bf..f4feb41d11d40 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport6.symbols +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport6.symbols @@ -2,13 +2,13 @@ const x = require("./lateBoundAssignmentDeclarationSupport6.js"); >x : Symbol(x, Decl(usage.js, 0, 5)) >require : Symbol(require) ->"./lateBoundAssignmentDeclarationSupport6.js" : Symbol("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport6", Decl(lateBoundAssignmentDeclarationSupport6.js, 0, 0)) +>"./lateBoundAssignmentDeclarationSupport6.js" : Symbol(x, Decl(lateBoundAssignmentDeclarationSupport6.js, 0, 0)) const inst = new x.F(); >inst : Symbol(inst, Decl(usage.js, 1, 5)) ->x.F : Symbol(F, Decl(lateBoundAssignmentDeclarationSupport6.js, 11, 22)) +>x.F : Symbol(x.F, Decl(lateBoundAssignmentDeclarationSupport6.js, 11, 22)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->F : Symbol(F, Decl(lateBoundAssignmentDeclarationSupport6.js, 11, 22)) +>F : Symbol(x.F, Decl(lateBoundAssignmentDeclarationSupport6.js, 11, 22)) const y = inst["my-fake-sym"]; >y : Symbol(y, Decl(usage.js, 2, 5)) @@ -17,9 +17,9 @@ const y = inst["my-fake-sym"]; const z = inst[x.S]; >z : Symbol(z, Decl(usage.js, 3, 5)) >inst : Symbol(inst, Decl(usage.js, 1, 5)) ->x.S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport6.js, 12, 21)) +>x.S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport6.js, 12, 21)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport6.js, 12, 21)) +>S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport6.js, 12, 21)) === tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport6.js === // currently unsupported diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport6.types b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport6.types index 4aa5319115454..54d6ca94a9e1b 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport6.types +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport6.types @@ -1,7 +1,7 @@ === tests/cases/conformance/salsa/usage.js === const x = require("./lateBoundAssignmentDeclarationSupport6.js"); ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport6") ->require("./lateBoundAssignmentDeclarationSupport6.js") : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport6") +>x : typeof x +>require("./lateBoundAssignmentDeclarationSupport6.js") : typeof x >require : any >"./lateBoundAssignmentDeclarationSupport6.js" : "./lateBoundAssignmentDeclarationSupport6.js" @@ -9,7 +9,7 @@ const inst = new x.F(); >inst : F >new x.F() : F >x.F : typeof F ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport6") +>x : typeof x >F : typeof F const y = inst["my-fake-sym"]; @@ -23,7 +23,7 @@ const z = inst[x.S]; >inst[x.S] : any >inst : F >x.S : unique symbol ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport6") +>x : typeof x >S : unique symbol === tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport6.js === diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.symbols b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.symbols index e0014532ecbec..434f00ed278fe 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.symbols +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.symbols @@ -2,23 +2,23 @@ const x = require("./lateBoundAssignmentDeclarationSupport7.js"); >x : Symbol(x, Decl(usage.js, 0, 5)) >require : Symbol(require) ->"./lateBoundAssignmentDeclarationSupport7.js" : Symbol("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport7", Decl(lateBoundAssignmentDeclarationSupport7.js, 0, 0)) +>"./lateBoundAssignmentDeclarationSupport7.js" : Symbol(x, Decl(lateBoundAssignmentDeclarationSupport7.js, 0, 0)) const y = x.F["my-fake-sym"]; >y : Symbol(y, Decl(usage.js, 1, 5)) ->x.F : Symbol(F, Decl(lateBoundAssignmentDeclarationSupport7.js, 6, 15)) +>x.F : Symbol(x.F, Decl(lateBoundAssignmentDeclarationSupport7.js, 6, 15)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->F : Symbol(F, Decl(lateBoundAssignmentDeclarationSupport7.js, 6, 15)) +>F : Symbol(x.F, Decl(lateBoundAssignmentDeclarationSupport7.js, 6, 15)) >"my-fake-sym" : Symbol(F.F[_str], Decl(lateBoundAssignmentDeclarationSupport7.js, 5, 15)) const z = x.F[x.S]; >z : Symbol(z, Decl(usage.js, 2, 5)) ->x.F : Symbol(F, Decl(lateBoundAssignmentDeclarationSupport7.js, 6, 15)) +>x.F : Symbol(x.F, Decl(lateBoundAssignmentDeclarationSupport7.js, 6, 15)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->F : Symbol(F, Decl(lateBoundAssignmentDeclarationSupport7.js, 6, 15)) ->x.S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport7.js, 7, 21)) +>F : Symbol(x.F, Decl(lateBoundAssignmentDeclarationSupport7.js, 6, 15)) +>x.S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport7.js, 7, 21)) >x : Symbol(x, Decl(usage.js, 0, 5)) ->S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport7.js, 7, 21)) +>S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport7.js, 7, 21)) === tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport7.js === const _sym = Symbol(); diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.types b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.types index 84c3829369131..d0d472cb20ad4 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.types +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.types @@ -1,7 +1,7 @@ === tests/cases/conformance/salsa/usage.js === const x = require("./lateBoundAssignmentDeclarationSupport7.js"); ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport7") ->require("./lateBoundAssignmentDeclarationSupport7.js") : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport7") +>x : typeof x +>require("./lateBoundAssignmentDeclarationSupport7.js") : typeof x >require : any >"./lateBoundAssignmentDeclarationSupport7.js" : "./lateBoundAssignmentDeclarationSupport7.js" @@ -9,7 +9,7 @@ const y = x.F["my-fake-sym"]; >y : string >x.F["my-fake-sym"] : string >x.F : typeof F ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport7") +>x : typeof x >F : typeof F >"my-fake-sym" : "my-fake-sym" @@ -17,10 +17,10 @@ const z = x.F[x.S]; >z : string >x.F[x.S] : string >x.F : typeof F ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport7") +>x : typeof x >F : typeof F >x.S : unique symbol ->x : typeof import("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport7") +>x : typeof x >S : unique symbol === tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport7.js === diff --git a/tests/baselines/reference/localRequireFunction.types b/tests/baselines/reference/localRequireFunction.types index 21f9c81bd29d2..4e1eb6f49c935 100644 --- a/tests/baselines/reference/localRequireFunction.types +++ b/tests/baselines/reference/localRequireFunction.types @@ -8,15 +8,15 @@ function require(a) { } const fs = require("fs"); ->fs : any +>fs : error >require("fs") : any >require : (a: any) => any >"fs" : "fs" const text = fs.readFileSync("/a/b/c"); ->text : any ->fs.readFileSync("/a/b/c") : any ->fs.readFileSync : any +>text : error +>fs.readFileSync("/a/b/c") : error +>fs.readFileSync : error >fs : any >readFileSync : any >"/a/b/c" : "/a/b/c" diff --git a/tests/baselines/reference/moduleExportAlias2.symbols b/tests/baselines/reference/moduleExportAlias2.symbols index 3571a6760e191..2e33643aa9018 100644 --- a/tests/baselines/reference/moduleExportAlias2.symbols +++ b/tests/baselines/reference/moduleExportAlias2.symbols @@ -7,9 +7,9 @@ const C = require("./semver") var two = C.f(1) >two : Symbol(two, Decl(index.js, 2, 3)) ->C.f : Symbol(f, Decl(semver.js, 1, 28)) +>C.f : Symbol(C.f, Decl(semver.js, 1, 28)) >C : Symbol(C, Decl(index.js, 1, 5)) ->f : Symbol(f, Decl(semver.js, 1, 28)) +>f : Symbol(C.f, Decl(semver.js, 1, 28)) var c = new C >c : Symbol(c, Decl(index.js, 3, 3)) diff --git a/tests/baselines/reference/moduleExportAlias2.types b/tests/baselines/reference/moduleExportAlias2.types index 6552d86075414..6f8ba54ad61da 100644 --- a/tests/baselines/reference/moduleExportAlias2.types +++ b/tests/baselines/reference/moduleExportAlias2.types @@ -1,8 +1,8 @@ === tests/cases/conformance/salsa/index.js === /// const C = require("./semver") ->C : typeof import("tests/cases/conformance/salsa/semver") ->require("./semver") : typeof import("tests/cases/conformance/salsa/semver") +>C : typeof C +>require("./semver") : typeof C >require : (name: string) => any >"./semver" : "./semver" @@ -10,14 +10,14 @@ var two = C.f(1) >two : any >C.f(1) : any >C.f : (n: any) => any ->C : typeof import("tests/cases/conformance/salsa/semver") +>C : typeof C >f : (n: any) => any >1 : 1 var c = new C ->c : import("tests/cases/conformance/salsa/semver") ->new C : import("tests/cases/conformance/salsa/semver") ->C : typeof import("tests/cases/conformance/salsa/semver") +>c : C +>new C : C +>C : typeof C === tests/cases/conformance/salsa/node.d.ts === declare function require(name: string): any; diff --git a/tests/baselines/reference/moduleExportAlias4.symbols b/tests/baselines/reference/moduleExportAlias4.symbols index fd149513b7bb0..2d27298ac9038 100644 --- a/tests/baselines/reference/moduleExportAlias4.symbols +++ b/tests/baselines/reference/moduleExportAlias4.symbols @@ -9,13 +9,13 @@ module.exports = class C {} >module.exports : Symbol("tests/cases/conformance/salsa/bug24024", Decl(bug24024.js, 0, 0)) >module : Symbol(export=, Decl(bug24024.js, 1, 31)) >exports : Symbol(export=, Decl(bug24024.js, 1, 31)) ->C : Symbol(C, Decl(bug24024.js, 2, 16)) +>C : Symbol(wat, Decl(bug24024.js, 2, 16)) module.exports.D = class D { } ->module.exports.D : Symbol(D, Decl(bug24024.js, 2, 27)) ->module.exports : Symbol(D, Decl(bug24024.js, 2, 27)) +>module.exports.D : Symbol(wat.D, Decl(bug24024.js, 2, 27)) +>module.exports : Symbol(wat.D, Decl(bug24024.js, 2, 27)) >module : Symbol(module, Decl(bug24024.js, 1, 31)) >exports : Symbol("tests/cases/conformance/salsa/bug24024", Decl(bug24024.js, 0, 0)) ->D : Symbol(D, Decl(bug24024.js, 2, 27)) +>D : Symbol(wat.D, Decl(bug24024.js, 2, 27)) >D : Symbol(D, Decl(bug24024.js, 3, 18)) diff --git a/tests/baselines/reference/moduleExportAlias4.types b/tests/baselines/reference/moduleExportAlias4.types index 5bf29c9331e4c..173c7c714a284 100644 --- a/tests/baselines/reference/moduleExportAlias4.types +++ b/tests/baselines/reference/moduleExportAlias4.types @@ -1,25 +1,25 @@ === tests/cases/conformance/salsa/bug24024.js === // #24024 var wat = require('./bug24024') ->wat : typeof import("tests/cases/conformance/salsa/bug24024") ->require('./bug24024') : typeof import("tests/cases/conformance/salsa/bug24024") +>wat : typeof wat +>require('./bug24024') : typeof wat >require : any >'./bug24024' : "./bug24024" module.exports = class C {} ->module.exports = class C {} : typeof import("tests/cases/conformance/salsa/bug24024") ->module.exports : typeof import("tests/cases/conformance/salsa/bug24024") ->module : { "\"tests/cases/conformance/salsa/bug24024\"": typeof import("tests/cases/conformance/salsa/bug24024"); } ->exports : typeof import("tests/cases/conformance/salsa/bug24024") ->class C {} : typeof import("tests/cases/conformance/salsa/bug24024") ->C : typeof import("tests/cases/conformance/salsa/bug24024") +>module.exports = class C {} : typeof wat +>module.exports : typeof wat +>module : { "\"tests/cases/conformance/salsa/bug24024\"": typeof wat; } +>exports : typeof wat +>class C {} : typeof wat +>C : typeof wat module.exports.D = class D { } >module.exports.D = class D { } : typeof D >module.exports.D : typeof D ->module.exports : typeof import("tests/cases/conformance/salsa/bug24024") ->module : { "\"tests/cases/conformance/salsa/bug24024\"": typeof import("tests/cases/conformance/salsa/bug24024"); } ->exports : typeof import("tests/cases/conformance/salsa/bug24024") +>module.exports : typeof wat +>module : { "\"tests/cases/conformance/salsa/bug24024\"": typeof wat; } +>exports : typeof wat >D : typeof D >class D { } : typeof D >D : typeof D diff --git a/tests/baselines/reference/moduleExportAssignment.symbols b/tests/baselines/reference/moduleExportAssignment.symbols index be741bdb9880a..e89dabfd946ef 100644 --- a/tests/baselines/reference/moduleExportAssignment.symbols +++ b/tests/baselines/reference/moduleExportAssignment.symbols @@ -5,9 +5,9 @@ var npmlog = require('./npmlog') >'./npmlog' : Symbol("tests/cases/conformance/salsa/npmlog", Decl(npmlog.js, 0, 0)) npmlog.x ->npmlog.x : Symbol(x, Decl(npmlog.js, 7, 23)) +>npmlog.x : Symbol(npmlog.x, Decl(npmlog.js, 7, 23)) >npmlog : Symbol(npmlog, Decl(use.js, 0, 3)) ->x : Symbol(x, Decl(npmlog.js, 7, 23)) +>x : Symbol(npmlog.x, Decl(npmlog.js, 7, 23)) npmlog.on >npmlog.on : Symbol(EE.on, Decl(npmlog.js, 0, 10)) diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment.symbols b/tests/baselines/reference/moduleExportWithExportPropertyAssignment.symbols index 19725dbd2a519..c65205747a60f 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment.symbols +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment.symbols @@ -9,9 +9,9 @@ mod1() >mod1 : Symbol(mod1, Decl(a.js, 1, 3)) mod1.f() // error, not enough arguments ->mod1.f : Symbol(f, Decl(mod1.js, 1, 32)) +>mod1.f : Symbol(mod1.f, Decl(mod1.js, 1, 32)) >mod1 : Symbol(mod1, Decl(a.js, 1, 3)) ->f : Symbol(f, Decl(mod1.js, 1, 32)) +>f : Symbol(mod1.f, Decl(mod1.js, 1, 32)) === tests/cases/conformance/salsa/requires.d.ts === declare var module: { exports: any }; diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.symbols b/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.symbols index 1c4aa535f6164..6006339a0b418 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.symbols +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.symbols @@ -24,9 +24,9 @@ mod1.bothAfter.toFixed() // error, 'toFixed' not on 'string | number' mod1.justProperty.length >mod1.justProperty.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ->mod1.justProperty : Symbol(justProperty, Decl(mod1.js, 7, 35)) +>mod1.justProperty : Symbol(mod1.justProperty, Decl(mod1.js, 7, 35)) >mod1 : Symbol(mod1, Decl(a.js, 1, 3)) ->justProperty : Symbol(justProperty, Decl(mod1.js, 7, 35)) +>justProperty : Symbol(mod1.justProperty, Decl(mod1.js, 7, 35)) >length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) === tests/cases/conformance/salsa/requires.d.ts === diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols index 82277b0540a63..5f7dbc398dc2d 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols @@ -7,26 +7,26 @@ var mod1 = require('./mod1') mod1.justExport.toFixed() >mod1.justExport.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) ->mod1.justExport : Symbol(A.justExport, Decl(mod1.js, 1, 36)) +>mod1.justExport : Symbol(mod1.justExport, Decl(mod1.js, 1, 36)) >mod1 : Symbol(mod1, Decl(a.js, 1, 3)) ->justExport : Symbol(A.justExport, Decl(mod1.js, 1, 36)) +>justExport : Symbol(mod1.justExport, Decl(mod1.js, 1, 36)) >toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) mod1.bothBefore.toFixed() // error ->mod1.bothBefore : Symbol(A.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) +>mod1.bothBefore : Symbol(mod1.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) >mod1 : Symbol(mod1, Decl(a.js, 1, 3)) ->bothBefore : Symbol(A.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) +>bothBefore : Symbol(mod1.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) mod1.bothAfter.toFixed() ->mod1.bothAfter : Symbol(A.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) +>mod1.bothAfter : Symbol(mod1.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) >mod1 : Symbol(mod1, Decl(a.js, 1, 3)) ->bothAfter : Symbol(A.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) +>bothAfter : Symbol(mod1.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) mod1.justProperty.length >mod1.justProperty.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ->mod1.justProperty : Symbol(justProperty, Decl(mod1.js, 9, 35)) +>mod1.justProperty : Symbol(mod1.justProperty, Decl(mod1.js, 9, 35)) >mod1 : Symbol(mod1, Decl(a.js, 1, 3)) ->justProperty : Symbol(justProperty, Decl(mod1.js, 9, 35)) +>justProperty : Symbol(mod1.justProperty, Decl(mod1.js, 9, 35)) >length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) === tests/cases/conformance/salsa/requires.d.ts === diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.types b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.types index 0ddaff1d58a90..d74a430cc15e0 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.types +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.types @@ -1,8 +1,8 @@ === tests/cases/conformance/salsa/a.js === /// var mod1 = require('./mod1') ->mod1 : typeof import("tests/cases/conformance/salsa/mod1") ->require('./mod1') : typeof import("tests/cases/conformance/salsa/mod1") +>mod1 : typeof mod1 +>require('./mod1') : typeof mod1 >require : (name: string) => any >'./mod1' : "./mod1" @@ -10,7 +10,7 @@ mod1.justExport.toFixed() >mod1.justExport.toFixed() : string >mod1.justExport.toFixed : (fractionDigits?: number) => string >mod1.justExport : number ->mod1 : typeof import("tests/cases/conformance/salsa/mod1") +>mod1 : typeof mod1 >justExport : number >toFixed : (fractionDigits?: number) => string @@ -18,7 +18,7 @@ mod1.bothBefore.toFixed() // error >mod1.bothBefore.toFixed() : any >mod1.bothBefore.toFixed : any >mod1.bothBefore : string | number ->mod1 : typeof import("tests/cases/conformance/salsa/mod1") +>mod1 : typeof mod1 >bothBefore : string | number >toFixed : any @@ -26,14 +26,14 @@ mod1.bothAfter.toFixed() >mod1.bothAfter.toFixed() : any >mod1.bothAfter.toFixed : any >mod1.bothAfter : string | number ->mod1 : typeof import("tests/cases/conformance/salsa/mod1") +>mod1 : typeof mod1 >bothAfter : string | number >toFixed : any mod1.justProperty.length >mod1.justProperty.length : number >mod1.justProperty : string ->mod1 : typeof import("tests/cases/conformance/salsa/mod1") +>mod1 : typeof mod1 >justProperty : string >length : number diff --git a/tests/baselines/reference/moduleExportsElementAccessAssignment.symbols b/tests/baselines/reference/moduleExportsElementAccessAssignment.symbols index 8032c898c934f..a13575852f071 100644 --- a/tests/baselines/reference/moduleExportsElementAccessAssignment.symbols +++ b/tests/baselines/reference/moduleExportsElementAccessAssignment.symbols @@ -2,39 +2,39 @@ const mod1 = require("./mod1"); >mod1 : Symbol(mod1, Decl(mod2.js, 0, 5)) >require : Symbol(require) ->"./mod1" : Symbol("tests/cases/conformance/jsdoc/mod1", Decl(mod1.js, 0, 0)) +>"./mod1" : Symbol(mod1, Decl(mod1.js, 0, 0)) mod1.a; ->mod1.a : Symbol(a, Decl(mod1.js, 0, 0)) +>mod1.a : Symbol(mod1.a, Decl(mod1.js, 0, 0)) >mod1 : Symbol(mod1, Decl(mod2.js, 0, 5)) ->a : Symbol(a, Decl(mod1.js, 0, 0)) +>a : Symbol(mod1.a, Decl(mod1.js, 0, 0)) mod1.b; ->mod1.b : Symbol("b", Decl(mod1.js, 0, 23)) +>mod1.b : Symbol(mod1["b"], Decl(mod1.js, 0, 23)) >mod1 : Symbol(mod1, Decl(mod2.js, 0, 5)) ->b : Symbol("b", Decl(mod1.js, 0, 23)) +>b : Symbol(mod1["b"], Decl(mod1.js, 0, 23)) mod1.c; ->mod1.c : Symbol("c", Decl(mod1.js, 2, 32)) +>mod1.c : Symbol(mod1["c"], Decl(mod1.js, 2, 32)) >mod1 : Symbol(mod1, Decl(mod2.js, 0, 5)) ->c : Symbol("c", Decl(mod1.js, 2, 32)) +>c : Symbol(mod1["c"], Decl(mod1.js, 2, 32)) mod1.d; ->mod1.d : Symbol("d", Decl(mod1.js, 3, 33), Decl(mod1.js, 5, 18)) +>mod1.d : Symbol(mod1["d"], Decl(mod1.js, 3, 33), Decl(mod1.js, 5, 18)) >mod1 : Symbol(mod1, Decl(mod2.js, 0, 5)) ->d : Symbol("d", Decl(mod1.js, 3, 33), Decl(mod1.js, 5, 18)) +>d : Symbol(mod1["d"], Decl(mod1.js, 3, 33), Decl(mod1.js, 5, 18)) mod1.d.e; ->mod1.d.e : Symbol("d".e, Decl(mod1.js, 4, 28)) ->mod1.d : Symbol("d", Decl(mod1.js, 3, 33), Decl(mod1.js, 5, 18)) +>mod1.d.e : Symbol(mod1["d"].e, Decl(mod1.js, 4, 28)) +>mod1.d : Symbol(mod1["d"], Decl(mod1.js, 3, 33), Decl(mod1.js, 5, 18)) >mod1 : Symbol(mod1, Decl(mod2.js, 0, 5)) ->d : Symbol("d", Decl(mod1.js, 3, 33), Decl(mod1.js, 5, 18)) ->e : Symbol("d".e, Decl(mod1.js, 4, 28)) +>d : Symbol(mod1["d"], Decl(mod1.js, 3, 33), Decl(mod1.js, 5, 18)) +>e : Symbol(mod1["d"].e, Decl(mod1.js, 4, 28)) mod1.default; ->mod1.default : Symbol(default, Decl(mod1.js, 1, 26)) +>mod1.default : Symbol(mod1.default, Decl(mod1.js, 1, 26)) >mod1 : Symbol(mod1, Decl(mod2.js, 0, 5)) ->default : Symbol(default, Decl(mod1.js, 1, 26)) +>default : Symbol(mod1.default, Decl(mod1.js, 1, 26)) === tests/cases/conformance/jsdoc/mod1.js === exports.a = { x: "x" }; diff --git a/tests/baselines/reference/moduleExportsElementAccessAssignment.types b/tests/baselines/reference/moduleExportsElementAccessAssignment.types index 39ff18ddd3411..b5f4c3e0e5ab0 100644 --- a/tests/baselines/reference/moduleExportsElementAccessAssignment.types +++ b/tests/baselines/reference/moduleExportsElementAccessAssignment.types @@ -1,40 +1,40 @@ === tests/cases/conformance/jsdoc/mod2.js === const mod1 = require("./mod1"); ->mod1 : typeof import("tests/cases/conformance/jsdoc/mod1") ->require("./mod1") : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod1 : typeof mod1 +>require("./mod1") : typeof mod1 >require : any >"./mod1" : "./mod1" mod1.a; >mod1.a : { x: string; } ->mod1 : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod1 : typeof mod1 >a : { x: string; } mod1.b; >mod1.b : { x: string; } ->mod1 : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod1 : typeof mod1 >b : { x: string; } mod1.c; >mod1.c : { x: string; } ->mod1 : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod1 : typeof mod1 >c : { x: string; } mod1.d; ->mod1.d : typeof import("tests/cases/conformance/jsdoc/mod1").d ->mod1 : typeof import("tests/cases/conformance/jsdoc/mod1") ->d : typeof import("tests/cases/conformance/jsdoc/mod1").d +>mod1.d : typeof mod1."d" +>mod1 : typeof mod1 +>d : typeof mod1."d" mod1.d.e; >mod1.d.e : number ->mod1.d : typeof import("tests/cases/conformance/jsdoc/mod1").d ->mod1 : typeof import("tests/cases/conformance/jsdoc/mod1") ->d : typeof import("tests/cases/conformance/jsdoc/mod1").d +>mod1.d : typeof mod1."d" +>mod1 : typeof mod1 +>d : typeof mod1."d" >e : number mod1.default; >mod1.default : { x: string; } ->mod1 : typeof import("tests/cases/conformance/jsdoc/mod1") +>mod1 : typeof mod1 >default : { x: string; } === tests/cases/conformance/jsdoc/mod1.js === diff --git a/tests/baselines/reference/noCrashOnParameterNamedRequire.errors.txt b/tests/baselines/reference/noCrashOnParameterNamedRequire.errors.txt new file mode 100644 index 0000000000000..847b16da03b5d --- /dev/null +++ b/tests/baselines/reference/noCrashOnParameterNamedRequire.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/index.js(2,25): error TS2307: Cannot find module './mod' or its corresponding type declarations. + + +==== tests/cases/compiler/index.js (1 errors) ==== + (function(require, module, exports){ + const mod = require("./mod"); + ~~~~~~~ +!!! error TS2307: Cannot find module './mod' or its corresponding type declarations. + mod.foo; + })(null, null, null); \ No newline at end of file diff --git a/tests/baselines/reference/requireAssertsFromTypescript.symbols b/tests/baselines/reference/requireAssertsFromTypescript.symbols new file mode 100644 index 0000000000000..0d39960aff7c5 --- /dev/null +++ b/tests/baselines/reference/requireAssertsFromTypescript.symbols @@ -0,0 +1,45 @@ +=== tests/cases/conformance/salsa/38379.js === +const { art } = require('./ex') +>art : Symbol(art, Decl(38379.js, 0, 7)) +>require : Symbol(require) +>'./ex' : Symbol("tests/cases/conformance/salsa/ex", Decl(ex.d.ts, 0, 0)) + +const artoo = require('./ex2') +>artoo : Symbol(artoo, Decl(38379.js, 1, 5)) +>require : Symbol(require) +>'./ex2' : Symbol("tests/cases/conformance/salsa/ex2", Decl(ex2.d.ts, 0, 0)) + +let x = 1 +>x : Symbol(x, Decl(38379.js, 2, 3)) + +art(x) +>art : Symbol(art, Decl(38379.js, 0, 7)) +>x : Symbol(x, Decl(38379.js, 2, 3)) + +let y = 1 +>y : Symbol(y, Decl(38379.js, 4, 3)) + +artoo(y) +>artoo : Symbol(artoo, Decl(38379.js, 1, 5)) +>y : Symbol(y, Decl(38379.js, 4, 3)) + +=== tests/cases/conformance/salsa/ex.d.ts === +// based on assert in @types/node +export function art(value: any, message?: string | Error): asserts value; +>art : Symbol(art, Decl(ex.d.ts, 0, 0)) +>value : Symbol(value, Decl(ex.d.ts, 1, 20)) +>message : Symbol(message, Decl(ex.d.ts, 1, 31)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(ex.d.ts, 1, 20)) + +=== tests/cases/conformance/salsa/ex2.d.ts === +declare function art(value: any, message?: string | Error): asserts value; +>art : Symbol(art, Decl(ex2.d.ts, 0, 0)) +>value : Symbol(value, Decl(ex2.d.ts, 0, 21)) +>message : Symbol(message, Decl(ex2.d.ts, 0, 32)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(ex2.d.ts, 0, 21)) + +export = art; +>art : Symbol(art, Decl(ex2.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/requireAssertsFromTypescript.types b/tests/baselines/reference/requireAssertsFromTypescript.types new file mode 100644 index 0000000000000..d146adfdc4fd6 --- /dev/null +++ b/tests/baselines/reference/requireAssertsFromTypescript.types @@ -0,0 +1,47 @@ +=== tests/cases/conformance/salsa/38379.js === +const { art } = require('./ex') +>art : (value: any, message?: string | Error) => asserts value +>require('./ex') : typeof import("tests/cases/conformance/salsa/ex") +>require : any +>'./ex' : "./ex" + +const artoo = require('./ex2') +>artoo : (value: any, message?: string | Error) => asserts value +>require('./ex2') : (value: any, message?: string | Error) => asserts value +>require : any +>'./ex2' : "./ex2" + +let x = 1 +>x : number +>1 : 1 + +art(x) +>art(x) : void +>art : (value: any, message?: string | Error) => asserts value +>x : number + +let y = 1 +>y : number +>1 : 1 + +artoo(y) +>artoo(y) : void +>artoo : (value: any, message?: string | Error) => asserts value +>y : number + +=== tests/cases/conformance/salsa/ex.d.ts === +// based on assert in @types/node +export function art(value: any, message?: string | Error): asserts value; +>art : (value: any, message?: string | Error) => asserts value +>value : any +>message : string | Error + +=== tests/cases/conformance/salsa/ex2.d.ts === +declare function art(value: any, message?: string | Error): asserts value; +>art : (value: any, message?: string | Error) => asserts value +>value : any +>message : string | Error + +export = art; +>art : (value: any, message?: string | Error) => asserts value + diff --git a/tests/baselines/reference/typeFromParamTagForFunction.types b/tests/baselines/reference/typeFromParamTagForFunction.types index 73daa299cf1be..f36bca8748c20 100644 --- a/tests/baselines/reference/typeFromParamTagForFunction.types +++ b/tests/baselines/reference/typeFromParamTagForFunction.types @@ -86,17 +86,17 @@ export function C() { === tests/cases/conformance/salsa/c.js === const { C } = require("./c-ext"); ->C : typeof import("tests/cases/conformance/salsa/c-ext").C +>C : typeof C >require("./c-ext") : typeof import("tests/cases/conformance/salsa/c-ext") >require : (id: string) => any >"./c-ext" : "./c-ext" /** @param {C} p */ function c(p) { p.x; } ->c : (p: import("tests/cases/conformance/salsa/c-ext").C) => void ->p : import("tests/cases/conformance/salsa/c-ext").C +>c : (p: C) => void +>p : C >p.x : number ->p : import("tests/cases/conformance/salsa/c-ext").C +>p : C >x : number === tests/cases/conformance/salsa/d-ext.js === @@ -144,17 +144,17 @@ export class E { === tests/cases/conformance/salsa/e.js === const { E } = require("./e-ext"); ->E : typeof import("tests/cases/conformance/salsa/e-ext").E +>E : typeof E >require("./e-ext") : typeof import("tests/cases/conformance/salsa/e-ext") >require : (id: string) => any >"./e-ext" : "./e-ext" /** @param {E} p */ function e(p) { p.x; } ->e : (p: import("tests/cases/conformance/salsa/e-ext").E) => void ->p : import("tests/cases/conformance/salsa/e-ext").E +>e : (p: E) => void +>p : E >p.x : number ->p : import("tests/cases/conformance/salsa/e-ext").E +>p : E >x : number === tests/cases/conformance/salsa/f.js === diff --git a/tests/baselines/reference/typeFromPropertyAssignment17.symbols b/tests/baselines/reference/typeFromPropertyAssignment17.symbols index 5d6f98f309b63..b6121ee2507cc 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment17.symbols +++ b/tests/baselines/reference/typeFromPropertyAssignment17.symbols @@ -7,16 +7,16 @@ var mini = require('./minimatch') mini.M.defaults() >mini.M.defaults : Symbol(M.defaults, Decl(minimatch.js, 8, 1)) ->mini.M : Symbol(minimatch.M, Decl(minimatch.js, 1, 26)) +>mini.M : Symbol(mini.M, Decl(minimatch.js, 1, 26)) >mini : Symbol(mini, Decl(use.js, 1, 3)) ->M : Symbol(minimatch.M, Decl(minimatch.js, 1, 26)) +>M : Symbol(mini.M, Decl(minimatch.js, 1, 26)) >defaults : Symbol(M.defaults, Decl(minimatch.js, 8, 1)) var m = new mini.M() >m : Symbol(m, Decl(use.js, 3, 3)) ->mini.M : Symbol(minimatch.M, Decl(minimatch.js, 1, 26)) +>mini.M : Symbol(mini.M, Decl(minimatch.js, 1, 26)) >mini : Symbol(mini, Decl(use.js, 1, 3)) ->M : Symbol(minimatch.M, Decl(minimatch.js, 1, 26)) +>M : Symbol(mini.M, Decl(minimatch.js, 1, 26)) m.m() >m.m : Symbol(M.m, Decl(minimatch.js, 11, 1)) @@ -24,9 +24,9 @@ m.m() >m : Symbol(M.m, Decl(minimatch.js, 11, 1)) mini.filter() ->mini.filter : Symbol(minimatch.filter, Decl(minimatch.js, 2, 15)) +>mini.filter : Symbol(mini.filter, Decl(minimatch.js, 2, 15)) >mini : Symbol(mini, Decl(use.js, 1, 3)) ->filter : Symbol(minimatch.filter, Decl(minimatch.js, 2, 15)) +>filter : Symbol(mini.filter, Decl(minimatch.js, 2, 15)) === tests/cases/conformance/salsa/types.d.ts === declare var require: any; diff --git a/tests/baselines/reference/typeFromPropertyAssignment17.types b/tests/baselines/reference/typeFromPropertyAssignment17.types index 9ed784c6a204b..86f6b6346f166 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment17.types +++ b/tests/baselines/reference/typeFromPropertyAssignment17.types @@ -1,8 +1,8 @@ === tests/cases/conformance/salsa/use.js === /// var mini = require('./minimatch') ->mini : typeof import("tests/cases/conformance/salsa/minimatch") ->require('./minimatch') : typeof import("tests/cases/conformance/salsa/minimatch") +>mini : typeof mini +>require('./minimatch') : typeof mini >require : any >'./minimatch' : "./minimatch" @@ -10,7 +10,7 @@ mini.M.defaults() >mini.M.defaults() : any >mini.M.defaults : (def: any) => any >mini.M : typeof M ->mini : typeof import("tests/cases/conformance/salsa/minimatch") +>mini : typeof mini >M : typeof M >defaults : (def: any) => any @@ -18,7 +18,7 @@ var m = new mini.M() >m : M >new mini.M() : M >mini.M : typeof M ->mini : typeof import("tests/cases/conformance/salsa/minimatch") +>mini : typeof mini >M : typeof M m.m() @@ -30,7 +30,7 @@ m.m() mini.filter() >mini.filter() : void >mini.filter : () => void ->mini : typeof import("tests/cases/conformance/salsa/minimatch") +>mini : typeof mini >filter : () => void === tests/cases/conformance/salsa/types.d.ts === diff --git a/tests/baselines/reference/typeFromPropertyAssignment19.types b/tests/baselines/reference/typeFromPropertyAssignment19.types index d09029fb94954..a82897616e32b 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment19.types +++ b/tests/baselines/reference/typeFromPropertyAssignment19.types @@ -1,8 +1,8 @@ === tests/cases/conformance/salsa/index.js === /// const C = require("./semver") ->C : typeof import("tests/cases/conformance/salsa/semver") ->require("./semver") : typeof import("tests/cases/conformance/salsa/semver") +>C : typeof C +>require("./semver") : typeof C >require : any >"./semver" : "./semver" @@ -10,7 +10,7 @@ var two = C.f(1) >two : any >C.f(1) : any >C.f : (n: any) => any ->C : typeof import("tests/cases/conformance/salsa/semver") +>C : typeof C >f : (n: any) => any >1 : 1 diff --git a/tests/baselines/reference/typeFromPropertyAssignment37.symbols b/tests/baselines/reference/typeFromPropertyAssignment37.symbols index 4d2af775b000a..909ded56c27c7 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment37.symbols +++ b/tests/baselines/reference/typeFromPropertyAssignment37.symbols @@ -2,20 +2,20 @@ const util = require('./mod') >util : Symbol(util, Decl(use.js, 0, 5)) >require : Symbol(require) ->'./mod' : Symbol("tests/cases/conformance/salsa/mod", Decl(mod.js, 0, 0)) +>'./mod' : Symbol(util, Decl(mod.js, 0, 0)) function n() { >n : Symbol(n, Decl(use.js, 0, 29)) util.existy // no error ->util.existy : Symbol(existy, Decl(mod.js, 1, 14)) +>util.existy : Symbol(util.existy, Decl(mod.js, 1, 14)) >util : Symbol(util, Decl(use.js, 0, 5)) ->existy : Symbol(existy, Decl(mod.js, 1, 14)) +>existy : Symbol(util.existy, Decl(mod.js, 1, 14)) } util.existy // no error ->util.existy : Symbol(existy, Decl(mod.js, 1, 14)) +>util.existy : Symbol(util.existy, Decl(mod.js, 1, 14)) >util : Symbol(util, Decl(use.js, 0, 5)) ->existy : Symbol(existy, Decl(mod.js, 1, 14)) +>existy : Symbol(util.existy, Decl(mod.js, 1, 14)) === tests/cases/conformance/salsa/mod.js === const util = exports = module.exports = {} diff --git a/tests/baselines/reference/typeFromPropertyAssignment37.types b/tests/baselines/reference/typeFromPropertyAssignment37.types index 5a6ed5d845469..2813969da827e 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment37.types +++ b/tests/baselines/reference/typeFromPropertyAssignment37.types @@ -1,7 +1,7 @@ === tests/cases/conformance/salsa/use.js === const util = require('./mod') ->util : typeof import("tests/cases/conformance/salsa/mod") ->require('./mod') : typeof import("tests/cases/conformance/salsa/mod") +>util : typeof util +>require('./mod') : typeof util >require : any >'./mod' : "./mod" @@ -10,12 +10,12 @@ function n() { util.existy // no error >util.existy : () => void ->util : typeof import("tests/cases/conformance/salsa/mod") +>util : typeof util >existy : () => void } util.existy // no error >util.existy : () => void ->util : typeof import("tests/cases/conformance/salsa/mod") +>util : typeof util >existy : () => void === tests/cases/conformance/salsa/mod.js === diff --git a/tests/baselines/reference/varRequireFromJavascript.symbols b/tests/baselines/reference/varRequireFromJavascript.symbols index 03a2a2516dee2..0ea20514a8c7e 100644 --- a/tests/baselines/reference/varRequireFromJavascript.symbols +++ b/tests/baselines/reference/varRequireFromJavascript.symbols @@ -2,19 +2,19 @@ var ex = require('./ex') >ex : Symbol(ex, Decl(use.js, 0, 3)) >require : Symbol(require) ->'./ex' : Symbol("tests/cases/conformance/salsa/ex", Decl(ex.js, 0, 0)) +>'./ex' : Symbol(ex, Decl(ex.js, 0, 0)) // values work var crunch = new ex.Crunch(1); >crunch : Symbol(crunch, Decl(use.js, 3, 3)) ->ex.Crunch : Symbol(Crunch, Decl(ex.js, 0, 0)) +>ex.Crunch : Symbol(ex.Crunch, Decl(ex.js, 0, 0)) >ex : Symbol(ex, Decl(use.js, 0, 3)) ->Crunch : Symbol(Crunch, Decl(ex.js, 0, 0)) +>Crunch : Symbol(ex.Crunch, Decl(ex.js, 0, 0)) crunch.n ->crunch.n : Symbol(Crunch.n, Decl(ex.js, 2, 20)) +>crunch.n : Symbol(ex.Crunch.n, Decl(ex.js, 2, 20)) >crunch : Symbol(crunch, Decl(use.js, 3, 3)) ->n : Symbol(Crunch.n, Decl(ex.js, 2, 20)) +>n : Symbol(ex.Crunch.n, Decl(ex.js, 2, 20)) // types work @@ -26,9 +26,9 @@ function f(wrap) { >wrap : Symbol(wrap, Decl(use.js, 11, 11)) wrap.n ->wrap.n : Symbol(Crunch.n, Decl(ex.js, 2, 20)) +>wrap.n : Symbol(ex.Crunch.n, Decl(ex.js, 2, 20)) >wrap : Symbol(wrap, Decl(use.js, 11, 11)) ->n : Symbol(Crunch.n, Decl(ex.js, 2, 20)) +>n : Symbol(ex.Crunch.n, Decl(ex.js, 2, 20)) } === tests/cases/conformance/salsa/ex.js === diff --git a/tests/baselines/reference/varRequireFromJavascript.types b/tests/baselines/reference/varRequireFromJavascript.types index 84fef5df25936..f304eb6a1a106 100644 --- a/tests/baselines/reference/varRequireFromJavascript.types +++ b/tests/baselines/reference/varRequireFromJavascript.types @@ -1,22 +1,22 @@ === tests/cases/conformance/salsa/use.js === var ex = require('./ex') ->ex : typeof import("tests/cases/conformance/salsa/ex") ->require('./ex') : typeof import("tests/cases/conformance/salsa/ex") +>ex : typeof ex +>require('./ex') : typeof ex >require : any >'./ex' : "./ex" // values work var crunch = new ex.Crunch(1); ->crunch : import("tests/cases/conformance/salsa/ex").Crunch ->new ex.Crunch(1) : import("tests/cases/conformance/salsa/ex").Crunch ->ex.Crunch : typeof import("tests/cases/conformance/salsa/ex").Crunch ->ex : typeof import("tests/cases/conformance/salsa/ex") ->Crunch : typeof import("tests/cases/conformance/salsa/ex").Crunch +>crunch : ex.Crunch +>new ex.Crunch(1) : ex.Crunch +>ex.Crunch : typeof ex.Crunch +>ex : typeof ex +>Crunch : typeof ex.Crunch >1 : 1 crunch.n >crunch.n : number ->crunch : import("tests/cases/conformance/salsa/ex").Crunch +>crunch : ex.Crunch >n : number @@ -25,12 +25,12 @@ crunch.n * @param {ex.Crunch} wrap */ function f(wrap) { ->f : (wrap: import("tests/cases/conformance/salsa/ex").Crunch) => void ->wrap : import("tests/cases/conformance/salsa/ex").Crunch +>f : (wrap: ex.Crunch) => void +>wrap : ex.Crunch wrap.n >wrap.n : number ->wrap : import("tests/cases/conformance/salsa/ex").Crunch +>wrap : ex.Crunch >n : number } diff --git a/tests/baselines/reference/varRequireFromTypescript.symbols b/tests/baselines/reference/varRequireFromTypescript.symbols index 70c918aba056c..9ed299b1d7b26 100644 --- a/tests/baselines/reference/varRequireFromTypescript.symbols +++ b/tests/baselines/reference/varRequireFromTypescript.symbols @@ -2,19 +2,19 @@ var ex = require('./ex') >ex : Symbol(ex, Decl(use.js, 0, 3)) >require : Symbol(require) ->'./ex' : Symbol("tests/cases/conformance/salsa/ex", Decl(ex.d.ts, 0, 0)) +>'./ex' : Symbol(ex, Decl(ex.d.ts, 0, 0)) // values work var crunch = new ex.Crunch(1); >crunch : Symbol(crunch, Decl(use.js, 3, 3)) ->ex.Crunch : Symbol(Crunch, Decl(ex.d.ts, 0, 33)) +>ex.Crunch : Symbol(ex.Crunch, Decl(ex.d.ts, 0, 33)) >ex : Symbol(ex, Decl(use.js, 0, 3)) ->Crunch : Symbol(Crunch, Decl(ex.d.ts, 0, 33)) +>Crunch : Symbol(ex.Crunch, Decl(ex.d.ts, 0, 33)) crunch.n ->crunch.n : Symbol(Crunch.n, Decl(ex.d.ts, 1, 21)) +>crunch.n : Symbol(ex.Crunch.n, Decl(ex.d.ts, 1, 21)) >crunch : Symbol(crunch, Decl(use.js, 3, 3)) ->n : Symbol(Crunch.n, Decl(ex.d.ts, 1, 21)) +>n : Symbol(ex.Crunch.n, Decl(ex.d.ts, 1, 21)) // types work @@ -33,9 +33,9 @@ function f(greatest, wrap) { >day : Symbol(day, Decl(ex.d.ts, 0, 24)) wrap.n ->wrap.n : Symbol(Crunch.n, Decl(ex.d.ts, 1, 21)) +>wrap.n : Symbol(ex.Crunch.n, Decl(ex.d.ts, 1, 21)) >wrap : Symbol(wrap, Decl(use.js, 12, 20)) ->n : Symbol(Crunch.n, Decl(ex.d.ts, 1, 21)) +>n : Symbol(ex.Crunch.n, Decl(ex.d.ts, 1, 21)) } === tests/cases/conformance/salsa/ex.d.ts === diff --git a/tests/baselines/reference/varRequireFromTypescript.types b/tests/baselines/reference/varRequireFromTypescript.types index 7010bfaf1a800..931f95e9bd5a2 100644 --- a/tests/baselines/reference/varRequireFromTypescript.types +++ b/tests/baselines/reference/varRequireFromTypescript.types @@ -1,22 +1,22 @@ === tests/cases/conformance/salsa/use.js === var ex = require('./ex') ->ex : typeof import("tests/cases/conformance/salsa/ex") ->require('./ex') : typeof import("tests/cases/conformance/salsa/ex") +>ex : typeof ex +>require('./ex') : typeof ex >require : any >'./ex' : "./ex" // values work var crunch = new ex.Crunch(1); ->crunch : import("tests/cases/conformance/salsa/ex").Crunch ->new ex.Crunch(1) : import("tests/cases/conformance/salsa/ex").Crunch ->ex.Crunch : typeof import("tests/cases/conformance/salsa/ex").Crunch ->ex : typeof import("tests/cases/conformance/salsa/ex") ->Crunch : typeof import("tests/cases/conformance/salsa/ex").Crunch +>crunch : ex.Crunch +>new ex.Crunch(1) : ex.Crunch +>ex.Crunch : typeof ex.Crunch +>ex : typeof ex +>Crunch : typeof ex.Crunch >1 : 1 crunch.n >crunch.n : number ->crunch : import("tests/cases/conformance/salsa/ex").Crunch +>crunch : ex.Crunch >n : number @@ -26,18 +26,18 @@ crunch.n * @param {ex.Crunch} wrap */ function f(greatest, wrap) { ->f : (greatest: import("tests/cases/conformance/salsa/ex").Greatest, wrap: import("tests/cases/conformance/salsa/ex").Crunch) => void ->greatest : import("tests/cases/conformance/salsa/ex").Greatest ->wrap : import("tests/cases/conformance/salsa/ex").Crunch +>f : (greatest: ex.Greatest, wrap: ex.Crunch) => void +>greatest : ex.Greatest +>wrap : ex.Crunch greatest.day >greatest.day : 1 ->greatest : import("tests/cases/conformance/salsa/ex").Greatest +>greatest : ex.Greatest >day : 1 wrap.n >wrap.n : number ->wrap : import("tests/cases/conformance/salsa/ex").Crunch +>wrap : ex.Crunch >n : number } diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences.ts index 29151bf965625..5d96e640242e4 100644 --- a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences.ts +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences.ts @@ -16,4 +16,4 @@ const thing = new Something(); module.exports = { thing -}; \ No newline at end of file +}; diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences2.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences2.ts new file mode 100644 index 0000000000000..bd67ecd26e060 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences2.ts @@ -0,0 +1,20 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: tests/cases/conformance/jsdoc/declarations/out +// @declaration: true +// @filename: something.ts +export const o = { + a: 1, + m: 1 +} + +// @filename: index.js + +const{ a, m } = require("./something").o; + +const thing = a + m + +module.exports = { + thing +}; diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences3.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences3.ts new file mode 100644 index 0000000000000..a78ca90d3b728 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences3.ts @@ -0,0 +1,17 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: tests/cases/conformance/jsdoc/declarations/out +// @declaration: true +// @filename: node_modules/@types/node/index.d.ts +declare module "fs" { + export class Something {} +} +// @filename: index.js +/// + +const Something = require("fs").Something; +module.exports.A = {} +module.exports.A.B = { + thing: new Something() +} diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences4.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences4.ts new file mode 100644 index 0000000000000..6134603f226b5 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences4.ts @@ -0,0 +1,22 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @outDir: tests/cases/conformance/jsdoc/declarations/out +// @declaration: true +// @filename: node_modules/@types/node/index.d.ts +declare module "fs" { + export class Something {} +} +// @filename: index.js +/// +export const Something = 2; // to show conflict that can occur +// @ts-ignore +export namespace A { + // @ts-ignore + export namespace B { + const Something = require("fs").Something; + const thing = new Something(); + // @ts-ignore + export { thing }; + } +} diff --git a/tests/cases/conformance/salsa/requireAssertsFromTypescript.ts b/tests/cases/conformance/salsa/requireAssertsFromTypescript.ts new file mode 100644 index 0000000000000..ccdd8353ba80b --- /dev/null +++ b/tests/cases/conformance/salsa/requireAssertsFromTypescript.ts @@ -0,0 +1,16 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: ex.d.ts +// based on assert in @types/node +export function art(value: any, message?: string | Error): asserts value; +// @Filename: ex2.d.ts +declare function art(value: any, message?: string | Error): asserts value; +export = art; +// @Filename: 38379.js +const { art } = require('./ex') +const artoo = require('./ex2') +let x = 1 +art(x) +let y = 1 +artoo(y) diff --git a/tests/cases/fourslash/findAllRefsCommonJsRequire.ts b/tests/cases/fourslash/findAllRefsCommonJsRequire.ts new file mode 100644 index 0000000000000..387aaa07de45a --- /dev/null +++ b/tests/cases/fourslash/findAllRefsCommonJsRequire.ts @@ -0,0 +1,14 @@ +/// + +// @allowJs: true + +// @Filename: /a.js +//// function f() { } +//// export { f } + +// @Filename: /b.js +//// const { f } = require('./a') +//// /**/f + + +verify.baselineFindAllReferences(""); diff --git a/tests/cases/fourslash/findAllRefsCommonJsRequire2.ts b/tests/cases/fourslash/findAllRefsCommonJsRequire2.ts new file mode 100644 index 0000000000000..ff8275b7ef5fe --- /dev/null +++ b/tests/cases/fourslash/findAllRefsCommonJsRequire2.ts @@ -0,0 +1,14 @@ +/// + +// @allowJs: true + +// @Filename: /a.js +//// function f() { } +//// module.exports.f = f + +// @Filename: /b.js +//// const { f } = require('./a') +//// /**/f + + +verify.baselineFindAllReferences(""); diff --git a/tests/cases/fourslash/findAllRefsCommonJsRequire3.ts b/tests/cases/fourslash/findAllRefsCommonJsRequire3.ts new file mode 100644 index 0000000000000..b9687b417d75e --- /dev/null +++ b/tests/cases/fourslash/findAllRefsCommonJsRequire3.ts @@ -0,0 +1,14 @@ +/// + +// @allowJs: true + +// @Filename: /a.js +//// function f() { } +//// module.exports = { f } + +// @Filename: /b.js +//// const { f } = require('./a') +//// /**/f + + +verify.baselineFindAllReferences(""); diff --git a/tests/cases/fourslash/findAllRefsImportEqualsJsonFile.ts b/tests/cases/fourslash/findAllRefsImportEqualsJsonFile.ts index 2969ef07638bd..d047ed4e11e4e 100644 --- a/tests/cases/fourslash/findAllRefsImportEqualsJsonFile.ts +++ b/tests/cases/fourslash/findAllRefsImportEqualsJsonFile.ts @@ -20,5 +20,5 @@ verify.noErrors(); const [r0Def, r0, r1, r2, r3Def, r3, r4, r5, r6] = test.ranges(); verify.singleReferenceGroup('import j = require("./j.json")', [r0, r2]); verify.referenceGroups([r1, r4], [{ definition: 'module "/j"', ranges: [r1, r4, r6] }]); -verify.singleReferenceGroup('const j: {\n x: number;\n}', [r3, r5]); +verify.singleReferenceGroup('import j', [r3, r5]); verify.referenceGroups(r6, undefined); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index f50cb18774415..daab0d3266c01 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -294,6 +294,7 @@ declare namespace FourSlashInterface { symbolAtLocation(startRange: Range, ...declarationRanges: Range[]): void; typeOfSymbolAtLocation(range: Range, symbol: any, expected: string): void; /** + * @deprecated Use baselineFindAllReferences instead * For each of starts, asserts the ranges that are referenced from there. * This uses the 'findReferences' command instead of 'getReferencesAtPosition', so references are grouped by their definition. */ diff --git a/tests/cases/fourslash/goToDefinitionImportedNames10.ts b/tests/cases/fourslash/goToDefinitionImportedNames10.ts new file mode 100644 index 0000000000000..faa9ed745cc36 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionImportedNames10.ts @@ -0,0 +1,15 @@ +/// +// @allowjs: true + +// @Filename: a.js +//// class Class { +//// f; +//// } +//// module.exports./*classDefinition*/Class = Class; + +// @Filename: b.js +////const { Class } = require("./a"); +//// [|/*classAliasDefinition*/Class|]; + + +verify.goToDefinition("classAliasDefinition", "classDefinition"); diff --git a/tests/cases/fourslash/goToDefinitionImportedNames11.ts b/tests/cases/fourslash/goToDefinitionImportedNames11.ts new file mode 100644 index 0000000000000..f34b3543881a6 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionImportedNames11.ts @@ -0,0 +1,15 @@ +/// +// @allowjs: true + +// @Filename: a.js +//// class Class { +//// f; +//// } +//// module.exports = { /*classDefinition*/Class }; + +// @Filename: b.js +////const { Class } = require("./a"); +//// [|/*classAliasDefinition*/Class|]; + + +verify.goToDefinition("classAliasDefinition", "classDefinition"); diff --git a/tests/cases/fourslash/goToDefinitionImportedNames8.ts b/tests/cases/fourslash/goToDefinitionImportedNames8.ts new file mode 100644 index 0000000000000..ad3d1c107853d --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionImportedNames8.ts @@ -0,0 +1,14 @@ +/// +// @allowjs: true + +// @Filename: b.js +////import { [|/*classAliasDefinition*/Class|] } from "./a"; + + +// @Filename: a.js +////class /*classDefinition*/Class { +//// private f; +////} +//// export { Class }; + +verify.goToDefinition("classAliasDefinition", "classDefinition"); diff --git a/tests/cases/fourslash/goToDefinitionImportedNames9.ts b/tests/cases/fourslash/goToDefinitionImportedNames9.ts new file mode 100644 index 0000000000000..2f838efca26b1 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionImportedNames9.ts @@ -0,0 +1,15 @@ +/// +// @allowjs: true + +// @Filename: a.js +////class /*classDefinition*/Class { +//// f; +////} +//// export { Class }; + +// @Filename: b.js +////const { Class } = require("./a"); +//// [|/*classAliasDefinition*/Class|]; + + +verify.goToDefinition("classAliasDefinition", "classDefinition"); diff --git a/tests/cases/fourslash/goToDefinitionJsModuleNameAtImportName.ts b/tests/cases/fourslash/goToDefinitionJsModuleNameAtImportName.ts index d0b5e61c44357..3763387efd24a 100644 --- a/tests/cases/fourslash/goToDefinitionJsModuleNameAtImportName.ts +++ b/tests/cases/fourslash/goToDefinitionJsModuleNameAtImportName.ts @@ -3,10 +3,11 @@ // @allowJs: true // @Filename: /foo.js -//// /*moduleDef*/class Blah { +//// /*moduleDef*/function notExported() { } +//// class Blah { //// abc = 123; -////} -////module.exports.Blah = Blah; +//// } +//// module.exports.Blah = Blah; // @Filename: /bar.js ////const [|/*importDef*/BlahModule|] = require("./foo.js"); diff --git a/tests/cases/fourslash/jsRequireQuickInfo.ts b/tests/cases/fourslash/jsRequireQuickInfo.ts index 5c78e87815a60..ee6ddc61d7a43 100644 --- a/tests/cases/fourslash/jsRequireQuickInfo.ts +++ b/tests/cases/fourslash/jsRequireQuickInfo.ts @@ -7,4 +7,4 @@ // @Filename: b.js ////exports.x = 0; -verify.quickInfoAt("",'const x: typeof import("/tests/cases/fourslash/b")'); +verify.quickInfoAt("",'import x'); diff --git a/tests/cases/fourslash/renameJsExports02.ts b/tests/cases/fourslash/renameJsExports02.ts index 17f69760931c9..976d9b6c9e9cd 100644 --- a/tests/cases/fourslash/renameJsExports02.ts +++ b/tests/cases/fourslash/renameJsExports02.ts @@ -10,7 +10,7 @@ const [rDef, r0, r1Def, r1] = test.ranges(); verify.referenceGroups(r0, [ { definition: "(local class) A", ranges: [r0] }, - { definition: "const A: typeof A", ranges: [r1] } + { definition: "(alias) (local class) A\nimport A", ranges: [r1] } ]); -verify.singleReferenceGroup("const A: typeof A", [r1]); +verify.singleReferenceGroup("(alias) (local class) A\nimport A", [r1]); diff --git a/tests/cases/fourslash/renameJsExports03.ts b/tests/cases/fourslash/renameJsExports03.ts index 02704eda8c7dc..f283d6bf45070 100644 --- a/tests/cases/fourslash/renameJsExports03.ts +++ b/tests/cases/fourslash/renameJsExports03.ts @@ -14,18 +14,18 @@ const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4] = test.ranges(); verify.referenceGroups([r0, r2], [ { definition: "class A", ranges: [r0, r2] }, - { definition: "const A: typeof A", ranges: [r3, r4] } + { definition: "(alias) class A\nimport A", ranges: [r3, r4] } ]); verify.referenceGroups(r1, [ { definition: "class A", ranges: [r1] }, - { definition: "const A: typeof A", ranges: [r4] } + { definition: "(alias) class A\nimport A", ranges: [r4] } ]); verify.referenceGroups(r3, [ - { definition: "const A: typeof A", ranges: [r3, r4] } + { definition: "(alias) class A\nimport A", ranges: [r3, r4] } ]); verify.referenceGroups(r4, [ - { definition: "const A: typeof A", ranges: [r3, r4] } + { definition: "(alias) class A\nimport A", ranges: [r3, r4] } ]);