Alias for commonjs require in JS (#39770)

* First attempt at aliases for require

* test+initial support for const x=require

* 1st round of baseline improvements

* 2nd round of baseline updates

* support property access after require

* check @type tag on require

* forbid expando missing namespaces on aliases

taken from #39558 as soon as it was created

* accept error baselines that are good, actually

* Scribbling on d.ts emit code

* use getSpecifierForModuleSymbol

* hideous hack for module.exports of aliases

* Fix module.exports.x --> export list emit

* fix isLocalImport predicate

* require only creates aliases in JS

* re-handle json imports

* update fourslash baseline

* Cleanup in the checker

1. Simplify alias resolution.
2. Simplify variable-like checking.
3. Make binding skip require calls with type tags -- they fall back to
the old require-call code and then check from there.

I haven't started on the declaration emit code since I don't know what
is going on there nearly as well.

* Function for getting module name from require call

* First round of cleanup plus a new test

Found one missing feature, not sure it's worth adding.

* more small cleanup

* more cleanup, including lint

* use trackSymbol, not serializeTypeForDeclaration

* Code review comments, plus remove unneeded code

Ad-hoc type reference resolution for `require` isn't needed anymore.

* find all refs works

* remove old ad-hoc code

* make it clear that old behaviour is not that correct

* update api baselines

* remove outdated comment

* PR feedback

1. Fix indentation
2. Add comment for exported JSON emit
3. Add test case for nested-namespace exports.

* add a fail-case test (which passes!)
This commit is contained in:
Nathan Shively-Sanders authored and GitHub committed 2020-08-17 14:00:37 -07:00
1 parent 97a072926f
commit c3d41bbb73
111 files changed
+1926 -526

No files matched your search

+4 -1
View File
@@ -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)) {
+151 -86
View File
@@ -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: <EntityNameExpression>}
*/
function isAliasSymbolDeclaration(node: Node): boolean {
return node.kind === SyntaxKind.ImportEqualsDeclaration ||
node.kind === SyntaxKind.NamespaceExportDeclaration ||
node.kind === SyntaxKind.ImportClause && !!(<ImportClause>node).name ||
node.kind === SyntaxKind.NamespaceImport ||
node.kind === SyntaxKind.NamespaceExport ||
node.kind === SyntaxKind.ImportSpecifier ||
node.kind === SyntaxKind.ExportSpecifier ||
node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(<ExportAssignment>node) ||
isBinaryExpression(node) && getAssignmentDeclarationKind(node) === AssignmentDeclarationKind.ModuleExports && exportAssignmentIsAlias(node) ||
isPropertyAccessExpression(node)
return node.kind === SyntaxKind.ImportEqualsDeclaration
|| node.kind === SyntaxKind.NamespaceExportDeclaration
|| node.kind === SyntaxKind.ImportClause && !!(<ImportClause>node).name
|| node.kind === SyntaxKind.NamespaceImport
|| node.kind === SyntaxKind.NamespaceExport
|| node.kind === SyntaxKind.ImportSpecifier
|| node.kind === SyntaxKind.ExportSpecifier
|| node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(<ExportAssignment>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(<ImportEqualsDeclaration>node, dontRecursivelyResolve);
case SyntaxKind.VariableDeclaration:
return getTargetOfImportEqualsDeclaration(node as ImportEqualsDeclaration | VariableDeclaration, dontRecursivelyResolve);
case SyntaxKind.ImportClause:
return getTargetOfImportClause(<ImportClause>node, dontRecursivelyResolve);
return getTargetOfImportClause(node as ImportClause, dontRecursivelyResolve);
case SyntaxKind.NamespaceImport:
return getTargetOfNamespaceImport(<NamespaceImport>node, dontRecursivelyResolve);
case SyntaxKind.NamespaceExport:
return getTargetOfNamespaceExport(<NamespaceExport>node, dontRecursivelyResolve);
case SyntaxKind.ImportSpecifier:
return getTargetOfImportSpecifier(<ImportSpecifier>node, dontRecursivelyResolve);
case SyntaxKind.BindingElement:
return getTargetOfImportSpecifier(node as ImportSpecifier | BindingElement, dontRecursivelyResolve);
case SyntaxKind.ExportSpecifier:
return getTargetOfExportSpecifier(<ExportSpecifier>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 {
+2 -1
View File
@@ -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.
+14 -1
View File
@@ -1856,6 +1856,11 @@ namespace ts {
return (<ExternalModuleReference>(<ImportEqualsDeclaration>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 && (<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) {
+4 -12
View File
@@ -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;
}
+10 -3
View File
@@ -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;
@@ -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;
@@ -2,8 +2,8 @@
/// <reference path="node.d.ts"/>
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"
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -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.
@@ -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))
@@ -1,8 +1,8 @@
=== tests/cases/conformance/salsa/use.js ===
/// <reference path='./types.d.ts'/>
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')
@@ -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 };
@@ -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
@@ -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; }
@@ -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"
@@ -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
}
]
}
]
@@ -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
}
]
}
]
@@ -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
}
]
}
]
@@ -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;
@@ -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
@@ -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");
@@ -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))
@@ -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"
@@ -43,5 +43,6 @@ declare class Obj {
//// [index.d.ts]
export = Container;
declare class Container {
usage: import("./obj");
usage: Obj;
}
import Obj = require("./obj");
@@ -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
}
}
@@ -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 {};
@@ -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))
@@ -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";
@@ -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]
@@ -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
@@ -13,7 +13,8 @@ const thing = new Something();
module.exports = {
thing
};
};
//// [index.js]
/// <reference types="node" />
@@ -26,4 +27,6 @@ module.exports = {
//// [index.d.ts]
/// <reference types="node" />
export const thing: import("fs").Something;
export const thing: Something;
import fs_1 = require("fs");
import Something = fs_1.Something;
@@ -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))
@@ -2,29 +2,30 @@
/// <reference types="node" />
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")
@@ -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
}
@@ -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;
@@ -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))
}
@@ -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
}
@@ -0,0 +1,34 @@
//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences3.ts] ////
//// [index.d.ts]
declare module "fs" {
export class Something {}
}
//// [index.js]
/// <reference types="node" />
const Something = require("fs").Something;
module.exports.A = {}
module.exports.A.B = {
thing: new Something()
}
//// [index.js]
/// <reference types="node" />
var Something = require("fs").Something;
module.exports.A = {};
module.exports.A.B = {
thing: new Something()
};
//// [index.d.ts]
/// <reference types="node" />
export namespace A {
namespace B {
const thing: Something;
}
}
import fs_1 = require("fs");
import Something = fs_1.Something;
@@ -0,0 +1,38 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
/// <reference types="node" />
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))
}
@@ -0,0 +1,44 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
/// <reference types="node" />
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
}
@@ -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) ====
/// <reference types="node" />
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 {}
}
@@ -0,0 +1,48 @@
//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences4.ts] ////
//// [index.d.ts]
declare module "fs" {
export class Something {}
}
//// [index.js]
/// <reference types="node" />
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;
/// <reference types="node" />
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]
/// <reference types="node" />
export const Something: 2;
export namespace A {
namespace B {
export { thing };
export const thing: import("fs").Something;
}
}
@@ -0,0 +1,37 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
/// <reference types="node" />
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))
}
@@ -0,0 +1,40 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
/// <reference types="node" />
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
}
@@ -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;
@@ -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 ===
@@ -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;
@@ -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 ===
@@ -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 */
@@ -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
@@ -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 ===
@@ -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
}
};
@@ -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
};
@@ -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
@@ -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 ===
@@ -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
@@ -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 ===
@@ -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
@@ -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 ===
@@ -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
@@ -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 ===
@@ -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
@@ -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 ===
@@ -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
@@ -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 ===
@@ -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();
@@ -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 ===
@@ -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"
@@ -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))
@@ -1,8 +1,8 @@
=== tests/cases/conformance/salsa/index.js ===
/// <reference path='node.d.ts' />
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;
@@ -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))
@@ -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
@@ -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))
@@ -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 };
@@ -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 ===
@@ -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 ===
@@ -1,8 +1,8 @@
=== tests/cases/conformance/salsa/a.js ===
/// <reference path='./requires.d.ts' />
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
@@ -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" };
@@ -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 ===
@@ -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);
@@ -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))
@@ -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
@@ -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 ===
@@ -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;
@@ -1,8 +1,8 @@
=== tests/cases/conformance/salsa/use.js ===
/// <reference path='./types.d.ts'/>
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 ===
@@ -1,8 +1,8 @@
=== tests/cases/conformance/salsa/index.js ===
/// <reference path='./types.d.ts'/>
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
@@ -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 = {}
@@ -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 ===
@@ -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 ===
@@ -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
}
@@ -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 ===
@@ -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
}
@@ -16,4 +16,4 @@ const thing = new Something();
module.exports = {
thing
};
};
@@ -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
};
@@ -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
/// <reference types="node" />
const Something = require("fs").Something;
module.exports.A = {}
module.exports.A.B = {
thing: new Something()
}
@@ -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
/// <reference types="node" />
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 };
}
}
@@ -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)
@@ -0,0 +1,14 @@
/// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: /a.js
//// function f() { }
//// export { f }
// @Filename: /b.js
//// const { f } = require('./a')
//// /**/f
verify.baselineFindAllReferences("");
@@ -0,0 +1,14 @@
/// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: /a.js
//// function f() { }
//// module.exports.f = f
// @Filename: /b.js
//// const { f } = require('./a')
//// /**/f
verify.baselineFindAllReferences("");
Loaded 100 of 111 files, more files were not shown because too many files have changed in this diff. Show more