Allow allowJs and declaration to be used together (#32372)

* Allow allowJs and declaration to be used together

This intorduces a new symbol-based declaration emitter - currently this
is only used for JSON and JavaScript, as the output is likely worse than
what the other declaration emitter is capable of. In addition, it is
still incomplete - it does not yet support serializaing namespaces.

* Add tests for various import/export forms, add notes on export as namespace and fix export * from

* Tests & fixes for computed names

* Add test with current @enum tag behavior

* fix declaration emit for jsdoc @enum tags

* Small adjustments to base class serialization to fix bugs in it

* Guard against type/type parameter confusion when using typeParameterToName a bit

* Integrate feedback from PR

* Fix issue with export= declarations visibility calculation and type declaration emit that impacted all forms of declaration emit

* Only make one merged getCommonJsExportEquals symbol for a symbol

* Support preserving type reference directives in js declarations

* Skip declare mdoifiers for namespace members in ambient contexts

* FAKE ALIASES AND NAMESPACES EVERYWHERE

* Dont do namespace sugar when type members contain keyword names

* Fix json source file export modifier under new output

* Such clean nested aliasing, very wow

* Fix lint

* Add visibility errors, reuse type nodes where possible

* Suppoer having correctly named import types in bundled js declaration emit & adjust binding to allow namespaces with aliases to merge when the aliases look to be type-only

* Better support for module.exports = class expression

* Fix discovered crash bug

* Allow export assigned class expressions to be reachable symbols from external declarations

* Add missing semicolon

* Support @enum tag post-merge

* preserve comments on signatures and declarations where possible

* Basic support for js classy functions

* Add example we should do better with

* Prototype assignments make things a bit wonky, but the example from the PR seems OK

* Make a ton of changes to support the new way js classes are bound

* Remove some old comments, fix import and export default names

* Fix bug in object define handling and add tests for object define property declaration emit

* Fix organization nits from PR comments

* Preserve comments from jsdoc declarations on properties and js declaration type aliases

* Merge export declarations with identical specifiers

* Remove completed TODO comment

* Split lint

* Remove now-unused function

* PR feedback

* Add some project references tests, remove some checks from project refs codepaths that are now invalid

* Update project references tests again

* Merge and update project references tests

* Rename case

* Update test to include declaration output

* Remove yet another project refernces redirect extension check

* Update comment

* Add additional import ref to test

* Add shorthand prop to test

* Fix comment text

* Extract var to temp

* Simplify function and add whitespace

* Update project refs test to use incremental edit entry

* Stylistic refactors in the symbol serializer

* Another round of PR feedback, mostly style, small bugfix with constructors, and test showing bug in export assigned class expression name shadowing

* Use x instead of index
This commit is contained in:
Wesley Wigham authored and GitHub committed 2019-09-26 14:27:16 -07:00
1 parent 62a43576b3
commit 61cb06ce40
304 files changed
+17585 -475

No files matched your search

+69 -8
View File
@@ -13,11 +13,26 @@ namespace ts {
referenced: boolean;
}
export function getModuleInstanceState(node: ModuleDeclaration): ModuleInstanceState {
return node.body ? getModuleInstanceStateWorker(node.body) : ModuleInstanceState.Instantiated;
export function getModuleInstanceState(node: ModuleDeclaration, visited?: Map<ModuleInstanceState | undefined>): ModuleInstanceState {
if (node.body && !node.body.parent) {
// getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already
setParentPointers(node, node.body);
}
return node.body ? getModuleInstanceStateCached(node.body, visited) : ModuleInstanceState.Instantiated;
}
function getModuleInstanceStateWorker(node: Node): ModuleInstanceState {
function getModuleInstanceStateCached(node: Node, visited = createMap<ModuleInstanceState | undefined>()) {
const nodeId = "" + getNodeId(node);
if (visited.has(nodeId)) {
return visited.get(nodeId) || ModuleInstanceState.NonInstantiated;
}
visited.set(nodeId, undefined);
const result = getModuleInstanceStateWorker(node, visited);
visited.set(nodeId, result);
return result;
}
function getModuleInstanceStateWorker(node: Node, visited: Map<ModuleInstanceState | undefined>): ModuleInstanceState {
// A module is uninstantiated if it contains only
switch (node.kind) {
// 1. interface declarations, type alias declarations
@@ -37,11 +52,27 @@ namespace ts {
return ModuleInstanceState.NonInstantiated;
}
break;
// 4. other uninstantiated module declarations.
// 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain
case SyntaxKind.ExportDeclaration:
if (!(node as ExportDeclaration).moduleSpecifier && !!(node as ExportDeclaration).exportClause) {
let state = ModuleInstanceState.NonInstantiated;
for (const specifier of (node as ExportDeclaration).exportClause!.elements) {
const specifierState = getModuleInstanceStateForAliasTarget(specifier, visited);
if (specifierState > state) {
state = specifierState;
}
if (state === ModuleInstanceState.Instantiated) {
return state;
}
}
return state;
}
break;
// 5. other uninstantiated module declarations.
case SyntaxKind.ModuleBlock: {
let state = ModuleInstanceState.NonInstantiated;
forEachChild(node, n => {
const childState = getModuleInstanceStateWorker(n);
const childState = getModuleInstanceStateCached(n, visited);
switch (childState) {
case ModuleInstanceState.NonInstantiated:
// child is non-instantiated - continue searching
@@ -61,7 +92,7 @@ namespace ts {
return state;
}
case SyntaxKind.ModuleDeclaration:
return getModuleInstanceState(node as ModuleDeclaration);
return getModuleInstanceState(node as ModuleDeclaration, visited);
case SyntaxKind.Identifier:
// Only jsdoc typedef definition can exist in jsdoc namespace, and it should
// be considered the same as type alias
@@ -72,6 +103,36 @@ namespace ts {
return ModuleInstanceState.Instantiated;
}
function getModuleInstanceStateForAliasTarget(specifier: ExportSpecifier, visited: Map<ModuleInstanceState | undefined>) {
const name = specifier.propertyName || specifier.name;
let p: Node | undefined = specifier.parent;
while (p) {
if (isBlock(p) || isModuleBlock(p) || isSourceFile(p)) {
const statements = p.statements;
let found: ModuleInstanceState | undefined;
for (const statement of statements) {
if (nodeHasName(statement, name)) {
if (!statement.parent) {
setParentPointers(p, statement);
}
const state = getModuleInstanceStateCached(statement, visited);
if (found === undefined || state > found) {
found = state;
}
if (found === ModuleInstanceState.Instantiated) {
return found;
}
}
}
if (found !== undefined) {
return found;
}
}
p = p.parent;
}
return ModuleInstanceState.Instantiated; // Couldn't locate, assume could refer to a value
}
const enum ContainerFlags {
// The current node is not a container, and no container manipulation should happen before
// recursing into it.
@@ -2561,7 +2622,7 @@ namespace ts {
// Declare a 'member' if the container is an ES5 class or ES6 constructor
constructorSymbol.members = constructorSymbol.members || createSymbolTable();
// It's acceptable for multiple 'this' assignments of the same identifier to occur
declareSymbol(constructorSymbol.members, constructorSymbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property);
declareSymbol(constructorSymbol.members, constructorSymbol, node, SymbolFlags.Property | SymbolFlags.Assignment, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property);
addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, SymbolFlags.Class);
}
break;
@@ -2575,7 +2636,7 @@ namespace ts {
// Bind this property to the containing class
const containingClass = thisContainer.parent;
const symbolTable = hasModifier(thisContainer, ModifierFlags.Static) ? containingClass.symbol.exports! : containingClass.symbol.members!;
declareSymbol(symbolTable, containingClass.symbol, node, SymbolFlags.Property, SymbolFlags.None, /*isReplaceableByMethod*/ true);
declareSymbol(symbolTable, containingClass.symbol, node, SymbolFlags.Property | SymbolFlags.Assignment, SymbolFlags.None, /*isReplaceableByMethod*/ true);
break;
case SyntaxKind.SourceFile:
// this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script
+1423 -63
View File
File diff suppressed because it is too large. Load diff
+8
View File
@@ -1552,6 +1552,14 @@ namespace ts {
return fn ? fn.bind(obj) : undefined;
}
export function mapMap<T, U>(map: Map<T>, f: (t: T, key: string) => [string, U]): Map<U>;
export function mapMap<T, U>(map: UnderscoreEscapedMap<T>, f: (t: T, key: __String) => [string, U]): Map<U>;
export function mapMap<T, U>(map: Map<T> | UnderscoreEscapedMap<T>, f: ((t: T, key: string) => [string, U]) | ((t: T, key: __String) => [string, U])): Map<U> {
const result = createMap<U>();
map.forEach((t: T, key: string & __String) => result.set(...(f(t, key))));
return result;
}
export interface MultiMap<T> extends Map<T[]> {
/**
* Adds the value to an array of values associated with the key, and returns the array.
+8
View File
@@ -4587,6 +4587,14 @@
"category": "Error",
"code": 9004
},
"Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit.": {
"category": "Error",
"code": 9005
},
"Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit.": {
"category": "Error",
"code": 9006
},
"JSX attributes must only be assigned a non-empty 'expression'.": {
"category": "Error",
"code": 17000
+8 -10
View File
@@ -96,9 +96,7 @@ namespace ts {
comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === Comparison.EqualTo;
const jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath;
const sourceMapFilePath = !jsFilePath || isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options);
// For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error
const isJs = isSourceFileJS(sourceFile);
const declarationFilePath = ((forceDtsPaths || getEmitDeclarations(options)) && !isJs) ? getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined;
const declarationFilePath = (forceDtsPaths || getEmitDeclarations(options)) ? getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined;
const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath: undefined };
}
@@ -146,7 +144,7 @@ namespace ts {
/* @internal */
export function getOutputDeclarationFileName(inputFileName: string, configFile: ParsedCommandLine, ignoreCase: boolean) {
Debug.assert(!fileExtensionIs(inputFileName, Extension.Dts) && hasTSFileExtension(inputFileName));
Debug.assert(!fileExtensionIs(inputFileName, Extension.Dts));
return changeExtension(
getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir),
Extension.Dts
@@ -199,7 +197,7 @@ namespace ts {
if (js && configFile.options.sourceMap) {
addOutput(`${js}.map`);
}
if (getEmitDeclarations(configFile.options) && hasTSFileExtension(inputFileName)) {
if (getEmitDeclarations(configFile.options)) {
const dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
addOutput(dts);
if (configFile.options.declarationMap) {
@@ -248,7 +246,7 @@ namespace ts {
const jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase);
if (jsFilePath) return jsFilePath;
if (fileExtensionIs(inputFileName, Extension.Json)) continue;
if (getEmitDeclarations(configFile.options) && hasTSFileExtension(inputFileName)) {
if (getEmitDeclarations(configFile.options)) {
return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
}
}
@@ -395,17 +393,16 @@ namespace ts {
declarationFilePath: string | undefined,
declarationMapPath: string | undefined,
relativeToBuildInfo: (path: string) => string) {
if (!sourceFileOrBundle || !(declarationFilePath && !isInJSFile(sourceFileOrBundle))) {
if (!sourceFileOrBundle || !declarationFilePath) {
return;
}
const sourceFiles = isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles;
// Setup and perform the transformation to retrieve declarations from the input files
const nonJsFiles = filter(sourceFiles, isSourceFileNotJS);
const inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [createBundle(nonJsFiles, !isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles;
const inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [createBundle(sourceFiles, !isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles;
if (emitOnlyDtsFiles && !getEmitDeclarations(compilerOptions)) {
// Checker wont collect the linked aliases since thats only done when declaration is enabled.
// Do that here when emitting only dts files
nonJsFiles.forEach(collectLinkedAliases);
sourceFiles.forEach(collectLinkedAliases);
}
const declarationTransform = transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false);
if (length(declarationTransform.diagnostics)) {
@@ -659,6 +656,7 @@ namespace ts {
getAllAccessorDeclarations: notImplemented,
getSymbolOfExternalModuleSpecifier: notImplemented,
isBindingCapturedByNode: notImplemented,
getDeclarationStatementsForSourceFile: notImplemented,
};
/*@internal*/
+5
View File
@@ -2259,6 +2259,11 @@ namespace ts {
: node;
}
/* @internal */
export function createEmptyExports() {
return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined);
}
export function createNamedExports(elements: readonly ExportSpecifier[]) {
const node = <NamedExports>createSynthesizedNode(SyntaxKind.NamedExports);
node.elements = createNodeArray(elements);
+4 -11
View File
@@ -856,7 +856,7 @@ namespace ts {
}
else if (getEmitModuleKind(parsedRef.commandLine.options) === ModuleKind.None) {
for (const fileName of parsedRef.commandLine.fileNames) {
if (!fileExtensionIs(fileName, Extension.Dts) && hasTSFileExtension(fileName)) {
if (!fileExtensionIs(fileName, Extension.Dts)) {
processSourceFile(getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined);
}
}
@@ -2448,8 +2448,8 @@ namespace ts {
}
function getProjectReferenceRedirectProject(fileName: string) {
// Ignore dts or any of the non ts files
if (!resolvedProjectReferences || !resolvedProjectReferences.length || fileExtensionIs(fileName, Extension.Dts) || !fileExtensionIsOneOf(fileName, supportedTSExtensions)) {
// Ignore dts
if (!resolvedProjectReferences || !resolvedProjectReferences.length || fileExtensionIs(fileName, Extension.Dts)) {
return undefined;
}
@@ -2510,7 +2510,7 @@ namespace ts {
}
else {
forEach(resolvedRef.commandLine.fileNames, fileName => {
if (!fileExtensionIs(fileName, Extension.Dts) && hasTSFileExtension(fileName)) {
if (!fileExtensionIs(fileName, Extension.Dts)) {
const outputDts = getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames());
mapFromToProjectReferenceRedirectSource!.set(toPath(outputDts), fileName);
}
@@ -3077,10 +3077,6 @@ namespace ts {
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
}
if (!options.noEmit && options.allowJs && getEmitDeclarations(options)) {
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options));
}
if (options.checkJs && !options.allowJs) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs"));
}
@@ -3425,9 +3421,6 @@ namespace ts {
return resolveConfigFileProjectName(passedInRef.path);
}
function getEmitDeclarationOptionName(options: CompilerOptions) {
return options.declaration ? "declaration" : "composite";
}
/* @internal */
/**
* Returns a DiagnosticMessage if we won't include a resolved module due to its extension.
+30 -26
View File
@@ -1,11 +1,8 @@
/*@internal*/
namespace ts {
export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, file: SourceFile | undefined): DiagnosticWithLocation[] | undefined {
if (file && isSourceFileJS(file)) {
return []; // No declaration diagnostics for js for now
}
const compilerOptions = host.getCompilerOptions();
const result = transformNodes(resolver, host, compilerOptions, file ? [file] : filter(host.getSourceFiles(), isSourceFileNotJS), [transformDeclarations], /*allowDtsFiles*/ false);
const result = transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false);
return result.diagnostics;
}
@@ -190,15 +187,24 @@ namespace ts {
}
}
function createEmptyExports() {
return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined);
function transformDeclarationsForJS(sourceFile: SourceFile, bundled?: boolean) {
const oldDiag = getSymbolAccessibilityDiagnostic;
getSymbolAccessibilityDiagnostic = (s) => ({
diagnosticMessage: s.errorModuleName
? Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit
: Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit,
errorNode: s.errorNode || sourceFile
});
const result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled);
getSymbolAccessibilityDiagnostic = oldDiag;
return result;
}
function transformRoot(node: Bundle): Bundle;
function transformRoot(node: SourceFile): SourceFile;
function transformRoot(node: SourceFile | Bundle): SourceFile | Bundle;
function transformRoot(node: SourceFile | Bundle) {
if (node.kind === SyntaxKind.SourceFile && (node.isDeclarationFile || isSourceFileJS(node))) {
if (node.kind === SyntaxKind.SourceFile && node.isDeclarationFile) {
return node;
}
@@ -209,7 +215,7 @@ namespace ts {
let hasNoDefaultLib = false;
const bundle = createBundle(map(node.sourceFiles,
sourceFile => {
if (sourceFile.isDeclarationFile || isSourceFileJS(sourceFile)) return undefined!; // Omit declaration files from bundle results, too // TODO: GH#18217
if (sourceFile.isDeclarationFile) return undefined!; // Omit declaration files from bundle results, too // TODO: GH#18217
hasNoDefaultLib = hasNoDefaultLib || sourceFile.hasNoDefaultLib;
currentSourceFile = sourceFile;
enclosingDeclaration = sourceFile;
@@ -221,10 +227,10 @@ namespace ts {
resultHasScopeMarker = false;
collectReferences(sourceFile, refs);
collectLibs(sourceFile, libs);
if (isExternalModule(sourceFile)) {
if (isExternalOrCommonJsModule(sourceFile) || isJsonSourceFile(sourceFile)) {
resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules)
needsDeclare = false;
const statements = visitNodes(sourceFile.statements, visitDeclarationStatements);
const statements = isSourceFileJS(sourceFile) ? createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : visitNodes(sourceFile.statements, visitDeclarationStatements);
const newFile = updateSourceFileNode(sourceFile, [createModuleDeclaration(
[],
[createModifier(SyntaxKind.DeclareKeyword)],
@@ -234,7 +240,7 @@ namespace ts {
return newFile;
}
needsDeclare = true;
const updated = visitNodes(sourceFile.statements, visitDeclarationStatements);
const updated = isSourceFileJS(sourceFile) ? createNodeArray(transformDeclarationsForJS(sourceFile)) : visitNodes(sourceFile.statements, visitDeclarationStatements);
return updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []);
}
), mapDefined(node.prepends, prepend => {
@@ -276,12 +282,19 @@ namespace ts {
const references: FileReference[] = [];
const outputFilePath = getDirectoryPath(normalizeSlashes(getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath!));
const referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
const statements = visitNodes(node.statements, visitDeclarationStatements);
let combinedStatements = setTextRange(createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
refs.forEach(referenceVisitor);
emittedImports = filter(combinedStatements, isAnyImportSyntax);
if (isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) {
combinedStatements = setTextRange(createNodeArray([...combinedStatements, createEmptyExports()]), combinedStatements);
let combinedStatements: NodeArray<Statement>;
if (isSourceFileJS(currentSourceFile)) {
combinedStatements = createNodeArray(transformDeclarationsForJS(node));
emittedImports = filter(combinedStatements, isAnyImportSyntax);
}
else {
const statements = visitNodes(node.statements, visitDeclarationStatements);
combinedStatements = setTextRange(createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
refs.forEach(referenceVisitor);
emittedImports = filter(combinedStatements, isAnyImportSyntax);
if (isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) {
combinedStatements = setTextRange(createNodeArray([...combinedStatements, createEmptyExports()]), combinedStatements);
}
}
const updated = updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences());
updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit;
@@ -755,15 +768,6 @@ namespace ts {
}
}
function isExternalModuleIndicator(result: LateVisibilityPaintedStatement | ExportAssignment) {
// Exported top-level member indicates moduleness
return isAnyImportOrReExport(result) || isExportAssignment(result) || hasModifier(result, ModifierFlags.Export);
}
function needsScopeMarker(result: LateVisibilityPaintedStatement | ExportAssignment) {
return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasModifier(result, ModifierFlags.Export) && !isAmbientModule(result);
}
function visitDeclarationSubtree(input: Node): VisitResult<Node> {
if (shouldStripInternal(input)) return;
if (isDeclaration(input)) {
+9 -1
View File
@@ -3734,6 +3734,7 @@ namespace ts {
getAllAccessorDeclarations(declaration: AccessorDeclaration): AllAccessorDeclarations;
getSymbolOfExternalModuleSpecifier(node: StringLiteralLike): Symbol | undefined;
isBindingCapturedByNode(node: Node, decl: VariableDeclaration | BindingElement): boolean;
getDeclarationStatementsForSourceFile(node: SourceFile, flags: NodeBuilderFlags, tracker: SymbolTracker, bundled?: boolean): Statement[] | undefined;
}
export const enum SymbolFlags {
@@ -3814,6 +3815,12 @@ namespace ts {
ClassMember = Method | Accessor | Property,
/* @internal */
ExportSupportsDefaultModifier = Class | Function | Interface,
/* @internal */
ExportDoesNotSupportDefaultModifier = ~ExportSupportsDefaultModifier,
/* @internal */
// The set of things we consider semantically classifiable. Used to speed up the LS during
// classification.
@@ -3877,6 +3884,7 @@ namespace ts {
variances?: VarianceFlags[]; // Alias symbol type argument variance cache
deferralConstituents?: Type[]; // Calculated list of constituents for a deferred type
deferralParent?: Type; // Source union/intersection of a deferred type
cjsExportMerged?: Symbol; // Version of the symbol with all non export= exports merged with the export= target
}
/* @internal */
@@ -6024,7 +6032,7 @@ namespace ts {
// Called when the symbol writer encounters a symbol to write. Currently only used by the
// declaration emitter to help determine if it should patch up the final declaration file
// with import statements it previously saw (but chose not to emit).
trackSymbol?(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void;
trackSymbol?(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags): void;
reportInaccessibleThisError?(): void;
reportPrivateInBaseOfClassExpression?(propertyName: string): void;
reportInaccessibleUniqueSymbolError?(): void;
+68 -7
View File
@@ -2606,6 +2606,8 @@ namespace ts {
// export = <EntityNameExpression>
// export default <EntityNameExpression>
// module.exports = <EntityNameExpression>
// {<Identifier>}
// {name: <EntityNameExpression>}
export function isAliasSymbolDeclaration(node: Node): boolean {
return node.kind === SyntaxKind.ImportEqualsDeclaration ||
node.kind === SyntaxKind.NamespaceExportDeclaration ||
@@ -2614,12 +2616,28 @@ namespace ts {
node.kind === SyntaxKind.ImportSpecifier ||
node.kind === SyntaxKind.ExportSpecifier ||
node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(<ExportAssignment>node) ||
isBinaryExpression(node) && getAssignmentDeclarationKind(node) === AssignmentDeclarationKind.ModuleExports && exportAssignmentIsAlias(node);
isBinaryExpression(node) && getAssignmentDeclarationKind(node) === AssignmentDeclarationKind.ModuleExports && exportAssignmentIsAlias(node) ||
isPropertyAccessExpression(node) && isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === SyntaxKind.EqualsToken && isAliasableExpression(node.parent.right) ||
node.kind === SyntaxKind.ShorthandPropertyAssignment ||
node.kind === SyntaxKind.PropertyAssignment && isAliasableExpression((node as PropertyAssignment).initializer);
}
function isAliasableExpression(e: Expression) {
return isEntityNameExpression(e) || isClassExpression(e);
}
export function exportAssignmentIsAlias(node: ExportAssignment | BinaryExpression): boolean {
const e = isExportAssignment(node) ? node.expression : node.right;
return isEntityNameExpression(e) || isClassExpression(e);
const e = getExportAssignmentExpression(node);
return isAliasableExpression(e);
}
export function getExportAssignmentExpression(node: ExportAssignment | BinaryExpression): Expression {
return isExportAssignment(node) ? node.expression : node.right;
}
export function getPropertyAssignmentAliasLikeExpression(node: PropertyAssignment | ShorthandPropertyAssignment | PropertyAccessExpression): Expression {
return node.kind === SyntaxKind.ShorthandPropertyAssignment ? node.name : node.kind === SyntaxKind.PropertyAssignment ? node.initializer :
(node.parent as BinaryExpression).right;
}
export function getEffectiveBaseTypeNode(node: ClassLikeDeclaration | InterfaceDeclaration) {
@@ -2699,6 +2717,11 @@ namespace ts {
return token !== undefined && isNonContextualKeyword(token);
}
export function isStringAKeyword(name: string) {
const token = stringToToken(name);
return token !== undefined && isKeyword(token);
}
export function isIdentifierANonContextualKeyword({ originalKeywordKind }: Identifier): boolean {
return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind);
}
@@ -3450,11 +3473,17 @@ namespace ts {
};
}
export function getResolvedExternalModuleName(host: EmitHost, file: SourceFile, referenceFile?: SourceFile): string {
export interface ResolveModuleNameResolutionHost {
getCanonicalFileName(p: string): string;
getCommonSourceDirectory(): string;
getCurrentDirectory(): string;
}
export function getResolvedExternalModuleName(host: ResolveModuleNameResolutionHost, file: SourceFile, referenceFile?: SourceFile): string {
return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
}
export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode): string | undefined {
export function getExternalModuleNameFromDeclaration(host: ResolveModuleNameResolutionHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode): string | undefined {
const file = resolver.getExternalModuleFileFromDeclaration(declaration);
if (!file || file.isDeclarationFile) {
return undefined;
@@ -3465,7 +3494,7 @@ namespace ts {
/**
* Resolves a local path to a path which is absolute to the base of the emit
*/
export function getExternalModuleNameFromPath(host: EmitHost, fileName: string, referencePath?: string): string {
export function getExternalModuleNameFromPath(host: ResolveModuleNameResolutionHost, fileName: string, referencePath?: string): string {
const getCanonicalFileName = (f: string) => host.getCanonicalFileName(f);
const dir = toPath(referencePath ? getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
const filePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
@@ -5224,6 +5253,17 @@ namespace ts {
return name && isIdentifier(name) ? name : undefined;
}
/** @internal */
export function nodeHasName(statement: Node, name: Identifier) {
if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name as Identifier) === idText(name)) {
return true;
}
if (isVariableStatement(statement) && some(statement.declarationList.declarations, d => nodeHasName(d, name))) {
return true;
}
return false;
}
export function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined {
return declaration.name || nameForNamelessJSDocTypedef(declaration);
}
@@ -6145,7 +6185,7 @@ namespace ts {
return node.kind === SyntaxKind.JSDocTypeExpression;
}
export function isJSDocAllType(node: JSDocAllType): node is JSDocAllType {
export function isJSDocAllType(node: Node): node is JSDocAllType {
return node.kind === SyntaxKind.JSDocAllType;
}
@@ -6762,6 +6802,27 @@ namespace ts {
return false;
}
/* @internal */
export function isScopeMarker(node: Node) {
return isExportAssignment(node) || isExportDeclaration(node);
}
/* @internal */
export function hasScopeMarker(statements: readonly Statement[]) {
return some(statements, isScopeMarker);
}
/* @internal */
export function needsScopeMarker(result: Statement) {
return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasModifier(result, ModifierFlags.Export) && !isAmbientModule(result);
}
/* @internal */
export function isExternalModuleIndicator(result: Statement) {
// Exported top-level member indicates moduleness
return isAnyImportOrReExport(result) || isExportAssignment(result) || hasModifier(result, ModifierFlags.Export);
}
/* @internal */
export function isForInOrOfStatement(node: Node): node is ForInOrOfStatement {
return node.kind === SyntaxKind.ForInStatement || node.kind === SyntaxKind.ForOfStatement;
+13 -8
View File
@@ -219,14 +219,19 @@ namespace compiler {
return vpath.changeExtension(path, ext);
}
public getNumberOfJsFiles() {
let count = this.js.size;
this.js.forEach(document => {
if (ts.fileExtensionIs(document.file, ts.Extension.Json)) {
count--;
}
});
return count;
public getNumberOfJsFiles(includeJson: boolean) {
if (includeJson) {
return this.js.size;
}
else {
let count = this.js.size;
this.js.forEach(document => {
if (ts.fileExtensionIs(document.file, ts.Extension.Json)) {
count--;
}
});
return count;
}
}
}
+3 -3
View File
@@ -888,7 +888,7 @@ namespace Harness {
throw new Error("Only declaration files should be generated when emitDeclarationOnly:true");
}
}
else if (result.dts.size !== result.getNumberOfJsFiles()) {
else if (result.dts.size !== result.getNumberOfJsFiles(/*includeJson*/ true)) {
throw new Error("There were no errors and declFiles generated did not match number of js files generated");
}
}
@@ -907,7 +907,7 @@ namespace Harness {
if (vpath.isDeclaration(file.unitName) || vpath.isJson(file.unitName)) {
dtsFiles.push(file);
}
else if (vpath.isTypeScript(file.unitName)) {
else if (vpath.isTypeScript(file.unitName) || (vpath.isJavaScript(file.unitName) && options.allowJs)) {
const declFile = findResultCodeFile(file.unitName);
if (declFile && !findUnit(declFile.file, declInputFiles) && !findUnit(declFile.file, declOtherFiles)) {
dtsFiles.push({ unitName: declFile.file, content: utils.removeByteOrderMark(declFile.text) });
@@ -1269,7 +1269,7 @@ namespace Harness {
return;
}
else if (options.sourceMap || declMaps) {
if (result.maps.size !== (result.getNumberOfJsFiles() * (declMaps && options.sourceMap ? 2 : 1))) {
if (result.maps.size !== ((options.sourceMap ? result.getNumberOfJsFiles(/*includeJson*/ false) : 0) + (declMaps ? result.getNumberOfJsFiles(/*includeJson*/ true) : 0))) {
throw new Error("Number of sourcemap files should be same as js files.");
}
+1 -2
View File
@@ -1971,8 +1971,7 @@ namespace ts {
const notAccessible = () => { typeIsAccessible = false; };
const res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, {
trackSymbol: (symbol, declaration, meaning) => {
// TODO: GH#18217
typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning!, /*shouldComputeAliasToMarkVisible*/ false).accessibility === SymbolAccessibility.Accessible;
typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === SymbolAccessibility.Accessible;
},
reportInaccessibleThisError: notAccessible,
reportPrivateInBaseOfClassExpression: notAccessible,
+1
View File
@@ -99,6 +99,7 @@
"unittests/tsbuild/emptyFiles.ts",
"unittests/tsbuild/graphOrdering.ts",
"unittests/tsbuild/inferredTypeFromTransitiveModule.ts",
"unittests/tsbuild/javascriptProjectEmit.ts",
"unittests/tsbuild/lateBoundSymbol.ts",
"unittests/tsbuild/missingExtendedFile.ts",
"unittests/tsbuild/moduleSpecifiers.ts",
@@ -0,0 +1,286 @@
namespace ts {
describe("unittests:: tsbuild:: javascriptProjectEmit:: loads js-based projects and emits them correctly", () => {
verifyTsc({
scenario: "javascriptProjectEmit",
subScenario: `loads js-based projects and emits them correctly`,
fs: () => loadProjectFromFiles({
"/src/common/nominal.js": utils.dedent`
/**
* @template T, Name
* @typedef {T & {[Symbol.species]: Name}} Nominal
*/
module.exports = {};
`,
"/src/common/tsconfig.json": utils.dedent`
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"composite": true
},
"include": ["nominal.js"]
}`,
"/src/sub-project/index.js": utils.dedent`
import { Nominal } from '../common/nominal';
/**
* @typedef {Nominal<string, 'MyNominal'>} MyNominal
*/
`,
"/src/sub-project/tsconfig.json": utils.dedent`
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"composite": true
},
"references": [
{ "path": "../common" }
],
"include": ["./index.js"]
}`,
"/src/sub-project-2/index.js": utils.dedent`
import { MyNominal } from '../sub-project/index';
const variable = {
key: /** @type {MyNominal} */('value'),
};
/**
* @return {keyof typeof variable}
*/
export function getVar() {
return 'key';
}
`,
"/src/sub-project-2/tsconfig.json": utils.dedent`
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"composite": true
},
"references": [
{ "path": "../sub-project" }
],
"include": ["./index.js"]
}`,
"/src/tsconfig.json": utils.dedent`
{
"compilerOptions": {
"composite": true
},
"references": [
{ "path": "./sub-project" },
{ "path": "./sub-project-2" }
],
"include": []
}`,
"/src/tsconfig.base.json": utils.dedent`
{
"compilerOptions": {
"skipLibCheck": true,
"rootDir": "./",
"outDir": "../lib",
"allowJs": true,
"checkJs": true,
"declaration": true
}
}`,
}, symbolLibContent),
commandLineArgs: ["-b", "/src"]
});
});
describe("unittests:: tsbuild:: javascriptProjectEmit:: loads outfile js projects and concatenates them correctly", () => {
let projFs: vfs.FileSystem;
before(() => {
projFs = loadProjectFromFiles({
"/src/common/nominal.js": utils.dedent`
/**
* @template T, Name
* @typedef {T & {[Symbol.species]: Name}} Nominal
*/
`,
"/src/common/tsconfig.json": utils.dedent`
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outFile": "common.js"
},
"include": ["nominal.js"]
}`,
"/src/sub-project/index.js": utils.dedent`
/**
* @typedef {Nominal<string, 'MyNominal'>} MyNominal
*/
const c = /** @type {*} */(null);
`,
"/src/sub-project/tsconfig.json": utils.dedent`
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outFile": "sub-project.js"
},
"references": [
{ "path": "../common", "prepend": true }
],
"include": ["./index.js"]
}`,
"/src/sub-project-2/index.js": utils.dedent`
const variable = {
key: /** @type {MyNominal} */('value'),
};
/**
* @return {keyof typeof variable}
*/
function getVar() {
return 'key';
}
`,
"/src/sub-project-2/tsconfig.json": utils.dedent`
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outFile": "sub-project-2.js"
},
"references": [
{ "path": "../sub-project", "prepend": true }
],
"include": ["./index.js"]
}`,
"/src/tsconfig.json": utils.dedent`
{
"compilerOptions": {
"composite": true,
"outFile": "src.js"
},
"references": [
{ "path": "./sub-project", "prepend": true },
{ "path": "./sub-project-2", "prepend": true }
],
"include": []
}`,
"/src/tsconfig.base.json": utils.dedent`
{
"compilerOptions": {
"skipLibCheck": true,
"rootDir": "./",
"allowJs": true,
"checkJs": true,
"declaration": true
}
}`,
}, symbolLibContent);
});
after(() => {
projFs = undefined!;
});
verifyTsc({
scenario: "javascriptProjectEmit",
subScenario: `loads outfile js projects and concatenates them correctly`,
fs: () => projFs,
commandLineArgs: ["-b", "/src"]
});
verifyTscIncrementalEdits({
scenario: "javascriptProjectEmit",
subScenario: `modifies outfile js projects and concatenates them correctly`,
fs: () => projFs,
commandLineArgs: ["-b", "/src"],
incrementalScenarios: [{
buildKind: BuildKind.IncrementalDtsUnchanged,
modifyFs: fs => replaceText(fs, "/src/sub-project/index.js", "null", "undefined")
}]
});
});
describe("unittests:: tsbuild:: javascriptProjectEmit:: loads js-based projects with non-moved json files and emits them correctly", () => {
verifyTsc({
scenario: "javascriptProjectEmit",
subScenario: `loads js-based projects with non-moved json files and emits them correctly`,
fs: () => loadProjectFromFiles({
"/src/common/obj.json": utils.dedent`
{
"val": 42
}`,
"/src/common/index.ts": utils.dedent`
import x = require("./obj.json");
export = x;
`,
"/src/common/tsconfig.json": utils.dedent`
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": null
"composite": true
},
"include": ["index.ts", "obj.json"]
}`,
"/src/sub-project/index.js": utils.dedent`
import mod from '../common';
export const m = mod;
`,
"/src/sub-project/tsconfig.json": utils.dedent`
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"composite": true
},
"references": [
{ "path": "../common" }
],
"include": ["./index.js"]
}`,
"/src/sub-project-2/index.js": utils.dedent`
import { m } from '../sub-project/index';
const variable = {
key: m,
};
export function getVar() {
return variable;
}
`,
"/src/sub-project-2/tsconfig.json": utils.dedent`
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"composite": true
},
"references": [
{ "path": "../sub-project" }
],
"include": ["./index.js"]
}`,
"/src/tsconfig.json": utils.dedent`
{
"compilerOptions": {
"composite": true
},
"references": [
{ "path": "./sub-project" },
{ "path": "./sub-project-2" }
],
"include": []
}`,
"/src/tsconfig.base.json": utils.dedent`
{
"compilerOptions": {
"skipLibCheck": true,
"rootDir": "./",
"outDir": "../out",
"allowJs": true,
"checkJs": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"declaration": true
}
}`,
}, symbolLibContent),
commandLineArgs: ["-b", "/src"]
});
});
}
@@ -52,7 +52,12 @@ namespace ts {
export default hello.hello`);
const allExpectedOutputs = ["/src/dist/src/index.js", "/src/dist/src/index.d.ts", "/src/dist/src/index.json"];
verifyProjectWithResolveJsonModuleWithFs(fs, "/src/tsconfig_withIncludeOfJson.json", allExpectedOutputs);
verifyProjectWithResolveJsonModuleWithFs(
fs,
"/src/tsconfig_withIncludeOfJson.json",
allExpectedOutputs,
errorDiagnostic([Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, "/src/dist/src/index.d.ts"])
);
});
it("with resolveJsonModule and files containing json file", () => {
@@ -885,8 +885,8 @@ namespace ts.tscWatch {
// More comment`;
const configFileContentAfterComment = `
"compilerOptions": {
"allowJs": true,
"declaration": true
"inlineSourceMap": true,
"mapRoot": "./"
}
}`;
const configFileContentWithComment = configFileContentBeforeComment + configFileContentComment + configFileContentAfterComment;
@@ -900,8 +900,9 @@ namespace ts.tscWatch {
const host = createWatchedSystem(files);
const watch = createWatchOfConfigFile(configFile.path, host);
const errors = () => [
getDiagnosticOfFile(watch().getCompilerOptions().configFile!, configFile.content.indexOf('"allowJs"'), '"allowJs"'.length, Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration"),
getDiagnosticOfFile(watch().getCompilerOptions().configFile!, configFile.content.indexOf('"declaration"'), '"declaration"'.length, Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration")
getDiagnosticOfFile(watch().getCompilerOptions().configFile!, configFile.content.indexOf('"inlineSourceMap"'), '"inlineSourceMap"'.length, Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"),
getDiagnosticOfFile(watch().getCompilerOptions().configFile!, configFile.content.indexOf('"mapRoot"'), '"mapRoot"'.length, Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"),
getDiagnosticOfFile(watch().getCompilerOptions().configFile!, configFile.content.indexOf('"mapRoot"'), '"mapRoot"'.length, Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "mapRoot", "sourceMap", "declarationMap")
];
const intialErrors = errors();
checkOutputErrorsInitial(host, intialErrors);
@@ -849,8 +849,8 @@ declare module '@custom/plugin' {
// comment`;
const configFileContentAfterComment = `
"compilerOptions": {
"allowJs": true,
"declaration": true
"inlineSourceMap": true,
"mapRoot": "./"
}
}`;
const configFileContentWithComment = configFileContentBeforeComment + configFileContentComment + configFileContentAfterComment;
@@ -874,7 +874,7 @@ declare module '@custom/plugin' {
seq: 2,
arguments: { file: configFile.path, projectFileName: projectName, includeLinePosition: true }
}).response as readonly server.protocol.DiagnosticWithLinePosition[];
assert.isTrue(diags.length === 2);
assert.isTrue(diags.length === 3);
configFile.content = configFileContentWithoutCommentLine;
host.reloadFS([file, configFile]);
@@ -885,10 +885,11 @@ declare module '@custom/plugin' {
seq: 2,
arguments: { file: configFile.path, projectFileName: projectName, includeLinePosition: true }
}).response as readonly server.protocol.DiagnosticWithLinePosition[];
assert.isTrue(diagsAfterEdit.length === 2);
assert.isTrue(diagsAfterEdit.length === 3);
verifyDiagnostic(diags[0], diagsAfterEdit[0]);
verifyDiagnostic(diags[1], diagsAfterEdit[1]);
verifyDiagnostic(diags[2], diagsAfterEdit[2]);
function verifyDiagnostic(beforeEditDiag: server.protocol.DiagnosticWithLinePosition, afterEditDiag: server.protocol.DiagnosticWithLinePosition) {
assert.equal(beforeEditDiag.message, afterEditDiag.message);
+1 -1
View File
@@ -3586,7 +3586,7 @@ declare namespace ts {
function isUnparsedTextLike(node: Node): node is UnparsedTextLike;
function isUnparsedNode(node: Node): node is UnparsedNode;
function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression;
function isJSDocAllType(node: JSDocAllType): node is JSDocAllType;
function isJSDocAllType(node: Node): node is JSDocAllType;
function isJSDocUnknownType(node: Node): node is JSDocUnknownType;
function isJSDocNullableType(node: Node): node is JSDocNullableType;
function isJSDocNonNullableType(node: Node): node is JSDocNonNullableType;
+1 -1
View File
@@ -3586,7 +3586,7 @@ declare namespace ts {
function isUnparsedTextLike(node: Node): node is UnparsedTextLike;
function isUnparsedNode(node: Node): node is UnparsedNode;
function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression;
function isJSDocAllType(node: JSDocAllType): node is JSDocAllType;
function isJSDocAllType(node: Node): node is JSDocAllType;
function isJSDocUnknownType(node: Node): node is JSDocUnknownType;
function isJSDocNullableType(node: Node): node is JSDocNullableType;
function isJSDocNonNullableType(node: Node): node is JSDocNonNullableType;
@@ -10,7 +10,7 @@ namespace foo {
>1 : 1
}
export = foo;
>foo : typeof foo
>foo : typeof import("tests/cases/compiler/file1")
=== tests/cases/compiler/file2.ts ===
import x = require("./file1");
@@ -10,7 +10,7 @@ namespace foo {
>1 : 1
}
export = foo;
>foo : foo
>foo : import("tests/cases/compiler/file1")
=== tests/cases/compiler/file2.ts ===
import x = require("./file1");
@@ -18,7 +18,7 @@ declare module "express" {
function e(): e.Express;
>e : Symbol(e, Decl(express.d.ts, 6, 26), Decl(express.d.ts, 7, 28), Decl(augmentation.ts, 1, 29))
>e : Symbol(e, Decl(express.d.ts, 6, 26), Decl(express.d.ts, 7, 28))
>Express : Symbol(Express, Decl(express.d.ts, 52, 9))
>Express : Symbol(e.Express, Decl(express.d.ts, 52, 9))
namespace e {
>e : Symbol(e, Decl(express.d.ts, 6, 26), Decl(express.d.ts, 7, 28), Decl(augmentation.ts, 1, 29))
@@ -13,7 +13,7 @@ namespace foo {
>a : any
}
export = foo;
>foo : foo
>foo : import("tests/cases/compiler/file1")
=== tests/cases/compiler/file2.ts ===
import x = require("./file1");
@@ -22,11 +22,11 @@ export = Foo;
/** @typedef {(foo: Foo) => string} FooFun */
module.exports = /** @type {FooFun} */(void 0);
>module.exports = /** @type {FooFun} */(void 0) : (foo: typeof Foo) => string
>module.exports : (foo: typeof Foo) => string
>module : { "tests/cases/compiler/something": (foo: typeof Foo) => string; }
>exports : (foo: typeof Foo) => string
>(void 0) : (foo: typeof Foo) => string
>module.exports = /** @type {FooFun} */(void 0) : (foo: typeof import("tests/cases/compiler/file")) => string
>module.exports : (foo: typeof import("tests/cases/compiler/file")) => string
>module : { "tests/cases/compiler/something": (foo: typeof import("tests/cases/compiler/file")) => string; }
>exports : (foo: typeof import("tests/cases/compiler/file")) => string
>(void 0) : (foo: typeof import("tests/cases/compiler/file")) => string
>void 0 : undefined
>0 : 0
@@ -9,16 +9,16 @@ declare var module: any, exports: any;
=== tests/cases/conformance/salsa/index.js ===
const A = require("./other");
>A : typeof A
>require("./other") : typeof A
>A : typeof import("tests/cases/conformance/salsa/other")
>require("./other") : typeof import("tests/cases/conformance/salsa/other")
>require : (id: string) => any
>"./other" : "./other"
const a = new A().id;
>a : number
>new A().id : number
>new A() : A
>A : typeof A
>new A() : import("tests/cases/conformance/salsa/other")
>A : typeof import("tests/cases/conformance/salsa/other")
>id : number
const B = function() { this.id = 1; }
@@ -167,7 +167,7 @@ export declare module M.P {
var a: typeof M.f;
var b: typeof M.C;
var c: typeof M.N;
var g: typeof M.c.g;
var g: typeof M.N.g;
var d: typeof M.d;
}
export declare module M.Q {
@@ -0,0 +1,22 @@
tests/cases/compiler/input.ts(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
tests/cases/compiler/input.ts(6,14): error TS2323: Cannot redeclare exported variable 'Sub'.
==== tests/cases/compiler/input.ts (2 errors) ====
export = exports;
~~~~~~~~~~~~~~~~~
!!! error TS2309: An export assignment cannot be used in a module with other exported elements.
declare class exports {
constructor(p: number);
t: number;
}
export class Sub {
~~~
!!! error TS2323: Cannot redeclare exported variable 'Sub'.
instance!: {
t: number;
};
}
declare namespace exports {
export { Sub };
}
@@ -0,0 +1,23 @@
//// [input.ts]
export = exports;
declare class exports {
constructor(p: number);
t: number;
}
export class Sub {
instance!: {
t: number;
};
}
declare namespace exports {
export { Sub };
}
//// [input.js]
"use strict";
var Sub = /** @class */ (function () {
function Sub() {
}
return Sub;
}());
module.exports = exports;
@@ -0,0 +1,30 @@
=== tests/cases/compiler/input.ts ===
export = exports;
>exports : Symbol(exports, Decl(input.ts, 0, 17), Decl(input.ts, 9, 1))
declare class exports {
>exports : Symbol(exports, Decl(input.ts, 0, 17), Decl(input.ts, 9, 1))
constructor(p: number);
>p : Symbol(p, Decl(input.ts, 2, 16))
t: number;
>t : Symbol(exports.t, Decl(input.ts, 2, 27))
}
export class Sub {
>Sub : Symbol(Sub, Decl(input.ts, 4, 1), Decl(input.ts, 4, 1))
instance!: {
>instance : Symbol(Sub.instance, Decl(input.ts, 5, 18))
t: number;
>t : Symbol(t, Decl(input.ts, 6, 16))
};
}
declare namespace exports {
>exports : Symbol(exports, Decl(input.ts, 0, 17), Decl(input.ts, 9, 1))
export { Sub };
>Sub : Symbol(exports.Sub, Decl(input.ts, 11, 12))
}
@@ -0,0 +1,30 @@
=== tests/cases/compiler/input.ts ===
export = exports;
>exports : import("tests/cases/compiler/input")
declare class exports {
>exports : exports
constructor(p: number);
>p : number
t: number;
>t : number
}
export class Sub {
>Sub : Sub
instance!: {
>instance : { t: number; }
t: number;
>t : number
};
}
declare namespace exports {
>exports : typeof exports
export { Sub };
>Sub : typeof import("tests/cases/compiler/input").Sub
}
@@ -0,0 +1,57 @@
//// [tests/cases/compiler/declarationImportTypeAliasInferredAndEmittable.ts] ////
//// [foo.ts]
class Conn {
constructor() { }
item = 3;
method() { }
}
export = Conn;
//// [usage.ts]
type Conn = import("./foo");
declare var x: Conn;
export class Wrap {
connItem: number;
constructor(c = x) {
this.connItem = c.item;
}
}
//// [foo.js]
"use strict";
var Conn = /** @class */ (function () {
function Conn() {
this.item = 3;
}
Conn.prototype.method = function () { };
return Conn;
}());
module.exports = Conn;
//// [usage.js]
"use strict";
exports.__esModule = true;
var Wrap = /** @class */ (function () {
function Wrap(c) {
if (c === void 0) { c = x; }
this.connItem = c.item;
}
return Wrap;
}());
exports.Wrap = Wrap;
//// [foo.d.ts]
declare class Conn {
constructor();
item: number;
method(): void;
}
export = Conn;
//// [usage.d.ts]
export declare class Wrap {
connItem: number;
constructor(c?: import("./foo"));
}
@@ -0,0 +1,43 @@
=== tests/cases/compiler/foo.ts ===
class Conn {
>Conn : Symbol(Conn, Decl(foo.ts, 0, 0))
constructor() { }
item = 3;
>item : Symbol(Conn.item, Decl(foo.ts, 1, 21))
method() { }
>method : Symbol(Conn.method, Decl(foo.ts, 2, 13))
}
export = Conn;
>Conn : Symbol(Conn, Decl(foo.ts, 0, 0))
=== tests/cases/compiler/usage.ts ===
type Conn = import("./foo");
>Conn : Symbol(Conn, Decl(usage.ts, 0, 0))
declare var x: Conn;
>x : Symbol(x, Decl(usage.ts, 1, 11))
>Conn : Symbol(Conn, Decl(usage.ts, 0, 0))
export class Wrap {
>Wrap : Symbol(Wrap, Decl(usage.ts, 1, 20))
connItem: number;
>connItem : Symbol(Wrap.connItem, Decl(usage.ts, 3, 19))
constructor(c = x) {
>c : Symbol(c, Decl(usage.ts, 5, 16))
>x : Symbol(x, Decl(usage.ts, 1, 11))
this.connItem = c.item;
>this.connItem : Symbol(Wrap.connItem, Decl(usage.ts, 3, 19))
>this : Symbol(Wrap, Decl(usage.ts, 1, 20))
>connItem : Symbol(Wrap.connItem, Decl(usage.ts, 3, 19))
>c.item : Symbol(Conn.item, Decl(foo.ts, 1, 21))
>c : Symbol(c, Decl(usage.ts, 5, 16))
>item : Symbol(Conn.item, Decl(foo.ts, 1, 21))
}
}
@@ -0,0 +1,44 @@
=== tests/cases/compiler/foo.ts ===
class Conn {
>Conn : Conn
constructor() { }
item = 3;
>item : number
>3 : 3
method() { }
>method : () => void
}
export = Conn;
>Conn : Conn
=== tests/cases/compiler/usage.ts ===
type Conn = import("./foo");
>Conn : import("tests/cases/compiler/foo")
declare var x: Conn;
>x : import("tests/cases/compiler/foo")
export class Wrap {
>Wrap : Wrap
connItem: number;
>connItem : number
constructor(c = x) {
>c : import("tests/cases/compiler/foo")
>x : import("tests/cases/compiler/foo")
this.connItem = c.item;
>this.connItem = c.item : number
>this.connItem : number
>this : this
>connItem : number
>c.item : number
>c : import("tests/cases/compiler/foo")
>item : number
}
}
@@ -29,7 +29,7 @@ export = y;
=== tests/cases/conformance/externalModules/foo3.ts ===
module x {
>x : typeof x
>x : typeof import("tests/cases/conformance/externalModules/foo3")
export var x = 10;
>x : number
@@ -3,5 +3,5 @@ export function f() { }
>f : typeof f
export = f;
>f : { (): void; f: typeof import("tests/cases/compiler/es5ExportEquals").f; }
>f : { (): void; f: typeof import("tests/cases/compiler/es5ExportEquals"); }
@@ -3,5 +3,5 @@ export function f() { }
>f : typeof f
export = f;
>f : { (): void; f: typeof import("tests/cases/compiler/es6ExportEquals").f; }
>f : { (): void; f: typeof import("tests/cases/compiler/es6ExportEquals"); }
@@ -15,5 +15,5 @@ class C1 {
// Invalid, as there is already an exported member.
export = C1;
>C1 : C1
>C1 : import("tests/cases/conformance/externalModules/foo_0")
@@ -6,5 +6,5 @@ class D { }
>D : D
export = D;
>D : D
>D : import("tests/cases/compiler/exportAssignmentWithExports")
@@ -55,7 +55,7 @@ export { Bar }
=== tests/cases/conformance/types/import/usage.ts ===
export const x: import("./foo")<{x: number}> = { x: 0, y: 0, data: {x: 12} };
>x : Point<{ x: number; }>
>x : import("tests/cases/conformance/types/import/foo")<{ x: number; }>
>x : number
>{ x: 0, y: 0, data: {x: 12} } : { x: number; y: number; data: { x: number; }; }
>x : number
@@ -37,20 +37,20 @@ export = MyClass;
*/
let a = /** @type {Foo} */(/** @type {*} */(undefined));
>a : MyClass
>(/** @type {*} */(undefined)) : MyClass
>a : import("tests/cases/conformance/types/import/externs")
>(/** @type {*} */(undefined)) : import("tests/cases/conformance/types/import/externs")
>(undefined) : any
>undefined : undefined
a = new Foo({doer: Foo.Bar});
>a = new Foo({doer: Foo.Bar}) : MyClass
>a : MyClass
>new Foo({doer: Foo.Bar}) : MyClass
>Foo : typeof MyClass
>a = new Foo({doer: Foo.Bar}) : import("tests/cases/conformance/types/import/externs")
>a : import("tests/cases/conformance/types/import/externs")
>new Foo({doer: Foo.Bar}) : import("tests/cases/conformance/types/import/externs")
>Foo : typeof import("tests/cases/conformance/types/import/externs")
>{doer: Foo.Bar} : { doer: (x: string, y?: number) => void; }
>doer : (x: string, y?: number) => void
>Foo.Bar : (x: string, y?: number) => void
>Foo : typeof MyClass
>Foo : typeof import("tests/cases/conformance/types/import/externs")
>Bar : (x: string, y?: number) => void
const q = /** @type {import("./externs").Bar} */({ doer: q => q });
@@ -46,7 +46,7 @@ export { Bar }
=== tests/cases/conformance/types/import/usage.ts ===
export const x: import("./foo") = { x: 0, y: 0 };
>x : Point
>x : import("tests/cases/conformance/types/import/foo")
>{ x: 0, y: 0 } : { x: number; y: number; }
>x : number
>0 : 0
@@ -0,0 +1,68 @@
//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsClassExtendsVisibility.ts] ////
//// [bar.js]
class Bar {}
module.exports = Bar;
//// [cls.js]
const Bar = require("./bar");
const Strings = {
a: "A",
b: "B"
};
class Foo extends Bar {}
module.exports = Foo;
module.exports.Strings = Strings;
//// [bar.js]
var Bar = /** @class */ (function () {
function Bar() {
}
return Bar;
}());
module.exports = Bar;
//// [cls.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var Bar = require("./bar");
var Strings = {
a: "A",
b: "B"
};
var Foo = /** @class */ (function (_super) {
__extends(Foo, _super);
function Foo() {
return _super !== null && _super.apply(this, arguments) || this;
}
return Foo;
}(Bar));
module.exports = Foo;
module.exports.Strings = Strings;
//// [bar.d.ts]
export = Bar;
declare class Bar {
}
//// [cls.d.ts]
export = Foo;
declare const Foo_base: typeof import("./bar");
declare class Foo extends Foo_base {
}
declare namespace Foo {
export { Strings };
}
declare namespace Strings {
export const a: string;
export const b: string;
}
@@ -0,0 +1,44 @@
=== tests/cases/conformance/jsdoc/declarations/cls.js ===
const Bar = require("./bar");
>Bar : Symbol(Bar, Decl(cls.js, 0, 5))
>require : Symbol(require)
>"./bar" : Symbol("tests/cases/conformance/jsdoc/declarations/bar", Decl(bar.js, 0, 0))
const Strings = {
>Strings : Symbol(Strings, Decl(cls.js, 1, 5))
a: "A",
>a : Symbol(a, Decl(cls.js, 1, 17))
b: "B"
>b : Symbol(b, Decl(cls.js, 2, 11))
};
class Foo extends Bar {}
>Foo : Symbol(Foo, Decl(cls.js, 4, 2))
>Bar : Symbol(Bar, Decl(cls.js, 0, 5))
module.exports = Foo;
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0))
>module : Symbol(export=, Decl(cls.js, 5, 24))
>exports : Symbol(export=, Decl(cls.js, 5, 24))
>Foo : Symbol(Foo, Decl(cls.js, 4, 2))
module.exports.Strings = Strings;
>module.exports.Strings : Symbol(Strings)
>module.exports : Symbol(Strings, Decl(cls.js, 6, 21))
>module : Symbol(module, Decl(cls.js, 5, 24))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0))
>Strings : Symbol(Strings, Decl(cls.js, 6, 21))
>Strings : Symbol(Strings, Decl(cls.js, 1, 5))
=== tests/cases/conformance/jsdoc/declarations/bar.js ===
class Bar {}
>Bar : Symbol(Bar, Decl(bar.js, 0, 0))
module.exports = Bar;
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/bar", Decl(bar.js, 0, 0))
>module : Symbol(export=, Decl(bar.js, 0, 12))
>exports : Symbol(export=, Decl(bar.js, 0, 12))
>Bar : Symbol(Bar, Decl(bar.js, 0, 0))
@@ -0,0 +1,51 @@
=== 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")
>require : any
>"./bar" : "./bar"
const Strings = {
>Strings : { a: string; b: string; }
>{ a: "A", b: "B"} : { a: string; b: string; }
a: "A",
>a : string
>"A" : "A"
b: "B"
>b : string
>"B" : "B"
};
class Foo extends Bar {}
>Foo : Foo
>Bar : import("tests/cases/conformance/jsdoc/declarations/bar")
module.exports = Foo;
>module.exports = Foo : typeof Foo
>module.exports : typeof Foo
>module : { "tests/cases/conformance/jsdoc/declarations/cls": typeof Foo; }
>exports : typeof Foo
>Foo : typeof Foo
module.exports.Strings = Strings;
>module.exports.Strings = Strings : { a: string; b: string; }
>module.exports.Strings : { a: string; b: string; }
>module.exports : typeof Foo
>module : { "tests/cases/conformance/jsdoc/declarations/cls": typeof Foo; }
>exports : typeof Foo
>Strings : { a: string; b: string; }
>Strings : { a: string; b: string; }
=== tests/cases/conformance/jsdoc/declarations/bar.js ===
class Bar {}
>Bar : Bar
module.exports = Bar;
>module.exports = Bar : typeof Bar
>module.exports : typeof Bar
>module : { "tests/cases/conformance/jsdoc/declarations/bar": typeof Bar; }
>exports : typeof Bar
>Bar : typeof Bar
@@ -0,0 +1,591 @@
//// [index.js]
export class A {}
export class B {
static cat = "cat";
}
export class C {
static Cls = class {}
}
export class D {
/**
* @param {number} a
* @param {number} b
*/
constructor(a, b) {}
}
/**
* @template T,U
*/
export class E {
/**
* @type {T & U}
*/
field;
// @readonly is currently unsupported, it seems - included here just in case that changes
/**
* @type {T & U}
* @readonly
*/
readonlyField;
initializedField = 12;
/**
* @return {U}
*/
get f1() { return /** @type {*} */(null); }
/**
* @param {U} _p
*/
set f1(_p) {}
/**
* @return {U}
*/
get f2() { return /** @type {*} */(null); }
/**
* @param {U} _p
*/
set f3(_p) {}
/**
* @param {T} a
* @param {U} b
*/
constructor(a, b) {}
/**
* @type {string}
*/
static staticField;
// @readonly is currently unsupported, it seems - included here just in case that changes
/**
* @type {string}
* @readonly
*/
static staticReadonlyField;
static staticInitializedField = 12;
/**
* @return {string}
*/
static get s1() { return ""; }
/**
* @param {string} _p
*/
static set s1(_p) {}
/**
* @return {string}
*/
static get s2() { return ""; }
/**
* @param {string} _p
*/
static set s3(_p) {}
}
/**
* @template T,U
*/
export class F {
/**
* @type {T & U}
*/
field;
/**
* @param {T} a
* @param {U} b
*/
constructor(a, b) {}
/**
* @template A,B
* @param {A} a
* @param {B} b
*/
static create(a, b) { return new F(a, b); }
}
class G {}
export { G };
class HH {}
export { HH as H };
export class I {}
export { I as II };
export { J as JJ };
export class J {}
export class K {
constructor() {
this.p1 = 12;
this.p2 = "ok";
}
method() {
return this.p1;
}
}
export class L extends K {}
export class M extends null {
constructor() {
this.prop = 12;
}
}
/**
* @template T
*/
export class N extends L {
/**
* @param {T} param
*/
constructor(param) {
super();
this.another = param;
}
}
/**
* @template U
* @extends {N<U>}
*/
export class O extends N {
/**
* @param {U} param
*/
constructor(param) {
super(param);
this.another2 = param;
}
}
var x = /** @type {*} */(null);
export class VariableBase extends x {}
export class HasStatics {
static staticMethod() {}
}
export class ExtendsStatics extends HasStatics {
static also() {}
}
//// [index.js]
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var A = /** @class */ (function () {
function A() {
}
return A;
}());
exports.A = A;
var B = /** @class */ (function () {
function B() {
}
B.cat = "cat";
return B;
}());
exports.B = B;
var C = /** @class */ (function () {
function C() {
}
C.Cls = /** @class */ (function () {
function class_1() {
}
return class_1;
}());
return C;
}());
exports.C = C;
var D = /** @class */ (function () {
/**
* @param {number} a
* @param {number} b
*/
function D(a, b) {
}
return D;
}());
exports.D = D;
/**
* @template T,U
*/
var E = /** @class */ (function () {
/**
* @param {T} a
* @param {U} b
*/
function E(a, b) {
this.initializedField = 12;
}
Object.defineProperty(E.prototype, "f1", {
/**
* @return {U}
*/
get: function () { return /** @type {*} */ (null); },
/**
* @param {U} _p
*/
set: function (_p) { },
enumerable: true,
configurable: true
});
Object.defineProperty(E.prototype, "f2", {
/**
* @return {U}
*/
get: function () { return /** @type {*} */ (null); },
enumerable: true,
configurable: true
});
Object.defineProperty(E.prototype, "f3", {
/**
* @param {U} _p
*/
set: function (_p) { },
enumerable: true,
configurable: true
});
Object.defineProperty(E, "s1", {
/**
* @return {string}
*/
get: function () { return ""; },
/**
* @param {string} _p
*/
set: function (_p) { },
enumerable: true,
configurable: true
});
Object.defineProperty(E, "s2", {
/**
* @return {string}
*/
get: function () { return ""; },
enumerable: true,
configurable: true
});
Object.defineProperty(E, "s3", {
/**
* @param {string} _p
*/
set: function (_p) { },
enumerable: true,
configurable: true
});
E.staticInitializedField = 12;
return E;
}());
exports.E = E;
/**
* @template T,U
*/
var F = /** @class */ (function () {
/**
* @param {T} a
* @param {U} b
*/
function F(a, b) {
}
/**
* @template A,B
* @param {A} a
* @param {B} b
*/
F.create = function (a, b) { return new F(a, b); };
return F;
}());
exports.F = F;
var G = /** @class */ (function () {
function G() {
}
return G;
}());
exports.G = G;
var HH = /** @class */ (function () {
function HH() {
}
return HH;
}());
exports.H = HH;
var I = /** @class */ (function () {
function I() {
}
return I;
}());
exports.I = I;
exports.II = I;
var J = /** @class */ (function () {
function J() {
}
return J;
}());
exports.JJ = J;
exports.J = J;
var K = /** @class */ (function () {
function K() {
this.p1 = 12;
this.p2 = "ok";
}
K.prototype.method = function () {
return this.p1;
};
return K;
}());
exports.K = K;
var L = /** @class */ (function (_super) {
__extends(L, _super);
function L() {
return _super !== null && _super.apply(this, arguments) || this;
}
return L;
}(K));
exports.L = L;
var M = /** @class */ (function (_super) {
__extends(M, _super);
function M() {
_this.prop = 12;
}
return M;
}(null));
exports.M = M;
/**
* @template T
*/
var N = /** @class */ (function (_super) {
__extends(N, _super);
/**
* @param {T} param
*/
function N(param) {
var _this = _super.call(this) || this;
_this.another = param;
return _this;
}
return N;
}(L));
exports.N = N;
/**
* @template U
* @extends {N<U>}
*/
var O = /** @class */ (function (_super) {
__extends(O, _super);
/**
* @param {U} param
*/
function O(param) {
var _this = _super.call(this, param) || this;
_this.another2 = param;
return _this;
}
return O;
}(N));
exports.O = O;
var x = /** @type {*} */ (null);
var VariableBase = /** @class */ (function (_super) {
__extends(VariableBase, _super);
function VariableBase() {
return _super !== null && _super.apply(this, arguments) || this;
}
return VariableBase;
}(x));
exports.VariableBase = VariableBase;
var HasStatics = /** @class */ (function () {
function HasStatics() {
}
HasStatics.staticMethod = function () { };
return HasStatics;
}());
exports.HasStatics = HasStatics;
var ExtendsStatics = /** @class */ (function (_super) {
__extends(ExtendsStatics, _super);
function ExtendsStatics() {
return _super !== null && _super.apply(this, arguments) || this;
}
ExtendsStatics.also = function () { };
return ExtendsStatics;
}(HasStatics));
exports.ExtendsStatics = ExtendsStatics;
//// [index.d.ts]
export class A {
}
export class B {
static cat: string;
}
export class C {
static Cls: {
new (): {};
};
}
export class D {
/**
* @param {number} a
* @param {number} b
*/
constructor(a: number, b: number);
}
/**
* @template T,U
*/
export class E<T, U> {
/**
* @type {string}
*/
static staticField: string;
/**
* @type {string}
* @readonly
*/
static staticReadonlyField: string;
static staticInitializedField: number;
/**
* @return {string}
*/
static s1: string;
/**
* @return {string}
*/
static readonly s2: string;
/**
* @param {string} _p
*/
static s3: string;
/**
* @param {T} a
* @param {U} b
*/
constructor(a: T, b: U);
/**
* @type {T & U}
*/
field: T & U;
/**
* @type {T & U}
* @readonly
*/
readonlyField: T & U;
initializedField: number;
/**
* @return {U}
*/
f1: U;
/**
* @return {U}
*/
readonly f2: U;
/**
* @param {U} _p
*/
f3: U;
}
/**
* @template T,U
*/
export class F<T, U> {
/**
* @template A,B
* @param {A} a
* @param {B} b
*/
static create<A_1, B_1>(a: A_1, b: B_1): F<A_1, B_1>;
/**
* @param {T} a
* @param {U} b
*/
constructor(a: T, b: U);
/**
* @type {T & U}
*/
field: T & U;
}
export class I {
}
export class J {
}
export class K {
p1: number;
p2: string;
method(): number;
}
export class L extends K {
}
export class M {
prop: number;
}
/**
* @template T
*/
export class N<T> extends L {
/**
* @param {T} param
*/
constructor(param: T);
another: T;
}
/**
* @template U
* @extends {N<U>}
*/
export class O<U> extends N<U> {
/**
* @param {U} param
*/
constructor(param: U);
another2: U;
}
declare const VariableBase_base: any;
export class VariableBase extends VariableBase_base {
[x: string]: any;
}
export class HasStatics {
static staticMethod(): void;
}
export class ExtendsStatics extends HasStatics {
static also(): void;
}
export class G {
}
declare class HH {
}
export { HH as H, I as II, J as JJ };
@@ -0,0 +1,307 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
export class A {}
>A : Symbol(A, Decl(index.js, 0, 0))
export class B {
>B : Symbol(B, Decl(index.js, 0, 17))
static cat = "cat";
>cat : Symbol(B.cat, Decl(index.js, 2, 16))
}
export class C {
>C : Symbol(C, Decl(index.js, 4, 1))
static Cls = class {}
>Cls : Symbol(C.Cls, Decl(index.js, 6, 16))
}
export class D {
>D : Symbol(D, Decl(index.js, 8, 1))
/**
* @param {number} a
* @param {number} b
*/
constructor(a, b) {}
>a : Symbol(a, Decl(index.js, 15, 16))
>b : Symbol(b, Decl(index.js, 15, 18))
}
/**
* @template T,U
*/
export class E {
>E : Symbol(E, Decl(index.js, 16, 1))
/**
* @type {T & U}
*/
field;
>field : Symbol(E.field, Decl(index.js, 21, 16))
// @readonly is currently unsupported, it seems - included here just in case that changes
/**
* @type {T & U}
* @readonly
*/
readonlyField;
>readonlyField : Symbol(E.readonlyField, Decl(index.js, 25, 10))
initializedField = 12;
>initializedField : Symbol(E.initializedField, Decl(index.js, 32, 18))
/**
* @return {U}
*/
get f1() { return /** @type {*} */(null); }
>f1 : Symbol(E.f1, Decl(index.js, 34, 26), Decl(index.js, 39, 47))
/**
* @param {U} _p
*/
set f1(_p) {}
>f1 : Symbol(E.f1, Decl(index.js, 34, 26), Decl(index.js, 39, 47))
>_p : Symbol(_p, Decl(index.js, 44, 11))
/**
* @return {U}
*/
get f2() { return /** @type {*} */(null); }
>f2 : Symbol(E.f2, Decl(index.js, 44, 17))
/**
* @param {U} _p
*/
set f3(_p) {}
>f3 : Symbol(E.f3, Decl(index.js, 49, 47))
>_p : Symbol(_p, Decl(index.js, 54, 11))
/**
* @param {T} a
* @param {U} b
*/
constructor(a, b) {}
>a : Symbol(a, Decl(index.js, 60, 16))
>b : Symbol(b, Decl(index.js, 60, 18))
/**
* @type {string}
*/
static staticField;
>staticField : Symbol(E.staticField, Decl(index.js, 60, 24))
// @readonly is currently unsupported, it seems - included here just in case that changes
/**
* @type {string}
* @readonly
*/
static staticReadonlyField;
>staticReadonlyField : Symbol(E.staticReadonlyField, Decl(index.js, 66, 23))
static staticInitializedField = 12;
>staticInitializedField : Symbol(E.staticInitializedField, Decl(index.js, 73, 31))
/**
* @return {string}
*/
static get s1() { return ""; }
>s1 : Symbol(E.s1, Decl(index.js, 75, 39), Decl(index.js, 80, 34))
/**
* @param {string} _p
*/
static set s1(_p) {}
>s1 : Symbol(E.s1, Decl(index.js, 75, 39), Decl(index.js, 80, 34))
>_p : Symbol(_p, Decl(index.js, 85, 18))
/**
* @return {string}
*/
static get s2() { return ""; }
>s2 : Symbol(E.s2, Decl(index.js, 85, 24))
/**
* @param {string} _p
*/
static set s3(_p) {}
>s3 : Symbol(E.s3, Decl(index.js, 90, 34))
>_p : Symbol(_p, Decl(index.js, 95, 18))
}
/**
* @template T,U
*/
export class F {
>F : Symbol(F, Decl(index.js, 96, 1))
/**
* @type {T & U}
*/
field;
>field : Symbol(F.field, Decl(index.js, 101, 16))
/**
* @param {T} a
* @param {U} b
*/
constructor(a, b) {}
>a : Symbol(a, Decl(index.js, 110, 16))
>b : Symbol(b, Decl(index.js, 110, 18))
/**
* @template A,B
* @param {A} a
* @param {B} b
*/
static create(a, b) { return new F(a, b); }
>create : Symbol(F.create, Decl(index.js, 110, 24))
>a : Symbol(a, Decl(index.js, 117, 18))
>b : Symbol(b, Decl(index.js, 117, 20))
>F : Symbol(F, Decl(index.js, 96, 1))
>a : Symbol(a, Decl(index.js, 117, 18))
>b : Symbol(b, Decl(index.js, 117, 20))
}
class G {}
>G : Symbol(G, Decl(index.js, 118, 1))
export { G };
>G : Symbol(G, Decl(index.js, 122, 8))
class HH {}
>HH : Symbol(HH, Decl(index.js, 122, 13))
export { HH as H };
>HH : Symbol(HH, Decl(index.js, 122, 13))
>H : Symbol(H, Decl(index.js, 126, 8))
export class I {}
>I : Symbol(I, Decl(index.js, 126, 19))
export { I as II };
>I : Symbol(I, Decl(index.js, 126, 19))
>II : Symbol(II, Decl(index.js, 129, 8))
export { J as JJ };
>J : Symbol(J, Decl(index.js, 131, 19))
>JJ : Symbol(JJ, Decl(index.js, 131, 8))
export class J {}
>J : Symbol(J, Decl(index.js, 131, 19))
export class K {
>K : Symbol(K, Decl(index.js, 132, 17))
constructor() {
this.p1 = 12;
>this.p1 : Symbol(K.p1, Decl(index.js, 136, 19))
>this : Symbol(K, Decl(index.js, 132, 17))
>p1 : Symbol(K.p1, Decl(index.js, 136, 19))
this.p2 = "ok";
>this.p2 : Symbol(K.p2, Decl(index.js, 137, 21))
>this : Symbol(K, Decl(index.js, 132, 17))
>p2 : Symbol(K.p2, Decl(index.js, 137, 21))
}
method() {
>method : Symbol(K.method, Decl(index.js, 139, 5))
return this.p1;
>this.p1 : Symbol(K.p1, Decl(index.js, 136, 19))
>this : Symbol(K, Decl(index.js, 132, 17))
>p1 : Symbol(K.p1, Decl(index.js, 136, 19))
}
}
export class L extends K {}
>L : Symbol(L, Decl(index.js, 144, 1))
>K : Symbol(K, Decl(index.js, 132, 17))
export class M extends null {
>M : Symbol(M, Decl(index.js, 146, 27))
constructor() {
this.prop = 12;
>this.prop : Symbol(M.prop, Decl(index.js, 149, 19))
>this : Symbol(M, Decl(index.js, 146, 27))
>prop : Symbol(M.prop, Decl(index.js, 149, 19))
}
}
/**
* @template T
*/
export class N extends L {
>N : Symbol(N, Decl(index.js, 152, 1))
>L : Symbol(L, Decl(index.js, 144, 1))
/**
* @param {T} param
*/
constructor(param) {
>param : Symbol(param, Decl(index.js, 162, 16))
super();
>super : Symbol(L, Decl(index.js, 144, 1))
this.another = param;
>this.another : Symbol(N.another, Decl(index.js, 163, 16))
>this : Symbol(N, Decl(index.js, 152, 1))
>another : Symbol(N.another, Decl(index.js, 163, 16))
>param : Symbol(param, Decl(index.js, 162, 16))
}
}
/**
* @template U
* @extends {N<U>}
*/
export class O extends N {
>O : Symbol(O, Decl(index.js, 166, 1))
>N : Symbol(N, Decl(index.js, 152, 1))
/**
* @param {U} param
*/
constructor(param) {
>param : Symbol(param, Decl(index.js, 176, 16))
super(param);
>super : Symbol(N, Decl(index.js, 152, 1))
>param : Symbol(param, Decl(index.js, 176, 16))
this.another2 = param;
>this.another2 : Symbol(O.another2, Decl(index.js, 177, 21))
>this : Symbol(O, Decl(index.js, 166, 1))
>another2 : Symbol(O.another2, Decl(index.js, 177, 21))
>param : Symbol(param, Decl(index.js, 176, 16))
}
}
var x = /** @type {*} */(null);
>x : Symbol(x, Decl(index.js, 182, 3))
export class VariableBase extends x {}
>VariableBase : Symbol(VariableBase, Decl(index.js, 182, 31))
>x : Symbol(x, Decl(index.js, 182, 3))
export class HasStatics {
>HasStatics : Symbol(HasStatics, Decl(index.js, 184, 38))
static staticMethod() {}
>staticMethod : Symbol(HasStatics.staticMethod, Decl(index.js, 186, 25))
}
export class ExtendsStatics extends HasStatics {
>ExtendsStatics : Symbol(ExtendsStatics, Decl(index.js, 188, 1))
>HasStatics : Symbol(HasStatics, Decl(index.js, 184, 38))
static also() {}
>also : Symbol(ExtendsStatics.also, Decl(index.js, 190, 48))
}
@@ -0,0 +1,331 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
export class A {}
>A : A
export class B {
>B : B
static cat = "cat";
>cat : string
>"cat" : "cat"
}
export class C {
>C : C
static Cls = class {}
>Cls : typeof (Anonymous class)
>class {} : typeof (Anonymous class)
}
export class D {
>D : D
/**
* @param {number} a
* @param {number} b
*/
constructor(a, b) {}
>a : number
>b : number
}
/**
* @template T,U
*/
export class E {
>E : E<T, U>
/**
* @type {T & U}
*/
field;
>field : T & U
// @readonly is currently unsupported, it seems - included here just in case that changes
/**
* @type {T & U}
* @readonly
*/
readonlyField;
>readonlyField : T & U
initializedField = 12;
>initializedField : number
>12 : 12
/**
* @return {U}
*/
get f1() { return /** @type {*} */(null); }
>f1 : U
>(null) : any
>null : null
/**
* @param {U} _p
*/
set f1(_p) {}
>f1 : U
>_p : U
/**
* @return {U}
*/
get f2() { return /** @type {*} */(null); }
>f2 : U
>(null) : any
>null : null
/**
* @param {U} _p
*/
set f3(_p) {}
>f3 : U
>_p : U
/**
* @param {T} a
* @param {U} b
*/
constructor(a, b) {}
>a : T
>b : U
/**
* @type {string}
*/
static staticField;
>staticField : string
// @readonly is currently unsupported, it seems - included here just in case that changes
/**
* @type {string}
* @readonly
*/
static staticReadonlyField;
>staticReadonlyField : string
static staticInitializedField = 12;
>staticInitializedField : number
>12 : 12
/**
* @return {string}
*/
static get s1() { return ""; }
>s1 : string
>"" : ""
/**
* @param {string} _p
*/
static set s1(_p) {}
>s1 : string
>_p : string
/**
* @return {string}
*/
static get s2() { return ""; }
>s2 : string
>"" : ""
/**
* @param {string} _p
*/
static set s3(_p) {}
>s3 : string
>_p : string
}
/**
* @template T,U
*/
export class F {
>F : F<T, U>
/**
* @type {T & U}
*/
field;
>field : T & U
/**
* @param {T} a
* @param {U} b
*/
constructor(a, b) {}
>a : T
>b : U
/**
* @template A,B
* @param {A} a
* @param {B} b
*/
static create(a, b) { return new F(a, b); }
>create : <A, B>(a: A, b: B) => F<A, B>
>a : A
>b : B
>new F(a, b) : F<A, B>
>F : typeof F
>a : A
>b : B
}
class G {}
>G : G
export { G };
>G : typeof G
class HH {}
>HH : HH
export { HH as H };
>HH : typeof HH
>H : typeof HH
export class I {}
>I : I
export { I as II };
>I : typeof I
>II : typeof I
export { J as JJ };
>J : typeof J
>JJ : typeof J
export class J {}
>J : J
export class K {
>K : K
constructor() {
this.p1 = 12;
>this.p1 = 12 : 12
>this.p1 : number
>this : this
>p1 : number
>12 : 12
this.p2 = "ok";
>this.p2 = "ok" : "ok"
>this.p2 : string
>this : this
>p2 : string
>"ok" : "ok"
}
method() {
>method : () => number
return this.p1;
>this.p1 : number
>this : this
>p1 : number
}
}
export class L extends K {}
>L : L
>K : K
export class M extends null {
>M : M
>null : null
constructor() {
this.prop = 12;
>this.prop = 12 : 12
>this.prop : number
>this : this
>prop : number
>12 : 12
}
}
/**
* @template T
*/
export class N extends L {
>N : N<T>
>L : L
/**
* @param {T} param
*/
constructor(param) {
>param : T
super();
>super() : void
>super : typeof L
this.another = param;
>this.another = param : T
>this.another : T
>this : this
>another : T
>param : T
}
}
/**
* @template U
* @extends {N<U>}
*/
export class O extends N {
>O : O<U>
>N : N<U>
/**
* @param {U} param
*/
constructor(param) {
>param : U
super(param);
>super(param) : void
>super : typeof N
>param : U
this.another2 = param;
>this.another2 = param : U
>this.another2 : U
>this : this
>another2 : U
>param : U
}
}
var x = /** @type {*} */(null);
>x : any
>(null) : any
>null : null
export class VariableBase extends x {}
>VariableBase : VariableBase
>x : any
export class HasStatics {
>HasStatics : HasStatics
static staticMethod() {}
>staticMethod : () => void
}
export class ExtendsStatics extends HasStatics {
>ExtendsStatics : ExtendsStatics
>HasStatics : HasStatics
static also() {}
>also : () => void
}
@@ -0,0 +1,136 @@
tests/cases/conformance/jsdoc/declarations/index.js(4,16): error TS8004: 'type parameter declarations' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(5,12): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(8,16): error TS8004: 'type parameter declarations' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(8,29): error TS8011: 'type arguments' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(9,12): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(13,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(19,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(23,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(27,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(28,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(32,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(39,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(43,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(47,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(48,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(52,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(53,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(59,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(63,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(67,11): error TS8010: 'types' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(68,11): error TS8010: 'types' can only be used in a .ts file.
==== tests/cases/conformance/jsdoc/declarations/index.js (21 errors) ====
// Pretty much all of this should be an error, (since index signatures and generics are forbidden in js),
// but we should be able to synthesize declarations from the symbols regardless
export class M<T> {
~
!!! error TS8004: 'type parameter declarations' can only be used in a .ts file.
field: T;
~
!!! error TS8010: 'types' can only be used in a .ts file.
}
export class N<U> extends M<U> {
~
!!! error TS8004: 'type parameter declarations' can only be used in a .ts file.
~
!!! error TS8011: 'type arguments' can only be used in a .ts file.
other: U;
~
!!! error TS8010: 'types' can only be used in a .ts file.
}
export class O {
[idx: string]: string;
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
}
export class P extends O {}
export class Q extends O {
[idx: string]: "ok";
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
}
export class R extends O {
[idx: number]: "ok";
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
}
export class S extends O {
[idx: string]: "ok";
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
[idx: number]: never;
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
}
export class T {
[idx: number]: string;
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
}
export class U extends T {}
export class V extends T {
[idx: string]: string;
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
}
export class W extends T {
[idx: number]: "ok";
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
}
export class X extends T {
[idx: string]: string;
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
[idx: number]: "ok";
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
}
export class Y {
[idx: string]: {x: number};
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
[idx: number]: {x: number, y: number};
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
}
export class Z extends Y {}
export class AA extends Y {
[idx: string]: {x: number, y: number};
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
}
export class BB extends Y {
[idx: number]: {x: 0, y: 0};
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
}
export class CC extends Y {
[idx: string]: {x: number, y: number};
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
[idx: number]: {x: 0, y: 0};
~~~~~~
!!! error TS8010: 'types' can only be used in a .ts file.
}
@@ -0,0 +1,290 @@
//// [index.js]
// Pretty much all of this should be an error, (since index signatures and generics are forbidden in js),
// but we should be able to synthesize declarations from the symbols regardless
export class M<T> {
field: T;
}
export class N<U> extends M<U> {
other: U;
}
export class O {
[idx: string]: string;
}
export class P extends O {}
export class Q extends O {
[idx: string]: "ok";
}
export class R extends O {
[idx: number]: "ok";
}
export class S extends O {
[idx: string]: "ok";
[idx: number]: never;
}
export class T {
[idx: number]: string;
}
export class U extends T {}
export class V extends T {
[idx: string]: string;
}
export class W extends T {
[idx: number]: "ok";
}
export class X extends T {
[idx: string]: string;
[idx: number]: "ok";
}
export class Y {
[idx: string]: {x: number};
[idx: number]: {x: number, y: number};
}
export class Z extends Y {}
export class AA extends Y {
[idx: string]: {x: number, y: number};
}
export class BB extends Y {
[idx: number]: {x: 0, y: 0};
}
export class CC extends Y {
[idx: string]: {x: number, y: number};
[idx: number]: {x: 0, y: 0};
}
//// [index.js]
"use strict";
// Pretty much all of this should be an error, (since index signatures and generics are forbidden in js),
// but we should be able to synthesize declarations from the symbols regardless
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var M = /** @class */ (function () {
function M() {
}
return M;
}());
exports.M = M;
var N = /** @class */ (function (_super) {
__extends(N, _super);
function N() {
return _super !== null && _super.apply(this, arguments) || this;
}
return N;
}(M));
exports.N = N;
var O = /** @class */ (function () {
function O() {
}
return O;
}());
exports.O = O;
var P = /** @class */ (function (_super) {
__extends(P, _super);
function P() {
return _super !== null && _super.apply(this, arguments) || this;
}
return P;
}(O));
exports.P = P;
var Q = /** @class */ (function (_super) {
__extends(Q, _super);
function Q() {
return _super !== null && _super.apply(this, arguments) || this;
}
return Q;
}(O));
exports.Q = Q;
var R = /** @class */ (function (_super) {
__extends(R, _super);
function R() {
return _super !== null && _super.apply(this, arguments) || this;
}
return R;
}(O));
exports.R = R;
var S = /** @class */ (function (_super) {
__extends(S, _super);
function S() {
return _super !== null && _super.apply(this, arguments) || this;
}
return S;
}(O));
exports.S = S;
var T = /** @class */ (function () {
function T() {
}
return T;
}());
exports.T = T;
var U = /** @class */ (function (_super) {
__extends(U, _super);
function U() {
return _super !== null && _super.apply(this, arguments) || this;
}
return U;
}(T));
exports.U = U;
var V = /** @class */ (function (_super) {
__extends(V, _super);
function V() {
return _super !== null && _super.apply(this, arguments) || this;
}
return V;
}(T));
exports.V = V;
var W = /** @class */ (function (_super) {
__extends(W, _super);
function W() {
return _super !== null && _super.apply(this, arguments) || this;
}
return W;
}(T));
exports.W = W;
var X = /** @class */ (function (_super) {
__extends(X, _super);
function X() {
return _super !== null && _super.apply(this, arguments) || this;
}
return X;
}(T));
exports.X = X;
var Y = /** @class */ (function () {
function Y() {
}
return Y;
}());
exports.Y = Y;
var Z = /** @class */ (function (_super) {
__extends(Z, _super);
function Z() {
return _super !== null && _super.apply(this, arguments) || this;
}
return Z;
}(Y));
exports.Z = Z;
var AA = /** @class */ (function (_super) {
__extends(AA, _super);
function AA() {
return _super !== null && _super.apply(this, arguments) || this;
}
return AA;
}(Y));
exports.AA = AA;
var BB = /** @class */ (function (_super) {
__extends(BB, _super);
function BB() {
return _super !== null && _super.apply(this, arguments) || this;
}
return BB;
}(Y));
exports.BB = BB;
var CC = /** @class */ (function (_super) {
__extends(CC, _super);
function CC() {
return _super !== null && _super.apply(this, arguments) || this;
}
return CC;
}(Y));
exports.CC = CC;
//// [index.d.ts]
export class M<T_1> {
field: T_1;
}
export class N<U_1> extends M<U_1> {
other: U_1;
}
export class O {
[idx: string]: string;
}
export class P extends O {
}
export class Q extends O {
[idx: string]: "ok";
}
export class R extends O {
[idx: number]: "ok";
}
export class S extends O {
[idx: string]: "ok";
[idx: number]: never;
}
export class T {
[idx: number]: string;
}
export class U extends T {
}
export class V extends T {
[idx: string]: string;
}
export class W extends T {
[idx: number]: "ok";
}
export class X extends T {
[idx: string]: string;
[idx: number]: "ok";
}
export class Y {
[idx: string]: {
x: number;
};
[idx: number]: {
x: number;
y: number;
};
}
export class Z extends Y {
}
export class AA extends Y {
[idx: string]: {
x: number;
y: number;
};
}
export class BB extends Y {
[idx: number]: {
x: 0;
y: 0;
};
}
export class CC extends Y {
[idx: string]: {
x: number;
y: number;
};
[idx: number]: {
x: 0;
y: 0;
};
}
@@ -0,0 +1,153 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
// Pretty much all of this should be an error, (since index signatures and generics are forbidden in js),
// but we should be able to synthesize declarations from the symbols regardless
export class M<T> {
>M : Symbol(M, Decl(index.js, 0, 0))
>T : Symbol(T, Decl(index.js, 3, 15))
field: T;
>field : Symbol(M.field, Decl(index.js, 3, 19))
>T : Symbol(T, Decl(index.js, 3, 15))
}
export class N<U> extends M<U> {
>N : Symbol(N, Decl(index.js, 5, 1))
>U : Symbol(U, Decl(index.js, 7, 15))
>M : Symbol(M, Decl(index.js, 0, 0))
>U : Symbol(U, Decl(index.js, 7, 15))
other: U;
>other : Symbol(N.other, Decl(index.js, 7, 32))
>U : Symbol(U, Decl(index.js, 7, 15))
}
export class O {
>O : Symbol(O, Decl(index.js, 9, 1))
[idx: string]: string;
>idx : Symbol(idx, Decl(index.js, 12, 5))
}
export class P extends O {}
>P : Symbol(P, Decl(index.js, 13, 1))
>O : Symbol(O, Decl(index.js, 9, 1))
export class Q extends O {
>Q : Symbol(Q, Decl(index.js, 15, 27))
>O : Symbol(O, Decl(index.js, 9, 1))
[idx: string]: "ok";
>idx : Symbol(idx, Decl(index.js, 18, 5))
}
export class R extends O {
>R : Symbol(R, Decl(index.js, 19, 1))
>O : Symbol(O, Decl(index.js, 9, 1))
[idx: number]: "ok";
>idx : Symbol(idx, Decl(index.js, 22, 5))
}
export class S extends O {
>S : Symbol(S, Decl(index.js, 23, 1))
>O : Symbol(O, Decl(index.js, 9, 1))
[idx: string]: "ok";
>idx : Symbol(idx, Decl(index.js, 26, 5))
[idx: number]: never;
>idx : Symbol(idx, Decl(index.js, 27, 5))
}
export class T {
>T : Symbol(T, Decl(index.js, 28, 1))
[idx: number]: string;
>idx : Symbol(idx, Decl(index.js, 31, 5))
}
export class U extends T {}
>U : Symbol(U, Decl(index.js, 32, 1))
>T : Symbol(T, Decl(index.js, 28, 1))
export class V extends T {
>V : Symbol(V, Decl(index.js, 34, 27))
>T : Symbol(T, Decl(index.js, 28, 1))
[idx: string]: string;
>idx : Symbol(idx, Decl(index.js, 38, 5))
}
export class W extends T {
>W : Symbol(W, Decl(index.js, 39, 1))
>T : Symbol(T, Decl(index.js, 28, 1))
[idx: number]: "ok";
>idx : Symbol(idx, Decl(index.js, 42, 5))
}
export class X extends T {
>X : Symbol(X, Decl(index.js, 43, 1))
>T : Symbol(T, Decl(index.js, 28, 1))
[idx: string]: string;
>idx : Symbol(idx, Decl(index.js, 46, 5))
[idx: number]: "ok";
>idx : Symbol(idx, Decl(index.js, 47, 5))
}
export class Y {
>Y : Symbol(Y, Decl(index.js, 48, 1))
[idx: string]: {x: number};
>idx : Symbol(idx, Decl(index.js, 51, 5))
>x : Symbol(x, Decl(index.js, 51, 20))
[idx: number]: {x: number, y: number};
>idx : Symbol(idx, Decl(index.js, 52, 5))
>x : Symbol(x, Decl(index.js, 52, 20))
>y : Symbol(y, Decl(index.js, 52, 30))
}
export class Z extends Y {}
>Z : Symbol(Z, Decl(index.js, 53, 1))
>Y : Symbol(Y, Decl(index.js, 48, 1))
export class AA extends Y {
>AA : Symbol(AA, Decl(index.js, 55, 27))
>Y : Symbol(Y, Decl(index.js, 48, 1))
[idx: string]: {x: number, y: number};
>idx : Symbol(idx, Decl(index.js, 58, 5))
>x : Symbol(x, Decl(index.js, 58, 20))
>y : Symbol(y, Decl(index.js, 58, 30))
}
export class BB extends Y {
>BB : Symbol(BB, Decl(index.js, 59, 1))
>Y : Symbol(Y, Decl(index.js, 48, 1))
[idx: number]: {x: 0, y: 0};
>idx : Symbol(idx, Decl(index.js, 62, 5))
>x : Symbol(x, Decl(index.js, 62, 20))
>y : Symbol(y, Decl(index.js, 62, 25))
}
export class CC extends Y {
>CC : Symbol(CC, Decl(index.js, 63, 1))
>Y : Symbol(Y, Decl(index.js, 48, 1))
[idx: string]: {x: number, y: number};
>idx : Symbol(idx, Decl(index.js, 66, 5))
>x : Symbol(x, Decl(index.js, 66, 20))
>y : Symbol(y, Decl(index.js, 66, 30))
[idx: number]: {x: 0, y: 0};
>idx : Symbol(idx, Decl(index.js, 67, 5))
>x : Symbol(x, Decl(index.js, 67, 20))
>y : Symbol(y, Decl(index.js, 67, 25))
}
@@ -0,0 +1,148 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
// Pretty much all of this should be an error, (since index signatures and generics are forbidden in js),
// but we should be able to synthesize declarations from the symbols regardless
export class M<T> {
>M : M<T>
field: T;
>field : T
}
export class N<U> extends M<U> {
>N : N<U>
>M : M<U>
other: U;
>other : U
}
export class O {
>O : O
[idx: string]: string;
>idx : string
}
export class P extends O {}
>P : P
>O : O
export class Q extends O {
>Q : Q
>O : O
[idx: string]: "ok";
>idx : string
}
export class R extends O {
>R : R
>O : O
[idx: number]: "ok";
>idx : number
}
export class S extends O {
>S : S
>O : O
[idx: string]: "ok";
>idx : string
[idx: number]: never;
>idx : number
}
export class T {
>T : T
[idx: number]: string;
>idx : number
}
export class U extends T {}
>U : U
>T : T
export class V extends T {
>V : V
>T : T
[idx: string]: string;
>idx : string
}
export class W extends T {
>W : W
>T : T
[idx: number]: "ok";
>idx : number
}
export class X extends T {
>X : X
>T : T
[idx: string]: string;
>idx : string
[idx: number]: "ok";
>idx : number
}
export class Y {
>Y : Y
[idx: string]: {x: number};
>idx : string
>x : number
[idx: number]: {x: number, y: number};
>idx : number
>x : number
>y : number
}
export class Z extends Y {}
>Z : Z
>Y : Y
export class AA extends Y {
>AA : AA
>Y : Y
[idx: string]: {x: number, y: number};
>idx : string
>x : number
>y : number
}
export class BB extends Y {
>BB : BB
>Y : Y
[idx: number]: {x: 0, y: 0};
>idx : number
>x : 0
>y : 0
}
export class CC extends Y {
>CC : CC
>Y : Y
[idx: string]: {x: number, y: number};
>idx : string
>x : number
>y : number
[idx: number]: {x: 0, y: 0};
>idx : number
>x : 0
>y : 0
}
@@ -0,0 +1,92 @@
//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsComputedNames.ts] ////
//// [index.js]
const TopLevelSym = Symbol();
const InnerSym = Symbol();
module.exports = {
[TopLevelSym](x = 12) {
return x;
},
items: {
[InnerSym]: (arg = {x: 12}) => arg.x
}
}
//// [index2.js]
const TopLevelSym = Symbol();
const InnerSym = Symbol();
export class MyClass {
static [TopLevelSym] = 12;
[InnerSym] = "ok";
/**
* @param {typeof TopLevelSym | typeof InnerSym} _p
*/
constructor(_p = InnerSym) {
// switch on _p
}
}
//// [index.js]
var _a, _b;
var TopLevelSym = Symbol();
var InnerSym = Symbol();
module.exports = (_a = {},
_a[TopLevelSym] = function (x) {
if (x === void 0) { x = 12; }
return x;
},
_a.items = (_b = {},
_b[InnerSym] = function (arg) {
if (arg === void 0) { arg = { x: 12 }; }
return arg.x;
},
_b),
_a);
//// [index2.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var TopLevelSym = Symbol();
var InnerSym = Symbol();
var MyClass = /** @class */ (function () {
/**
* @param {typeof TopLevelSym | typeof InnerSym} _p
*/
function MyClass(_p) {
if (_p === void 0) { _p = InnerSym; }
this[_b] = "ok";
// switch on _p
}
var _a, _b;
_a = TopLevelSym, _b = InnerSym;
MyClass[_a] = 12;
return MyClass;
}());
exports.MyClass = MyClass;
//// [index.d.ts]
declare const _exports: {
[TopLevelSym](x?: number): number;
items: {
[InnerSym]: (arg?: {
x: number;
}) => number;
};
};
export = _exports;
declare const TopLevelSym: unique symbol;
declare const InnerSym: unique symbol;
//// [index2.d.ts]
export class MyClass {
static [TopLevelSym]: number;
/**
* @param {typeof TopLevelSym | typeof InnerSym} _p
*/
constructor(_p?: typeof TopLevelSym | typeof InnerSym);
[InnerSym]: string;
}
declare const InnerSym: unique symbol;
declare const TopLevelSym: unique symbol;
export {};
@@ -0,0 +1,68 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
const TopLevelSym = Symbol();
>TopLevelSym : Symbol(TopLevelSym, Decl(index.js, 0, 5))
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
const InnerSym = Symbol();
>InnerSym : Symbol(InnerSym, Decl(index.js, 1, 5))
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
module.exports = {
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(export=, Decl(index.js, 1, 26))
>exports : Symbol(export=, Decl(index.js, 1, 26))
[TopLevelSym](x = 12) {
>[TopLevelSym] : Symbol([TopLevelSym], Decl(index.js, 2, 18))
>TopLevelSym : Symbol(TopLevelSym, Decl(index.js, 0, 5))
>x : Symbol(x, Decl(index.js, 3, 18))
return x;
>x : Symbol(x, Decl(index.js, 3, 18))
},
items: {
>items : Symbol(items, Decl(index.js, 5, 6))
[InnerSym]: (arg = {x: 12}) => arg.x
>[InnerSym] : Symbol([InnerSym], Decl(index.js, 6, 12))
>InnerSym : Symbol(InnerSym, Decl(index.js, 1, 5))
>arg : Symbol(arg, Decl(index.js, 7, 21))
>x : Symbol(x, Decl(index.js, 7, 28))
>arg.x : Symbol(x, Decl(index.js, 7, 28))
>arg : Symbol(arg, Decl(index.js, 7, 21))
>x : Symbol(x, Decl(index.js, 7, 28))
}
}
=== tests/cases/conformance/jsdoc/declarations/index2.js ===
const TopLevelSym = Symbol();
>TopLevelSym : Symbol(TopLevelSym, Decl(index2.js, 0, 5))
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
const InnerSym = Symbol();
>InnerSym : Symbol(InnerSym, Decl(index2.js, 1, 5))
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
export class MyClass {
>MyClass : Symbol(MyClass, Decl(index2.js, 1, 26))
static [TopLevelSym] = 12;
>[TopLevelSym] : Symbol(MyClass[TopLevelSym], Decl(index2.js, 3, 22))
>TopLevelSym : Symbol(TopLevelSym, Decl(index2.js, 0, 5))
[InnerSym] = "ok";
>[InnerSym] : Symbol(MyClass[InnerSym], Decl(index2.js, 4, 30))
>InnerSym : Symbol(InnerSym, Decl(index2.js, 1, 5))
/**
* @param {typeof TopLevelSym | typeof InnerSym} _p
*/
constructor(_p = InnerSym) {
>_p : Symbol(_p, Decl(index2.js, 9, 16))
>InnerSym : Symbol(InnerSym, Decl(index2.js, 1, 5))
// switch on _p
}
}
@@ -0,0 +1,81 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
const TopLevelSym = Symbol();
>TopLevelSym : unique symbol
>Symbol() : unique symbol
>Symbol : SymbolConstructor
const InnerSym = Symbol();
>InnerSym : unique symbol
>Symbol() : unique symbol
>Symbol : SymbolConstructor
module.exports = {
>module.exports = { [TopLevelSym](x = 12) { return x; }, items: { [InnerSym]: (arg = {x: 12}) => arg.x }} : { [TopLevelSym](x?: number): number; items: { [InnerSym]: (arg?: { x: number; }) => number; }; }
>module.exports : { [TopLevelSym](x?: number): number; items: { [InnerSym]: (arg?: { x: number; }) => number; }; }
>module : { "tests/cases/conformance/jsdoc/declarations/index": { [TopLevelSym](x?: number): number; items: { [InnerSym]: (arg?: { x: number; }) => number; }; }; }
>exports : { [TopLevelSym](x?: number): number; items: { [InnerSym]: (arg?: { x: number; }) => number; }; }
>{ [TopLevelSym](x = 12) { return x; }, items: { [InnerSym]: (arg = {x: 12}) => arg.x }} : { [TopLevelSym](x?: number): number; items: { [InnerSym]: (arg?: { x: number; }) => number; }; }
[TopLevelSym](x = 12) {
>[TopLevelSym] : (x?: number) => number
>TopLevelSym : unique symbol
>x : number
>12 : 12
return x;
>x : number
},
items: {
>items : { [InnerSym]: (arg?: { x: number; }) => number; }
>{ [InnerSym]: (arg = {x: 12}) => arg.x } : { [InnerSym]: (arg?: { x: number; }) => number; }
[InnerSym]: (arg = {x: 12}) => arg.x
>[InnerSym] : (arg?: { x: number; }) => number
>InnerSym : unique symbol
>(arg = {x: 12}) => arg.x : (arg?: { x: number; }) => number
>arg : { x: number; }
>{x: 12} : { x: number; }
>x : number
>12 : 12
>arg.x : number
>arg : { x: number; }
>x : number
}
}
=== tests/cases/conformance/jsdoc/declarations/index2.js ===
const TopLevelSym = Symbol();
>TopLevelSym : unique symbol
>Symbol() : unique symbol
>Symbol : SymbolConstructor
const InnerSym = Symbol();
>InnerSym : unique symbol
>Symbol() : unique symbol
>Symbol : SymbolConstructor
export class MyClass {
>MyClass : MyClass
static [TopLevelSym] = 12;
>[TopLevelSym] : number
>TopLevelSym : unique symbol
>12 : 12
[InnerSym] = "ok";
>[InnerSym] : string
>InnerSym : unique symbol
>"ok" : "ok"
/**
* @param {typeof TopLevelSym | typeof InnerSym} _p
*/
constructor(_p = InnerSym) {
>_p : unique symbol | unique symbol
>InnerSym : unique symbol
// switch on _p
}
}
@@ -0,0 +1,141 @@
//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefault.ts] ////
//// [index1.js]
export default 12;
//// [index2.js]
export default function foo() {
return foo;
}
export const x = foo;
export { foo as bar };
//// [index3.js]
export default class Foo {
a = /** @type {Foo} */(null);
};
export const X = Foo;
export { Foo as Bar };
//// [index4.js]
import Fab from "./index3";
class Bar extends Fab {
x = /** @type {Bar} */(null);
}
export default Bar;
//// [index5.js]
// merge type alias and const (OK)
export default 12;
/**
* @typedef {string | number} default
*/
//// [index6.js]
// merge type alias and function (OK)
export default function func() {};
/**
* @typedef {string | number} default
*/
//// [index1.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = 12;
//// [index2.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function foo() {
return foo;
}
exports.default = foo;
exports.bar = foo;
exports.x = foo;
//// [index3.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Foo = /** @class */ (function () {
function Foo() {
this.a = (null);
}
return Foo;
}());
exports.Bar = Foo;
exports.default = Foo;
;
exports.X = Foo;
//// [index4.js]
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var index3_1 = require("./index3");
var Bar = /** @class */ (function (_super) {
__extends(Bar, _super);
function Bar() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.x = (null);
return _this;
}
return Bar;
}(index3_1.default));
exports.default = Bar;
//// [index5.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// merge type alias and const (OK)
exports.default = 12;
/**
* @typedef {string | number} default
*/
//// [index6.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// merge type alias and function (OK)
function func() { }
exports.default = func;
;
/**
* @typedef {string | number} default
*/
//// [index1.d.ts]
declare var _default: 12;
export default _default;
//// [index2.d.ts]
export default function foo(): typeof foo;
export function x(): typeof foo;
export { foo as bar };
//// [index3.d.ts]
export default class Foo {
a: Foo;
}
export const X: typeof Foo;
export { Foo as Bar };
//// [index4.d.ts]
export default Bar;
declare class Bar extends Fab {
x: Bar;
}
import Fab from "./index3";
//// [index5.d.ts]
type _default = string | number;
declare var _default: 12;
export default _default;
//// [index6.d.ts]
declare function func(): void;
type func = string | number;
export default func;
@@ -0,0 +1,64 @@
=== tests/cases/conformance/jsdoc/declarations/index1.js ===
export default 12;
No type information for this code.
No type information for this code.=== tests/cases/conformance/jsdoc/declarations/index2.js ===
export default function foo() {
>foo : Symbol(foo, Decl(index2.js, 0, 0))
return foo;
>foo : Symbol(foo, Decl(index2.js, 0, 0))
}
export const x = foo;
>x : Symbol(x, Decl(index2.js, 3, 12))
>foo : Symbol(foo, Decl(index2.js, 0, 0))
export { foo as bar };
>foo : Symbol(foo, Decl(index2.js, 0, 0))
>bar : Symbol(bar, Decl(index2.js, 4, 8))
=== tests/cases/conformance/jsdoc/declarations/index3.js ===
export default class Foo {
>Foo : Symbol(Foo, Decl(index3.js, 0, 0))
a = /** @type {Foo} */(null);
>a : Symbol(Foo.a, Decl(index3.js, 0, 26))
};
export const X = Foo;
>X : Symbol(X, Decl(index3.js, 3, 12))
>Foo : Symbol(Foo, Decl(index3.js, 0, 0))
export { Foo as Bar };
>Foo : Symbol(Foo, Decl(index3.js, 0, 0))
>Bar : Symbol(Bar, Decl(index3.js, 4, 8))
=== tests/cases/conformance/jsdoc/declarations/index4.js ===
import Fab from "./index3";
>Fab : Symbol(Fab, Decl(index4.js, 0, 6))
class Bar extends Fab {
>Bar : Symbol(Bar, Decl(index4.js, 0, 27))
>Fab : Symbol(Fab, Decl(index4.js, 0, 6))
x = /** @type {Bar} */(null);
>x : Symbol(Bar.x, Decl(index4.js, 1, 23))
}
export default Bar;
>Bar : Symbol(Bar, Decl(index4.js, 0, 27))
=== tests/cases/conformance/jsdoc/declarations/index5.js ===
// merge type alias and const (OK)
No type information for this code.export default 12;
No type information for this code./**
No type information for this code. * @typedef {string | number} default
No type information for this code. */
No type information for this code.
No type information for this code.=== tests/cases/conformance/jsdoc/declarations/index6.js ===
// merge type alias and function (OK)
export default function func() {};
>func : Symbol(func, Decl(index6.js, 0, 0), Decl(index6.js, 3, 3))
/**
* @typedef {string | number} default
*/
@@ -0,0 +1,68 @@
=== tests/cases/conformance/jsdoc/declarations/index1.js ===
export default 12;
No type information for this code.
No type information for this code.=== tests/cases/conformance/jsdoc/declarations/index2.js ===
export default function foo() {
>foo : () => typeof foo
return foo;
>foo : () => typeof foo
}
export const x = foo;
>x : () => typeof foo
>foo : () => typeof foo
export { foo as bar };
>foo : () => typeof foo
>bar : () => typeof foo
=== tests/cases/conformance/jsdoc/declarations/index3.js ===
export default class Foo {
>Foo : Foo
a = /** @type {Foo} */(null);
>a : Foo
>(null) : Foo
>null : null
};
export const X = Foo;
>X : typeof Foo
>Foo : typeof Foo
export { Foo as Bar };
>Foo : typeof Foo
>Bar : typeof Foo
=== tests/cases/conformance/jsdoc/declarations/index4.js ===
import Fab from "./index3";
>Fab : typeof Fab
class Bar extends Fab {
>Bar : Bar
>Fab : Fab
x = /** @type {Bar} */(null);
>x : Bar
>(null) : Bar
>null : null
}
export default Bar;
>Bar : Bar
=== tests/cases/conformance/jsdoc/declarations/index5.js ===
// merge type alias and const (OK)
No type information for this code.export default 12;
No type information for this code./**
No type information for this code. * @typedef {string | number} default
No type information for this code. */
No type information for this code.
No type information for this code.=== tests/cases/conformance/jsdoc/declarations/index6.js ===
// merge type alias and function (OK)
export default function func() {};
>func : () => void
/**
* @typedef {string | number} default
*/
@@ -0,0 +1,34 @@
tests/cases/conformance/jsdoc/declarations/index2.js(2,22): error TS2300: Duplicate identifier 'C'.
tests/cases/conformance/jsdoc/declarations/index2.js(4,31): error TS2300: Duplicate identifier 'default'.
==== tests/cases/conformance/jsdoc/declarations/index1.js (0 errors) ====
// merge type alias and alias (should error, see #32367)
class Cls {
x = 12;
static y = "ok"
}
export default Cls;
/**
* @typedef {string | number} default
*/
==== tests/cases/conformance/jsdoc/declarations/index2.js (2 errors) ====
// merge type alias and class (error message improvement needed, see #32368)
export default class C {};
~
!!! error TS2300: Duplicate identifier 'C'.
/**
* @typedef {string | number} default
~~~~~~~
!!! error TS2300: Duplicate identifier 'default'.
*/
==== tests/cases/conformance/jsdoc/declarations/index3.js (0 errors) ====
// merge type alias and variable (behavior is borked, see #32366)
const x = 12;
export {x as default};
/**
* @typedef {string | number} default
*/
@@ -0,0 +1,83 @@
//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefaultsErr.ts] ////
//// [index1.js]
// merge type alias and alias (should error, see #32367)
class Cls {
x = 12;
static y = "ok"
}
export default Cls;
/**
* @typedef {string | number} default
*/
//// [index2.js]
// merge type alias and class (error message improvement needed, see #32368)
export default class C {};
/**
* @typedef {string | number} default
*/
//// [index3.js]
// merge type alias and variable (behavior is borked, see #32366)
const x = 12;
export {x as default};
/**
* @typedef {string | number} default
*/
//// [index1.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// merge type alias and alias (should error, see #32367)
var Cls = /** @class */ (function () {
function Cls() {
this.x = 12;
}
Cls.y = "ok";
return Cls;
}());
exports.default = Cls;
/**
* @typedef {string | number} default
*/
//// [index2.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// merge type alias and class (error message improvement needed, see #32368)
var C = /** @class */ (function () {
function C() {
}
return C;
}());
exports.default = C;
;
/**
* @typedef {string | number} default
*/
//// [index3.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// merge type alias and variable (behavior is borked, see #32366)
var x = 12;
exports.default = x;
/**
* @typedef {string | number} default
*/
//// [index1.d.ts]
export type Cls = string | number;
export default Cls;
declare class Cls {
static y: string;
x: number;
}
//// [index2.d.ts]
export default class C {
}
//// [index3.d.ts]
export type _default = string | number;
export { x as default };
declare const x: 12;
@@ -0,0 +1,40 @@
=== tests/cases/conformance/jsdoc/declarations/index1.js ===
// merge type alias and alias (should error, see #32367)
class Cls {
>Cls : Symbol(Cls, Decl(index1.js, 0, 0))
x = 12;
>x : Symbol(Cls.x, Decl(index1.js, 1, 11))
static y = "ok"
>y : Symbol(Cls.y, Decl(index1.js, 2, 11))
}
export default Cls;
>Cls : Symbol(Cls, Decl(index1.js, 0, 0))
/**
* @typedef {string | number} default
*/
=== tests/cases/conformance/jsdoc/declarations/index2.js ===
// merge type alias and class (error message improvement needed, see #32368)
export default class C {};
>C : Symbol(C, Decl(index2.js, 0, 0))
/**
* @typedef {string | number} default
*/
=== tests/cases/conformance/jsdoc/declarations/index3.js ===
// merge type alias and variable (behavior is borked, see #32366)
const x = 12;
>x : Symbol(x, Decl(index3.js, 1, 5))
export {x as default};
>x : Symbol(x, Decl(index3.js, 1, 5))
>default : Symbol(default, Decl(index3.js, 2, 8), Decl(index3.js, 4, 3))
/**
* @typedef {string | number} default
*/
@@ -0,0 +1,43 @@
=== tests/cases/conformance/jsdoc/declarations/index1.js ===
// merge type alias and alias (should error, see #32367)
class Cls {
>Cls : Cls
x = 12;
>x : number
>12 : 12
static y = "ok"
>y : string
>"ok" : "ok"
}
export default Cls;
>Cls : Cls
/**
* @typedef {string | number} default
*/
=== tests/cases/conformance/jsdoc/declarations/index2.js ===
// merge type alias and class (error message improvement needed, see #32368)
export default class C {};
>C : C
/**
* @typedef {string | number} default
*/
=== tests/cases/conformance/jsdoc/declarations/index3.js ===
// merge type alias and variable (behavior is borked, see #32366)
const x = 12;
>x : 12
>12 : 12
export {x as default};
>x : 12
>default : 12
/**
* @typedef {string | number} default
*/
@@ -0,0 +1,130 @@
//// [index.js]
/** @enum {string} */
export const Target = {
START: "start",
MIDDLE: "middle",
END: "end",
/** @type {number} */
OK_I_GUESS: 2
}
/** @enum number */
export const Second = {
OK: 1,
/** @type {number} */
FINE: 2,
}
/** @enum {function(number): number} */
export const Fs = {
ADD1: n => n + 1,
ID: n => n,
SUB1: n => n - 1
}
/**
* @param {Target} t
* @param {Second} s
* @param {Fs} f
*/
export function consume(t,s,f) {
/** @type {string} */
var str = t
/** @type {number} */
var num = s
/** @type {(n: number) => number} */
var fun = f
/** @type {Target} */
var v = Target.START
v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums
}
/** @param {string} s */
export function ff(s) {
// element access with arbitrary string is an error only with noImplicitAny
if (!Target[s]) {
return null
}
else {
return Target[s]
}
}
//// [index.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/** @enum {string} */
exports.Target = {
START: "start",
MIDDLE: "middle",
END: "end",
/** @type {number} */
OK_I_GUESS: 2
};
/** @enum number */
exports.Second = {
OK: 1,
/** @type {number} */
FINE: 2,
};
/** @enum {function(number): number} */
exports.Fs = {
ADD1: function (n) { return n + 1; },
ID: function (n) { return n; },
SUB1: function (n) { return n - 1; }
};
/**
* @param {Target} t
* @param {Second} s
* @param {Fs} f
*/
function consume(t, s, f) {
/** @type {string} */
var str = t;
/** @type {number} */
var num = s;
/** @type {(n: number) => number} */
var fun = f;
/** @type {Target} */
var v = exports.Target.START;
v = 'something else'; // allowed, like Typescript's classic enums and unlike its string enums
}
exports.consume = consume;
/** @param {string} s */
function ff(s) {
// element access with arbitrary string is an error only with noImplicitAny
if (!exports.Target[s]) {
return null;
}
else {
return exports.Target[s];
}
}
exports.ff = ff;
//// [index.d.ts]
/**
* @param {Target} t
* @param {Second} s
* @param {Fs} f
*/
export function consume(t: string, s: number, f: (arg0: number) => number): void;
/** @param {string} s */
export function ff(s: string): any;
export type Target = string;
export namespace Target {
export const START: string;
export const MIDDLE: string;
export const END: string;
export const OK_I_GUESS: number;
}
export type Second = number;
export namespace Second {
export const OK: number;
export const FINE: number;
}
export type Fs = (arg0: number) => number;
export namespace Fs {
export function ADD1(n: any): any;
export function ID(n: any): any;
export function SUB1(n: any): number;
}
@@ -0,0 +1,104 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
/** @enum {string} */
export const Target = {
>Target : Symbol(Target, Decl(index.js, 1, 12), Decl(index.js, 0, 4))
START: "start",
>START : Symbol(START, Decl(index.js, 1, 23))
MIDDLE: "middle",
>MIDDLE : Symbol(MIDDLE, Decl(index.js, 2, 19))
END: "end",
>END : Symbol(END, Decl(index.js, 3, 21))
/** @type {number} */
OK_I_GUESS: 2
>OK_I_GUESS : Symbol(OK_I_GUESS, Decl(index.js, 4, 15))
}
/** @enum number */
export const Second = {
>Second : Symbol(Second, Decl(index.js, 9, 12), Decl(index.js, 8, 4))
OK: 1,
>OK : Symbol(OK, Decl(index.js, 9, 23))
/** @type {number} */
FINE: 2,
>FINE : Symbol(FINE, Decl(index.js, 10, 10))
}
/** @enum {function(number): number} */
export const Fs = {
>Fs : Symbol(Fs, Decl(index.js, 15, 12), Decl(index.js, 14, 4))
ADD1: n => n + 1,
>ADD1 : Symbol(ADD1, Decl(index.js, 15, 19))
>n : Symbol(n, Decl(index.js, 16, 9))
>n : Symbol(n, Decl(index.js, 16, 9))
ID: n => n,
>ID : Symbol(ID, Decl(index.js, 16, 21))
>n : Symbol(n, Decl(index.js, 17, 7))
>n : Symbol(n, Decl(index.js, 17, 7))
SUB1: n => n - 1
>SUB1 : Symbol(SUB1, Decl(index.js, 17, 15))
>n : Symbol(n, Decl(index.js, 18, 9))
>n : Symbol(n, Decl(index.js, 18, 9))
}
/**
* @param {Target} t
* @param {Second} s
* @param {Fs} f
*/
export function consume(t,s,f) {
>consume : Symbol(consume, Decl(index.js, 19, 1))
>t : Symbol(t, Decl(index.js, 26, 24))
>s : Symbol(s, Decl(index.js, 26, 26))
>f : Symbol(f, Decl(index.js, 26, 28))
/** @type {string} */
var str = t
>str : Symbol(str, Decl(index.js, 28, 7))
>t : Symbol(t, Decl(index.js, 26, 24))
/** @type {number} */
var num = s
>num : Symbol(num, Decl(index.js, 30, 7))
>s : Symbol(s, Decl(index.js, 26, 26))
/** @type {(n: number) => number} */
var fun = f
>fun : Symbol(fun, Decl(index.js, 32, 7))
>f : Symbol(f, Decl(index.js, 26, 28))
/** @type {Target} */
var v = Target.START
>v : Symbol(v, Decl(index.js, 34, 7))
>Target.START : Symbol(START, Decl(index.js, 1, 23))
>Target : Symbol(Target, Decl(index.js, 1, 12), Decl(index.js, 0, 4))
>START : Symbol(START, Decl(index.js, 1, 23))
v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums
>v : Symbol(v, Decl(index.js, 34, 7))
}
/** @param {string} s */
export function ff(s) {
>ff : Symbol(ff, Decl(index.js, 36, 1))
>s : Symbol(s, Decl(index.js, 38, 19))
// element access with arbitrary string is an error only with noImplicitAny
if (!Target[s]) {
>Target : Symbol(Target, Decl(index.js, 1, 12), Decl(index.js, 0, 4))
>s : Symbol(s, Decl(index.js, 38, 19))
return null
}
else {
return Target[s]
>Target : Symbol(Target, Decl(index.js, 1, 12), Decl(index.js, 0, 4))
>s : Symbol(s, Decl(index.js, 38, 19))
}
}
@@ -0,0 +1,126 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
/** @enum {string} */
export const Target = {
>Target : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; }
>{ START: "start", MIDDLE: "middle", END: "end", /** @type {number} */ OK_I_GUESS: 2} : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; }
START: "start",
>START : string
>"start" : "start"
MIDDLE: "middle",
>MIDDLE : string
>"middle" : "middle"
END: "end",
>END : string
>"end" : "end"
/** @type {number} */
OK_I_GUESS: 2
>OK_I_GUESS : number
>2 : 2
}
/** @enum number */
export const Second = {
>Second : { OK: number; FINE: number; }
>{ OK: 1, /** @type {number} */ FINE: 2,} : { OK: number; FINE: number; }
OK: 1,
>OK : number
>1 : 1
/** @type {number} */
FINE: 2,
>FINE : number
>2 : 2
}
/** @enum {function(number): number} */
export const Fs = {
>Fs : { ADD1: (n: any) => any; ID: (n: any) => any; SUB1: (n: any) => number; }
>{ ADD1: n => n + 1, ID: n => n, SUB1: n => n - 1} : { ADD1: (n: any) => any; ID: (n: any) => any; SUB1: (n: any) => number; }
ADD1: n => n + 1,
>ADD1 : (n: any) => any
>n => n + 1 : (n: any) => any
>n : any
>n + 1 : any
>n : any
>1 : 1
ID: n => n,
>ID : (n: any) => any
>n => n : (n: any) => any
>n : any
>n : any
SUB1: n => n - 1
>SUB1 : (n: any) => number
>n => n - 1 : (n: any) => number
>n : any
>n - 1 : number
>n : any
>1 : 1
}
/**
* @param {Target} t
* @param {Second} s
* @param {Fs} f
*/
export function consume(t,s,f) {
>consume : (t: string, s: number, f: (arg0: number) => number) => void
>t : string
>s : number
>f : (arg0: number) => number
/** @type {string} */
var str = t
>str : string
>t : string
/** @type {number} */
var num = s
>num : number
>s : number
/** @type {(n: number) => number} */
var fun = f
>fun : (n: number) => number
>f : (arg0: number) => number
/** @type {Target} */
var v = Target.START
>v : string
>Target.START : string
>Target : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; }
>START : string
v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums
>v = 'something else' : "something else"
>v : string
>'something else' : "something else"
}
/** @param {string} s */
export function ff(s) {
>ff : (s: string) => any
>s : string
// element access with arbitrary string is an error only with noImplicitAny
if (!Target[s]) {
>!Target[s] : boolean
>Target[s] : error
>Target : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; }
>s : string
return null
>null : null
}
else {
return Target[s]
>Target[s] : error
>Target : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; }
>s : string
}
}
@@ -0,0 +1,101 @@
tests/cases/conformance/jsdoc/declarations/index.js(4,13): error TS8015: 'enum declarations' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(6,13): error TS8015: 'enum declarations' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(10,6): error TS8015: 'enum declarations' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(14,6): error TS8015: 'enum declarations' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(18,13): error TS8015: 'enum declarations' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(22,13): error TS8015: 'enum declarations' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(24,13): error TS8015: 'enum declarations' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(30,13): error TS8015: 'enum declarations' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(35,13): error TS8015: 'enum declarations' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(41,19): error TS8015: 'enum declarations' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(47,13): error TS8015: 'enum declarations' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/index.js(55,19): error TS8015: 'enum declarations' can only be used in a .ts file.
==== tests/cases/conformance/jsdoc/declarations/index.js (12 errors) ====
// Pretty much all of this should be an error, (since enums are forbidden in js),
// but we should be able to synthesize declarations from the symbols regardless
export enum A {}
~
!!! error TS8015: 'enum declarations' can only be used in a .ts file.
export enum B {
~
!!! error TS8015: 'enum declarations' can only be used in a .ts file.
Member
}
enum C {}
~
!!! error TS8015: 'enum declarations' can only be used in a .ts file.
export { C };
enum DD {}
~~
!!! error TS8015: 'enum declarations' can only be used in a .ts file.
export { DD as D };
export enum E {}
~
!!! error TS8015: 'enum declarations' can only be used in a .ts file.
export { E as EE };
export { F as FF };
export enum F {}
~
!!! error TS8015: 'enum declarations' can only be used in a .ts file.
export enum G {
~
!!! error TS8015: 'enum declarations' can only be used in a .ts file.
A = 1,
B,
C
}
export enum H {
~
!!! error TS8015: 'enum declarations' can only be used in a .ts file.
A = "a",
B = "b"
}
export enum I {
~
!!! error TS8015: 'enum declarations' can only be used in a .ts file.
A = "a",
B = 0,
C
}
export const enum J {
~
!!! error TS8015: 'enum declarations' can only be used in a .ts file.
A = 1,
B,
C
}
export enum K {
~
!!! error TS8015: 'enum declarations' can only be used in a .ts file.
None = 0,
A = 1 << 0,
B = 1 << 1,
C = 1 << 2,
Mask = A | B | C,
}
export const enum L {
~
!!! error TS8015: 'enum declarations' can only be used in a .ts file.
None = 0,
A = 1 << 0,
B = 1 << 1,
C = 1 << 2,
Mask = A | B | C,
}
@@ -0,0 +1,167 @@
//// [index.js]
// Pretty much all of this should be an error, (since enums are forbidden in js),
// but we should be able to synthesize declarations from the symbols regardless
export enum A {}
export enum B {
Member
}
enum C {}
export { C };
enum DD {}
export { DD as D };
export enum E {}
export { E as EE };
export { F as FF };
export enum F {}
export enum G {
A = 1,
B,
C
}
export enum H {
A = "a",
B = "b"
}
export enum I {
A = "a",
B = 0,
C
}
export const enum J {
A = 1,
B,
C
}
export enum K {
None = 0,
A = 1 << 0,
B = 1 << 1,
C = 1 << 2,
Mask = A | B | C,
}
export const enum L {
None = 0,
A = 1 << 0,
B = 1 << 1,
C = 1 << 2,
Mask = A | B | C,
}
//// [index.js]
"use strict";
// Pretty much all of this should be an error, (since enums are forbidden in js),
// but we should be able to synthesize declarations from the symbols regardless
Object.defineProperty(exports, "__esModule", { value: true });
var A;
(function (A) {
})(A = exports.A || (exports.A = {}));
var B;
(function (B) {
B[B["Member"] = 0] = "Member";
})(B = exports.B || (exports.B = {}));
var C;
(function (C) {
})(C || (C = {}));
exports.C = C;
var DD;
(function (DD) {
})(DD || (DD = {}));
exports.D = DD;
var E;
(function (E) {
})(E = exports.E || (exports.E = {}));
exports.EE = E;
var F;
(function (F) {
})(F = exports.F || (exports.F = {}));
exports.FF = F;
var G;
(function (G) {
G[G["A"] = 1] = "A";
G[G["B"] = 2] = "B";
G[G["C"] = 3] = "C";
})(G = exports.G || (exports.G = {}));
var H;
(function (H) {
H["A"] = "a";
H["B"] = "b";
})(H = exports.H || (exports.H = {}));
var I;
(function (I) {
I["A"] = "a";
I[I["B"] = 0] = "B";
I[I["C"] = 1] = "C";
})(I = exports.I || (exports.I = {}));
var K;
(function (K) {
K[K["None"] = 0] = "None";
K[K["A"] = 1] = "A";
K[K["B"] = 2] = "B";
K[K["C"] = 4] = "C";
K[K["Mask"] = 7] = "Mask";
})(K = exports.K || (exports.K = {}));
//// [index.d.ts]
export enum A {
}
export enum B {
Member = 0
}
export enum E {
}
export enum F {
}
export enum G {
A = 1,
B = 2,
C = 3
}
export enum H {
A = "a",
B = "b"
}
export enum I {
A = "a",
B = 0,
C = 1
}
export const enum J {
A = 1,
B = 2,
C = 3
}
export enum K {
None = 0,
A = 1,
B = 2,
C = 4,
Mask = 7
}
export const enum L {
None = 0,
A = 1,
B = 2,
C = 4,
Mask = 7
}
export enum C {
}
declare enum DD {
}
export { DD as D, E as EE, F as FF };
@@ -0,0 +1,134 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
// Pretty much all of this should be an error, (since enums are forbidden in js),
// but we should be able to synthesize declarations from the symbols regardless
export enum A {}
>A : Symbol(A, Decl(index.js, 0, 0))
export enum B {
>B : Symbol(B, Decl(index.js, 3, 16))
Member
>Member : Symbol(B.Member, Decl(index.js, 5, 15))
}
enum C {}
>C : Symbol(C, Decl(index.js, 7, 1))
export { C };
>C : Symbol(C, Decl(index.js, 11, 8))
enum DD {}
>DD : Symbol(DD, Decl(index.js, 11, 13))
export { DD as D };
>DD : Symbol(DD, Decl(index.js, 11, 13))
>D : Symbol(D, Decl(index.js, 15, 8))
export enum E {}
>E : Symbol(E, Decl(index.js, 15, 19))
export { E as EE };
>E : Symbol(E, Decl(index.js, 15, 19))
>EE : Symbol(EE, Decl(index.js, 18, 8))
export { F as FF };
>F : Symbol(F, Decl(index.js, 20, 19))
>FF : Symbol(FF, Decl(index.js, 20, 8))
export enum F {}
>F : Symbol(F, Decl(index.js, 20, 19))
export enum G {
>G : Symbol(G, Decl(index.js, 21, 16))
A = 1,
>A : Symbol(G.A, Decl(index.js, 23, 15))
B,
>B : Symbol(G.B, Decl(index.js, 24, 10))
C
>C : Symbol(G.C, Decl(index.js, 25, 6))
}
export enum H {
>H : Symbol(H, Decl(index.js, 27, 1))
A = "a",
>A : Symbol(H.A, Decl(index.js, 29, 15))
B = "b"
>B : Symbol(H.B, Decl(index.js, 30, 12))
}
export enum I {
>I : Symbol(I, Decl(index.js, 32, 1))
A = "a",
>A : Symbol(I.A, Decl(index.js, 34, 15))
B = 0,
>B : Symbol(I.B, Decl(index.js, 35, 12))
C
>C : Symbol(I.C, Decl(index.js, 36, 10))
}
export const enum J {
>J : Symbol(J, Decl(index.js, 38, 1))
A = 1,
>A : Symbol(J.A, Decl(index.js, 40, 21))
B,
>B : Symbol(J.B, Decl(index.js, 41, 10))
C
>C : Symbol(J.C, Decl(index.js, 42, 6))
}
export enum K {
>K : Symbol(K, Decl(index.js, 44, 1))
None = 0,
>None : Symbol(K.None, Decl(index.js, 46, 15))
A = 1 << 0,
>A : Symbol(K.A, Decl(index.js, 47, 15))
B = 1 << 1,
>B : Symbol(K.B, Decl(index.js, 48, 15))
C = 1 << 2,
>C : Symbol(K.C, Decl(index.js, 49, 15))
Mask = A | B | C,
>Mask : Symbol(K.Mask, Decl(index.js, 50, 15))
>A : Symbol(K.A, Decl(index.js, 47, 15))
>B : Symbol(K.B, Decl(index.js, 48, 15))
>C : Symbol(K.C, Decl(index.js, 49, 15))
}
export const enum L {
>L : Symbol(L, Decl(index.js, 52, 1))
None = 0,
>None : Symbol(L.None, Decl(index.js, 54, 21))
A = 1 << 0,
>A : Symbol(L.A, Decl(index.js, 55, 15))
B = 1 << 1,
>B : Symbol(L.B, Decl(index.js, 56, 15))
C = 1 << 2,
>C : Symbol(L.C, Decl(index.js, 57, 15))
Mask = A | B | C,
>Mask : Symbol(L.Mask, Decl(index.js, 58, 15))
>A : Symbol(L.A, Decl(index.js, 55, 15))
>B : Symbol(L.B, Decl(index.js, 56, 15))
>C : Symbol(L.C, Decl(index.js, 57, 15))
}
@@ -0,0 +1,164 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
// Pretty much all of this should be an error, (since enums are forbidden in js),
// but we should be able to synthesize declarations from the symbols regardless
export enum A {}
>A : A
export enum B {
>B : B
Member
>Member : B.Member
}
enum C {}
>C : C
export { C };
>C : typeof C
enum DD {}
>DD : DD
export { DD as D };
>DD : typeof DD
>D : typeof DD
export enum E {}
>E : E
export { E as EE };
>E : typeof E
>EE : typeof E
export { F as FF };
>F : typeof F
>FF : typeof F
export enum F {}
>F : F
export enum G {
>G : G
A = 1,
>A : G.A
>1 : 1
B,
>B : G.B
C
>C : G.C
}
export enum H {
>H : H
A = "a",
>A : H.A
>"a" : "a"
B = "b"
>B : H.B
>"b" : "b"
}
export enum I {
>I : I
A = "a",
>A : I.A
>"a" : "a"
B = 0,
>B : I.B
>0 : 0
C
>C : I.C
}
export const enum J {
>J : J
A = 1,
>A : J.A
>1 : 1
B,
>B : J.B
C
>C : J.C
}
export enum K {
>K : K
None = 0,
>None : K
>0 : 0
A = 1 << 0,
>A : K
>1 << 0 : number
>1 : 1
>0 : 0
B = 1 << 1,
>B : K
>1 << 1 : number
>1 : 1
>1 : 1
C = 1 << 2,
>C : K
>1 << 2 : number
>1 : 1
>2 : 2
Mask = A | B | C,
>Mask : K
>A | B | C : number
>A | B : number
>A : K
>B : K
>C : K
}
export const enum L {
>L : L
None = 0,
>None : L
>0 : 0
A = 1 << 0,
>A : L
>1 << 0 : number
>1 : 1
>0 : 0
B = 1 << 1,
>B : L
>1 << 1 : number
>1 : 1
>1 : 1
C = 1 << 2,
>C : L
>1 << 2 : number
>1 : 1
>2 : 2
Mask = A | B | C,
>Mask : L
>A | B | C : number
>A | B : number
>A : L
>B : L
>C : L
}
@@ -0,0 +1,31 @@
//// [index.js]
module.exports = class Thing {
/**
* @param {number} p
*/
constructor(p) {
this.t = 12 + p;
}
}
//// [index.js]
module.exports = /** @class */ (function () {
/**
* @param {number} p
*/
function Thing(p) {
this.t = 12 + p;
}
return Thing;
}());
//// [index.d.ts]
export = Thing;
declare class Thing {
/**
* @param {number} p
*/
constructor(p: number);
t: number;
}
@@ -0,0 +1,20 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
module.exports = class Thing {
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(export=, Decl(index.js, 0, 0))
>exports : Symbol(export=, Decl(index.js, 0, 0))
>Thing : Symbol(Thing, Decl(index.js, 0, 16))
/**
* @param {number} p
*/
constructor(p) {
>p : Symbol(p, Decl(index.js, 4, 16))
this.t = 12 + p;
>this.t : Symbol(Thing.t, Decl(index.js, 4, 20))
>this : Symbol(Thing, Decl(index.js, 0, 16))
>t : Symbol(Thing.t, Decl(index.js, 4, 20))
>p : Symbol(p, Decl(index.js, 4, 16))
}
}
@@ -0,0 +1,25 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
module.exports = class Thing {
>module.exports = class Thing { /** * @param {number} p */ constructor(p) { this.t = 12 + p; }} : typeof import("tests/cases/conformance/jsdoc/declarations/index")
>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")
>class Thing { /** * @param {number} p */ constructor(p) { this.t = 12 + p; }} : typeof import("tests/cases/conformance/jsdoc/declarations/index")
>Thing : typeof import("tests/cases/conformance/jsdoc/declarations/index")
/**
* @param {number} p
*/
constructor(p) {
>p : number
this.t = 12 + p;
>this.t = 12 + p : number
>this.t : number
>this : this
>t : number
>12 + p : number
>12 : 12
>p : number
}
}
@@ -0,0 +1,31 @@
//// [index.js]
module.exports = class {
/**
* @param {number} p
*/
constructor(p) {
this.t = 12 + p;
}
}
//// [index.js]
module.exports = /** @class */ (function () {
/**
* @param {number} p
*/
function exports(p) {
this.t = 12 + p;
}
return exports;
}());
//// [index.d.ts]
export = exports;
declare class exports {
/**
* @param {number} p
*/
constructor(p: number);
t: number;
}
@@ -0,0 +1,19 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
module.exports = class {
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(export=, Decl(index.js, 0, 0))
>exports : Symbol(export=, Decl(index.js, 0, 0))
/**
* @param {number} p
*/
constructor(p) {
>p : Symbol(p, Decl(index.js, 4, 16))
this.t = 12 + p;
>this.t : Symbol(exports.t, Decl(index.js, 4, 20))
>this : Symbol(exports, Decl(index.js, 0, 16))
>t : Symbol(exports.t, Decl(index.js, 4, 20))
>p : Symbol(p, Decl(index.js, 4, 16))
}
}
@@ -0,0 +1,24 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
module.exports = class {
>module.exports = class { /** * @param {number} p */ constructor(p) { this.t = 12 + p; }} : typeof import("tests/cases/conformance/jsdoc/declarations/index")
>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")
>class { /** * @param {number} p */ constructor(p) { this.t = 12 + p; }} : typeof import("tests/cases/conformance/jsdoc/declarations/index")
/**
* @param {number} p
*/
constructor(p) {
>p : number
this.t = 12 + p;
>this.t = 12 + p : number
>this.t : number
>this : this
>t : number
>12 + p : number
>12 : 12
>p : number
}
}
@@ -0,0 +1,49 @@
//// [index.js]
module.exports = class {
/**
* @param {number} p
*/
constructor(p) {
this.t = 12 + p;
}
}
module.exports.Sub = class {
constructor() {
this.instance = new module.exports(10);
}
}
//// [index.js]
module.exports = /** @class */ (function () {
/**
* @param {number} p
*/
function exports(p) {
this.t = 12 + p;
}
return exports;
}());
module.exports.Sub = /** @class */ (function () {
function Sub() {
this.instance = new module.exports(10);
}
return Sub;
}());
//// [index.d.ts]
export = exports;
declare class exports {
/**
* @param {number} p
*/
constructor(p: number);
t: number;
}
declare namespace exports {
export { Sub };
}
declare class Sub {
instance: import(".");
}
@@ -0,0 +1,37 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
module.exports = class {
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(export=, Decl(index.js, 0, 0))
>exports : Symbol(export=, Decl(index.js, 0, 0))
/**
* @param {number} p
*/
constructor(p) {
>p : Symbol(p, Decl(index.js, 4, 16))
this.t = 12 + p;
>this.t : Symbol(exports.t, Decl(index.js, 4, 20))
>this : Symbol(exports, Decl(index.js, 0, 16))
>t : Symbol(exports.t, Decl(index.js, 4, 20))
>p : Symbol(p, Decl(index.js, 4, 16))
}
}
module.exports.Sub = class {
>module.exports.Sub : Symbol(Sub)
>module.exports : Symbol(Sub, Decl(index.js, 7, 1))
>module : Symbol(module, Decl(index.js, 0, 0), Decl(index.js, 10, 27))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>Sub : Symbol(Sub, Decl(index.js, 7, 1))
constructor() {
this.instance = new module.exports(10);
>this.instance : Symbol(Sub.instance, Decl(index.js, 9, 19))
>this : Symbol(Sub, Decl(index.js, 8, 20))
>instance : Symbol(Sub.instance, Decl(index.js, 9, 19))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 0), Decl(index.js, 10, 27))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
}
}
@@ -0,0 +1,47 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
module.exports = class {
>module.exports = class { /** * @param {number} p */ constructor(p) { this.t = 12 + p; }} : typeof import("tests/cases/conformance/jsdoc/declarations/index")
>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")
>class { /** * @param {number} p */ constructor(p) { this.t = 12 + p; }} : typeof import("tests/cases/conformance/jsdoc/declarations/index")
/**
* @param {number} p
*/
constructor(p) {
>p : number
this.t = 12 + p;
>this.t = 12 + p : number
>this.t : number
>this : this
>t : number
>12 + p : number
>12 : 12
>p : number
}
}
module.exports.Sub = class {
>module.exports.Sub = class { constructor() { this.instance = new module.exports(10); }} : typeof Sub
>module.exports.Sub : typeof Sub
>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")
>Sub : typeof Sub
>class { constructor() { this.instance = new module.exports(10); }} : typeof Sub
constructor() {
this.instance = new module.exports(10);
>this.instance = new module.exports(10) : import("tests/cases/conformance/jsdoc/declarations/index")
>this.instance : import("tests/cases/conformance/jsdoc/declarations/index")
>this : this
>instance : import("tests/cases/conformance/jsdoc/declarations/index")
>new module.exports(10) : import("tests/cases/conformance/jsdoc/declarations/index")
>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")
>10 : 10
}
}
@@ -0,0 +1,86 @@
//// [index.js]
// TODO: Fixup
class A {
member = new Q();
}
class Q {
x = 42;
}
module.exports = class Q {
constructor() {
this.x = new A();
}
}
module.exports.Another = Q;
//// [index.js]
// TODO: Fixup
var A = /** @class */ (function () {
function A() {
this.member = new Q();
}
return A;
}());
var Q = /** @class */ (function () {
function Q() {
this.x = 42;
}
return Q;
}());
module.exports = /** @class */ (function () {
function Q() {
this.x = new A();
}
return Q;
}());
module.exports.Another = Q;
//// [index.d.ts]
export = Q;
declare class Q {
x: A;
}
declare namespace Q {
export { Another };
}
declare class A {
member: Q;
}
declare var Another: typeof Q;
declare class Q {
x: number;
}
//// [DtsFileErrors]
out/index.d.ts(2,15): error TS2300: Duplicate identifier 'Q'.
out/index.d.ts(5,19): error TS2300: Duplicate identifier 'Q'.
out/index.d.ts(12,15): error TS2300: Duplicate identifier 'Q'.
==== ./out/index.d.ts (3 errors) ====
export = Q;
declare class Q {
~
!!! error TS2300: Duplicate identifier 'Q'.
x: A;
}
declare namespace Q {
~
!!! error TS2300: Duplicate identifier 'Q'.
export { Another };
}
declare class A {
member: Q;
}
declare var Another: typeof Q;
declare class Q {
~
!!! error TS2300: Duplicate identifier 'Q'.
x: number;
}
@@ -0,0 +1,37 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
// TODO: Fixup
class A {
>A : Symbol(A, Decl(index.js, 0, 0))
member = new Q();
>member : Symbol(A.member, Decl(index.js, 1, 9))
>Q : Symbol(Q, Decl(index.js, 3, 1))
}
class Q {
>Q : Symbol(Q, Decl(index.js, 3, 1))
x = 42;
>x : Symbol(Q.x, Decl(index.js, 4, 9))
}
module.exports = class Q {
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(export=, Decl(index.js, 6, 1))
>exports : Symbol(export=, Decl(index.js, 6, 1))
>Q : Symbol(Q, Decl(index.js, 7, 16))
constructor() {
this.x = new A();
>this.x : Symbol(Q.x, Decl(index.js, 8, 19))
>this : Symbol(Q, Decl(index.js, 7, 16))
>x : Symbol(Q.x, Decl(index.js, 8, 19))
>A : Symbol(A, Decl(index.js, 0, 0))
}
}
module.exports.Another = Q;
>module.exports.Another : Symbol(Another)
>module.exports : Symbol(Another, Decl(index.js, 11, 1))
>module : Symbol(module, Decl(index.js, 6, 1))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>Another : Symbol(Another, Decl(index.js, 11, 1))
>Q : Symbol(Q, Decl(index.js, 3, 1))
@@ -0,0 +1,44 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
// TODO: Fixup
class A {
>A : A
member = new Q();
>member : Q
>new Q() : Q
>Q : typeof Q
}
class Q {
>Q : Q
x = 42;
>x : number
>42 : 42
}
module.exports = class Q {
>module.exports = class Q { constructor() { this.x = new A(); }} : typeof import("tests/cases/conformance/jsdoc/declarations/index")
>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")
>class Q { constructor() { this.x = new A(); }} : typeof import("tests/cases/conformance/jsdoc/declarations/index")
>Q : typeof import("tests/cases/conformance/jsdoc/declarations/index")
constructor() {
this.x = new A();
>this.x = new A() : A
>this.x : A
>this : this
>x : A
>new A() : A
>A : typeof A
}
}
module.exports.Another = Q;
>module.exports.Another = Q : typeof Q
>module.exports.Another : typeof Q
>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")
>Another : typeof Q
>Q : typeof Q
@@ -0,0 +1,47 @@
//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedVisibility.ts] ////
//// [obj.js]
module.exports = class Obj {
constructor() {
this.x = 12;
}
}
//// [index.js]
const Obj = require("./obj");
class Container {
constructor() {
this.usage = new Obj();
}
}
module.exports = Container;
//// [obj.js]
module.exports = /** @class */ (function () {
function Obj() {
this.x = 12;
}
return Obj;
}());
//// [index.js]
var Obj = require("./obj");
var Container = /** @class */ (function () {
function Container() {
this.usage = new Obj();
}
return Container;
}());
module.exports = Container;
//// [obj.d.ts]
export = Obj;
declare class Obj {
x: number;
}
//// [index.d.ts]
export = Container;
declare class Container {
usage: import("./obj");
}
@@ -0,0 +1,38 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
const Obj = require("./obj");
>Obj : Symbol(Obj, Decl(index.js, 0, 5))
>require : Symbol(require)
>"./obj" : Symbol("tests/cases/conformance/jsdoc/declarations/obj", Decl(obj.js, 0, 0))
class Container {
>Container : Symbol(Container, Decl(index.js, 0, 29))
constructor() {
this.usage = new Obj();
>this.usage : Symbol(Container.usage, Decl(index.js, 3, 19))
>this : Symbol(Container, Decl(index.js, 0, 29))
>usage : Symbol(Container.usage, Decl(index.js, 3, 19))
>Obj : Symbol(Obj, Decl(index.js, 0, 5))
}
}
module.exports = Container;
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(export=, Decl(index.js, 6, 1))
>exports : Symbol(export=, Decl(index.js, 6, 1))
>Container : Symbol(Container, Decl(index.js, 0, 29))
=== tests/cases/conformance/jsdoc/declarations/obj.js ===
module.exports = class Obj {
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/obj", Decl(obj.js, 0, 0))
>module : Symbol(export=, Decl(obj.js, 0, 0))
>exports : Symbol(export=, Decl(obj.js, 0, 0))
>Obj : Symbol(Obj, Decl(obj.js, 0, 16))
constructor() {
this.x = 12;
>this.x : Symbol(Obj.x, Decl(obj.js, 1, 19))
>this : Symbol(Obj, Decl(obj.js, 0, 16))
>x : Symbol(Obj.x, Decl(obj.js, 1, 19))
}
}
@@ -0,0 +1,46 @@
=== 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")
>require : any
>"./obj" : "./obj"
class Container {
>Container : Container
constructor() {
this.usage = new Obj();
>this.usage = new Obj() : import("tests/cases/conformance/jsdoc/declarations/obj")
>this.usage : import("tests/cases/conformance/jsdoc/declarations/obj")
>this : this
>usage : import("tests/cases/conformance/jsdoc/declarations/obj")
>new Obj() : import("tests/cases/conformance/jsdoc/declarations/obj")
>Obj : typeof import("tests/cases/conformance/jsdoc/declarations/obj")
}
}
module.exports = Container;
>module.exports = Container : typeof Container
>module.exports : typeof Container
>module : { "tests/cases/conformance/jsdoc/declarations/index": typeof Container; }
>exports : typeof Container
>Container : typeof Container
=== tests/cases/conformance/jsdoc/declarations/obj.js ===
module.exports = class Obj {
>module.exports = class Obj { constructor() { this.x = 12; }} : typeof import("tests/cases/conformance/jsdoc/declarations/obj")
>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/obj")
>module : { "tests/cases/conformance/jsdoc/declarations/obj": typeof import("tests/cases/conformance/jsdoc/declarations/obj"); }
>exports : typeof import("tests/cases/conformance/jsdoc/declarations/obj")
>class Obj { constructor() { this.x = 12; }} : typeof import("tests/cases/conformance/jsdoc/declarations/obj")
>Obj : typeof import("tests/cases/conformance/jsdoc/declarations/obj")
constructor() {
this.x = 12;
>this.x = 12 : 12
>this.x : number
>this : this
>x : number
>12 : 12
}
}
@@ -0,0 +1,40 @@
//// [index.js]
const Strings = {
a: "A",
b: "B"
};
module.exports = {
thing: "ok",
also: "ok",
desc: {
item: "ok"
}
};
module.exports.Strings = Strings;
//// [index.js]
var Strings = {
a: "A",
b: "B"
};
module.exports = {
thing: "ok",
also: "ok",
desc: {
item: "ok"
}
};
module.exports.Strings = Strings;
//// [index.d.ts]
export namespace Strings {
export const a: string;
export const b: string;
}
export declare const thing: string;
export declare const also: string;
export declare namespace desc {
export const item: string;
}
@@ -0,0 +1,37 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
const Strings = {
>Strings : Symbol(Strings, Decl(index.js, 0, 5))
a: "A",
>a : Symbol(a, Decl(index.js, 0, 17))
b: "B"
>b : Symbol(b, Decl(index.js, 1, 11))
};
module.exports = {
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(export=, Decl(index.js, 3, 2))
>exports : Symbol(export=, Decl(index.js, 3, 2))
thing: "ok",
>thing : Symbol(thing, Decl(index.js, 4, 18))
also: "ok",
>also : Symbol(also, Decl(index.js, 5, 16))
desc: {
>desc : Symbol(desc, Decl(index.js, 6, 15))
item: "ok"
>item : Symbol(item, Decl(index.js, 7, 11))
}
};
module.exports.Strings = Strings;
>module.exports.Strings : Symbol(Strings, Decl(index.js, 10, 2))
>module.exports : Symbol(Strings, Decl(index.js, 10, 2))
>module : Symbol(module, Decl(index.js, 3, 2))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>Strings : Symbol(Strings, Decl(index.js, 10, 2))
>Strings : Symbol(Strings, Decl(index.js, 0, 5))
@@ -0,0 +1,47 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
const Strings = {
>Strings : { a: string; b: string; }
>{ a: "A", b: "B"} : { a: string; b: string; }
a: "A",
>a : string
>"A" : "A"
b: "B"
>b : string
>"B" : "B"
};
module.exports = {
>module.exports = { thing: "ok", also: "ok", desc: { item: "ok" }} : { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; }
>module.exports : { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; }
>module : { "tests/cases/conformance/jsdoc/declarations/index": { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; }; }
>exports : { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; }
>{ thing: "ok", also: "ok", desc: { item: "ok" }} : { thing: string; also: string; desc: { item: string; }; }
thing: "ok",
>thing : string
>"ok" : "ok"
also: "ok",
>also : string
>"ok" : "ok"
desc: {
>desc : { item: string; }
>{ item: "ok" } : { item: string; }
item: "ok"
>item : string
>"ok" : "ok"
}
};
module.exports.Strings = Strings;
>module.exports.Strings = Strings : { a: string; b: string; }
>module.exports.Strings : { a: string; b: string; }
>module.exports : { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; }
>module : { "tests/cases/conformance/jsdoc/declarations/index": { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; }; }
>exports : { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; }
>Strings : { a: string; b: string; }
>Strings : { a: string; b: string; }
@@ -0,0 +1,30 @@
//// [index.js]
var x = 12;
module.exports = {
extends: 'base',
more: {
others: ['strs']
},
x
};
//// [index.js]
var x = 12;
module.exports = {
extends: 'base',
more: {
others: ['strs']
},
x: x
};
//// [index.d.ts]
declare const _exports: {
extends: string;
more: {
others: string[];
};
x: number;
};
export = _exports;
@@ -0,0 +1,23 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
var x = 12;
>x : Symbol(x, Decl(index.js, 0, 3))
module.exports = {
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(export=, Decl(index.js, 0, 11))
>exports : Symbol(export=, Decl(index.js, 0, 11))
extends: 'base',
>extends : Symbol(extends, Decl(index.js, 1, 18))
more: {
>more : Symbol(more, Decl(index.js, 2, 20))
others: ['strs']
>others : Symbol(others, Decl(index.js, 3, 11))
},
x
>x : Symbol(x, Decl(index.js, 5, 6))
};
@@ -0,0 +1,30 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
var x = 12;
>x : number
>12 : 12
module.exports = {
>module.exports = { extends: 'base', more: { others: ['strs'] }, x} : { extends: string; more: { others: string[]; }; x: number; }
>module.exports : { extends: string; more: { others: string[]; }; x: number; }
>module : { "tests/cases/conformance/jsdoc/declarations/index": { extends: string; more: { others: string[]; }; x: number; }; }
>exports : { extends: string; more: { others: string[]; }; x: number; }
>{ extends: 'base', more: { others: ['strs'] }, x} : { extends: string; more: { others: string[]; }; x: number; }
extends: 'base',
>extends : string
>'base' : "base"
more: {
>more : { others: string[]; }
>{ others: ['strs'] } : { others: string[]; }
others: ['strs']
>others : string[]
>['strs'] : string[]
>'strs' : "strs"
},
x
>x : number
};
@@ -0,0 +1,165 @@
//// [index.js]
Object.defineProperty(module.exports, "a", { value: function a() {} });
Object.defineProperty(module.exports, "b", { value: function b() {} });
Object.defineProperty(module.exports.b, "cat", { value: "cat" });
/**
* @param {number} a
* @param {number} b
* @return {string}
*/
function d(a, b) { return /** @type {*} */(null); }
Object.defineProperty(module.exports, "d", { value: d });
/**
* @template T,U
* @param {T} a
* @param {U} b
* @return {T & U}
*/
function e(a, b) { return /** @type {*} */(null); }
Object.defineProperty(module.exports, "e", { value: e });
/**
* @template T
* @param {T} a
*/
function f(a) {
return a;
}
Object.defineProperty(module.exports, "f", { value: f });
Object.defineProperty(module.exports.f, "self", { value: module.exports.f });
/**
* @param {{x: string}} a
* @param {{y: typeof module.exports.b}} b
*/
function g(a, b) {
return a.x && b.y();
}
Object.defineProperty(module.exports, "g", { value: g });
/**
* @param {{x: string}} a
* @param {{y: typeof module.exports.b}} b
*/
function hh(a, b) {
return a.x && b.y();
}
Object.defineProperty(module.exports, "h", { value: hh });
Object.defineProperty(module.exports, "i", { value: function i(){} });
Object.defineProperty(module.exports, "ii", { value: module.exports.i });
// note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings
Object.defineProperty(module.exports, "jj", { value: module.exports.j });
Object.defineProperty(module.exports, "j", { value: function j() {} });
//// [index.js]
Object.defineProperty(module.exports, "a", { value: function a() { } });
Object.defineProperty(module.exports, "b", { value: function b() { } });
Object.defineProperty(module.exports.b, "cat", { value: "cat" });
/**
* @param {number} a
* @param {number} b
* @return {string}
*/
function d(a, b) { return /** @type {*} */ (null); }
Object.defineProperty(module.exports, "d", { value: d });
/**
* @template T,U
* @param {T} a
* @param {U} b
* @return {T & U}
*/
function e(a, b) { return /** @type {*} */ (null); }
Object.defineProperty(module.exports, "e", { value: e });
/**
* @template T
* @param {T} a
*/
function f(a) {
return a;
}
Object.defineProperty(module.exports, "f", { value: f });
Object.defineProperty(module.exports.f, "self", { value: module.exports.f });
/**
* @param {{x: string}} a
* @param {{y: typeof module.exports.b}} b
*/
function g(a, b) {
return a.x && b.y();
}
Object.defineProperty(module.exports, "g", { value: g });
/**
* @param {{x: string}} a
* @param {{y: typeof module.exports.b}} b
*/
function hh(a, b) {
return a.x && b.y();
}
Object.defineProperty(module.exports, "h", { value: hh });
Object.defineProperty(module.exports, "i", { value: function i() { } });
Object.defineProperty(module.exports, "ii", { value: module.exports.i });
// note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings
Object.defineProperty(module.exports, "jj", { value: module.exports.j });
Object.defineProperty(module.exports, "j", { value: function j() { } });
//// [index.d.ts]
export function a(): void;
export function b(): void;
export namespace b {
export const cat: string;
}
/**
* @param {number} a
* @param {number} b
* @return {string}
*/
export function d(a: number, b: number): string;
/**
* @template T,U
* @param {T} a
* @param {U} b
* @return {T & U}
*/
export function e<T, U>(a: T, b: U): T & U;
/**
* @template T
* @param {T} a
*/
export function f<T>(a: T): T;
export namespace f {
/**
* @template T
* @param {T} a
*/
export function self<T>(a: T): T;
}
/**
* @param {{x: string}} a
* @param {{y: typeof module.exports.b}} b
*/
export function g(a: {
x: string;
}, b: {
y: () => void;
}): void;
/**
* @param {{x: string}} a
* @param {{y: typeof module.exports.b}} b
*/
export function h(a: {
x: string;
}, b: {
y: () => void;
}): void;
export function i(): void;
export function ii(): void;
export function jj(): void;
export function j(): void;
@@ -0,0 +1,228 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
Object.defineProperty(module.exports, "a", { value: function a() {} });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>"a" : Symbol(a, Decl(index.js, 0, 0))
>value : Symbol(value, Decl(index.js, 0, 44))
>a : Symbol(a, Decl(index.js, 0, 51))
Object.defineProperty(module.exports, "b", { value: function b() {} });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>"b" : Symbol(b, Decl(index.js, 0, 71), Decl(index.js, 3, 37))
>value : Symbol(value, Decl(index.js, 2, 44))
>b : Symbol(b, Decl(index.js, 2, 51))
Object.defineProperty(module.exports.b, "cat", { value: "cat" });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports.b : Symbol(b, Decl(index.js, 0, 71), Decl(index.js, 3, 37))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>b : Symbol(b, Decl(index.js, 0, 71), Decl(index.js, 3, 37))
>"cat" : Symbol(b.cat, Decl(index.js, 2, 71))
>value : Symbol(value, Decl(index.js, 3, 48))
/**
* @param {number} a
* @param {number} b
* @return {string}
*/
function d(a, b) { return /** @type {*} */(null); }
>d : Symbol(d, Decl(index.js, 3, 65))
>a : Symbol(a, Decl(index.js, 10, 11))
>b : Symbol(b, Decl(index.js, 10, 13))
Object.defineProperty(module.exports, "d", { value: d });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>"d" : Symbol(d, Decl(index.js, 10, 51))
>value : Symbol(value, Decl(index.js, 11, 44))
>d : Symbol(d, Decl(index.js, 3, 65))
/**
* @template T,U
* @param {T} a
* @param {U} b
* @return {T & U}
*/
function e(a, b) { return /** @type {*} */(null); }
>e : Symbol(e, Decl(index.js, 11, 57))
>a : Symbol(a, Decl(index.js, 20, 11))
>b : Symbol(b, Decl(index.js, 20, 13))
Object.defineProperty(module.exports, "e", { value: e });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>"e" : Symbol(e, Decl(index.js, 20, 51))
>value : Symbol(value, Decl(index.js, 21, 44))
>e : Symbol(e, Decl(index.js, 11, 57))
/**
* @template T
* @param {T} a
*/
function f(a) {
>f : Symbol(f, Decl(index.js, 21, 57))
>a : Symbol(a, Decl(index.js, 27, 11))
return a;
>a : Symbol(a, Decl(index.js, 27, 11))
}
Object.defineProperty(module.exports, "f", { value: f });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>"f" : Symbol(f, Decl(index.js, 29, 1), Decl(index.js, 31, 37))
>value : Symbol(value, Decl(index.js, 30, 44))
>f : Symbol(f, Decl(index.js, 21, 57))
Object.defineProperty(module.exports.f, "self", { value: module.exports.f });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports.f : Symbol(f, Decl(index.js, 29, 1), Decl(index.js, 31, 37))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>f : Symbol(f, Decl(index.js, 29, 1), Decl(index.js, 31, 37))
>"self" : Symbol(f.self, Decl(index.js, 30, 57))
>value : Symbol(value, Decl(index.js, 31, 49))
>module.exports.f : Symbol(f, Decl(index.js, 29, 1), Decl(index.js, 31, 37))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>f : Symbol(f, Decl(index.js, 29, 1), Decl(index.js, 31, 37))
/**
* @param {{x: string}} a
* @param {{y: typeof module.exports.b}} b
*/
function g(a, b) {
>g : Symbol(g, Decl(index.js, 31, 77))
>a : Symbol(a, Decl(index.js, 37, 11))
>b : Symbol(b, Decl(index.js, 37, 13))
return a.x && b.y();
>a.x : Symbol(x, Decl(index.js, 34, 12))
>a : Symbol(a, Decl(index.js, 37, 11))
>x : Symbol(x, Decl(index.js, 34, 12))
>b.y : Symbol(y, Decl(index.js, 35, 12))
>b : Symbol(b, Decl(index.js, 37, 13))
>y : Symbol(y, Decl(index.js, 35, 12))
}
Object.defineProperty(module.exports, "g", { value: g });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>"g" : Symbol(g, Decl(index.js, 39, 1))
>value : Symbol(value, Decl(index.js, 40, 44))
>g : Symbol(g, Decl(index.js, 31, 77))
/**
* @param {{x: string}} a
* @param {{y: typeof module.exports.b}} b
*/
function hh(a, b) {
>hh : Symbol(hh, Decl(index.js, 40, 57))
>a : Symbol(a, Decl(index.js, 47, 12))
>b : Symbol(b, Decl(index.js, 47, 14))
return a.x && b.y();
>a.x : Symbol(x, Decl(index.js, 44, 12))
>a : Symbol(a, Decl(index.js, 47, 12))
>x : Symbol(x, Decl(index.js, 44, 12))
>b.y : Symbol(y, Decl(index.js, 45, 12))
>b : Symbol(b, Decl(index.js, 47, 14))
>y : Symbol(y, Decl(index.js, 45, 12))
}
Object.defineProperty(module.exports, "h", { value: hh });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>"h" : Symbol(h, Decl(index.js, 49, 1))
>value : Symbol(value, Decl(index.js, 50, 44))
>hh : Symbol(hh, Decl(index.js, 40, 57))
Object.defineProperty(module.exports, "i", { value: function i(){} });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>"i" : Symbol(i, Decl(index.js, 50, 58))
>value : Symbol(value, Decl(index.js, 52, 44))
>i : Symbol(i, Decl(index.js, 52, 51))
Object.defineProperty(module.exports, "ii", { value: module.exports.i });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>"ii" : Symbol(ii, Decl(index.js, 52, 70))
>value : Symbol(value, Decl(index.js, 53, 45))
>module.exports.i : Symbol(i, Decl(index.js, 50, 58))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>i : Symbol(i, Decl(index.js, 50, 58))
// note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings
Object.defineProperty(module.exports, "jj", { value: module.exports.j });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>"jj" : Symbol(jj, Decl(index.js, 53, 73))
>value : Symbol(value, Decl(index.js, 56, 45))
>module.exports.j : Symbol(j, Decl(index.js, 56, 73))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>j : Symbol(j, Decl(index.js, 56, 73))
Object.defineProperty(module.exports, "j", { value: function j() {} });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 22), Decl(index.js, 31, 56), Decl(index.js, 53, 52), Decl(index.js, 56, 52))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0))
>"j" : Symbol(j, Decl(index.js, 56, 73))
>value : Symbol(value, Decl(index.js, 57, 44))
>j : Symbol(j, Decl(index.js, 57, 51))
@@ -0,0 +1,267 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
Object.defineProperty(module.exports, "a", { value: function a() {} });
>Object.defineProperty(module.exports, "a", { value: function a() {} }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>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" : "a"
>{ value: function a() {} } : { value: () => void; }
>value : () => void
>function a() {} : () => void
>a : () => void
Object.defineProperty(module.exports, "b", { value: function b() {} });
>Object.defineProperty(module.exports, "b", { value: function b() {} }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>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")
>"b" : "b"
>{ value: function b() {} } : { value: () => void; }
>value : () => void
>function b() {} : () => void
>b : () => void
Object.defineProperty(module.exports.b, "cat", { value: "cat" });
>Object.defineProperty(module.exports.b, "cat", { value: "cat" }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>module.exports.b : () => void
>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")
>b : () => void
>"cat" : "cat"
>{ value: "cat" } : { value: string; }
>value : string
>"cat" : "cat"
/**
* @param {number} a
* @param {number} b
* @return {string}
*/
function d(a, b) { return /** @type {*} */(null); }
>d : (a: number, b: number) => string
>a : number
>b : number
>(null) : any
>null : null
Object.defineProperty(module.exports, "d", { value: d });
>Object.defineProperty(module.exports, "d", { value: d }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>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")
>"d" : "d"
>{ value: d } : { value: (a: number, b: number) => string; }
>value : (a: number, b: number) => string
>d : (a: number, b: number) => string
/**
* @template T,U
* @param {T} a
* @param {U} b
* @return {T & U}
*/
function e(a, b) { return /** @type {*} */(null); }
>e : <T, U>(a: T, b: U) => T & U
>a : T
>b : U
>(null) : any
>null : null
Object.defineProperty(module.exports, "e", { value: e });
>Object.defineProperty(module.exports, "e", { value: e }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>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")
>"e" : "e"
>{ value: e } : { value: <T, U>(a: T, b: U) => T & U; }
>value : <T, U>(a: T, b: U) => T & U
>e : <T, U>(a: T, b: U) => T & U
/**
* @template T
* @param {T} a
*/
function f(a) {
>f : <T>(a: T) => T
>a : T
return a;
>a : T
}
Object.defineProperty(module.exports, "f", { value: f });
>Object.defineProperty(module.exports, "f", { value: f }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>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")
>"f" : "f"
>{ value: f } : { value: <T>(a: T) => T; }
>value : <T>(a: T) => T
>f : <T>(a: T) => T
Object.defineProperty(module.exports.f, "self", { value: module.exports.f });
>Object.defineProperty(module.exports.f, "self", { value: module.exports.f }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>module.exports.f : <T>(a: T) => T
>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")
>f : <T>(a: T) => T
>"self" : "self"
>{ value: module.exports.f } : { value: <T>(a: T) => T; }
>value : <T>(a: T) => T
>module.exports.f : <T>(a: T) => T
>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")
>f : <T>(a: T) => T
/**
* @param {{x: string}} a
* @param {{y: typeof module.exports.b}} b
*/
function g(a, b) {
>g : (a: { x: string; }, b: { y: () => void; }) => void
>a : { x: string; }
>b : { y: () => void; }
return a.x && b.y();
>a.x && b.y() : void
>a.x : string
>a : { x: string; }
>x : string
>b.y() : void
>b.y : () => void
>b : { y: () => void; }
>y : () => void
}
Object.defineProperty(module.exports, "g", { value: g });
>Object.defineProperty(module.exports, "g", { value: g }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>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")
>"g" : "g"
>{ value: g } : { value: (a: { x: string; }, b: { y: () => void; }) => void; }
>value : (a: { x: string; }, b: { y: () => void; }) => void
>g : (a: { x: string; }, b: { y: () => void; }) => void
/**
* @param {{x: string}} a
* @param {{y: typeof module.exports.b}} b
*/
function hh(a, b) {
>hh : (a: { x: string; }, b: { y: () => void; }) => void
>a : { x: string; }
>b : { y: () => void; }
return a.x && b.y();
>a.x && b.y() : void
>a.x : string
>a : { x: string; }
>x : string
>b.y() : void
>b.y : () => void
>b : { y: () => void; }
>y : () => void
}
Object.defineProperty(module.exports, "h", { value: hh });
>Object.defineProperty(module.exports, "h", { value: hh }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>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")
>"h" : "h"
>{ value: hh } : { value: (a: { x: string; }, b: { y: () => void; }) => void; }
>value : (a: { x: string; }, b: { y: () => void; }) => void
>hh : (a: { x: string; }, b: { y: () => void; }) => void
Object.defineProperty(module.exports, "i", { value: function i(){} });
>Object.defineProperty(module.exports, "i", { value: function i(){} }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>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")
>"i" : "i"
>{ value: function i(){} } : { value: () => void; }
>value : () => void
>function i(){} : () => void
>i : () => void
Object.defineProperty(module.exports, "ii", { value: module.exports.i });
>Object.defineProperty(module.exports, "ii", { value: module.exports.i }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>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")
>"ii" : "ii"
>{ value: module.exports.i } : { value: () => void; }
>value : () => void
>module.exports.i : () => void
>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")
>i : () => void
// note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings
Object.defineProperty(module.exports, "jj", { value: module.exports.j });
>Object.defineProperty(module.exports, "jj", { value: module.exports.j }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>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")
>"jj" : "jj"
>{ value: module.exports.j } : { value: () => void; }
>value : () => void
>module.exports.j : () => void
>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")
>j : () => void
Object.defineProperty(module.exports, "j", { value: function j() {} });
>Object.defineProperty(module.exports, "j", { value: function j() {} }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>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")
>"j" : "j"
>{ value: function j() {} } : { value: () => void; }
>value : () => void
>function j() {} : () => void
>j : () => void
@@ -0,0 +1,169 @@
//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportForms.ts] ////
//// [cls.js]
export class Foo {}
//// [func.js]
export function func() {}
//// [bar.js]
export * from "./cls";
//// [bar2.js]
export * from "./func";
export * from "./cls";
//// [baz.js]
import {Foo} from "./cls";
export {Foo};
//// [bat.js]
import * as ns from "./cls";
export default ns;
//// [ban.js]
import * as ns from "./cls";
export {ns};
//// [bol.js]
import * as ns from "./cls";
export { ns as classContainer };
//// [cjs.js]
const ns = require("./cls");
module.exports = { ns };
//// [cjs2.js]
const ns = require("./cls");
module.exports = ns;
//// [cjs3.js]
const ns = require("./cls");
module.exports.ns = ns;
//// [cjs4.js]
const ns = require("./cls");
module.exports.names = ns;
//// [includeAll.js]
import "./cjs4";
import "./cjs3";
import "./cjs2";
import "./cjs";
import "./bol";
import "./ban";
import "./bat";
import "./baz";
import "./bar";
import "./bar2";
//// [cls.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Foo = /** @class */ (function () {
function Foo() {
}
return Foo;
}());
exports.Foo = Foo;
//// [func.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function func() { }
exports.func = func;
//// [bar.js]
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./cls"));
//// [bar2.js]
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./func"));
__export(require("./cls"));
//// [baz.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var cls_1 = require("./cls");
exports.Foo = cls_1.Foo;
//// [bat.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ns = require("./cls");
exports.default = ns;
//// [ban.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ns = require("./cls");
exports.ns = ns;
//// [bol.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ns = require("./cls");
exports.classContainer = ns;
//// [cjs.js]
var ns = require("./cls");
module.exports = { ns: ns };
//// [cjs2.js]
var ns = require("./cls");
module.exports = ns;
//// [cjs3.js]
var ns = require("./cls");
module.exports.ns = ns;
//// [cjs4.js]
var ns = require("./cls");
module.exports.names = ns;
//// [includeAll.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("./cjs4");
require("./cjs3");
require("./cjs2");
require("./cjs");
require("./bol");
require("./ban");
require("./bat");
require("./baz");
require("./bar");
require("./bar2");
//// [cls.d.ts]
export class Foo {
}
//// [func.d.ts]
export function func(): void;
//// [bar.d.ts]
export * from "./cls";
//// [bar2.d.ts]
export * from "./func";
export * from "./cls";
//// [baz.d.ts]
export { Foo };
import { Foo } from "./cls";
//// [bat.d.ts]
export default ns;
import * as ns from "./cls";
//// [ban.d.ts]
export { ns };
import * as ns from "./cls";
//// [bol.d.ts]
export { ns as classContainer };
import * as ns from "./cls";
//// [cjs.d.ts]
export const ns: typeof import("./cls");
//// [cjs2.d.ts]
export = ns;
declare const ns: typeof import("./cls");
//// [cjs3.d.ts]
export var ns: typeof import("./cls");
//// [cjs4.d.ts]
export var names: typeof import("./cls");
//// [includeAll.d.ts]
export {};
@@ -0,0 +1,109 @@
=== tests/cases/conformance/jsdoc/declarations/cls.js ===
export class Foo {}
>Foo : Symbol(Foo, Decl(cls.js, 0, 0))
=== tests/cases/conformance/jsdoc/declarations/func.js ===
export function func() {}
>func : Symbol(func, Decl(func.js, 0, 0))
=== tests/cases/conformance/jsdoc/declarations/bar.js ===
export * from "./cls";
No type information for this code.
No type information for this code.=== tests/cases/conformance/jsdoc/declarations/bar2.js ===
export * from "./func";
No type information for this code.export * from "./cls";
No type information for this code.
No type information for this code.=== tests/cases/conformance/jsdoc/declarations/baz.js ===
import {Foo} from "./cls";
>Foo : Symbol(Foo, Decl(baz.js, 0, 8))
export {Foo};
>Foo : Symbol(Foo, Decl(baz.js, 1, 8))
=== tests/cases/conformance/jsdoc/declarations/bat.js ===
import * as ns from "./cls";
>ns : Symbol(ns, Decl(bat.js, 0, 6))
export default ns;
>ns : Symbol(ns, Decl(bat.js, 0, 6))
=== tests/cases/conformance/jsdoc/declarations/ban.js ===
import * as ns from "./cls";
>ns : Symbol(ns, Decl(ban.js, 0, 6))
export {ns};
>ns : Symbol(ns, Decl(ban.js, 1, 8))
=== tests/cases/conformance/jsdoc/declarations/bol.js ===
import * as ns from "./cls";
>ns : Symbol(ns, Decl(bol.js, 0, 6))
export { ns as classContainer };
>ns : Symbol(ns, Decl(bol.js, 0, 6))
>classContainer : Symbol(classContainer, Decl(bol.js, 1, 8))
=== tests/cases/conformance/jsdoc/declarations/cjs.js ===
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))
module.exports = { ns };
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/cjs", Decl(cjs.js, 0, 0))
>module : Symbol(export=, Decl(cjs.js, 0, 28))
>exports : Symbol(export=, Decl(cjs.js, 0, 28))
>ns : Symbol(ns, Decl(cjs.js, 1, 18))
=== tests/cases/conformance/jsdoc/declarations/cjs2.js ===
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))
module.exports = ns;
>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/cjs2", Decl(cjs2.js, 0, 0))
>module : Symbol(export=, Decl(cjs2.js, 0, 28))
>exports : Symbol(export=, Decl(cjs2.js, 0, 28))
>ns : Symbol(ns, Decl(cjs2.js, 0, 5))
=== tests/cases/conformance/jsdoc/declarations/cjs3.js ===
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))
module.exports.ns = ns;
>module.exports.ns : Symbol(ns, Decl(cjs3.js, 0, 28))
>module.exports : Symbol(ns, Decl(cjs3.js, 0, 28))
>module : Symbol(module, Decl(cjs3.js, 0, 28))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/cjs3", Decl(cjs3.js, 0, 0))
>ns : Symbol(ns, Decl(cjs3.js, 0, 28))
>ns : Symbol(ns, Decl(cjs3.js, 0, 5))
=== tests/cases/conformance/jsdoc/declarations/cjs4.js ===
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))
module.exports.names = ns;
>module.exports.names : Symbol(names, Decl(cjs4.js, 0, 28))
>module.exports : Symbol(names, Decl(cjs4.js, 0, 28))
>module : Symbol(module, Decl(cjs4.js, 0, 28))
>exports : Symbol("tests/cases/conformance/jsdoc/declarations/cjs4", Decl(cjs4.js, 0, 0))
>names : Symbol(names, Decl(cjs4.js, 0, 28))
>ns : Symbol(ns, Decl(cjs4.js, 0, 5))
=== tests/cases/conformance/jsdoc/declarations/includeAll.js ===
import "./cjs4";
No type information for this code.import "./cjs3";
No type information for this code.import "./cjs2";
No type information for this code.import "./cjs";
No type information for this code.import "./bol";
No type information for this code.import "./ban";
No type information for this code.import "./bat";
No type information for this code.import "./baz";
No type information for this code.import "./bar";
No type information for this code.import "./bar2";
No type information for this code.
No type information for this code.
@@ -0,0 +1,118 @@
=== tests/cases/conformance/jsdoc/declarations/cls.js ===
export class Foo {}
>Foo : Foo
=== tests/cases/conformance/jsdoc/declarations/func.js ===
export function func() {}
>func : () => void
=== tests/cases/conformance/jsdoc/declarations/bar.js ===
export * from "./cls";
No type information for this code.
No type information for this code.=== tests/cases/conformance/jsdoc/declarations/bar2.js ===
export * from "./func";
No type information for this code.export * from "./cls";
No type information for this code.
No type information for this code.=== tests/cases/conformance/jsdoc/declarations/baz.js ===
import {Foo} from "./cls";
>Foo : typeof Foo
export {Foo};
>Foo : typeof Foo
=== tests/cases/conformance/jsdoc/declarations/bat.js ===
import * as ns from "./cls";
>ns : typeof ns
export default ns;
>ns : typeof ns
=== tests/cases/conformance/jsdoc/declarations/ban.js ===
import * as ns from "./cls";
>ns : typeof ns
export {ns};
>ns : typeof ns
=== tests/cases/conformance/jsdoc/declarations/bol.js ===
import * as ns from "./cls";
>ns : typeof ns
export { ns as classContainer };
>ns : typeof ns
>classContainer : typeof ns
=== 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")
>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")
=== 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")
>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")
=== 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")
>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 : 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")
=== 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")
>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 : 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")
=== tests/cases/conformance/jsdoc/declarations/includeAll.js ===
import "./cjs4";
No type information for this code.import "./cjs3";
No type information for this code.import "./cjs2";
No type information for this code.import "./cjs";
No type information for this code.import "./bol";
No type information for this code.import "./ban";
No type information for this code.import "./bat";
No type information for this code.import "./baz";
No type information for this code.import "./bar";
No type information for this code.import "./bar2";
No type information for this code.
No type information for this code.
@@ -0,0 +1,34 @@
tests/cases/conformance/jsdoc/declarations/bar.js(1,1): error TS8002: 'import ... =' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/bar.js(2,1): error TS8003: 'export=' can only be used in a .ts file.
tests/cases/conformance/jsdoc/declarations/bin.js(2,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
tests/cases/conformance/jsdoc/declarations/globalNs.js(2,1): error TS1315: Global module exports may only appear in declaration files.
==== tests/cases/conformance/jsdoc/declarations/cls.js (0 errors) ====
export class Foo {}
==== tests/cases/conformance/jsdoc/declarations/bar.js (2 errors) ====
import ns = require("./cls");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS8002: 'import ... =' can only be used in a .ts file.
export = ns; // TS Only
~~~~~~~~~~~~
!!! error TS8003: 'export=' can only be used in a .ts file.
==== tests/cases/conformance/jsdoc/declarations/bin.js (1 errors) ====
import * as ns from "./cls";
module.exports = ns; // We refuse to bind cjs module exports assignments in the same file we find an import in
~~~~~~
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
==== tests/cases/conformance/jsdoc/declarations/globalNs.js (1 errors) ====
export * from "./cls";
export as namespace GLO; // TS Only
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1315: Global module exports may only appear in declaration files.
==== tests/cases/conformance/jsdoc/declarations/includeAll.js (0 errors) ====
import "./bar";
import "./bin";
import "./globalNs";
@@ -0,0 +1,68 @@
//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportFormsErr.ts] ////
//// [cls.js]
export class Foo {}
//// [bar.js]
import ns = require("./cls");
export = ns; // TS Only
//// [bin.js]
import * as ns from "./cls";
module.exports = ns; // We refuse to bind cjs module exports assignments in the same file we find an import in
//// [globalNs.js]
export * from "./cls";
export as namespace GLO; // TS Only
//// [includeAll.js]
import "./bar";
import "./bin";
import "./globalNs";
//// [cls.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Foo = /** @class */ (function () {
function Foo() {
}
return Foo;
}());
exports.Foo = Foo;
//// [bar.js]
"use strict";
var ns = require("./cls");
module.exports = ns;
//// [bin.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ns = require("./cls");
module.exports = ns; // We refuse to bind cjs module exports assignments in the same file we find an import in
//// [globalNs.js]
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./cls"));
//// [includeAll.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("./bar");
require("./bin");
require("./globalNs");
//// [cls.d.ts]
export class Foo {
}
//// [bar.d.ts]
export = ns;
import ns = require("./bar");
//// [bin.d.ts]
export {};
//// [globalNs.d.ts]
export * from "./cls";
//// [includeAll.d.ts]
export {};
@@ -0,0 +1,28 @@
=== tests/cases/conformance/jsdoc/declarations/cls.js ===
export class Foo {}
>Foo : Symbol(Foo, Decl(cls.js, 0, 0))
=== tests/cases/conformance/jsdoc/declarations/bar.js ===
import ns = require("./cls");
>ns : Symbol(ns, Decl(bar.js, 0, 0))
export = ns; // TS Only
>ns : Symbol(ns, Decl(bar.js, 0, 0))
=== tests/cases/conformance/jsdoc/declarations/bin.js ===
import * as ns from "./cls";
>ns : Symbol(ns, Decl(bin.js, 0, 6))
module.exports = ns; // We refuse to bind cjs module exports assignments in the same file we find an import in
>ns : Symbol(ns, Decl(bin.js, 0, 6))
=== tests/cases/conformance/jsdoc/declarations/globalNs.js ===
export * from "./cls";
No type information for this code.export as namespace GLO; // TS Only
No type information for this code.
No type information for this code.=== tests/cases/conformance/jsdoc/declarations/includeAll.js ===
import "./bar";
No type information for this code.import "./bin";
No type information for this code.import "./globalNs";
No type information for this code.
No type information for this code.
@@ -0,0 +1,33 @@
=== tests/cases/conformance/jsdoc/declarations/cls.js ===
export class Foo {}
>Foo : Foo
=== tests/cases/conformance/jsdoc/declarations/bar.js ===
import ns = require("./cls");
>ns : typeof ns
export = ns; // TS Only
>ns : typeof ns
=== tests/cases/conformance/jsdoc/declarations/bin.js ===
import * as ns from "./cls";
>ns : typeof ns
module.exports = ns; // We refuse to bind cjs module exports assignments in the same file we find an import in
>module.exports = ns : any
>module.exports : any
>module : any
>exports : any
>ns : typeof ns
=== tests/cases/conformance/jsdoc/declarations/globalNs.js ===
export * from "./cls";
export as namespace GLO; // TS Only
>GLO : any
=== tests/cases/conformance/jsdoc/declarations/includeAll.js ===
import "./bar";
No type information for this code.import "./bin";
No type information for this code.import "./globalNs";
No type information for this code.
No type information for this code.
Loaded 100 of 304 files, more files were not shown because too many files have changed in this diff. Show more