From 116c09948ef1ed427a1ff37ccf4b92d78027dcf8 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 29 Mar 2021 11:16:03 -0700 Subject: [PATCH] Add --metadataDecorator option --- src/compiler/checker.ts | 551 +++++++++++++----- src/compiler/commandLineParser.ts | 15 + src/compiler/diagnosticMessages.json | 39 +- src/compiler/factory/emitHelpers.ts | 4 +- src/compiler/factory/emitNode.ts | 20 + src/compiler/factory/nodeFactory.ts | 12 + src/compiler/factory/nodeTests.ts | 6 +- src/compiler/factory/utilities.ts | 25 +- src/compiler/program.ts | 40 +- src/compiler/transformers/es2020.ts | 14 +- src/compiler/transformers/jsx.ts | 4 +- src/compiler/transformers/ts.ts | 150 +++-- src/compiler/types.ts | 17 +- src/compiler/utilities.ts | 94 ++- src/compiler/utilitiesPublic.ts | 2 + .../reference/api/tsserverlibrary.d.ts | 259 ++++---- tests/baselines/reference/api/typescript.d.ts | 259 ++++---- .../reference/bluebirdStaticThis.errors.txt | 20 +- ...tomMetadataDecorator.globalIdentifier.1.js | 54 ++ ...ataDecorator.globalIdentifier.2.errors.txt | 48 ++ ...ataDecorator.globalIdentifier.3.errors.txt | 42 ++ ...ataDecorator.globalIdentifier.4.errors.txt | 54 ++ ...ataDecorator.globalIdentifier.5.errors.txt | 43 ++ ...ataDecorator.globalIdentifier.6.errors.txt | 49 ++ ...ataDecorator.globalIdentifier.7.errors.txt | 64 ++ ...stomMetadataDecorator.globalNamespace.1.js | 56 ++ ...dataDecorator.globalNamespace.2.errors.txt | 50 ++ ...dataDecorator.globalNamespace.3.errors.txt | 45 ++ ...dataDecorator.globalNamespace.4.errors.txt | 56 ++ ...dataDecorator.globalNamespace.5.errors.txt | 45 ++ ...dataDecorator.globalNamespace.6.errors.txt | 51 ++ ...dataDecorator.globalNamespace.7.errors.txt | 66 +++ ...dataDecorator.globalNamespace.8.errors.txt | 42 ++ ...mMetadataDecorator.importedIdentifier.1.js | 58 ++ ...MetadataDecorator.importedIdentifier.10.js | 59 ++ ...aDecorator.importedIdentifier.2.errors.txt | 24 + ...aDecorator.importedIdentifier.3.errors.txt | 24 + ...aDecorator.importedIdentifier.4.errors.txt | 57 ++ ...aDecorator.importedIdentifier.5.errors.txt | 46 ++ ...aDecorator.importedIdentifier.6.errors.txt | 52 ++ ...aDecorator.importedIdentifier.7.errors.txt | 21 + ...aDecorator.importedIdentifier.8.errors.txt | 36 ++ ...aDecorator.importedIdentifier.9.errors.txt | 67 +++ ...omMetadataDecorator.importedNamespace.1.js | 60 ++ ...taDecorator.importedNamespace.2.errors.txt | 29 + ...taDecorator.importedNamespace.3.errors.txt | 28 + ...taDecorator.importedNamespace.4.errors.txt | 59 ++ ...taDecorator.importedNamespace.5.errors.txt | 48 ++ ...taDecorator.importedNamespace.6.errors.txt | 54 ++ ...taDecorator.importedNamespace.7.errors.txt | 69 +++ ...taDecorator.importedNamespace.8.errors.txt | 38 ++ .../decoratorMetadata-jsdoc.errors.txt | 8 +- .../reference/decoratorMetadata-jsdoc.symbols | 2 +- .../reference/decoratorMetadata-jsdoc.types | 2 +- .../baselines/reference/decoratorMetadata.js | 2 +- .../reference/decoratorMetadata.symbols | 4 +- .../reference/decoratorMetadata.types | 4 +- .../decoratorMetadataWithTypeOnlyImport.js | 2 +- ...ecoratorMetadataWithTypeOnlyImport.symbols | 4 +- .../decoratorMetadataWithTypeOnlyImport.types | 4 +- .../reference/extendArray.errors.txt | 10 +- .../importedModuleAddToGlobal.errors.txt | 5 +- ...lModuleWithoutExportAccessError.errors.txt | 4 +- ...lModuleWithoutExportAccessError.errors.txt | 4 +- .../invalidInstantiatedModule.errors.txt | 5 +- .../jsdocPropertyTagInvalid.errors.txt | 5 +- ...agmentFactoryErrorNotIdentifier.errors.txt | 4 +- ...nfinishedTypeNameBeforeKeyword1.errors.txt | 4 +- .../parserUnterminatedGeneric1.errors.txt | 8 +- .../parserUnterminatedGeneric2.errors.txt | 8 +- .../potentiallyUncalledDecorators.errors.txt | 32 +- .../primaryExpressionMods.errors.txt | 5 +- .../metadataDecorator/tsconfig.json | 5 + .../tsconfig.json | 5 + ...ltiple-declaration-files-in-the-program.js | 5 + ...ltiple-declaration-files-in-the-program.js | 5 + ...tomMetadataDecorator.globalIdentifier.1.ts | 23 + ...tomMetadataDecorator.globalIdentifier.2.ts | 24 + ...tomMetadataDecorator.globalIdentifier.3.ts | 23 + ...tomMetadataDecorator.globalIdentifier.4.ts | 24 + ...tomMetadataDecorator.globalIdentifier.5.ts | 24 + ...tomMetadataDecorator.globalIdentifier.6.ts | 26 + ...tomMetadataDecorator.globalIdentifier.7.ts | 26 + ...stomMetadataDecorator.globalNamespace.1.ts | 25 + ...stomMetadataDecorator.globalNamespace.2.ts | 26 + ...stomMetadataDecorator.globalNamespace.3.ts | 26 + ...stomMetadataDecorator.globalNamespace.4.ts | 26 + ...stomMetadataDecorator.globalNamespace.5.ts | 26 + ...stomMetadataDecorator.globalNamespace.6.ts | 28 + ...stomMetadataDecorator.globalNamespace.7.ts | 28 + ...stomMetadataDecorator.globalNamespace.8.ts | 23 + ...mMetadataDecorator.importedIdentifier.1.ts | 27 + ...MetadataDecorator.importedIdentifier.10.ts | 28 + ...mMetadataDecorator.importedIdentifier.2.ts | 28 + ...mMetadataDecorator.importedIdentifier.3.ts | 28 + ...mMetadataDecorator.importedIdentifier.4.ts | 28 + ...mMetadataDecorator.importedIdentifier.5.ts | 28 + ...mMetadataDecorator.importedIdentifier.6.ts | 30 + ...mMetadataDecorator.importedIdentifier.7.ts | 25 + ...mMetadataDecorator.importedIdentifier.8.ts | 27 + ...mMetadataDecorator.importedIdentifier.9.ts | 30 + ...omMetadataDecorator.importedNamespace.1.ts | 29 + ...omMetadataDecorator.importedNamespace.2.ts | 30 + ...omMetadataDecorator.importedNamespace.3.ts | 30 + ...omMetadataDecorator.importedNamespace.4.ts | 30 + ...omMetadataDecorator.importedNamespace.5.ts | 30 + ...omMetadataDecorator.importedNamespace.6.ts | 32 + ...omMetadataDecorator.importedNamespace.7.ts | 32 + ...omMetadataDecorator.importedNamespace.8.ts | 29 + .../decoratorMetadata-jsdoc.ts | 0 .../decoratorMetadata.ts | 0 .../decoratorMetadataWithTypeOnlyImport.ts | 0 112 files changed, 3642 insertions(+), 528 deletions(-) create mode 100644 tests/baselines/reference/customMetadataDecorator.globalIdentifier.1.js create mode 100644 tests/baselines/reference/customMetadataDecorator.globalIdentifier.2.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.globalIdentifier.3.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.globalIdentifier.4.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.globalIdentifier.5.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.globalIdentifier.6.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.globalIdentifier.7.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.globalNamespace.1.js create mode 100644 tests/baselines/reference/customMetadataDecorator.globalNamespace.2.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.globalNamespace.3.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.globalNamespace.4.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.globalNamespace.5.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.globalNamespace.6.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.globalNamespace.7.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.globalNamespace.8.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedIdentifier.1.js create mode 100644 tests/baselines/reference/customMetadataDecorator.importedIdentifier.10.js create mode 100644 tests/baselines/reference/customMetadataDecorator.importedIdentifier.2.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedIdentifier.3.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedIdentifier.4.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedIdentifier.5.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedIdentifier.6.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedIdentifier.7.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedIdentifier.8.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedIdentifier.9.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedNamespace.1.js create mode 100644 tests/baselines/reference/customMetadataDecorator.importedNamespace.2.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedNamespace.3.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedNamespace.4.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedNamespace.5.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedNamespace.6.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedNamespace.7.errors.txt create mode 100644 tests/baselines/reference/customMetadataDecorator.importedNamespace.8.errors.txt create mode 100644 tests/baselines/reference/showConfig/Shows tsconfig for single option/metadataDecorator/tsconfig.json create mode 100644 tests/baselines/reference/showConfig/Shows tsconfig for single option/metadataDecoratorImportSource/tsconfig.json create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.1.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.2.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.3.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.4.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.5.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.6.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.7.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.1.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.2.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.3.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.4.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.5.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.6.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.7.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.8.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.1.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.10.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.2.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.3.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.4.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.5.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.6.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.7.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.8.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.9.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.1.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.2.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.3.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.4.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.5.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.6.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.7.ts create mode 100644 tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.8.ts rename tests/cases/conformance/decorators/{ => decoratorMetadata}/decoratorMetadata-jsdoc.ts (100%) rename tests/cases/conformance/decorators/{ => decoratorMetadata}/decoratorMetadata.ts (100%) rename tests/cases/conformance/decorators/{ => decoratorMetadata}/decoratorMetadataWithTypeOnlyImport.ts (100%) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 193bb1d8c8099..9790c3779cfd4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -932,6 +932,7 @@ namespace ts { let lastFlowNode: FlowNode | undefined; let lastFlowNodeReachable: boolean; let flowTypeCache: Type[] | undefined; + let speculativeAliasResolution = false; // indicates whether we are speculatively resolving an alias for a spelling suggestion. const emptyStringType = getLiteralType(""); const zeroType = getLiteralType(0); @@ -975,7 +976,7 @@ namespace ts { let _jsxNamespace: __String; let _jsxFactoryEntity: EntityName | undefined; let outofbandVarianceMarkerHandler: ((onlyUnreliable: boolean) => void) | undefined; - + const metadataDecoratorImportSymbols = new Map(); const subtypeRelation = new Map(); const strictSubtypeRelation = new Map(); const assignableRelation = new Map(); @@ -1088,6 +1089,27 @@ namespace ts { return diagnostic; } + /** + * Reports an error, attaching it to an optional containing message chain. + * @param location The location at which the error is to be reported. + * @param containingMessageChain An optional callback that can return a `DiagnosticMessageChain` that should contain the message. + * @param message The Diagnostic message to report. + * @returns The newly created diagnostic. + */ + function errorWithContainingMessageChain(location: Node | undefined, containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number) { + const headChain = containingMessageChain?.(); + if (headChain) { + const tailChain = chainDiagnosticMessages(/*details*/ undefined, message, arg0, arg1, arg2, arg3); + concatenateDiagnosticMessageChains(headChain, tailChain); + const diagnostic = location + ? createDiagnosticForNodeFromMessageChain(location, headChain) + : createCompilerDiagnosticFromMessageChain(headChain); + diagnostics.add(diagnostic); + return diagnostic; + } + return error(location, message, arg0, arg1, arg2, arg3); + } + function addErrorOrSuggestion(isError: boolean, diagnostic: DiagnosticWithLocation) { if (isError) { diagnostics.add(diagnostic); @@ -1096,18 +1118,37 @@ namespace ts { suggestionDiagnostics.add({ ...diagnostic, category: DiagnosticCategory.Suggestion }); } } + function errorOrSuggestion(isError: boolean, location: Node, message: DiagnosticMessage | DiagnosticMessageChain, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): void { // Pseudo-synthesized input node - if (location.pos < 0 || location.end < 0) { + if (nodeIsSynthesized(location)) { if (!isError) { return; // Drop suggestions (we have no span to suggest on) } // Issue errors globally const file = getSourceFileOfNode(location); - addErrorOrSuggestion(isError, "message" in message ? createFileDiagnostic(file, 0, 0, message, arg0, arg1, arg2, arg3) : createDiagnosticForFileFromMessageChain(file, message)); // eslint-disable-line no-in-operator + addErrorOrSuggestion(isError, isDiagnosticMessageChain(message) ? createDiagnosticForFileFromMessageChain(file, message) : createFileDiagnostic(file, 0, 0, message, arg0, arg1, arg2, arg3)); return; } - addErrorOrSuggestion(isError, "message" in message ? createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator + addErrorOrSuggestion(isError, isDiagnosticMessageChain(message) ? createDiagnosticForNodeFromMessageChain(location, message) : createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)); + } + + /** + * Reports an error or suggestion, attaching it to an optional containing message chain. + * @param isError Indicates whether to report as an error (`true`), or as a suggestion (`false`). + * @param location The location at which the error is to be reported. + * @param containingMessageChain An optional callback that can return a `DiagnosticMessageChain` that should contain the message. + * @param message The Diagnostic message or nested diagnostic message chain to report. + * @returns The newly created diagnostic. + */ + function errorOrSuggestionWithContainingMessageChain(isError: boolean, location: Node, containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined, message: DiagnosticMessage | DiagnosticMessageChain, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): void { + const headChain = containingMessageChain?.(); + if (headChain) { + const tailChain = isDiagnosticMessageChain(message) ? message : chainDiagnosticMessages(/*details*/ undefined, message, arg0, arg1, arg2, arg3); + concatenateDiagnosticMessageChains(headChain, tailChain); + message = headChain; + } + errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3); } function errorAndMaybeSuggestAwait( @@ -1414,21 +1455,31 @@ namespace ts { return node.kind === SyntaxKind.SourceFile && !isExternalOrCommonJsModule(node); } + /** + * Returns whether the provided symbol (or its target if the symbol is an Alias) has the correct meaning. + */ + function resolvedSymbolHasCorrectMeaning(symbol: Symbol, meaning: SymbolFlags) { + Debug.assert((getCheckFlags(symbol) & CheckFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); + if (symbol.flags & meaning) { + return true; + } + if (symbol.flags & SymbolFlags.Alias) { + const target = resolveAlias(symbol); + // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors + if (target === unknownSymbol || target.flags & meaning) { + return true; + } + } + return false; + } + function getSymbol(symbols: SymbolTable, name: __String, meaning: SymbolFlags): Symbol | undefined { if (meaning) { const symbol = getMergedSymbol(symbols.get(name)); if (symbol) { - Debug.assert((getCheckFlags(symbol) & CheckFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); - if (symbol.flags & meaning) { + if (resolvedSymbolHasCorrectMeaning(symbol, meaning)) { return symbol; } - if (symbol.flags & SymbolFlags.Alias) { - const target = resolveAlias(symbol); - // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors - if (target === unknownSymbol || target.flags & meaning) { - return symbol; - } - } } } // return undefined if we can't find a symbol. @@ -1702,7 +1753,15 @@ namespace ts { * the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with * the given name can be found. * - * @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters. + * @param location The location at which to begin name resolution. + * @param name The escaped name of the symbol to resolve. + * @param meaning The meaning of the symbol to resolve. + * @param nameNotFoundMessage The diagnostic message to report if the name is not found. Pass `undefined` to disable error reporting. + * @param nameArg An `Identifier` or escaped string from which to derive the name used when reporting diagnostics. + * @param isUse If true, this will count towards `--noUnusedLocals` / `--noUnusedParameters`. + * @param excludeGlobals Indicates that the global symbol table should not be used when resolving this name (default `false`). + * @param suggestedNameNotFoundMessage A secondary diagnostic message used to provide "Did you mean...?" spelling suggestions. Ignored if `nameNotfoundMessage` is not provided. + * @returns The resolved `Symbol`, or `undefined` if no `Symbol` with the given name and meaning can be found. */ function resolveName( location: Node | undefined, @@ -1713,9 +1772,29 @@ namespace ts { isUse: boolean, excludeGlobals = false, suggestedNameNotFoundMessage?: DiagnosticMessage): Symbol | undefined { - return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage); + return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage, /*errorLocation*/ undefined, /*containingMessageChain*/ undefined); } + /** + * Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and + * the `nameNotFoundMessage` argument is not `undefined`. + * + * ***NOTE**: You should not call this directly. This function is intended to be used only by `resolveName`, + * `resolveEntityName`, and `getSuggestedSymbolForNonexistentSymbol`. + * + * @param location The location at which to begin name resolution. + * @param name The escaped name of the symbol to resolve. + * @param meaning The meaning of the symbol to resolve. + * @param nameNotFoundMessage The diagnostic message to report if the name is not found. Pass `undefined` to disable error reporting. + * @param nameArg An `Identifier` or escaped string from which to derive the name used when reporting diagnostics. + * @param isUse If true, this will count towards `--noUnusedLocals` / `--noUnusedParameters`. + * @param excludeGlobals Indicates that the global symbol table should not be used when resolving this name (default `false`). + * @param lookup The function to use to perform symbol lookup against a `SymbolTable`. + * @param suggestedNameNotFoundMessage A secondary diagnostic message used to provide "Did you mean...?" spelling suggestions. Ignored if `nameNotfoundMessage` is not provided. + * @param errorLocation The location at which to report any resolution errors. Defaults to `location` if not provided. Ignored if `nameNotFoundMessage` is not provided. + * @param containingMessageChain An optional callback that provides a containing `DiagnosticMessageChain` to provide more context for name resolution diagnostics. Ignored if `nameNotFoundMessage` is not provided. + * @returns The resolved `Symbol`, or `undefined` if no `Symbol` with the given name and meaning can be found. + */ function resolveNameHelper( location: Node | undefined, name: __String, @@ -1725,7 +1804,10 @@ namespace ts { isUse: boolean, excludeGlobals: boolean, lookup: typeof getSymbol, - suggestedNameNotFoundMessage?: DiagnosticMessage): Symbol | undefined { + suggestedNameNotFoundMessage?: DiagnosticMessage, + errorLocation = location, + containingMessageChain?: () => DiagnosticMessageChain | undefined + ): Symbol | undefined { const originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location let result: Symbol | undefined; let lastLocation: Node | undefined; @@ -1733,7 +1815,6 @@ namespace ts { let propertyWithInvalidInitializer: Node | undefined; let associatedDeclarationForContainingInitializerOrBindingName: ParameterDeclaration | BindingElement | undefined; let withinDeferredContext = false; - const errorLocation = location; let grandparent: Node; let isInExternalModule = false; @@ -1878,7 +1959,7 @@ namespace ts { // TypeScript 1.0 spec (April 2014): 3.4.1 // The scope of a type parameter extends over the entire declaration with which the type // parameter list is associated, with the exception of static member declarations in classes. - error(errorLocation, Diagnostics.Static_members_cannot_reference_class_type_parameters); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } break loop; @@ -1897,7 +1978,7 @@ namespace ts { const container = location.parent.parent; if (isClassLike(container) && (result = lookup(getSymbolOfNode(container).members!, name, meaning & SymbolFlags.Type))) { if (nameNotFoundMessage) { - error(errorLocation, Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } return undefined; } @@ -1916,7 +1997,7 @@ namespace ts { if (isClassLike(grandparent) || grandparent.kind === SyntaxKind.InterfaceDeclaration) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent as ClassLikeDeclaration | InterfaceDeclaration).members!, name, meaning & SymbolFlags.Type)) { - error(errorLocation, Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } @@ -2054,13 +2135,13 @@ namespace ts { if (!result) { if (nameNotFoundMessage) { if (!errorLocation || - !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg!) && // TODO: GH#18217 - !checkAndReportErrorForExtendingInterface(errorLocation) && - !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && - !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) && - !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) && - !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) && - !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) { + !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg, containingMessageChain) && // TODO: GH#18217 + !checkAndReportErrorForExtendingInterface(errorLocation, containingMessageChain) && + !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning, containingMessageChain) && + !checkAndReportErrorForExportingPrimitiveType(errorLocation, name, containingMessageChain) && + !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning, containingMessageChain) && + !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning, containingMessageChain) && + !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning, containingMessageChain)) { let suggestion: Symbol | undefined; if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); @@ -2070,7 +2151,7 @@ namespace ts { } if (suggestion) { const suggestionName = symbolToString(suggestion); - const diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg!), suggestionName); + const diagnostic = errorWithContainingMessageChain(errorLocation, containingMessageChain, suggestedNameNotFoundMessage, diagnosticName(nameArg ?? name), suggestionName); if (suggestion.valueDeclaration) { addRelatedInfo( diagnostic, @@ -2083,10 +2164,10 @@ namespace ts { if (nameArg) { const lib = getSuggestedLibForNonExistentName(nameArg); if (lib) { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib); + errorWithContainingMessageChain(errorLocation, containingMessageChain, nameNotFoundMessage, diagnosticName(nameArg), lib); } else { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); + errorWithContainingMessageChain(errorLocation, containingMessageChain, nameNotFoundMessage, diagnosticName(nameArg)); } } } @@ -2103,8 +2184,8 @@ namespace ts { // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed // with ESNext+useDefineForClassFields because the scope semantics are different. const propertyName = (propertyWithInvalidInitializer).name; - error(errorLocation, Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, - declarationNameToString(propertyName), diagnosticName(nameArg!)); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, + declarationNameToString(propertyName), diagnosticName(nameArg ?? name)); return undefined; } @@ -2124,7 +2205,7 @@ namespace ts { ((meaning & SymbolFlags.Class || meaning & SymbolFlags.Enum) && (meaning & SymbolFlags.Value) === SymbolFlags.Value))) { const exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable || exportOrLocalSymbol.flags & SymbolFlags.Class || exportOrLocalSymbol.flags & SymbolFlags.Enum) { - checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation, containingMessageChain); } } @@ -2132,7 +2213,7 @@ namespace ts { if (result && isInExternalModule && (meaning & SymbolFlags.Value) === SymbolFlags.Value && !(originalLocation!.flags & NodeFlags.JSDoc)) { const merged = getMergedSymbol(result); if (length(merged.declarations) && every(merged.declarations, d => isNamespaceExportDeclaration(d) || isSourceFile(d) && !!d.symbol.globalExports)) { - errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation!, Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, unescapeLeadingUnderscores(name)); + errorOrSuggestionWithContainingMessageChain(!compilerOptions.allowUmdGlobalAccess, errorLocation!, containingMessageChain, Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, unescapeLeadingUnderscores(name)); } } @@ -2142,21 +2223,21 @@ namespace ts { const root = (getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName) as ParameterDeclaration); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) { - error(errorLocation, Diagnostics.Parameter_0_cannot_reference_itself, declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name)); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.Parameter_0_cannot_reference_itself, declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name)); } // And it cannot refer to any declarations which come after it else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) { - error(errorLocation, Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), declarationNameToString(errorLocation)); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), declarationNameToString(errorLocation)); } } if (result && errorLocation && meaning & SymbolFlags.Value && result.flags & SymbolFlags.Alias) { - checkSymbolUsageInExpressionContext(result, name, errorLocation); + checkSymbolUsageInExpressionContext(result, name, errorLocation, containingMessageChain); } } return result; } - function checkSymbolUsageInExpressionContext(symbol: Symbol, name: __String, useSite: Node) { + function checkSymbolUsageInExpressionContext(symbol: Symbol, name: __String, useSite: Node, containingMessageChain?: () => DiagnosticMessageChain | undefined) { if (!isValidTypeOnlyAliasUseSite(useSite)) { const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol); if (typeOnlyDeclaration) { @@ -2169,7 +2250,7 @@ namespace ts { : Diagnostics._0_was_imported_here; const unescapedName = unescapeLeadingUnderscores(name); addRelatedInfo( - error(useSite, message, unescapedName), + errorWithContainingMessageChain(useSite, containingMessageChain, message, unescapedName), createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, unescapedName)); } } @@ -2226,7 +2307,7 @@ namespace ts { return false; } - function checkAndReportErrorForMissingPrefix(errorLocation: Node, name: __String, nameArg: __String | Identifier): boolean { + function checkAndReportErrorForMissingPrefix(errorLocation: Node, name: __String, nameArg: __String | Identifier | undefined, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { if (!isIdentifier(errorLocation) || errorLocation.escapedText !== name || isTypeReferenceIdentifier(errorLocation) || isInTypeQuery(errorLocation)) { return false; } @@ -2243,7 +2324,7 @@ namespace ts { // Check to see if a static member exists. const constructorType = getTypeOfSymbol(classSymbol); if (getPropertyOfType(constructorType, name)) { - error(errorLocation, Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, diagnosticName(nameArg), symbolToString(classSymbol)); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, diagnosticName(nameArg ?? name), symbolToString(classSymbol)); return true; } @@ -2252,7 +2333,7 @@ namespace ts { if (location === container && !hasSyntacticModifier(location, ModifierFlags.Static)) { const instanceType = (getDeclaredTypeOfSymbol(classSymbol)).thisType!; // TODO: GH#18217 if (getPropertyOfType(instanceType, name)) { - error(errorLocation, Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg)); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg ?? name)); return true; } } @@ -2264,10 +2345,10 @@ namespace ts { } - function checkAndReportErrorForExtendingInterface(errorLocation: Node): boolean { + function checkAndReportErrorForExtendingInterface(errorLocation: Node, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { const expression = getEntityNameForExtendingInterface(errorLocation); if (expression && resolveEntityName(expression, SymbolFlags.Interface, /*ignoreErrors*/ true)) { - error(errorLocation, Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, getTextOfNode(expression)); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, getTextOfNode(expression)); return true; } return false; @@ -2291,7 +2372,7 @@ namespace ts { } } - function checkAndReportErrorForUsingTypeAsNamespace(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean { + function checkAndReportErrorForUsingTypeAsNamespace(errorLocation: Node, name: __String, meaning: SymbolFlags, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { const namespaceMeaning = SymbolFlags.Namespace | (isInJSFile(errorLocation) ? SymbolFlags.Value : 0); if (meaning === namespaceMeaning) { const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~namespaceMeaning, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); @@ -2302,8 +2383,9 @@ namespace ts { const propName = parent.right.escapedText; const propType = getPropertyOfType(getDeclaredTypeOfSymbol(symbol), propName); if (propType) { - error( + errorWithContainingMessageChain( parent, + containingMessageChain, Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, unescapeLeadingUnderscores(name), unescapeLeadingUnderscores(propName), @@ -2311,7 +2393,7 @@ namespace ts { return true; } } - error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here, unescapeLeadingUnderscores(name)); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here, unescapeLeadingUnderscores(name)); return true; } } @@ -2319,11 +2401,11 @@ namespace ts { return false; } - function checkAndReportErrorForUsingValueAsType(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean { + function checkAndReportErrorForUsingValueAsType(errorLocation: Node, name: __String, meaning: SymbolFlags, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { if (meaning & (SymbolFlags.Type & ~SymbolFlags.Namespace)) { const symbol = resolveSymbol(resolveName(errorLocation, name, ~SymbolFlags.Type & SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & SymbolFlags.Namespace)) { - error(errorLocation, Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, unescapeLeadingUnderscores(name)); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, unescapeLeadingUnderscores(name)); return true; } } @@ -2334,31 +2416,31 @@ namespace ts { return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown"; } - function checkAndReportErrorForExportingPrimitiveType(errorLocation: Node, name: __String): boolean { + function checkAndReportErrorForExportingPrimitiveType(errorLocation: Node, name: __String, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { if (isPrimitiveTypeName(name) && errorLocation.parent.kind === SyntaxKind.ExportSpecifier) { - error(errorLocation, Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name as string); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name as string); return true; } return false; } - function checkAndReportErrorForUsingTypeAsValue(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean { + function checkAndReportErrorForUsingTypeAsValue(errorLocation: Node, name: __String, meaning: SymbolFlags, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { if (meaning & (SymbolFlags.Value & ~SymbolFlags.NamespaceModule)) { if (isPrimitiveTypeName(name)) { - error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, unescapeLeadingUnderscores(name)); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, unescapeLeadingUnderscores(name)); return true; } const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & SymbolFlags.NamespaceModule)) { const rawName = unescapeLeadingUnderscores(name); if (isES2015OrLaterConstructorName(name)) { - error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName); } else if (maybeMappedType(errorLocation, symbol)) { - error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0, rawName, rawName === "K" ? "P" : "K"); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0, rawName, rawName === "K" ? "P" : "K"); } else { - error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, rawName); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, rawName); } return true; } @@ -2389,12 +2471,13 @@ namespace ts { return false; } - function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean { + function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation: Node, name: __String, meaning: SymbolFlags, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { if (meaning & (SymbolFlags.Value & ~SymbolFlags.NamespaceModule & ~SymbolFlags.Type)) { const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { - error( + errorWithContainingMessageChain( errorLocation, + containingMessageChain, Diagnostics.Cannot_use_namespace_0_as_a_value, unescapeLeadingUnderscores(name)); return true; @@ -2403,14 +2486,14 @@ namespace ts { else if (meaning & (SymbolFlags.Type & ~SymbolFlags.NamespaceModule & ~SymbolFlags.Value)) { const symbol = resolveSymbol(resolveName(errorLocation, name, (SymbolFlags.ValueModule | SymbolFlags.NamespaceModule) & ~SymbolFlags.Type, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { - error(errorLocation, Diagnostics.Cannot_use_namespace_0_as_a_type, unescapeLeadingUnderscores(name)); + errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.Cannot_use_namespace_0_as_a_type, unescapeLeadingUnderscores(name)); return true; } } return false; } - function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void { + function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node, containingMessageChain?: () => DiagnosticMessageChain | undefined): void { Debug.assert(!!(result.flags & SymbolFlags.BlockScopedVariable || result.flags & SymbolFlags.Class || result.flags & SymbolFlags.Enum)); if (result.flags & (SymbolFlags.Function | SymbolFlags.FunctionScopedVariable | SymbolFlags.Assignment) && result.flags & SymbolFlags.Class) { // constructor functions aren't block scoped @@ -2426,18 +2509,18 @@ namespace ts { let diagnosticMessage; const declarationName = declarationNameToString(getNameOfDeclaration(declaration)); if (result.flags & SymbolFlags.BlockScopedVariable) { - diagnosticMessage = error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); + diagnosticMessage = errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } else if (result.flags & SymbolFlags.Class) { - diagnosticMessage = error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName); + diagnosticMessage = errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.Class_0_used_before_its_declaration, declarationName); } else if (result.flags & SymbolFlags.RegularEnum) { - diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName); + diagnosticMessage = errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.Enum_0_used_before_its_declaration, declarationName); } else { Debug.assert(!!(result.flags & SymbolFlags.ConstEnum)); if (shouldPreserveConstEnums(compilerOptions)) { - diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName); + diagnosticMessage = errorWithContainingMessageChain(errorLocation, containingMessageChain, Diagnostics.Enum_0_used_before_its_declaration, declarationName); } } @@ -2968,6 +3051,12 @@ namespace ts { const node = getDeclarationOfAliasSymbol(symbol); if (!node) return Debug.fail(); const target = getTargetOfAliasDeclaration(node); + // Don't cache resolutions when we are speculatively resolving an alias for spelling suggestions + // as that can cause us to incorrectly warn about circular definitions below. + if (speculativeAliasResolution) { + links.target = undefined; + return target || unknownSymbol; + } if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; } @@ -2976,6 +3065,11 @@ namespace ts { } } else if (links.target === resolvingSymbol) { + // If we are speculatively resolving an alias for spelling suggestions, do not change the + // target as that can result in an incorrect warning about circular definitions. + if (speculativeAliasResolution) { + return unknownSymbol; + } links.target = unknownSymbol; } return links.target; @@ -2984,7 +3078,14 @@ namespace ts { function tryResolveAlias(symbol: Symbol): Symbol | undefined { const links = getSymbolLinks(symbol); if (links.target !== resolvingSymbol) { - return resolveAlias(symbol); + const savedSpeculativeAliasResolution = speculativeAliasResolution; + speculativeAliasResolution = true; + try { + return resolveAlias(symbol); + } + finally { + speculativeAliasResolution = savedSpeculativeAliasResolution; + } } return undefined; @@ -3123,8 +3224,16 @@ namespace ts { /** * Resolves a qualified name and any involved aliases. + * @param name The `EntityName` or `EntityNameExpression` to resolve. + * @param meaning The meaning of the symbol we are looking for. + * @param ignoreErrors Indicates whether to report errors when a symbol cannot be found. + * @param dontResolveAlias Indicates that we should not resolve Alias symbols. + * @param location The node at which start name resolution for the left-most identifier of the entity name. + * @param errorNode When provided, overrides the location used to report an error for a missing symbol. + * @param rootSymbol When provided, overrides the symbol to use for the left-most identifier of the entity name. + * @param containingMessageChain When provided, creates a diagnostic message chain that is prepended to the error. */ - function resolveEntityName(name: EntityNameOrEntityNameExpression, meaning: SymbolFlags, ignoreErrors?: boolean, dontResolveAlias?: boolean, location?: Node): Symbol | undefined { + function resolveEntityName(name: EntityNameOrEntityNameExpression, meaning: SymbolFlags, ignoreErrors?: boolean, dontResolveAlias?: boolean, location?: Node, errorNode?: Node, rootSymbol?: Symbol, containingMessageChain?: () => DiagnosticMessageChain | undefined): Symbol | undefined { if (nodeIsMissing(name)) { return undefined; } @@ -3132,9 +3241,22 @@ namespace ts { const namespaceMeaning = SymbolFlags.Namespace | (isInJSFile(name) ? meaning & SymbolFlags.Value : 0); let symbol: Symbol | undefined; if (name.kind === SyntaxKind.Identifier) { - const message = meaning === namespaceMeaning || nodeIsSynthesized(name) ? Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); + const message = meaning === namespaceMeaning ? Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(name); + if (rootSymbol) { + if (resolvedSymbolHasCorrectMeaning(rootSymbol, meaning)) { + return rootSymbol; + } + if (!ignoreErrors) { + errorWithContainingMessageChain(errorNode || location || name, containingMessageChain, message, idText(name)); + } + return undefined; + } + const suggestionMessage = + message === Diagnostics.Cannot_find_name_0 ? Diagnostics.Cannot_find_name_0_Did_you_mean_1 : + message === Diagnostics.Cannot_find_namespace_0 ? Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 : + undefined; const symbolFromJSPrototype = isInJSFile(name) && !nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; - symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true)); + symbol = getMergedSymbol(resolveNameHelper(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, /*excludeGlobals*/ false, getSymbol, suggestionMessage, errorNode, containingMessageChain)); if (!symbol) { return getMergedSymbol(symbolFromJSPrototype); } @@ -3142,7 +3264,7 @@ namespace ts { else if (name.kind === SyntaxKind.QualifiedName || name.kind === SyntaxKind.PropertyAccessExpression) { const left = name.kind === SyntaxKind.QualifiedName ? name.left : name.expression; const right = name.kind === SyntaxKind.QualifiedName ? name.right : name.name; - let namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); + let namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location, errorNode, rootSymbol, containingMessageChain); if (!namespace || nodeIsMissing(right)) { return undefined; } @@ -3168,12 +3290,25 @@ namespace ts { symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, meaning)); if (!symbol) { if (!ignoreErrors) { - const namespaceName = getFullyQualifiedName(namespace); + let namespaceName = getFullyQualifiedName(namespace); + let moduleName: string | undefined; + const match = /^"([^"]+)"\.(.*)$/.exec(namespaceName); + if (match) { + moduleName = match[1]; + namespaceName = match[2]; + } const declarationName = declarationNameToString(right); const suggestion = getSuggestedSymbolForNonexistentModule(right, namespace); - suggestion ? - error(right, Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, namespaceName, declarationName, symbolToString(suggestion)) : - error(right, Diagnostics.Namespace_0_has_no_exported_member_1, namespaceName, declarationName); + const diagnostic = suggestion ? + moduleName ? + errorWithContainingMessageChain(errorNode || right, containingMessageChain, Diagnostics._0_from_module_1_has_no_exported_member_named_2_Did_you_mean_3, namespaceName, moduleName, declarationName, symbolToString(suggestion)) : + errorWithContainingMessageChain(errorNode || right, containingMessageChain, Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, namespaceName, declarationName, symbolToString(suggestion)) : + moduleName ? + errorWithContainingMessageChain(errorNode || right, containingMessageChain, Diagnostics.Namespace_0_from_module_1_has_no_exported_member_2, namespaceName, moduleName, declarationName) : + errorWithContainingMessageChain(errorNode || right, containingMessageChain, Diagnostics.Namespace_0_has_no_exported_member_1, namespaceName, declarationName); + if (suggestion?.valueDeclaration) { + addRelatedInfo(diagnostic, createDiagnosticForNode(suggestion.valueDeclaration, Diagnostics._0_is_declared_here, symbolName(suggestion))); + } } return undefined; } @@ -21576,7 +21711,7 @@ namespace ts { case "BigUint64Array": return Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later; default: - if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { + if (node.parent?.kind === SyntaxKind.ShorthandPropertyAssignment) { return Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -25614,6 +25749,10 @@ namespace ts { return checkIteratedTypeOrElementType(IterationUse.Spread, arrayOrIterableType, undefinedType, node.expression); } + function checkSyntheticCallExpression(node: SyntheticCallExpression): Type { + return getReturnTypeOfSignature(getResolvedSignature(node)); + } + function checkSyntheticExpression(node: SyntheticExpression): Type { return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } @@ -27308,7 +27447,7 @@ namespace ts { // So the table *contains* `x` but `x` isn't actually in scope. // However, resolveNameHelper will continue and call this callback again, so we'll eventually get a correct suggestion. return symbol || getSpellingSuggestionForName(unescapeLeadingUnderscores(name), arrayFrom(symbols.values()), meaning); - }); + }, /*suggestedNameNotFoundMessage*/ undefined, /*errorLocation*/ undefined, /*containingMessageChain*/ undefined); return result; } @@ -27558,7 +27697,7 @@ namespace ts { else if (isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== SyntaxKind.Decorator) { + else if (node.kind !== SyntaxKind.Decorator && node.kind !== SyntaxKind.SyntheticCallExpression) { forEach((node).arguments, argument => { checkExpression(argument); }); @@ -27685,7 +27824,7 @@ namespace ts { argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; // If we are missing the close parenthesis, the call is incomplete. - callIsIncomplete = node.arguments.end === node.end; + callIsIncomplete = !isSyntheticCallExpression(node) && node.arguments.end === node.end; // If a spread argument is present, check that it corresponds to a rest parameter or at least that it's in the valid range. const spreadArgIndex = getSpreadArgumentIndex(args); @@ -27775,7 +27914,7 @@ namespace ts { return getInferredTypes(context); } - function getThisArgumentType(thisArgumentNode: LeftHandSideExpression | undefined) { + function getThisArgumentType(thisArgumentNode: LeftHandSideExpression | SyntheticExpression | undefined) { if (!thisArgumentNode) { return voidType; } @@ -28140,8 +28279,11 @@ namespace ts { /** * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ - function getThisArgumentOfCall(node: CallLikeExpression): LeftHandSideExpression | undefined { - if (node.kind === SyntaxKind.CallExpression) { + function getThisArgumentOfCall(node: CallLikeExpression): LeftHandSideExpression | SyntheticExpression | undefined { + if (isSyntheticCallExpression(node) && node.thisArg) { + return node.thisArg; + } + if (isCallExpression(node) || isSyntheticCallExpression(node)) { const callee = skipOuterExpressions(node.expression); if (isAccessExpression(callee)) { return callee.expression; @@ -28156,6 +28298,13 @@ namespace ts { return result; } + function createSyntheticCallExpression(parent: Node, thisArg: LeftHandSideExpression | SyntheticExpression | undefined, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentList: readonly Expression[], containingMessageChain?: () => DiagnosticMessageChain | undefined) { + const result = parseNodeFactory.createSyntheticCallExpression(thisArg, expression, typeArguments, argumentList, containingMessageChain); + setTextRange(result, parent); + setParent(result, parent); + return result; + } + /** * Returns the effective arguments for an expression that works like a function invocation. */ @@ -28171,7 +28320,7 @@ namespace ts { return args; } if (node.kind === SyntaxKind.Decorator) { - return getEffectiveDecoratorArguments(node); + return getEffectiveDecoratorArguments(node.parent, node.expression); } if (isJsxOpeningLikeElement(node)) { return node.attributes.properties.length > 0 || (isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : emptyArray; @@ -28205,25 +28354,23 @@ namespace ts { /** * Returns the synthetic argument list for a decorator invocation. */ - function getEffectiveDecoratorArguments(node: Decorator): readonly Expression[] { - const parent = node.parent; - const expr = node.expression; - switch (parent.kind) { + function getEffectiveDecoratorArguments(decoratorTarget: NamedDeclaration, errorNode: Node): readonly Expression[] { + switch (decoratorTarget.kind) { case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ - createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) + createSyntheticExpression(errorNode, getTypeOfSymbol(getSymbolOfNode(decoratorTarget))) ]; case SyntaxKind.Parameter: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). - const func = parent.parent; + const func = decoratorTarget.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === SyntaxKind.Constructor ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), - createSyntheticExpression(expr, anyType), - createSyntheticExpression(expr, numberType) + createSyntheticExpression(errorNode, decoratorTarget.parent.kind === SyntaxKind.Constructor ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(errorNode, anyType), + createSyntheticExpression(errorNode, numberType) ]; case SyntaxKind.PropertyDeclaration: case SyntaxKind.MethodDeclaration: @@ -28232,11 +28379,11 @@ namespace ts { // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - const hasPropDesc = parent.kind !== SyntaxKind.PropertyDeclaration && languageVersion !== ScriptTarget.ES3; + const hasPropDesc = decoratorTarget.kind !== SyntaxKind.PropertyDeclaration && languageVersion !== ScriptTarget.ES3; return [ - createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), - createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), - createSyntheticExpression(expr, hasPropDesc ? createTypedPropertyDescriptorType(getTypeOfNode(parent)) : anyType) + createSyntheticExpression(errorNode, getParentTypeOfClassElement(decoratorTarget)), + createSyntheticExpression(errorNode, getClassElementPropertyKeyType(decoratorTarget)), + createSyntheticExpression(errorNode, hasPropDesc ? createTypedPropertyDescriptorType(getTypeOfNode(decoratorTarget)) : anyType) ]; } return Debug.fail(); @@ -28286,6 +28433,11 @@ namespace ts { return createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2, arg3); } else { + const headChain = isSyntheticCallExpression(node) ? node.containingMessageChain?.() : undefined; + if (headChain) { + const errorInfo = chainDiagnosticMessages(/*details*/ undefined, message, arg0, arg1, arg2, arg3); + return createDiagnosticForNodeFromMessageChain(node, concatenateDiagnosticMessageChains(headChain, errorInfo)); + } return createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3); } } @@ -28364,7 +28516,7 @@ namespace ts { } } - if (!hasSpreadArgument && argCount < min) { + if (!hasSpreadArgument && argCount < min || isSyntheticCallExpression(node)) { const diagnostic = getDiagnosticForCallNode(node, error, paramRange, argCount); return related ? addRelatedInfo(diagnostic, related) : diagnostic; } @@ -28527,6 +28679,7 @@ namespace ts { chain = chainDiagnosticMessages(chain, Diagnostics.The_last_overload_gave_the_following_error); chain = chainDiagnosticMessages(chain, Diagnostics.No_overload_matches_this_call); } + chain = concatenateDiagnosticMessageChains(isSyntheticCallExpression(node) ? node.containingMessageChain?.() : undefined, chain); const diags = getSignatureApplicabilityError(node, args, last, assignableRelation, CheckMode.Normal, /*reportErrors*/ true, () => chain); if (diags) { for (const d of diags) { @@ -28566,9 +28719,11 @@ namespace ts { const diags = max > 1 ? allDiagnostics[minIndex] : flatten(allDiagnostics); Debug.assert(diags.length > 0, "No errors reported for 3 or fewer overload signatures"); - const chain = chainDiagnosticMessages( - map(diags, d => typeof d.messageText === "string" ? (d as DiagnosticMessageChain) : d.messageText), - Diagnostics.No_overload_matches_this_call); + const chain = concatenateDiagnosticMessageChains( + isSyntheticCallExpression(node) ? node.containingMessageChain?.() : undefined, + chainDiagnosticMessages( + map(diags, d => typeof d.messageText === "string" ? (d as DiagnosticMessageChain) : d.messageText), + Diagnostics.No_overload_matches_this_call)); // The below is a spread to guarantee we get a new (mutable) array - our `flatMap` helper tries to do "smart" optimizations where it reuses input // arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic const related = [...flatMap(diags, d => (d as Diagnostic).relatedInformation) as DiagnosticRelatedInformation[]]; @@ -28837,7 +28992,7 @@ namespace ts { return maxParamsIndex; } - function resolveCallExpression(node: CallExpression, candidatesOutArray: Signature[] | undefined, checkMode: CheckMode): Signature { + function resolveCallExpression(node: CallExpression | SyntheticCallExpression, candidatesOutArray: Signature[] | undefined, checkMode: CheckMode): Signature { if (node.expression.kind === SyntaxKind.SuperKeyword) { const superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { @@ -28920,7 +29075,7 @@ namespace ts { relatedInformation = createDiagnosticForNode(node.expression, Diagnostics.Are_you_missing_a_semicolon); } } - invocationError(node.expression, apparentType, SignatureKind.Call, relatedInformation); + invocationError(node.expression, node, apparentType, SignatureKind.Call, relatedInformation); } return resolveErrorCall(node); } @@ -29042,7 +29197,7 @@ namespace ts { return signature; } - invocationError(node.expression, expressionType, SignatureKind.Construct); + invocationError(node.expression, node, expressionType, SignatureKind.Construct); return resolveErrorCall(node); } @@ -29115,7 +29270,7 @@ namespace ts { return true; } - function invocationErrorDetails(errorTarget: Node, apparentType: Type, kind: SignatureKind): { messageChain: DiagnosticMessageChain, relatedMessage: DiagnosticMessage | undefined } { + function invocationErrorDetails(errorTarget: Node, invocationNode: CallLikeExpression, apparentType: Type, kind: SignatureKind): { messageChain: DiagnosticMessageChain, relatedMessage: DiagnosticMessage | undefined } { let errorInfo: DiagnosticMessageChain | undefined; const isCall = kind === SignatureKind.Call; const awaitedType = getAwaitedType(apparentType); @@ -29188,20 +29343,28 @@ namespace ts { let headMessage = isCall ? Diagnostics.This_expression_is_not_callable : Diagnostics.This_expression_is_not_constructable; // Diagnose get accessors incorrectly called as functions - if (isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { + if (isCallExpression(invocationNode) && invocationNode.arguments.length === 0) { const { resolvedSymbol } = getNodeLinks(errorTarget); if (resolvedSymbol && resolvedSymbol.flags & SymbolFlags.GetAccessor) { headMessage = Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without; } } + let messageChain = chainDiagnosticMessages(errorInfo, headMessage); + if (isSyntheticCallExpression(invocationNode)) { + const headChain = invocationNode.containingMessageChain?.(); + if (headChain) { + concatenateDiagnosticMessageChains(headChain, messageChain); + messageChain = headChain; + } + } return { - messageChain: chainDiagnosticMessages(errorInfo, headMessage), + messageChain, relatedMessage: maybeMissingAwait ? Diagnostics.Did_you_forget_to_use_await : undefined, }; } - function invocationError(errorTarget: Node, apparentType: Type, kind: SignatureKind, relatedInformation?: DiagnosticRelatedInformation) { - const { messageChain, relatedMessage: relatedInfo } = invocationErrorDetails(errorTarget, apparentType, kind); + function invocationError(errorTarget: Node, invocationNode: CallLikeExpression, apparentType: Type, kind: SignatureKind, relatedInformation?: DiagnosticRelatedInformation) { + const { messageChain, relatedMessage: relatedInfo } = invocationErrorDetails(errorTarget, invocationNode, apparentType, kind); const diagnostic = createDiagnosticForNodeFromMessageChain(errorTarget, messageChain); if (relatedInfo) { addRelatedInfo(diagnostic, createDiagnosticForNode(errorTarget, relatedInfo)); @@ -29255,7 +29418,7 @@ namespace ts { return resolveErrorCall(node); } - invocationError(node.tag, apparentType, SignatureKind.Call); + invocationError(node.tag, node, apparentType, SignatureKind.Call); return resolveErrorCall(node); } @@ -29265,8 +29428,8 @@ namespace ts { /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ - function getDiagnosticHeadMessageForDecoratorResolution(node: Decorator) { - switch (node.parent.kind) { + function getDiagnosticHeadMessageForDecoratorResolution(decoratorTarget: NamedDeclaration) { + switch (decoratorTarget.kind) { case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: return Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; @@ -29309,9 +29472,9 @@ namespace ts { return resolveErrorCall(node); } - const headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + const headMessage = getDiagnosticHeadMessageForDecoratorResolution(node.parent); if (!callSignatures.length) { - const errorDetails = invocationErrorDetails(node.expression, apparentType, SignatureKind.Call); + const errorDetails = invocationErrorDetails(node.expression, node, apparentType, SignatureKind.Call); const messageChain = chainDiagnosticMessages(errorDetails.messageChain, headMessage); const diag = createDiagnosticForNodeFromMessageChain(node.expression, messageChain); if (errorDetails.relatedMessage) { @@ -29396,6 +29559,7 @@ namespace ts { function resolveSignature(node: CallLikeExpression, candidatesOutArray: Signature[] | undefined, checkMode: CheckMode): Signature { switch (node.kind) { case SyntaxKind.CallExpression: + case SyntaxKind.SyntheticCallExpression: return resolveCallExpression(node, candidatesOutArray, checkMode); case SyntaxKind.NewExpression: return resolveNewExpression(node, candidatesOutArray, checkMode); @@ -32493,6 +32657,8 @@ namespace ts { return checkYieldExpression(node); case SyntaxKind.SyntheticExpression: return checkSyntheticExpression(node); + case SyntaxKind.SyntheticCallExpression: + return checkSyntheticCallExpression(node); case SyntaxKind.JsxExpression: return checkJsxExpression(node, checkMode); case SyntaxKind.JsxElement: @@ -34075,44 +34241,36 @@ namespace ts { checkAwaitedType(returnType, node, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - /** Check a decorator */ - function checkDecorator(node: Decorator): void { - const signature = getResolvedSignature(node); - checkDeprecatedSignature(signature, node); - const returnType = getReturnTypeOfSignature(signature); + function checkDecoratorReturnType(decorationTarget: NamedDeclaration, returnType: Type, errorNode: Node, containingMessageChain?: () => DiagnosticMessageChain) { if (returnType.flags & TypeFlags.Any) { return; } let expectedReturnType: Type; - const headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); - let errorInfo: DiagnosticMessageChain | undefined; - switch (node.parent.kind) { + let headMessage = getDiagnosticHeadMessageForDecoratorResolution(decorationTarget); + let tailMessage: DiagnosticMessage | undefined; + switch (decorationTarget.kind) { case SyntaxKind.ClassDeclaration: - const classSymbol = getSymbolOfNode(node.parent); + const classSymbol = getSymbolOfNode(decorationTarget); const classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; case SyntaxKind.Parameter: expectedReturnType = voidType; - errorInfo = chainDiagnosticMessages( - /*details*/ undefined, - Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); - + tailMessage = headMessage; + headMessage = Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any; break; - case SyntaxKind.PropertyDeclaration: expectedReturnType = voidType; - errorInfo = chainDiagnosticMessages( - /*details*/ undefined, - Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); + tailMessage = headMessage; + headMessage = Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any; break; case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: - const methodType = getTypeOfNode(node.parent); + const methodType = getTypeOfNode(decorationTarget); const descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); break; @@ -34121,12 +34279,34 @@ namespace ts { return Debug.fail(); } + if (tailMessage) { + if (containingMessageChain) { + const previousContainingMessageChain = containingMessageChain; + containingMessageChain = () => { + const headChain = previousContainingMessageChain(); + concatenateDiagnosticMessageChains(headChain, chainDiagnosticMessages(/*details*/ undefined, tailMessage!)); + return headChain; + }; + } + else { + containingMessageChain = () => chainDiagnosticMessages(/*details*/ undefined, tailMessage!); + } + } + checkTypeAssignableTo( returnType, expectedReturnType, - node, + errorNode, headMessage, - () => errorInfo); + containingMessageChain); + } + + /** Check a decorator */ + function checkDecorator(node: Decorator): void { + const signature = getResolvedSignature(node); + checkDeprecatedSignature(signature, node); + const returnType = getReturnTypeOfSignature(signature); + checkDecoratorReturnType(node.parent, returnType, node); } /** @@ -34229,6 +34409,92 @@ namespace ts { return isRestParameter(node) ? getRestParameterElementType(typeNode) : typeNode; } + function checkSyntheticMetadataDecorator(node: DecoratableDeclaration, firstDecorator: Decorator) { + let useMetadataHelper = true; + // Attempt to use a user-defined metadata decorator, if one is provided. + const metadataDecorator = compilerOptions.metadataDecorator ? + parseIsolatedEntityName(compilerOptions.metadataDecorator, getEmitScriptTarget(compilerOptions)) : + undefined; + if (metadataDecorator) { + const containingMessageChain = () => importSource ? + chainDiagnosticMessages( + /*details*/ undefined, + Diagnostics.Unable_to_resolve_signature_of_implicit_decorator_0_from_module_1_when_called_as_an_expression, + compilerOptions.metadataDecorator, + importSource) : + chainDiagnosticMessages( + /*details*/ undefined, + Diagnostics.Unable_to_resolve_signature_of_implicit_decorator_0_when_called_as_an_expression, + compilerOptions.metadataDecorator); + + let decoratorSymbol: Symbol | undefined; + + // Mark all positions in the parsed entity name as synthetic so that we don't + // report (Missing). + setSyntheticPositionsRecursive(metadataDecorator); + + // If the metadata decorator is imported, we resolve the decorator + // using the exports of the source module + const importSource = getMetadataDecoratorImportSource(compilerOptions); + if (importSource) { + // If `--metadataDecoratorImportSource` is provided, we only use the custom + // metadata decorator if we believe the source file is a module. + const sourceFile = getSourceFileOfNode(node); + if (isEffectiveExternalModule(sourceFile, compilerOptions)) { + useMetadataHelper = false; + // Cache the resolution so that we don't perform this lookup repeatedly + decoratorSymbol = metadataDecoratorImportSymbols.get(sourceFile); + if (!decoratorSymbol) { + const moduleSymbol = resolveExternalModule(sourceFile, importSource, Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, firstDecorator); + if (moduleSymbol) { + // If `--metadataDecorator` is an entity name like `foo.bar`, we first resolve + // the export `foo` from the source module, and then resolve the rest of the + // entity name relative to that export. + const firstIdentifier = getFirstIdentifier(metadataDecorator); + const decoratorBaseSymbol = getMergedSymbol(getSymbol(moduleSymbol.exports!, firstIdentifier.escapedText, SymbolFlags.Value)); + if (!decoratorBaseSymbol) { + error(firstDecorator, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, importSource, idText(firstIdentifier)); + } + else { + if (firstIdentifier === metadataDecorator) { + decoratorSymbol = decoratorBaseSymbol; + } + else if (decoratorBaseSymbol.valueDeclaration) { + decoratorSymbol = resolveEntityName(metadataDecorator, SymbolFlags.Value, /*ignoreErrors*/ false, /*dontResolveAlias*/ false, /*location*/ undefined, firstDecorator, decoratorBaseSymbol, containingMessageChain); + } + } + } + metadataDecoratorImportSymbols.set(sourceFile, decoratorSymbol || unknownSymbol); + } + } + else { + error(firstDecorator, Diagnostics.Unable_to_import_implicit_decorator_0_from_module_1_as_this_file_is_not_a_module, compilerOptions.metadataDecorator, importSource); + } + } + else { + useMetadataHelper = false; + decoratorSymbol = resolveEntityName(metadataDecorator, SymbolFlags.Value, /*ignoreErrors*/ false, /*dontResolveAlias*/ false, firstDecorator, firstDecorator, /*rootSymbol*/ undefined, containingMessageChain); + } + if (decoratorSymbol && decoratorSymbol !== unknownSymbol) { + const syntheticCall = createSyntheticCallExpression( + firstDecorator, + isEntityName(metadataDecorator) && decoratorSymbol.parent ? createSyntheticExpression(firstDecorator, getTypeOfSymbol(decoratorSymbol.parent)) : undefined, + createSyntheticExpression(firstDecorator, getTypeOfSymbol(decoratorSymbol)), + /*typeArguments*/ undefined, + getEffectiveDecoratorArguments(node, firstDecorator), + containingMessageChain); + const returnType = checkSyntheticCallExpression(syntheticCall); + checkDecoratorReturnType(node, returnType, firstDecorator, containingMessageChain); + } + } + + // We don't use the metadata helper when `--metadataDecorator` is provided, unless `--metadataDecoratorImportSource` is *also* provided + // and the node's source file is not an external module. + if (useMetadataHelper) { + checkExternalEmitHelpers(firstDecorator, ExternalEmitHelpers.Metadata); + } + } + /** Check the decorators of a node */ function checkDecorators(node: Node): void { if (!node.decorators) { @@ -34252,12 +34518,12 @@ namespace ts { } if (compilerOptions.emitDecoratorMetadata) { - checkExternalEmitHelpers(firstDecorator, ExternalEmitHelpers.Metadata); + checkSyntheticMetadataDecorator(node, firstDecorator); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { case SyntaxKind.ClassDeclaration: - const constructor = getFirstConstructorWithBody(node); + const constructor = getFirstConstructorWithBody(node); if (constructor) { for (const parameter of constructor.parameters) { markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); @@ -34268,23 +34534,23 @@ namespace ts { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: const otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; - const otherAccessor = getDeclarationOfKind(getSymbolOfNode(node as AccessorDeclaration), otherKind); - markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node as AccessorDeclaration) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); + const otherAccessor = getDeclarationOfKind(getSymbolOfNode(node), otherKind); + markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; case SyntaxKind.MethodDeclaration: - for (const parameter of (node).parameters) { + for (const parameter of node.parameters) { markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } - markDecoratorMedataDataTypeNodeAsReferenced(getEffectiveReturnTypeNode(node)); + markDecoratorMedataDataTypeNodeAsReferenced(getEffectiveReturnTypeNode(node)); break; case SyntaxKind.PropertyDeclaration: - markDecoratorMedataDataTypeNodeAsReferenced(getEffectiveTypeAnnotationNode(node)); + markDecoratorMedataDataTypeNodeAsReferenced(getEffectiveTypeAnnotationNode(node)); break; case SyntaxKind.Parameter: - markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); + markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); const containingSignature = (node as ParameterDeclaration).parent; for (const parameter of containingSignature.parameters) { markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); @@ -39347,8 +39613,9 @@ namespace ts { // When resolved as an expression identifier, if the given node references an import, return the declaration of // that import. Otherwise, return undefined. function getReferencedImportDeclaration(nodeIn: Identifier): Declaration | undefined { - if (nodeIn.generatedImportReference) { - return nodeIn.generatedImportReference; + const syntheticImportReference = getGeneratedImportReference(nodeIn); + if (syntheticImportReference) { + return syntheticImportReference; } const node = getParseTreeNode(nodeIn, isIdentifier); if (node) { @@ -40266,7 +40533,7 @@ namespace ts { } } else if (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor) { - const accessors = getAllAccessorDeclarations((node.parent).members, node); + const accessors = getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index a62f7238b6917..298be7bd4e671 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -872,6 +872,21 @@ namespace ts { description: Diagnostics.Include_modules_imported_with_json_extension }, + { + name: "metadataDecorator", + type: "string", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Specify_the_name_of_the_metadata_decorator_function_to_use_when_emitDecoratorMetadata_is_set + }, + { + name: "metadataDecoratorImportSource", + type: "string", + affectsEmit: true, + affectsModuleResolution: true, + category: Diagnostics.Advanced_Options, + description: Diagnostics.Specify_the_module_specifier_to_be_used_to_import_the_metadata_decorator_provided_by_metadataDecorator + }, + { name: "out", type: "string", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f7d4fcc84eef2..f84a598c2a55b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1360,6 +1360,19 @@ "category": "Error", "code": 1432 }, + "Unable to resolve signature of implicit decorator '{0}' when called as an expression.": { + "category": "Error", + "code": 1433 + }, + "Unable to resolve signature of implicit decorator '{0}' from module '{1}' when called as an expression.": { + "category": "Error", + "code": 1434 + }, + "Unable to import implicit decorator '{0}' from module '{1}' as this file is not a module.": { + "category": "Error", + "code": 1435 + }, + "The types of '{0}' are incompatible between these types.": { "category": "Error", @@ -3308,6 +3321,18 @@ "category": "Error", "code": 2808 }, + "Namespace '{0}' from module '{1}' has no exported member '{2}'.": { + "category": "Error", + "code": 2809 + }, + "'{0}' from module '{1}' has no exported member named '{2}'. Did you mean '{3}'?": { + "category": "Error", + "code": 2810 + }, + "Cannot find namespace '{0}'. Did you mean '{1}?": { + "category": "Error", + "code": 2811 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", @@ -3814,7 +3839,7 @@ "category": "Error", "code": 5066 }, - "Invalid value for 'jsxFactory'. '{0}' is not a valid identifier or qualified-name.": { + "Invalid value for '{0}'. '{1}' is not a valid identifier or qualified-name.": { "category": "Error", "code": 5067 }, @@ -4821,6 +4846,14 @@ "category": "Error", "code": 6238 }, + "Specify the name of the metadata decorator function to use when '--emitDecoratorMetadata' is set": { + "category": "Message", + "code": 6239 + }, + "Specify the module specifier to be used to import the metadata decorator provided by '--metadataDecorator'.": { + "category": "Message", + "code": 6240 + }, "Projects to reference": { "category": "Message", @@ -6438,10 +6471,6 @@ "category": "Message", "code": 18034 }, - "Invalid value for 'jsxFragmentFactory'. '{0}' is not a valid identifier or qualified-name.": { - "category": "Error", - "code": 18035 - }, "Class decorators can't be used with static private identifier. Consider removing the experimental decorator.": { "category": "Error", "code": 18036 diff --git a/src/compiler/factory/emitHelpers.ts b/src/compiler/factory/emitHelpers.ts index f3e0004efd407..0edb5c65ba280 100644 --- a/src/compiler/factory/emitHelpers.ts +++ b/src/compiler/factory/emitHelpers.ts @@ -234,7 +234,7 @@ namespace ts { // ES2017 Helpers - function createAwaiterHelper(hasLexicalThis: boolean, hasLexicalArguments: boolean, promiseConstructor: EntityName | Expression | undefined, body: Block) { + function createAwaiterHelper(hasLexicalThis: boolean, hasLexicalArguments: boolean, promiseConstructor: EntityNameOrEntityNameExpression | undefined, body: Block) { context.requestEmitHelper(awaiterHelper); const generatorFunc = factory.createFunctionExpression( @@ -256,7 +256,7 @@ namespace ts { [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), hasLexicalArguments ? factory.createIdentifier("arguments") : factory.createVoidZero(), - promiseConstructor ? createExpressionFromEntityName(factory, promiseConstructor) : factory.createVoidZero(), + promiseConstructor ? isEntityName(promiseConstructor) ? createExpressionFromEntityName(factory, promiseConstructor) : promiseConstructor : factory.createVoidZero(), generatorFunc ] ); diff --git a/src/compiler/factory/emitNode.ts b/src/compiler/factory/emitNode.ts index 1da968d027dec..3d6367b5e17b8 100644 --- a/src/compiler/factory/emitNode.ts +++ b/src/compiler/factory/emitNode.ts @@ -259,4 +259,24 @@ namespace ts { getOrCreateEmitNode(node).flags |= EmitFlags.IgnoreSourceNewlines; return node; } + + /** + * For a synthetic import, specifies the synthesized import reference so that the import can be resolved during subsequent transformations. + * + * @param node Imported identifier + * @param importReference The `ImportSpecifier` to use for the reference, or `undefined`. + */ + /* @internal */ + export function setGeneratedImportReference(node: T, importReference: ImportSpecifier | undefined) { + getOrCreateEmitNode(node).generatedImportReference = importReference; + return node; + } + + /** + * For a synthetic import, gets any associated synthesized import reference. + */ + /* @internal */ + export function getGeneratedImportReference(node: Identifier) { + return node.emitNode?.generatedImportReference; + } } \ No newline at end of file diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index e443d4d0bdafb..d61d1f16157c9 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -427,6 +427,7 @@ namespace ts { createUnparsedSyntheticReference, createInputFiles, createSyntheticExpression, + createSyntheticCallExpression, createSyntaxList, createNotEmittedStatement, createPartiallyEmittedExpression, @@ -5104,6 +5105,17 @@ namespace ts { return node; } + // @api + function createSyntheticCallExpression(thisArg: LeftHandSideExpression | SyntheticExpression | undefined, expression: Expression | SyntheticExpression, typeArguments: readonly TypeNode[] | undefined, argumentList: readonly Expression[], containingMessageChain?: () => DiagnosticMessageChain | undefined): SyntheticCallExpression { + const node = createBaseNode(SyntaxKind.SyntheticCallExpression); + node.thisArg = thisArg; + node.expression = expression; + node.typeArguments = typeArguments; + node.arguments = argumentList; + node.containingMessageChain = containingMessageChain; + return node; + } + // @api function createSyntaxList(children: Node[]) { const node = createBaseNode(SyntaxKind.SyntaxList); diff --git a/src/compiler/factory/nodeTests.ts b/src/compiler/factory/nodeTests.ts index 64a88d32d099e..6300b999d0640 100644 --- a/src/compiler/factory/nodeTests.ts +++ b/src/compiler/factory/nodeTests.ts @@ -444,6 +444,10 @@ namespace ts { return node.kind === SyntaxKind.CommaListExpression; } + export function isSyntheticCallExpression(node: Node): node is SyntheticCallExpression { + return node.kind === SyntaxKind.SyntheticCallExpression; + } + // Misc export function isTemplateSpan(node: Node): node is TemplateSpan { @@ -629,7 +633,7 @@ namespace ts { } /* @internal */ - export function isSyntheticReference(node: Node): node is SyntheticReferenceExpression { + export function isSyntheticReferenceExpression(node: Node): node is SyntheticReferenceExpression { return node.kind === SyntaxKind.SyntheticReferenceExpression; } diff --git a/src/compiler/factory/utilities.ts b/src/compiler/factory/utilities.ts index 433f13c5c3e29..13885e9810d52 100644 --- a/src/compiler/factory/utilities.ts +++ b/src/compiler/factory/utilities.ts @@ -157,16 +157,27 @@ namespace ts { } } - export function createExpressionFromEntityName(factory: NodeFactory, node: EntityName | Expression): Expression { + export function createExpressionFromEntityName(factory: NodeFactory, node: EntityName, emulateParseTree = true): EntityNameExpression { if (isQualifiedName(node)) { - const left = createExpressionFromEntityName(factory, node.left); - // TODO(rbuckton): Does this need to be parented? - const right = setParent(setTextRange(factory.cloneNode(node.right), node.right), node.right.parent); - return setTextRange(factory.createPropertyAccessExpression(left, right), node); + const left = createExpressionFromEntityName(factory, node.left, emulateParseTree); + const right = factory.cloneNode(node.right); + if (emulateParseTree) { + setTextRange(right, node.right); + setParent(right, node.right.parent); + } + const expression = factory.createPropertyAccessExpression(left, right); + if (emulateParseTree) { + setTextRange(expression, node); + } + return expression as PropertyAccessEntityNameExpression; } else { - // TODO(rbuckton): Does this need to be parented? - return setParent(setTextRange(factory.cloneNode(node), node), node.parent); + const name = factory.cloneNode(node); + if (emulateParseTree) { + setTextRange(name, node); + setParent(name, node.parent); + } + return name; } } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 29231b7fa5786..5deeaa5ddfdac 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2290,6 +2290,14 @@ namespace ts { // synthesize `import "base/jsx-runtime"` declaration (imports ||= []).push(createSyntheticImport(jsxImport, file)); } + if (file.transformFlags & TransformFlags.ContainsTypeScriptClassSyntax && + options.emitDecoratorMetadata && + options.metadataDecorator) { + const metadataDecoratorImport = options.metadataDecoratorImportSource; + if (metadataDecoratorImport) { + (imports ||= []).push(createSyntheticImport(metadataDecoratorImport, file)); + } + } } for (const node of file.statements) { @@ -3244,6 +3252,30 @@ namespace ts { createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"); } + if (options.metadataDecorator) { + if (!options.experimentalDecorators) { + createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "metadataDecorator", "experimentalDecorators"); + } + if (!options.emitDecoratorMetadata) { + createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "metadataDecorator", "emitDecoratorMetadata"); + } + if (!parseIsolatedEntityName(options.metadataDecorator, languageVersion)) { + createOptionValueDiagnostic("metadataDecorator", Diagnostics.Invalid_value_for_0_1_is_not_a_valid_identifier_or_qualified_name, "metadataDecorator", options.metadataDecorator); + } + } + + if (options.metadataDecoratorImportSource) { + if (!options.experimentalDecorators) { + createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "metadataDecorator", "experimentalDecorators"); + } + if (!options.emitDecoratorMetadata) { + createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "metadataDecorator", "emitDecoratorMetadata"); + } + if (!options.metadataDecorator) { + createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "metadataDecoratorImportSource", "metadataDecorator"); + } + } + if (options.jsxFactory) { if (options.reactNamespace) { createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory"); @@ -3252,7 +3284,7 @@ namespace ts { createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", inverseJsxOptionMap.get("" + options.jsx)); } if (!parseIsolatedEntityName(options.jsxFactory, languageVersion)) { - createOptionValueDiagnostic("jsxFactory", Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory); + createOptionValueDiagnostic("jsxFactory", Diagnostics.Invalid_value_for_0_1_is_not_a_valid_identifier_or_qualified_name, "jsxFactory", options.jsxFactory); } } else if (options.reactNamespace && !isIdentifierText(options.reactNamespace, languageVersion)) { @@ -3267,7 +3299,7 @@ namespace ts { createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", inverseJsxOptionMap.get("" + options.jsx)); } if (!parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) { - createOptionValueDiagnostic("jsxFragmentFactory", Diagnostics.Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFragmentFactory); + createOptionValueDiagnostic("jsxFragmentFactory", Diagnostics.Invalid_value_for_0_1_is_not_a_valid_identifier_or_qualified_name, "jsxFragmentFactory", options.jsxFragmentFactory); } } @@ -3553,8 +3585,8 @@ namespace ts { createDiagnosticForOption(/*onKey*/ true, option1, option2, message, option1, option2, option3); } - function createOptionValueDiagnostic(option1: string, message: DiagnosticMessage, arg0: string) { - createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0); + function createOptionValueDiagnostic(option1: string, message: DiagnosticMessage, arg0: string, arg1?: string) { + createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0, arg1); } function createDiagnosticForReference(sourceFile: JsonSourceFile | undefined, index: number, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number) { diff --git a/src/compiler/transformers/es2020.ts b/src/compiler/transformers/es2020.ts index 2434e36559be1..fcbae6039ba64 100644 --- a/src/compiler/transformers/es2020.ts +++ b/src/compiler/transformers/es2020.ts @@ -23,14 +23,14 @@ namespace ts { switch (node.kind) { case SyntaxKind.CallExpression: { const updated = visitNonOptionalCallExpression(node as CallExpression, /*captureThisArg*/ false); - Debug.assertNotNode(updated, isSyntheticReference); + Debug.assertNotNode(updated, isSyntheticReferenceExpression); return updated; } case SyntaxKind.PropertyAccessExpression: case SyntaxKind.ElementAccessExpression: if (isOptionalChain(node)) { const updated = visitOptionalExpression(node, /*captureThisArg*/ false, /*isDelete*/ false); - Debug.assertNotNode(updated, isSyntheticReference); + Debug.assertNotNode(updated, isSyntheticReferenceExpression); return updated; } return visitEachChild(node, visitor, context); @@ -59,7 +59,7 @@ namespace ts { function visitNonOptionalParenthesizedExpression(node: ParenthesizedExpression, captureThisArg: boolean, isDelete: boolean): Expression { const expression = visitNonOptionalExpression(node.expression, captureThisArg, isDelete); - if (isSyntheticReference(expression)) { + if (isSyntheticReferenceExpression(expression)) { // `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` } // `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` } return factory.createSyntheticReferenceExpression(factory.updateParenthesizedExpression(node, expression.expression), expression.thisArg); @@ -74,7 +74,7 @@ namespace ts { } let expression: Expression = visitNode(node.expression, visitor, isExpression); - Debug.assertNotNode(expression, isSyntheticReference); + Debug.assertNotNode(expression, isSyntheticReferenceExpression); let thisArg: Expression | undefined; if (captureThisArg) { @@ -102,7 +102,7 @@ namespace ts { // capture thisArg for calls of parenthesized optional chains like `(foo?.bar)()` const expression = visitNonOptionalParenthesizedExpression(node.expression, /*captureThisArg*/ true, /*isDelete*/ false); const args = visitNodes(node.arguments, visitor, isExpression); - if (isSyntheticReference(expression)) { + if (isSyntheticReferenceExpression(expression)) { return setTextRange(factory.createFunctionCallCall(expression.expression, expression.thisArg, args), node); } return factory.updateCallExpression(node, expression, /*typeArguments*/ undefined, args); @@ -123,8 +123,8 @@ namespace ts { function visitOptionalExpression(node: OptionalChain, captureThisArg: boolean, isDelete: boolean): Expression { const { expression, chain } = flattenChain(node); const left = visitNonOptionalExpression(expression, isCallChain(chain[0]), /*isDelete*/ false); - const leftThisArg = isSyntheticReference(left) ? left.thisArg : undefined; - let leftExpression = isSyntheticReference(left) ? left.expression : left; + const leftThisArg = isSyntheticReferenceExpression(left) ? left.thisArg : undefined; + let leftExpression = isSyntheticReferenceExpression(left) ? left.expression : left; let capturedLeft: Expression = leftExpression; if (!isSimpleCopiableExpression(leftExpression)) { capturedLeft = factory.createTempVariable(hoistVariableDeclaration); diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index 1759d72bfda4e..b7e964fbeb051 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -57,7 +57,7 @@ namespace ts { } const generatedName = factory.createUniqueName(`_${name}`, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel | GeneratedIdentifierFlags.AllowNameSubstitution); const specifier = factory.createImportSpecifier(factory.createIdentifier(name), generatedName); - generatedName.generatedImportReference = specifier; + setGeneratedImportReference(generatedName, specifier); specifierSourceImports.set(name, specifier); return generatedName; } @@ -525,7 +525,7 @@ namespace ts { return factory.createStringLiteral(idText(name)); } else { - return createExpressionFromEntityName(factory, name); + return name; } } } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 0d24f332c15bd..2446a31dad926 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -67,6 +67,9 @@ namespace ts { let currentNameScope: ClassDeclaration | undefined; let currentScopeFirstDeclarationsOfName: UnderscoreEscapedMap | undefined; let currentClassHasParameterProperties: boolean | undefined; + let currentMetadataDecoratorImportSpecifier: ImportSpecifier | undefined; + + const getMetadataDecoratorEntityNameExpression = memoize(getMetadataDecoratorEntityNameExpressionWorker); /** * Keeps track of whether expression substitution has been enabled for specific edge cases. @@ -120,6 +123,7 @@ namespace ts { addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined!; + currentMetadataDecoratorImportSpecifier = undefined; return visited; } @@ -560,9 +564,39 @@ namespace ts { !(isExternalModule(node) && moduleKind >= ModuleKind.ES2015) && !isJsonSourceFile(node); - return factory.updateSourceFile( - node, - visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); + let statements = visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict); + if (compilerOptions.metadataDecoratorImportSource && currentMetadataDecoratorImportSpecifier) { + if (isExternalModule(node) || compilerOptions.isolatedModules) { + const importStatement = factory.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + factory.createImportClause( + /*typeOnly*/ false, + /*name*/ undefined, + factory.createNamedImports([currentMetadataDecoratorImportSpecifier]) + ), + factory.createStringLiteral(compilerOptions.metadataDecoratorImportSource)); + setParentRecursive(importStatement, /*incremental*/ false); + statements = setTextRange(factory.createNodeArray(insertStatementAfterCustomPrologue(statements.slice(), importStatement)), statements); + } + else if (isExternalOrCommonJsModule(node)) { + // Add `require` statement + const requireStatement = factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([ + factory.createVariableDeclaration( + factory.createObjectBindingPattern([ + factory.createBindingElement(/*dotdotdot*/ undefined, currentMetadataDecoratorImportSpecifier.propertyName, currentMetadataDecoratorImportSpecifier.name) + ]), + /*exclaimationToken*/ undefined, + /*type*/ undefined, + factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createStringLiteral(compilerOptions.metadataDecoratorImportSource)]) + ) + ], NodeFlags.Const)); + setParentRecursive(requireStatement, /*incremental*/ false); + statements = setTextRange(factory.createNodeArray(insertStatementAfterCustomPrologue(statements.slice(), requireStatement)), statements); + } + } + + return factory.updateSourceFile(node, statements); } /** @@ -1309,16 +1343,59 @@ namespace ts { } } + function replaceFirstIdentifier(name: EntityNameExpression, newFirst: Identifier): EntityNameExpression { + return isPropertyAccessEntityNameExpression(name) ? + factory.updatePropertyAccessExpression(name, replaceFirstIdentifier(name.expression, newFirst), name.name) as PropertyAccessEntityNameExpression : + newFirst; + } + + function getMetadataDecoratorEntityNameExpressionWorker() { + if (compilerOptions.metadataDecorator) { + const entityName = parseIsolatedEntityName(compilerOptions.metadataDecorator, getEmitScriptTarget(compilerOptions)); + return entityName && serializeEntityNameAsExpression(entityName, /*emulateParseTree*/ false); + } + } + + function getMetadataDecoratorExpression() { + const entityNameExpression = getMetadataDecoratorEntityNameExpression(); + if (entityNameExpression) { + if (compilerOptions.metadataDecoratorImportSource) { + if (!currentMetadataDecoratorImportSpecifier) { + const first = getFirstIdentifier(entityNameExpression); + const generatedName = factory.createUniqueName(idText(first), GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel); + currentMetadataDecoratorImportSpecifier = factory.createImportSpecifier(first, generatedName); + setGeneratedImportReference(generatedName, currentMetadataDecoratorImportSpecifier); + } + return replaceFirstIdentifier(entityNameExpression, currentMetadataDecoratorImportSpecifier.name); + } + return entityNameExpression; + } + } + + function createMetadataDecorator(metadataKey: string, metadataValue: Expression) { + const decoratorExpression = getMetadataDecoratorExpression(); + if (decoratorExpression) { + return setSourceMapRange(factory.createCallExpression( + decoratorExpression, + /*typeArguments*/ undefined, + [ + factory.createStringLiteral(metadataKey), + metadataValue + ]), getSourceMapRange(metadataValue)); + } + return emitHelpers().createMetadataHelper(metadataKey, metadataValue); + } + function addOldTypeMetadata(node: Declaration, container: ClassLikeDeclaration, decoratorExpressions: Expression[]) { if (compilerOptions.emitDecoratorMetadata) { if (shouldAddTypeMetadata(node)) { - decoratorExpressions.push(emitHelpers().createMetadataHelper("design:type", serializeTypeOfNode(node))); + decoratorExpressions.push(createMetadataDecorator("design:type", serializeTypeOfNode(node))); } if (shouldAddParamTypesMetadata(node)) { - decoratorExpressions.push(emitHelpers().createMetadataHelper("design:paramtypes", serializeParameterTypesOfNode(node, container))); + decoratorExpressions.push(createMetadataDecorator("design:paramtypes", serializeParameterTypesOfNode(node, container))); } if (shouldAddReturnTypeMetadata(node)) { - decoratorExpressions.push(emitHelpers().createMetadataHelper("design:returntype", serializeReturnTypeOfNode(node))); + decoratorExpressions.push(createMetadataDecorator("design:returntype", serializeReturnTypeOfNode(node))); } } } @@ -1336,7 +1413,7 @@ namespace ts { (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(SyntaxKind.EqualsGreaterThanToken), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true))); + decoratorExpressions.push(createMetadataDecorator("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true))); } } } @@ -1505,73 +1582,73 @@ namespace ts { case SyntaxKind.VoidKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NeverKeyword: - return factory.createVoidZero(); + return setSourceMapRange(factory.createVoidZero(), node); case SyntaxKind.ParenthesizedType: return serializeTypeNode((node).type); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: - return factory.createIdentifier("Function"); + return setSourceMapRange(factory.createIdentifier("Function"), node); case SyntaxKind.ArrayType: case SyntaxKind.TupleType: - return factory.createIdentifier("Array"); + return setSourceMapRange(factory.createIdentifier("Array"), node); case SyntaxKind.TypePredicate: case SyntaxKind.BooleanKeyword: - return factory.createIdentifier("Boolean"); + return setSourceMapRange(factory.createIdentifier("Boolean"), node); case SyntaxKind.StringKeyword: - return factory.createIdentifier("String"); + return setSourceMapRange(factory.createIdentifier("String"), node); case SyntaxKind.ObjectKeyword: - return factory.createIdentifier("Object"); + return setSourceMapRange(factory.createIdentifier("Object"), node); case SyntaxKind.LiteralType: switch ((node).literal.kind) { case SyntaxKind.StringLiteral: case SyntaxKind.NoSubstitutionTemplateLiteral: - return factory.createIdentifier("String"); + return setSourceMapRange(factory.createIdentifier("String"), node); case SyntaxKind.PrefixUnaryExpression: case SyntaxKind.NumericLiteral: - return factory.createIdentifier("Number"); + return setSourceMapRange(factory.createIdentifier("Number"), node); case SyntaxKind.BigIntLiteral: - return getGlobalBigIntNameWithFallback(); + return setSourceMapRange(getGlobalBigIntNameWithFallback(), node); case SyntaxKind.TrueKeyword: case SyntaxKind.FalseKeyword: - return factory.createIdentifier("Boolean"); + return setSourceMapRange(factory.createIdentifier("Boolean"), node); case SyntaxKind.NullKeyword: - return factory.createVoidZero(); + return setSourceMapRange(factory.createVoidZero(), node); default: return Debug.failBadSyntaxKind((node).literal); } case SyntaxKind.NumberKeyword: - return factory.createIdentifier("Number"); + return setSourceMapRange(factory.createIdentifier("Number"), node); case SyntaxKind.BigIntKeyword: - return getGlobalBigIntNameWithFallback(); + return setSourceMapRange(getGlobalBigIntNameWithFallback(), node); case SyntaxKind.SymbolKeyword: return languageVersion < ScriptTarget.ES2015 - ? getGlobalSymbolNameWithFallback() - : factory.createIdentifier("Symbol"); + ? setSourceMapRange(getGlobalSymbolNameWithFallback(), node) + : setSourceMapRange(factory.createIdentifier("Symbol"), node); case SyntaxKind.TypeReference: - return serializeTypeReferenceNode(node); + return setSourceMapRange(serializeTypeReferenceNode(node), node); case SyntaxKind.IntersectionType: case SyntaxKind.UnionType: - return serializeTypeList((node).types); + return setSourceMapRange(serializeTypeList((node).types), node); case SyntaxKind.ConditionalType: - return serializeTypeList([(node).trueType, (node).falseType]); + return setSourceMapRange(serializeTypeList([(node).trueType, (node).falseType]), node); case SyntaxKind.TypeOperator: if ((node).operator === SyntaxKind.ReadonlyKeyword) { @@ -1605,7 +1682,7 @@ namespace ts { return Debug.failBadSyntaxKind(node); } - return factory.createIdentifier("Object"); + return setSourceMapRange(factory.createIdentifier("Object"), node); } function serializeTypeList(types: readonly TypeNode[]): SerializedTypeNode { @@ -1635,7 +1712,7 @@ namespace ts { if (!isIdentifier(serializedUnion) || !isIdentifier(serializedIndividual) || serializedUnion.escapedText !== serializedIndividual.escapedText) { - return factory.createIdentifier("Object"); + return (factory.createIdentifier("Object")); } } else { @@ -1660,7 +1737,7 @@ namespace ts { case TypeReferenceSerializationKind.Unknown: // From conditional type type reference that cannot be resolved is Similar to any or unknown if (findAncestor(node, n => n.parent && isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n))) { - return factory.createIdentifier("Object"); + return (factory.createIdentifier("Object")); } const serialized = serializeEntityNameAsExpressionFallback(node.typeName); @@ -1751,18 +1828,21 @@ namespace ts { * * @param node The entity name to serialize. */ - function serializeEntityNameAsExpression(node: EntityName): SerializedEntityNameAsExpression { + function serializeEntityNameAsExpression(node: EntityName, emulateParseTree = true): EntityNameExpression { switch (node.kind) { case SyntaxKind.Identifier: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. - const name = setParent(setTextRange(parseNodeFactory.cloneNode(node), node), node.parent); - name.original = undefined; - setParent(name, getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. + const name = parseNodeFactory.cloneNode(node); + if (emulateParseTree) { + setTextRange(name, node); + setParent(name, getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. + name.original = undefined; + } return name; case SyntaxKind.QualifiedName: - return serializeQualifiedNameAsExpression(node); + return serializeQualifiedNameAsExpression(node, emulateParseTree); } } @@ -1773,8 +1853,8 @@ namespace ts { * @param useFallback A value indicating whether to use logical operators to test for the * qualified name at runtime. */ - function serializeQualifiedNameAsExpression(node: QualifiedName): SerializedEntityNameAsExpression { - return factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right); + function serializeQualifiedNameAsExpression(node: QualifiedName, emulateParseTree: boolean): PropertyAccessEntityNameExpression { + return factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left, emulateParseTree), node.right) as PropertyAccessEntityNameExpression; } /** diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0deacbe8e8a6a..5270ba0b93afb 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -269,6 +269,7 @@ namespace ts { NonNullExpression, MetaProperty, SyntheticExpression, + SyntheticCallExpression, // Misc TemplateSpan, @@ -1098,7 +1099,6 @@ namespace ts { readonly originalKeywordKind?: SyntaxKind; // Original syntaxKind which get set so that we can report an error later /*@internal*/ readonly autoGenerateFlags?: GeneratedIdentifierFlags; // Specifies whether to auto-generate the text for an identifier. /*@internal*/ readonly autoGenerateId?: number; // Ensures unique generated identifiers get unique names, but clones get the same name. - /*@internal*/ generatedImportReference?: ImportSpecifier; // Reference to the generated import specifier this identifier refers to isInJSDocNamespace?: boolean; // if the node is a member in a JSDoc namespace /*@internal*/ typeArguments?: NodeArray; // Only defined on synthesized nodes. Though not syntactically valid, used in emitting diagnostics, quickinfo, and signature help. /*@internal*/ jsdocDotPos?: number; // Identifier occurs in JSDoc-style generic: Id. @@ -2305,6 +2305,15 @@ namespace ts { // see: https://tc39.github.io/ecma262/#prod-SuperProperty export type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; + export interface SyntheticCallExpression extends LeftHandSideExpression { + readonly kind: SyntaxKind.SyntheticCallExpression; + readonly thisArg?: LeftHandSideExpression | SyntheticExpression; + readonly expression: Expression; + readonly typeArguments?: readonly TypeNode[]; + readonly arguments: readonly Expression[]; + /* @internal */ containingMessageChain?: () => DiagnosticMessageChain | undefined; + } + export interface CallExpression extends LeftHandSideExpression, Declaration { readonly kind: SyntaxKind.CallExpression; readonly expression: LeftHandSideExpression; @@ -2420,6 +2429,7 @@ namespace ts { | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement + | SyntheticCallExpression ; export interface AsExpression extends Expression { @@ -5889,6 +5899,8 @@ namespace ts { downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; + metadataDecorator?: string; + metadataDecoratorImportSource?: string; experimentalDecorators?: boolean; forceConsistentCasingInFileNames?: boolean; /*@internal*/generateCpuProfile?: string; @@ -6590,6 +6602,8 @@ namespace ts { externalHelpers?: boolean; helpers?: EmitHelper[]; // Emit helpers for the node startsOnNewLine?: boolean; // If the node should begin on a new line + generatedImportReference?: ImportSpecifier; // For a synthetic import, specifies the synthesized import reference so that + // the import can be resolved during subsequent transformations. } export const enum EmitFlags { @@ -7341,6 +7355,7 @@ namespace ts { // Synthetic Nodes // /* @internal */ createSyntheticExpression(type: Type, isSpread?: boolean, tupleNameSource?: ParameterDeclaration | NamedTupleMember): SyntheticExpression; + /* @internal */ createSyntheticCallExpression(thisArg: LeftHandSideExpression | SyntheticExpression | undefined, expression: Expression | SyntheticExpression, typeArguments: readonly TypeNode[] | undefined, argumentList: readonly Expression[], containingMessageChain?: () => DiagnosticMessageChain | undefined): SyntheticCallExpression; /* @internal */ createSyntaxList(children: Node[]): SyntaxList; // diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 0b7e5f2003eb9..572b6da70698d 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -927,7 +927,16 @@ namespace ts { // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. export function declarationNameToString(name: DeclarationName | QualifiedName | undefined) { - return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + if (name) { + if (getFullWidth(name) !== 0) { + return getTextOfNode(name); + } + if (nodeIsSynthesized(name)) { + if (isIdentifier(name)) return idText(name); + if (isQualifiedName(name)) return entityNameToString(name); + } + } + return "(Missing)"; } export function getNameFromIndexInfo(info: IndexInfo): string | undefined { @@ -997,6 +1006,10 @@ namespace ts { return createFileDiagnosticFromMessageChain(sourceFile, span.start, span.length, messageChain, relatedInformation); } + export function isDiagnosticMessageChain(message: DiagnosticMessage | DiagnosticMessageChain): message is DiagnosticMessageChain { + return !("message" in message); // eslint-disable-line no-in-operator + } + function assertDiagnosticLocation(file: SourceFile | undefined, start: number, length: number) { Debug.assertGreaterThanOrEqual(start, 0); Debug.assertGreaterThanOrEqual(length, 0); @@ -1772,9 +1785,39 @@ namespace ts { } } + export interface DecoratablePropertyDeclaration extends PropertyDeclaration { + readonly parent: ClassDeclaration; + } + export interface DecoratableGetAccessorDeclaration extends GetAccessorDeclaration { + readonly parent: ClassDeclaration; + } + export interface DecoratableSetAccessorDeclaration extends SetAccessorDeclaration { + readonly parent: ClassDeclaration; + } + export interface DecoratableMethodDeclaration extends MethodDeclaration { + readonly parent: ClassDeclaration; + readonly body: Block; + } + export interface DecoratableParameterDeclaration extends ParameterDeclaration { + readonly parent: ConstructorDeclaration | DecoratableMethodDeclaration | DecoratableGetAccessorDeclaration | DecoratableSetAccessorDeclaration; + } + + export type DecoratableClassElement = + | DecoratablePropertyDeclaration + | DecoratableGetAccessorDeclaration + | DecoratableSetAccessorDeclaration + | DecoratableMethodDeclaration + ; + + export type DecoratableDeclaration = + | ClassDeclaration + | DecoratableClassElement + | DecoratableParameterDeclaration + ; + export function nodeCanBeDecorated(node: ClassDeclaration): true; - export function nodeCanBeDecorated(node: ClassElement, parent: Node): boolean; - export function nodeCanBeDecorated(node: Node, parent: Node, grandparent: Node): boolean; + export function nodeCanBeDecorated(node: ClassElement, parent: Node): node is DecoratableClassElement; + export function nodeCanBeDecorated(node: Node, parent: Node, grandparent: Node): node is DecoratableDeclaration; export function nodeCanBeDecorated(node: Node, parent?: Node, grandparent?: Node): boolean { // private names cannot be used with decorators yet if (isNamedDeclaration(node) && isPrivateIdentifier(node.name)) { @@ -5889,6 +5932,12 @@ namespace ts { }; } + /** + * Creates a new outer `DiagnosticMessageChain` that optionally points back to a more specific set of diagnostics. + * @param details The inner `DiagnosticMessageChain` to surround. + * @param message The message for the new `DiagnosticMessageChain`. + * @param args Format arguments for the message. + */ export function chainDiagnosticMessages(details: DiagnosticMessageChain | DiagnosticMessageChain[] | undefined, message: DiagnosticMessage, ...args: (string | number | undefined)[]): DiagnosticMessageChain; export function chainDiagnosticMessages(details: DiagnosticMessageChain | DiagnosticMessageChain[] | undefined, message: DiagnosticMessage): DiagnosticMessageChain { let text = getLocaleSpecificMessage(message); @@ -5905,13 +5954,26 @@ namespace ts { }; } - export function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): void { + /** + * Sets `tailChain` as the innermost `DiagnosticMessageChain` of `headChain`, returning the outermost chain. + * + * @param headChain The outermost `DiagnosticMessageChain` into which to insert `tailChain`. + * @param tailChain A `DiagnosticMessageChain` to insert into `headChain`. + */ + export function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain | undefined): DiagnosticMessageChain; + export function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain | undefined, tailChain: DiagnosticMessageChain): DiagnosticMessageChain; + export function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain | undefined, tailChain: DiagnosticMessageChain | undefined): DiagnosticMessageChain | undefined; + export function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain | undefined, tailChain: DiagnosticMessageChain | undefined): DiagnosticMessageChain | undefined { + if (!headChain) return tailChain; + if (!tailChain) return headChain; + let lastChain = headChain; while (lastChain.next) { lastChain = lastChain.next[0]; } lastChain.next = [tailChain]; + return headChain; } function getDiagnosticFilePath(diagnostic: Diagnostic): string | undefined { @@ -6105,6 +6167,10 @@ namespace ts { return base ? `${base}/${options.jsx === JsxEmit.ReactJSXDev ? "jsx-dev-runtime" : "jsx-runtime"}` : undefined; } + export function getMetadataDecoratorImportSource(compilerOptions: CompilerOptions): string | undefined { + return compilerOptions.metadataDecoratorImportSource; + } + export function hasZeroOrOneAsteriskCharacter(str: string): boolean { let seenAsterisk = false; for (let i = 0; i < str.length; i++) { @@ -7096,6 +7162,26 @@ namespace ts { } } + /** + * **WARNING:** This is an inherently unsafe operation and should be used with care. + * + * Sets the text range of `rootNode` and each of its children recursively to `{pos: -1, end: -1}`. + * + * Only sets the text ranges of children whose parent is `undefined` or points to the parent (reused + * subtrees are not reset). + */ + /* @internal */ + export function setSyntheticPositionsRecursive(rootNode: T): T { + setTextRangePosEnd(rootNode, -1, -1); + forEachChildRecursively(rootNode, (child, parent) => { + if (child.parent !== undefined && child.parent !== parent) { + return "skip"; + } + setTextRangePosEnd(child, -1, -1); + }); + return rootNode; + } + function isPackedElement(node: Expression) { return !isOmittedExpression(node); } diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 6bec2e5f07e86..17b86343dd94b 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -1502,6 +1502,7 @@ namespace ts { case SyntaxKind.NonNullExpression: case SyntaxKind.MetaProperty: case SyntaxKind.ImportKeyword: // technically this is only an Expression if it's in a CallExpression + case SyntaxKind.SyntheticCallExpression: return true; default: return false; @@ -1561,6 +1562,7 @@ namespace ts { case SyntaxKind.OmittedExpression: case SyntaxKind.CommaListExpression: case SyntaxKind.PartiallyEmittedExpression: + case SyntaxKind.SyntheticExpression: return true; default: return isUnaryExpressionKind(kind); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index a2ff8fc1ea29a..dc36f959d75b6 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -333,123 +333,124 @@ declare namespace ts { NonNullExpression = 226, MetaProperty = 227, SyntheticExpression = 228, - TemplateSpan = 229, - SemicolonClassElement = 230, - Block = 231, - EmptyStatement = 232, - VariableStatement = 233, - ExpressionStatement = 234, - IfStatement = 235, - DoStatement = 236, - WhileStatement = 237, - ForStatement = 238, - ForInStatement = 239, - ForOfStatement = 240, - ContinueStatement = 241, - BreakStatement = 242, - ReturnStatement = 243, - WithStatement = 244, - SwitchStatement = 245, - LabeledStatement = 246, - ThrowStatement = 247, - TryStatement = 248, - DebuggerStatement = 249, - VariableDeclaration = 250, - VariableDeclarationList = 251, - FunctionDeclaration = 252, - ClassDeclaration = 253, - InterfaceDeclaration = 254, - TypeAliasDeclaration = 255, - EnumDeclaration = 256, - ModuleDeclaration = 257, - ModuleBlock = 258, - CaseBlock = 259, - NamespaceExportDeclaration = 260, - ImportEqualsDeclaration = 261, - ImportDeclaration = 262, - ImportClause = 263, - NamespaceImport = 264, - NamedImports = 265, - ImportSpecifier = 266, - ExportAssignment = 267, - ExportDeclaration = 268, - NamedExports = 269, - NamespaceExport = 270, - ExportSpecifier = 271, - MissingDeclaration = 272, - ExternalModuleReference = 273, - JsxElement = 274, - JsxSelfClosingElement = 275, - JsxOpeningElement = 276, - JsxClosingElement = 277, - JsxFragment = 278, - JsxOpeningFragment = 279, - JsxClosingFragment = 280, - JsxAttribute = 281, - JsxAttributes = 282, - JsxSpreadAttribute = 283, - JsxExpression = 284, - CaseClause = 285, - DefaultClause = 286, - HeritageClause = 287, - CatchClause = 288, - PropertyAssignment = 289, - ShorthandPropertyAssignment = 290, - SpreadAssignment = 291, - EnumMember = 292, - UnparsedPrologue = 293, - UnparsedPrepend = 294, - UnparsedText = 295, - UnparsedInternalText = 296, - UnparsedSyntheticReference = 297, - SourceFile = 298, - Bundle = 299, - UnparsedSource = 300, - InputFiles = 301, - JSDocTypeExpression = 302, - JSDocNameReference = 303, - JSDocAllType = 304, - JSDocUnknownType = 305, - JSDocNullableType = 306, - JSDocNonNullableType = 307, - JSDocOptionalType = 308, - JSDocFunctionType = 309, - JSDocVariadicType = 310, - JSDocNamepathType = 311, - JSDocComment = 312, - JSDocText = 313, - JSDocTypeLiteral = 314, - JSDocSignature = 315, - JSDocLink = 316, - JSDocTag = 317, - JSDocAugmentsTag = 318, - JSDocImplementsTag = 319, - JSDocAuthorTag = 320, - JSDocDeprecatedTag = 321, - JSDocClassTag = 322, - JSDocPublicTag = 323, - JSDocPrivateTag = 324, - JSDocProtectedTag = 325, - JSDocReadonlyTag = 326, - JSDocOverrideTag = 327, - JSDocCallbackTag = 328, - JSDocEnumTag = 329, - JSDocParameterTag = 330, - JSDocReturnTag = 331, - JSDocThisTag = 332, - JSDocTypeTag = 333, - JSDocTemplateTag = 334, - JSDocTypedefTag = 335, - JSDocSeeTag = 336, - JSDocPropertyTag = 337, - SyntaxList = 338, - NotEmittedStatement = 339, - PartiallyEmittedExpression = 340, - CommaListExpression = 341, - MergeDeclarationMarker = 342, - EndOfDeclarationMarker = 343, - SyntheticReferenceExpression = 344, - Count = 345, + SyntheticCallExpression = 229, + TemplateSpan = 230, + SemicolonClassElement = 231, + Block = 232, + EmptyStatement = 233, + VariableStatement = 234, + ExpressionStatement = 235, + IfStatement = 236, + DoStatement = 237, + WhileStatement = 238, + ForStatement = 239, + ForInStatement = 240, + ForOfStatement = 241, + ContinueStatement = 242, + BreakStatement = 243, + ReturnStatement = 244, + WithStatement = 245, + SwitchStatement = 246, + LabeledStatement = 247, + ThrowStatement = 248, + TryStatement = 249, + DebuggerStatement = 250, + VariableDeclaration = 251, + VariableDeclarationList = 252, + FunctionDeclaration = 253, + ClassDeclaration = 254, + InterfaceDeclaration = 255, + TypeAliasDeclaration = 256, + EnumDeclaration = 257, + ModuleDeclaration = 258, + ModuleBlock = 259, + CaseBlock = 260, + NamespaceExportDeclaration = 261, + ImportEqualsDeclaration = 262, + ImportDeclaration = 263, + ImportClause = 264, + NamespaceImport = 265, + NamedImports = 266, + ImportSpecifier = 267, + ExportAssignment = 268, + ExportDeclaration = 269, + NamedExports = 270, + NamespaceExport = 271, + ExportSpecifier = 272, + MissingDeclaration = 273, + ExternalModuleReference = 274, + JsxElement = 275, + JsxSelfClosingElement = 276, + JsxOpeningElement = 277, + JsxClosingElement = 278, + JsxFragment = 279, + JsxOpeningFragment = 280, + JsxClosingFragment = 281, + JsxAttribute = 282, + JsxAttributes = 283, + JsxSpreadAttribute = 284, + JsxExpression = 285, + CaseClause = 286, + DefaultClause = 287, + HeritageClause = 288, + CatchClause = 289, + PropertyAssignment = 290, + ShorthandPropertyAssignment = 291, + SpreadAssignment = 292, + EnumMember = 293, + UnparsedPrologue = 294, + UnparsedPrepend = 295, + UnparsedText = 296, + UnparsedInternalText = 297, + UnparsedSyntheticReference = 298, + SourceFile = 299, + Bundle = 300, + UnparsedSource = 301, + InputFiles = 302, + JSDocTypeExpression = 303, + JSDocNameReference = 304, + JSDocAllType = 305, + JSDocUnknownType = 306, + JSDocNullableType = 307, + JSDocNonNullableType = 308, + JSDocOptionalType = 309, + JSDocFunctionType = 310, + JSDocVariadicType = 311, + JSDocNamepathType = 312, + JSDocComment = 313, + JSDocText = 314, + JSDocTypeLiteral = 315, + JSDocSignature = 316, + JSDocLink = 317, + JSDocTag = 318, + JSDocAugmentsTag = 319, + JSDocImplementsTag = 320, + JSDocAuthorTag = 321, + JSDocDeprecatedTag = 322, + JSDocClassTag = 323, + JSDocPublicTag = 324, + JSDocPrivateTag = 325, + JSDocProtectedTag = 326, + JSDocReadonlyTag = 327, + JSDocOverrideTag = 328, + JSDocCallbackTag = 329, + JSDocEnumTag = 330, + JSDocParameterTag = 331, + JSDocReturnTag = 332, + JSDocThisTag = 333, + JSDocTypeTag = 334, + JSDocTemplateTag = 335, + JSDocTypedefTag = 336, + JSDocSeeTag = 337, + JSDocPropertyTag = 338, + SyntaxList = 339, + NotEmittedStatement = 340, + PartiallyEmittedExpression = 341, + CommaListExpression = 342, + MergeDeclarationMarker = 343, + EndOfDeclarationMarker = 344, + SyntheticReferenceExpression = 345, + Count = 346, FirstAssignment = 62, LastAssignment = 77, FirstCompoundAssignment = 63, @@ -474,13 +475,13 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 29, LastBinaryOperator = 77, - FirstStatement = 233, - LastStatement = 249, + FirstStatement = 234, + LastStatement = 250, FirstNode = 158, - FirstJSDocNode = 302, - LastJSDocNode = 337, - FirstJSDocTagNode = 317, - LastJSDocTagNode = 337, + FirstJSDocNode = 303, + LastJSDocNode = 338, + FirstJSDocTagNode = 318, + LastJSDocTagNode = 338, } export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; @@ -1251,6 +1252,13 @@ declare namespace ts { readonly expression: SuperExpression; } export type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; + export interface SyntheticCallExpression extends LeftHandSideExpression { + readonly kind: SyntaxKind.SyntheticCallExpression; + readonly thisArg?: LeftHandSideExpression | SyntheticExpression; + readonly expression: Expression; + readonly typeArguments?: readonly TypeNode[]; + readonly arguments: readonly Expression[]; + } export interface CallExpression extends LeftHandSideExpression, Declaration { readonly kind: SyntaxKind.CallExpression; readonly expression: LeftHandSideExpression; @@ -1285,7 +1293,7 @@ declare namespace ts { readonly typeArguments?: NodeArray; readonly template: TemplateLiteral; } - export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; + export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement | SyntheticCallExpression; export interface AsExpression extends Expression { readonly kind: SyntaxKind.AsExpression; readonly expression: Expression; @@ -2830,6 +2838,8 @@ declare namespace ts { downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; + metadataDecorator?: string; + metadataDecoratorImportSource?: string; experimentalDecorators?: boolean; forceConsistentCasingInFileNames?: boolean; importHelpers?: boolean; @@ -4484,6 +4494,7 @@ declare namespace ts { function isSyntheticExpression(node: Node): node is SyntheticExpression; function isPartiallyEmittedExpression(node: Node): node is PartiallyEmittedExpression; function isCommaListExpression(node: Node): node is CommaListExpression; + function isSyntheticCallExpression(node: Node): node is SyntheticCallExpression; function isTemplateSpan(node: Node): node is TemplateSpan; function isSemicolonClassElement(node: Node): node is SemicolonClassElement; function isBlock(node: Node): node is Block; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 0b2d291eeddb5..c8ff8de378829 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -333,123 +333,124 @@ declare namespace ts { NonNullExpression = 226, MetaProperty = 227, SyntheticExpression = 228, - TemplateSpan = 229, - SemicolonClassElement = 230, - Block = 231, - EmptyStatement = 232, - VariableStatement = 233, - ExpressionStatement = 234, - IfStatement = 235, - DoStatement = 236, - WhileStatement = 237, - ForStatement = 238, - ForInStatement = 239, - ForOfStatement = 240, - ContinueStatement = 241, - BreakStatement = 242, - ReturnStatement = 243, - WithStatement = 244, - SwitchStatement = 245, - LabeledStatement = 246, - ThrowStatement = 247, - TryStatement = 248, - DebuggerStatement = 249, - VariableDeclaration = 250, - VariableDeclarationList = 251, - FunctionDeclaration = 252, - ClassDeclaration = 253, - InterfaceDeclaration = 254, - TypeAliasDeclaration = 255, - EnumDeclaration = 256, - ModuleDeclaration = 257, - ModuleBlock = 258, - CaseBlock = 259, - NamespaceExportDeclaration = 260, - ImportEqualsDeclaration = 261, - ImportDeclaration = 262, - ImportClause = 263, - NamespaceImport = 264, - NamedImports = 265, - ImportSpecifier = 266, - ExportAssignment = 267, - ExportDeclaration = 268, - NamedExports = 269, - NamespaceExport = 270, - ExportSpecifier = 271, - MissingDeclaration = 272, - ExternalModuleReference = 273, - JsxElement = 274, - JsxSelfClosingElement = 275, - JsxOpeningElement = 276, - JsxClosingElement = 277, - JsxFragment = 278, - JsxOpeningFragment = 279, - JsxClosingFragment = 280, - JsxAttribute = 281, - JsxAttributes = 282, - JsxSpreadAttribute = 283, - JsxExpression = 284, - CaseClause = 285, - DefaultClause = 286, - HeritageClause = 287, - CatchClause = 288, - PropertyAssignment = 289, - ShorthandPropertyAssignment = 290, - SpreadAssignment = 291, - EnumMember = 292, - UnparsedPrologue = 293, - UnparsedPrepend = 294, - UnparsedText = 295, - UnparsedInternalText = 296, - UnparsedSyntheticReference = 297, - SourceFile = 298, - Bundle = 299, - UnparsedSource = 300, - InputFiles = 301, - JSDocTypeExpression = 302, - JSDocNameReference = 303, - JSDocAllType = 304, - JSDocUnknownType = 305, - JSDocNullableType = 306, - JSDocNonNullableType = 307, - JSDocOptionalType = 308, - JSDocFunctionType = 309, - JSDocVariadicType = 310, - JSDocNamepathType = 311, - JSDocComment = 312, - JSDocText = 313, - JSDocTypeLiteral = 314, - JSDocSignature = 315, - JSDocLink = 316, - JSDocTag = 317, - JSDocAugmentsTag = 318, - JSDocImplementsTag = 319, - JSDocAuthorTag = 320, - JSDocDeprecatedTag = 321, - JSDocClassTag = 322, - JSDocPublicTag = 323, - JSDocPrivateTag = 324, - JSDocProtectedTag = 325, - JSDocReadonlyTag = 326, - JSDocOverrideTag = 327, - JSDocCallbackTag = 328, - JSDocEnumTag = 329, - JSDocParameterTag = 330, - JSDocReturnTag = 331, - JSDocThisTag = 332, - JSDocTypeTag = 333, - JSDocTemplateTag = 334, - JSDocTypedefTag = 335, - JSDocSeeTag = 336, - JSDocPropertyTag = 337, - SyntaxList = 338, - NotEmittedStatement = 339, - PartiallyEmittedExpression = 340, - CommaListExpression = 341, - MergeDeclarationMarker = 342, - EndOfDeclarationMarker = 343, - SyntheticReferenceExpression = 344, - Count = 345, + SyntheticCallExpression = 229, + TemplateSpan = 230, + SemicolonClassElement = 231, + Block = 232, + EmptyStatement = 233, + VariableStatement = 234, + ExpressionStatement = 235, + IfStatement = 236, + DoStatement = 237, + WhileStatement = 238, + ForStatement = 239, + ForInStatement = 240, + ForOfStatement = 241, + ContinueStatement = 242, + BreakStatement = 243, + ReturnStatement = 244, + WithStatement = 245, + SwitchStatement = 246, + LabeledStatement = 247, + ThrowStatement = 248, + TryStatement = 249, + DebuggerStatement = 250, + VariableDeclaration = 251, + VariableDeclarationList = 252, + FunctionDeclaration = 253, + ClassDeclaration = 254, + InterfaceDeclaration = 255, + TypeAliasDeclaration = 256, + EnumDeclaration = 257, + ModuleDeclaration = 258, + ModuleBlock = 259, + CaseBlock = 260, + NamespaceExportDeclaration = 261, + ImportEqualsDeclaration = 262, + ImportDeclaration = 263, + ImportClause = 264, + NamespaceImport = 265, + NamedImports = 266, + ImportSpecifier = 267, + ExportAssignment = 268, + ExportDeclaration = 269, + NamedExports = 270, + NamespaceExport = 271, + ExportSpecifier = 272, + MissingDeclaration = 273, + ExternalModuleReference = 274, + JsxElement = 275, + JsxSelfClosingElement = 276, + JsxOpeningElement = 277, + JsxClosingElement = 278, + JsxFragment = 279, + JsxOpeningFragment = 280, + JsxClosingFragment = 281, + JsxAttribute = 282, + JsxAttributes = 283, + JsxSpreadAttribute = 284, + JsxExpression = 285, + CaseClause = 286, + DefaultClause = 287, + HeritageClause = 288, + CatchClause = 289, + PropertyAssignment = 290, + ShorthandPropertyAssignment = 291, + SpreadAssignment = 292, + EnumMember = 293, + UnparsedPrologue = 294, + UnparsedPrepend = 295, + UnparsedText = 296, + UnparsedInternalText = 297, + UnparsedSyntheticReference = 298, + SourceFile = 299, + Bundle = 300, + UnparsedSource = 301, + InputFiles = 302, + JSDocTypeExpression = 303, + JSDocNameReference = 304, + JSDocAllType = 305, + JSDocUnknownType = 306, + JSDocNullableType = 307, + JSDocNonNullableType = 308, + JSDocOptionalType = 309, + JSDocFunctionType = 310, + JSDocVariadicType = 311, + JSDocNamepathType = 312, + JSDocComment = 313, + JSDocText = 314, + JSDocTypeLiteral = 315, + JSDocSignature = 316, + JSDocLink = 317, + JSDocTag = 318, + JSDocAugmentsTag = 319, + JSDocImplementsTag = 320, + JSDocAuthorTag = 321, + JSDocDeprecatedTag = 322, + JSDocClassTag = 323, + JSDocPublicTag = 324, + JSDocPrivateTag = 325, + JSDocProtectedTag = 326, + JSDocReadonlyTag = 327, + JSDocOverrideTag = 328, + JSDocCallbackTag = 329, + JSDocEnumTag = 330, + JSDocParameterTag = 331, + JSDocReturnTag = 332, + JSDocThisTag = 333, + JSDocTypeTag = 334, + JSDocTemplateTag = 335, + JSDocTypedefTag = 336, + JSDocSeeTag = 337, + JSDocPropertyTag = 338, + SyntaxList = 339, + NotEmittedStatement = 340, + PartiallyEmittedExpression = 341, + CommaListExpression = 342, + MergeDeclarationMarker = 343, + EndOfDeclarationMarker = 344, + SyntheticReferenceExpression = 345, + Count = 346, FirstAssignment = 62, LastAssignment = 77, FirstCompoundAssignment = 63, @@ -474,13 +475,13 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 29, LastBinaryOperator = 77, - FirstStatement = 233, - LastStatement = 249, + FirstStatement = 234, + LastStatement = 250, FirstNode = 158, - FirstJSDocNode = 302, - LastJSDocNode = 337, - FirstJSDocTagNode = 317, - LastJSDocTagNode = 337, + FirstJSDocNode = 303, + LastJSDocNode = 338, + FirstJSDocTagNode = 318, + LastJSDocTagNode = 338, } export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; @@ -1251,6 +1252,13 @@ declare namespace ts { readonly expression: SuperExpression; } export type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; + export interface SyntheticCallExpression extends LeftHandSideExpression { + readonly kind: SyntaxKind.SyntheticCallExpression; + readonly thisArg?: LeftHandSideExpression | SyntheticExpression; + readonly expression: Expression; + readonly typeArguments?: readonly TypeNode[]; + readonly arguments: readonly Expression[]; + } export interface CallExpression extends LeftHandSideExpression, Declaration { readonly kind: SyntaxKind.CallExpression; readonly expression: LeftHandSideExpression; @@ -1285,7 +1293,7 @@ declare namespace ts { readonly typeArguments?: NodeArray; readonly template: TemplateLiteral; } - export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; + export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement | SyntheticCallExpression; export interface AsExpression extends Expression { readonly kind: SyntaxKind.AsExpression; readonly expression: Expression; @@ -2830,6 +2838,8 @@ declare namespace ts { downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; + metadataDecorator?: string; + metadataDecoratorImportSource?: string; experimentalDecorators?: boolean; forceConsistentCasingInFileNames?: boolean; importHelpers?: boolean; @@ -4484,6 +4494,7 @@ declare namespace ts { function isSyntheticExpression(node: Node): node is SyntheticExpression; function isPartiallyEmittedExpression(node: Node): node is PartiallyEmittedExpression; function isCommaListExpression(node: Node): node is CommaListExpression; + function isSyntheticCallExpression(node: Node): node is SyntheticCallExpression; function isTemplateSpan(node: Node): node is TemplateSpan; function isSemicolonClassElement(node: Node): node is SemicolonClassElement; function isBlock(node: Node): node is Block; diff --git a/tests/baselines/reference/bluebirdStaticThis.errors.txt b/tests/baselines/reference/bluebirdStaticThis.errors.txt index 257cc1bb82339..ed28d06d4fab0 100644 --- a/tests/baselines/reference/bluebirdStaticThis.errors.txt +++ b/tests/baselines/reference/bluebirdStaticThis.errors.txt @@ -1,10 +1,10 @@ tests/cases/compiler/bluebirdStaticThis.ts(5,22): error TS2420: Class 'Promise' incorrectly implements interface 'Thenable'. Property 'then' is missing in type 'Promise' but required in type 'Thenable'. -tests/cases/compiler/bluebirdStaticThis.ts(22,51): error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Resolver'. -tests/cases/compiler/bluebirdStaticThis.ts(57,109): error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(58,91): error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(59,91): error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(22,51): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Resolver'. +tests/cases/compiler/bluebirdStaticThis.ts(57,109): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(58,91): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(59,91): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. ==== tests/cases/compiler/bluebirdStaticThis.ts (6 errors) ==== @@ -35,7 +35,7 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace '"tes static defer(dit: typeof Promise): Promise.Resolver; ~~~~~~~~ -!!! error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Resolver'. +!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Resolver'. static cast(dit: typeof Promise, value: Promise.Thenable): Promise; static cast(dit: typeof Promise, value: R): Promise; @@ -72,16 +72,16 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace '"tes static settle(dit: typeof Promise, values: Promise.Thenable[]>): Promise[]>; ~~~~~~~~~~ -!!! error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. +!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: Promise.Thenable): Promise[]>; ~~~~~~~~~~ -!!! error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. +!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: Promise.Thenable[]): Promise[]>; ~~~~~~~~~~ -!!! error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. +!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: R[]): Promise[]>; ~~~~~~~~~~ -!!! error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. +!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. static any(dit: typeof Promise, values: Promise.Thenable[]>): Promise; static any(dit: typeof Promise, values: Promise.Thenable): Promise; diff --git a/tests/baselines/reference/customMetadataDecorator.globalIdentifier.1.js b/tests/baselines/reference/customMetadataDecorator.globalIdentifier.1.js new file mode 100644 index 0000000000000..1a49f01641fd0 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalIdentifier.1.js @@ -0,0 +1,54 @@ +//// [tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.1.ts] //// + +//// [global.d.ts] +declare const metadata: any; +declare const dec: any; +//// [main.ts] +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} + +//// [main.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +let C = class C { + constructor(x) { } + method(x) { return ""; } + get accessor() { return ""; } +}; +__decorate([ + dec, + metadata("design:type", Number) +], C.prototype, "x", void 0); +__decorate([ + dec, + __param(0, dec), + metadata("design:type", Function), + metadata("design:paramtypes", [Number]), + metadata("design:returntype", String) +], C.prototype, "method", null); +__decorate([ + dec, + metadata("design:type", String), + metadata("design:paramtypes", []) +], C.prototype, "accessor", null); +C = __decorate([ + dec, + metadata("design:paramtypes", [Number]) +], C); diff --git a/tests/baselines/reference/customMetadataDecorator.globalIdentifier.2.errors.txt b/tests/baselines/reference/customMetadataDecorator.globalIdentifier.2.errors.txt new file mode 100644 index 0000000000000..7b950f7186e53 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalIdentifier.2.errors.txt @@ -0,0 +1,48 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Cannot find name 'metadata'. Did you mean 'metadat'? +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Cannot find name 'metadata'. Did you mean 'metadat'? +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Cannot find name 'metadata'. Did you mean 'metadat'? +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Cannot find name 'metadata'. Did you mean 'metadat'? +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Cannot find name 'metadata'. Did you mean 'metadat'? + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare const metadat: any; + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Cannot find name 'metadata'. Did you mean 'metadat'? +!!! related TS2728 tests/cases/conformance/decorators/decoratorMetadata/global.d.ts:1:15: 'metadat' is declared here. + class C { + @dec x!: number; + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Cannot find name 'metadata'. Did you mean 'metadat'? +!!! related TS2728 tests/cases/conformance/decorators/decoratorMetadata/global.d.ts:1:15: 'metadat' is declared here. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Cannot find name 'metadata'. Did you mean 'metadat'? +!!! related TS2728 tests/cases/conformance/decorators/decoratorMetadata/global.d.ts:1:15: 'metadat' is declared here. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Cannot find name 'metadata'. Did you mean 'metadat'? +!!! related TS2728 tests/cases/conformance/decorators/decoratorMetadata/global.d.ts:1:15: 'metadat' is declared here. + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Cannot find name 'metadata'. Did you mean 'metadat'? +!!! related TS2728 tests/cases/conformance/decorators/decoratorMetadata/global.d.ts:1:15: 'metadat' is declared here. + get accessor(): string { return ""; } + } \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.globalIdentifier.3.errors.txt b/tests/baselines/reference/customMetadataDecorator.globalIdentifier.3.errors.txt new file mode 100644 index 0000000000000..21f30d89dc987 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalIdentifier.3.errors.txt @@ -0,0 +1,42 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Cannot find name 'metadata'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Cannot find name 'metadata'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Cannot find name 'metadata'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Cannot find name 'metadata'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Cannot find name 'metadata'. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Cannot find name 'metadata'. + class C { + @dec x!: number; + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Cannot find name 'metadata'. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Cannot find name 'metadata'. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Cannot find name 'metadata'. + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Cannot find name 'metadata'. + get accessor(): string { return ""; } + } \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.globalIdentifier.4.errors.txt b/tests/baselines/reference/customMetadataDecorator.globalIdentifier.4.errors.txt new file mode 100644 index 0000000000000..1c8f554d904cb --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalIdentifier.4.errors.txt @@ -0,0 +1,54 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare const metadata: number; + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: This expression is not callable. +!!! error TS1433: Type 'Number' has no call signatures. +!!! related TS2734 tests/cases/conformance/decorators/decoratorMetadata/main.ts:1:1: Are you missing a semicolon? + class C { + @dec x!: number; + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: This expression is not callable. +!!! error TS1433: Type 'Number' has no call signatures. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: This expression is not callable. +!!! error TS1433: Type 'Number' has no call signatures. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: This expression is not callable. +!!! error TS1433: Type 'Number' has no call signatures. + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: This expression is not callable. +!!! error TS1433: Type 'Number' has no call signatures. + get accessor(): string { return ""; } + } \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.globalIdentifier.5.errors.txt b/tests/baselines/reference/customMetadataDecorator.globalIdentifier.5.errors.txt new file mode 100644 index 0000000000000..48382bc782598 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalIdentifier.5.errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Expected 0 arguments, but got 1. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Expected 0 arguments, but got 3. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Expected 0 arguments, but got 3. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Expected 0 arguments, but got 3. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Expected 0 arguments, but got 3. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare function metadata(): void; + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Expected 0 arguments, but got 1. + class C { + @dec x!: number; + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Expected 0 arguments, but got 3. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Expected 0 arguments, but got 3. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Expected 0 arguments, but got 3. + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Expected 0 arguments, but got 3. + get accessor(): string { return ""; } + } \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.globalIdentifier.6.errors.txt b/tests/baselines/reference/customMetadataDecorator.globalIdentifier.6.errors.txt new file mode 100644 index 0000000000000..cee2bfd9fc1ff --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalIdentifier.6.errors.txt @@ -0,0 +1,49 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Unable to resolve signature of class decorator when called as an expression. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Unable to resolve signature of property decorator when called as an expression. + The return type of a property decorator function must be either 'void' or 'any'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Unable to resolve signature of method decorator when called as an expression. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Unable to resolve signature of parameter decorator when called as an expression. + The return type of a parameter decorator function must be either 'void' or 'any'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Unable to resolve signature of method decorator when called as an expression. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare function metadata(target: Function): true; + declare function metadata(target: object, key: string, desc?: PropertyDescriptor): true; + declare function metadata(target: object, key: string, parameterIndex: number): true; + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Unable to resolve signature of class decorator when called as an expression. + class C { + @dec x!: number; + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1433: The return type of a property decorator function must be either 'void' or 'any'. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Unable to resolve signature of method decorator when called as an expression. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Unable to resolve signature of parameter decorator when called as an expression. +!!! error TS1433: The return type of a parameter decorator function must be either 'void' or 'any'. + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Unable to resolve signature of method decorator when called as an expression. + get accessor(): string { return ""; } + } \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.globalIdentifier.7.errors.txt b/tests/baselines/reference/customMetadataDecorator.globalIdentifier.7.errors.txt new file mode 100644 index 0000000000000..f3faa02d2e320 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalIdentifier.7.errors.txt @@ -0,0 +1,64 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + Argument of type 'typeof C' is not assignable to parameter of type 'number'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + No overload matches this call. + Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + No overload matches this call. + Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. + No overload matches this call. + Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare function metadata(target: number): void; + declare function metadata(target: number, key: string, desc?: PropertyDescriptor): void; + declare function metadata(target: number, key: string, parameterIndex: number): void; + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (4 errors) ==== + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: Argument of type 'typeof C' is not assignable to parameter of type 'number'. + class C { + @dec x!: number; + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: No overload matches this call. +!!! error TS1433: Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. +!!! error TS1433: Argument of type 'C' is not assignable to parameter of type 'number'. +!!! error TS1433: Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. +!!! error TS1433: Argument of type 'C' is not assignable to parameter of type 'number'. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: No overload matches this call. +!!! error TS1433: Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. +!!! error TS1433: Argument of type 'C' is not assignable to parameter of type 'number'. +!!! error TS1433: Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. +!!! error TS1433: Argument of type 'C' is not assignable to parameter of type 'number'. + method(@dec x: number): string { return ""; } + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'metadata' when called as an expression. +!!! error TS1433: No overload matches this call. +!!! error TS1433: Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. +!!! error TS1433: Argument of type 'C' is not assignable to parameter of type 'number'. +!!! error TS1433: Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. +!!! error TS1433: Argument of type 'C' is not assignable to parameter of type 'number'. + get accessor(): string { return ""; } + } \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.globalNamespace.1.js b/tests/baselines/reference/customMetadataDecorator.globalNamespace.1.js new file mode 100644 index 0000000000000..c33f1c826c306 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalNamespace.1.js @@ -0,0 +1,56 @@ +//// [tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.1.ts] //// + +//// [global.d.ts] +declare namespace Reflect { + const metadata: any; +} +declare const dec: any; +//// [main.ts] +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} + +//// [main.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +let C = class C { + constructor(x) { } + method(x) { return ""; } + get accessor() { return ""; } +}; +__decorate([ + dec, + Reflect.metadata("design:type", Number) +], C.prototype, "x", void 0); +__decorate([ + dec, + __param(0, dec), + Reflect.metadata("design:type", Function), + Reflect.metadata("design:paramtypes", [Number]), + Reflect.metadata("design:returntype", String) +], C.prototype, "method", null); +__decorate([ + dec, + Reflect.metadata("design:type", String), + Reflect.metadata("design:paramtypes", []) +], C.prototype, "accessor", null); +C = __decorate([ + dec, + Reflect.metadata("design:paramtypes", [Number]) +], C); diff --git a/tests/baselines/reference/customMetadataDecorator.globalNamespace.2.errors.txt b/tests/baselines/reference/customMetadataDecorator.globalNamespace.2.errors.txt new file mode 100644 index 0000000000000..05495331fd8f8 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalNamespace.2.errors.txt @@ -0,0 +1,50 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + 'Reflect' has no exported member named 'metadata'. Did you mean 'metadat'? +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + 'Reflect' has no exported member named 'metadata'. Did you mean 'metadat'? +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + 'Reflect' has no exported member named 'metadata'. Did you mean 'metadat'? +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + 'Reflect' has no exported member named 'metadata'. Did you mean 'metadat'? +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + 'Reflect' has no exported member named 'metadata'. Did you mean 'metadat'? + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare namespace Reflect { + const metadat: any; + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: 'Reflect' has no exported member named 'metadata'. Did you mean 'metadat'? +!!! related TS2728 tests/cases/conformance/decorators/decoratorMetadata/global.d.ts:2:11: 'metadat' is declared here. + class C { + @dec x!: number; + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: 'Reflect' has no exported member named 'metadata'. Did you mean 'metadat'? +!!! related TS2728 tests/cases/conformance/decorators/decoratorMetadata/global.d.ts:2:11: 'metadat' is declared here. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: 'Reflect' has no exported member named 'metadata'. Did you mean 'metadat'? +!!! related TS2728 tests/cases/conformance/decorators/decoratorMetadata/global.d.ts:2:11: 'metadat' is declared here. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: 'Reflect' has no exported member named 'metadata'. Did you mean 'metadat'? +!!! related TS2728 tests/cases/conformance/decorators/decoratorMetadata/global.d.ts:2:11: 'metadat' is declared here. + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: 'Reflect' has no exported member named 'metadata'. Did you mean 'metadat'? +!!! related TS2728 tests/cases/conformance/decorators/decoratorMetadata/global.d.ts:2:11: 'metadat' is declared here. + get accessor(): string { return ""; } + } \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.globalNamespace.3.errors.txt b/tests/baselines/reference/customMetadataDecorator.globalNamespace.3.errors.txt new file mode 100644 index 0000000000000..22ce6ee02ee8f --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalNamespace.3.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Namespace 'Reflect' has no exported member 'metadata'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Namespace 'Reflect' has no exported member 'metadata'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Namespace 'Reflect' has no exported member 'metadata'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Namespace 'Reflect' has no exported member 'metadata'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Namespace 'Reflect' has no exported member 'metadata'. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare namespace Reflect { + const _: any; + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Namespace 'Reflect' has no exported member 'metadata'. + class C { + @dec x!: number; + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Namespace 'Reflect' has no exported member 'metadata'. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Namespace 'Reflect' has no exported member 'metadata'. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Namespace 'Reflect' has no exported member 'metadata'. + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Namespace 'Reflect' has no exported member 'metadata'. + get accessor(): string { return ""; } + } \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.globalNamespace.4.errors.txt b/tests/baselines/reference/customMetadataDecorator.globalNamespace.4.errors.txt new file mode 100644 index 0000000000000..c046c07a76494 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalNamespace.4.errors.txt @@ -0,0 +1,56 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare namespace Reflect { + const metadata: number; + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: This expression is not callable. +!!! error TS1433: Type 'Number' has no call signatures. +!!! related TS2734 tests/cases/conformance/decorators/decoratorMetadata/main.ts:1:1: Are you missing a semicolon? + class C { + @dec x!: number; + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: This expression is not callable. +!!! error TS1433: Type 'Number' has no call signatures. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: This expression is not callable. +!!! error TS1433: Type 'Number' has no call signatures. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: This expression is not callable. +!!! error TS1433: Type 'Number' has no call signatures. + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: This expression is not callable. +!!! error TS1433: Type 'Number' has no call signatures. + get accessor(): string { return ""; } + } \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.globalNamespace.5.errors.txt b/tests/baselines/reference/customMetadataDecorator.globalNamespace.5.errors.txt new file mode 100644 index 0000000000000..5b8ab8c5cc635 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalNamespace.5.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Expected 0 arguments, but got 1. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Expected 0 arguments, but got 3. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Expected 0 arguments, but got 3. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Expected 0 arguments, but got 3. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Expected 0 arguments, but got 3. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare namespace Reflect { + function metadata(): void; + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Expected 0 arguments, but got 1. + class C { + @dec x!: number; + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Expected 0 arguments, but got 3. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Expected 0 arguments, but got 3. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Expected 0 arguments, but got 3. + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Expected 0 arguments, but got 3. + get accessor(): string { return ""; } + } \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.globalNamespace.6.errors.txt b/tests/baselines/reference/customMetadataDecorator.globalNamespace.6.errors.txt new file mode 100644 index 0000000000000..f0ac2b2e54f0d --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalNamespace.6.errors.txt @@ -0,0 +1,51 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Unable to resolve signature of class decorator when called as an expression. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Unable to resolve signature of property decorator when called as an expression. + The return type of a property decorator function must be either 'void' or 'any'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Unable to resolve signature of method decorator when called as an expression. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Unable to resolve signature of parameter decorator when called as an expression. + The return type of a parameter decorator function must be either 'void' or 'any'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Unable to resolve signature of method decorator when called as an expression. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare namespace Reflect { + function metadata(target: Function): true; + function metadata(target: object, key: string, desc?: PropertyDescriptor): true; + function metadata(target: object, key: string, parameterIndex: number): true; + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Unable to resolve signature of class decorator when called as an expression. + class C { + @dec x!: number; + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1433: The return type of a property decorator function must be either 'void' or 'any'. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Unable to resolve signature of method decorator when called as an expression. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Unable to resolve signature of parameter decorator when called as an expression. +!!! error TS1433: The return type of a parameter decorator function must be either 'void' or 'any'. + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Unable to resolve signature of method decorator when called as an expression. + get accessor(): string { return ""; } + } \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.globalNamespace.7.errors.txt b/tests/baselines/reference/customMetadataDecorator.globalNamespace.7.errors.txt new file mode 100644 index 0000000000000..1a25710b91bec --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalNamespace.7.errors.txt @@ -0,0 +1,66 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Argument of type 'typeof C' is not assignable to parameter of type 'number'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + No overload matches this call. + Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + No overload matches this call. + Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + No overload matches this call. + Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare namespace Reflect { + function metadata(target: number): void; + function metadata(target: number, key: string, desc?: PropertyDescriptor): void; + function metadata(target: number, key: string, parameterIndex: number): void; + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (4 errors) ==== + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Argument of type 'typeof C' is not assignable to parameter of type 'number'. + class C { + @dec x!: number; + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: No overload matches this call. +!!! error TS1433: Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. +!!! error TS1433: Argument of type 'C' is not assignable to parameter of type 'number'. +!!! error TS1433: Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. +!!! error TS1433: Argument of type 'C' is not assignable to parameter of type 'number'. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: No overload matches this call. +!!! error TS1433: Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. +!!! error TS1433: Argument of type 'C' is not assignable to parameter of type 'number'. +!!! error TS1433: Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. +!!! error TS1433: Argument of type 'C' is not assignable to parameter of type 'number'. + method(@dec x: number): string { return ""; } + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: No overload matches this call. +!!! error TS1433: Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. +!!! error TS1433: Argument of type 'C' is not assignable to parameter of type 'number'. +!!! error TS1433: Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. +!!! error TS1433: Argument of type 'C' is not assignable to parameter of type 'number'. + get accessor(): string { return ""; } + } \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.globalNamespace.8.errors.txt b/tests/baselines/reference/customMetadataDecorator.globalNamespace.8.errors.txt new file mode 100644 index 0000000000000..2f32ec95b5145 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.globalNamespace.8.errors.txt @@ -0,0 +1,42 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Namespace 'Reflect' has no exported member 'metadata'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Namespace 'Reflect' has no exported member 'metadata'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Namespace 'Reflect' has no exported member 'metadata'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Namespace 'Reflect' has no exported member 'metadata'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. + Namespace 'Reflect' has no exported member 'metadata'. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Namespace 'Reflect' has no exported member 'metadata'. + class C { + @dec x!: number; + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Namespace 'Reflect' has no exported member 'metadata'. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Namespace 'Reflect' has no exported member 'metadata'. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Namespace 'Reflect' has no exported member 'metadata'. + + @dec + ~~~~ +!!! error TS1433: Unable to resolve signature of implicit decorator 'Reflect.metadata' when called as an expression. +!!! error TS1433: Namespace 'Reflect' has no exported member 'metadata'. + get accessor(): string { return ""; } + } \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedIdentifier.1.js b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.1.js new file mode 100644 index 0000000000000..c7f1c3e7a6cab --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.1.js @@ -0,0 +1,58 @@ +//// [tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.1.ts] //// + +//// [global.d.ts] +declare module "foo" { + const metadata: any; +} +declare const dec: any; +//// [main.ts] +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; + +//// [main.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +import { metadata as metadata } from "foo"; +let C = class C { + constructor(x) { } + method(x) { return ""; } + get accessor() { return ""; } +}; +__decorate([ + dec, + metadata("design:type", Number) +], C.prototype, "x", void 0); +__decorate([ + dec, + __param(0, dec), + metadata("design:type", Function), + metadata("design:paramtypes", [Number]), + metadata("design:returntype", String) +], C.prototype, "method", null); +__decorate([ + dec, + metadata("design:type", String), + metadata("design:paramtypes", []) +], C.prototype, "accessor", null); +C = __decorate([ + dec, + metadata("design:paramtypes", [Number]) +], C); diff --git a/tests/baselines/reference/customMetadataDecorator.importedIdentifier.10.js b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.10.js new file mode 100644 index 0000000000000..c74106bebba6f --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.10.js @@ -0,0 +1,59 @@ +//// [tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.10.ts] //// + +//// [global.d.ts] +declare module "foo" { + const metadata: any; +} +declare const dec: any; +//// [main.ts] +declare const metadata: any; +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; + +//// [main.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +import { metadata as metadata_1 } from "foo"; +let C = class C { + constructor(x) { } + method(x) { return ""; } + get accessor() { return ""; } +}; +__decorate([ + dec, + metadata_1("design:type", Number) +], C.prototype, "x", void 0); +__decorate([ + dec, + __param(0, dec), + metadata_1("design:type", Function), + metadata_1("design:paramtypes", [Number]), + metadata_1("design:returntype", String) +], C.prototype, "method", null); +__decorate([ + dec, + metadata_1("design:type", String), + metadata_1("design:paramtypes", []) +], C.prototype, "accessor", null); +C = __decorate([ + dec, + metadata_1("design:paramtypes", [Number]) +], C); diff --git a/tests/baselines/reference/customMetadataDecorator.importedIdentifier.2.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.2.errors.txt new file mode 100644 index 0000000000000..aefe58b575ee7 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.2.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS2343: This syntax requires an imported helper named 'metadata' which does not exist in 'foo'. Consider upgrading your version of 'foo'. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare module "foo" { + const metadat: any; + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (1 errors) ==== + @dec + ~~~~ +!!! error TS2343: This syntax requires an imported helper named 'metadata' which does not exist in 'foo'. Consider upgrading your version of 'foo'. + class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } + } + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedIdentifier.3.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.3.errors.txt new file mode 100644 index 0000000000000..ac4a3b156c4a6 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.3.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS2343: This syntax requires an imported helper named 'metadata' which does not exist in 'foo'. Consider upgrading your version of 'foo'. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare module "foo" { + const _: any; + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (1 errors) ==== + @dec + ~~~~ +!!! error TS2343: This syntax requires an imported helper named 'metadata' which does not exist in 'foo'. Consider upgrading your version of 'foo'. + class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } + } + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedIdentifier.4.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.4.errors.txt new file mode 100644 index 0000000000000..ab49b8dee40e0 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.4.errors.txt @@ -0,0 +1,57 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare module "foo" { + const metadata: number; + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: This expression is not callable. +!!! error TS1434: Type 'Number' has no call signatures. +!!! related TS2734 tests/cases/conformance/decorators/decoratorMetadata/main.ts:1:1: Are you missing a semicolon? + class C { + @dec x!: number; + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: This expression is not callable. +!!! error TS1434: Type 'Number' has no call signatures. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: This expression is not callable. +!!! error TS1434: Type 'Number' has no call signatures. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: This expression is not callable. +!!! error TS1434: Type 'Number' has no call signatures. + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: This expression is not callable. +!!! error TS1434: Type 'Number' has no call signatures. + get accessor(): string { return ""; } + } + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedIdentifier.5.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.5.errors.txt new file mode 100644 index 0000000000000..4b4027f234f16 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.5.errors.txt @@ -0,0 +1,46 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + Expected 0 arguments, but got 1. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + Expected 0 arguments, but got 3. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + Expected 0 arguments, but got 3. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + Expected 0 arguments, but got 3. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + Expected 0 arguments, but got 3. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare module "foo" { + function metadata(): void; + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: Expected 0 arguments, but got 1. + class C { + @dec x!: number; + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: Expected 0 arguments, but got 3. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: Expected 0 arguments, but got 3. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: Expected 0 arguments, but got 3. + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: Expected 0 arguments, but got 3. + get accessor(): string { return ""; } + } + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedIdentifier.6.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.6.errors.txt new file mode 100644 index 0000000000000..84cbe5fef4b44 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.6.errors.txt @@ -0,0 +1,52 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + Unable to resolve signature of class decorator when called as an expression. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + Unable to resolve signature of property decorator when called as an expression. + The return type of a property decorator function must be either 'void' or 'any'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + Unable to resolve signature of method decorator when called as an expression. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + Unable to resolve signature of parameter decorator when called as an expression. + The return type of a parameter decorator function must be either 'void' or 'any'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + Unable to resolve signature of method decorator when called as an expression. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare module "foo" { + function metadata(target: Function): true; + function metadata(target: object, key: string, desc?: PropertyDescriptor): true; + function metadata(target: object, key: string, parameterIndex: number): true; + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: Unable to resolve signature of class decorator when called as an expression. + class C { + @dec x!: number; + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1434: The return type of a property decorator function must be either 'void' or 'any'. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: Unable to resolve signature of method decorator when called as an expression. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: Unable to resolve signature of parameter decorator when called as an expression. +!!! error TS1434: The return type of a parameter decorator function must be either 'void' or 'any'. + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: Unable to resolve signature of method decorator when called as an expression. + get accessor(): string { return ""; } + } + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedIdentifier.7.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.7.errors.txt new file mode 100644 index 0000000000000..78ad4302d077d --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.7.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS2354: This syntax requires an imported helper but module 'foo' cannot be found. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (1 errors) ==== + @dec + ~~~~ +!!! error TS2354: This syntax requires an imported helper but module 'foo' cannot be found. + class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } + } + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedIdentifier.8.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.8.errors.txt new file mode 100644 index 0000000000000..539a2a7aaecb4 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.8.errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1435: Unable to import implicit decorator 'metadata' from module 'foo' as this file is not a module. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1435: Unable to import implicit decorator 'metadata' from module 'foo' as this file is not a module. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1435: Unable to import implicit decorator 'metadata' from module 'foo' as this file is not a module. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1435: Unable to import implicit decorator 'metadata' from module 'foo' as this file is not a module. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1435: Unable to import implicit decorator 'metadata' from module 'foo' as this file is not a module. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare module "foo" { + const metadata: any; + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1435: Unable to import implicit decorator 'metadata' from module 'foo' as this file is not a module. + class C { + @dec x!: number; + ~~~~ +!!! error TS1435: Unable to import implicit decorator 'metadata' from module 'foo' as this file is not a module. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1435: Unable to import implicit decorator 'metadata' from module 'foo' as this file is not a module. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1435: Unable to import implicit decorator 'metadata' from module 'foo' as this file is not a module. + + @dec + ~~~~ +!!! error TS1435: Unable to import implicit decorator 'metadata' from module 'foo' as this file is not a module. + get accessor(): string { return ""; } + } + \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedIdentifier.9.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.9.errors.txt new file mode 100644 index 0000000000000..62926d7701508 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedIdentifier.9.errors.txt @@ -0,0 +1,67 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + Argument of type 'typeof C' is not assignable to parameter of type 'number'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + No overload matches this call. + Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + No overload matches this call. + Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. + No overload matches this call. + Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare module "foo" { + function metadata(target: number): void; + function metadata(target: number, key: string, desc?: PropertyDescriptor): void; + function metadata(target: number, key: string, parameterIndex: number): void; + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (4 errors) ==== + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: Argument of type 'typeof C' is not assignable to parameter of type 'number'. + class C { + @dec x!: number; + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: No overload matches this call. +!!! error TS1434: Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. +!!! error TS1434: Argument of type 'C' is not assignable to parameter of type 'number'. +!!! error TS1434: Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. +!!! error TS1434: Argument of type 'C' is not assignable to parameter of type 'number'. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: No overload matches this call. +!!! error TS1434: Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. +!!! error TS1434: Argument of type 'C' is not assignable to parameter of type 'number'. +!!! error TS1434: Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. +!!! error TS1434: Argument of type 'C' is not assignable to parameter of type 'number'. + method(@dec x: number): string { return ""; } + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'metadata' from module 'foo' when called as an expression. +!!! error TS1434: No overload matches this call. +!!! error TS1434: Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. +!!! error TS1434: Argument of type 'C' is not assignable to parameter of type 'number'. +!!! error TS1434: Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. +!!! error TS1434: Argument of type 'C' is not assignable to parameter of type 'number'. + get accessor(): string { return ""; } + } + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedNamespace.1.js b/tests/baselines/reference/customMetadataDecorator.importedNamespace.1.js new file mode 100644 index 0000000000000..cf88a14d5e640 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedNamespace.1.js @@ -0,0 +1,60 @@ +//// [tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.1.ts] //// + +//// [global.d.ts] +declare module "foo" { + namespace Reflect { + const metadata: any; + } +} +declare const dec: any; +//// [main.ts] +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; + +//// [main.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +import { Reflect as Reflect_1 } from "foo"; +let C = class C { + constructor(x) { } + method(x) { return ""; } + get accessor() { return ""; } +}; +__decorate([ + dec, + Reflect_1.metadata("design:type", Number) +], C.prototype, "x", void 0); +__decorate([ + dec, + __param(0, dec), + Reflect_1.metadata("design:type", Function), + Reflect_1.metadata("design:paramtypes", [Number]), + Reflect_1.metadata("design:returntype", String) +], C.prototype, "method", null); +__decorate([ + dec, + Reflect_1.metadata("design:type", String), + Reflect_1.metadata("design:paramtypes", []) +], C.prototype, "accessor", null); +C = __decorate([ + dec, + Reflect_1.metadata("design:paramtypes", [Number]) +], C); diff --git a/tests/baselines/reference/customMetadataDecorator.importedNamespace.2.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedNamespace.2.errors.txt new file mode 100644 index 0000000000000..5a8634d797d40 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedNamespace.2.errors.txt @@ -0,0 +1,29 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + 'Reflect' from module 'foo' has no exported member named 'metadata'. Did you mean 'metadat'? + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare module "foo" { + namespace Reflect { + const metadat: any; + } + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (1 errors) ==== + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: 'Reflect' from module 'foo' has no exported member named 'metadata'. Did you mean 'metadat'? +!!! related TS2728 tests/cases/conformance/decorators/decoratorMetadata/global.d.ts:3:15: 'metadat' is declared here. + class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } + } + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedNamespace.3.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedNamespace.3.errors.txt new file mode 100644 index 0000000000000..a0835d4217382 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedNamespace.3.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + Namespace 'Reflect' from module 'foo' has no exported member 'metadata'. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare module "foo" { + namespace Reflect { + const _: any; + } + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (1 errors) ==== + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: Namespace 'Reflect' from module 'foo' has no exported member 'metadata'. + class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } + } + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedNamespace.4.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedNamespace.4.errors.txt new file mode 100644 index 0000000000000..be36c4fbfef45 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedNamespace.4.errors.txt @@ -0,0 +1,59 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + This expression is not callable. + Type 'Number' has no call signatures. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare module "foo" { + namespace Reflect { + const metadata: number; + } + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: This expression is not callable. +!!! error TS1434: Type 'Number' has no call signatures. +!!! related TS2734 tests/cases/conformance/decorators/decoratorMetadata/main.ts:1:1: Are you missing a semicolon? + class C { + @dec x!: number; + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: This expression is not callable. +!!! error TS1434: Type 'Number' has no call signatures. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: This expression is not callable. +!!! error TS1434: Type 'Number' has no call signatures. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: This expression is not callable. +!!! error TS1434: Type 'Number' has no call signatures. + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: This expression is not callable. +!!! error TS1434: Type 'Number' has no call signatures. + get accessor(): string { return ""; } + } + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedNamespace.5.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedNamespace.5.errors.txt new file mode 100644 index 0000000000000..fe19b75717411 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedNamespace.5.errors.txt @@ -0,0 +1,48 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + Expected 0 arguments, but got 1. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + Expected 0 arguments, but got 3. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + Expected 0 arguments, but got 3. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + Expected 0 arguments, but got 3. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + Expected 0 arguments, but got 3. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare module "foo" { + namespace Reflect { + function metadata(): void; + } + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: Expected 0 arguments, but got 1. + class C { + @dec x!: number; + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: Expected 0 arguments, but got 3. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: Expected 0 arguments, but got 3. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: Expected 0 arguments, but got 3. + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: Expected 0 arguments, but got 3. + get accessor(): string { return ""; } + } + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedNamespace.6.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedNamespace.6.errors.txt new file mode 100644 index 0000000000000..0b008a9b5e0c5 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedNamespace.6.errors.txt @@ -0,0 +1,54 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + Unable to resolve signature of class decorator when called as an expression. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + Unable to resolve signature of property decorator when called as an expression. + The return type of a property decorator function must be either 'void' or 'any'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + Unable to resolve signature of method decorator when called as an expression. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + Unable to resolve signature of parameter decorator when called as an expression. + The return type of a parameter decorator function must be either 'void' or 'any'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + Unable to resolve signature of method decorator when called as an expression. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare module "foo" { + namespace Reflect { + function metadata(target: Function): true; + function metadata(target: object, key: string, desc?: PropertyDescriptor): true; + function metadata(target: object, key: string, parameterIndex: number): true; + } + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: Unable to resolve signature of class decorator when called as an expression. + class C { + @dec x!: number; + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1434: The return type of a property decorator function must be either 'void' or 'any'. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: Unable to resolve signature of method decorator when called as an expression. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: Unable to resolve signature of parameter decorator when called as an expression. +!!! error TS1434: The return type of a parameter decorator function must be either 'void' or 'any'. + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: Unable to resolve signature of method decorator when called as an expression. + get accessor(): string { return ""; } + } + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedNamespace.7.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedNamespace.7.errors.txt new file mode 100644 index 0000000000000..14489e6166ad7 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedNamespace.7.errors.txt @@ -0,0 +1,69 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + Argument of type 'typeof C' is not assignable to parameter of type 'number'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + No overload matches this call. + Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + No overload matches this call. + Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. + No overload matches this call. + Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. + Argument of type 'C' is not assignable to parameter of type 'number'. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare module "foo" { + namespace Reflect { + function metadata(target: number): void; + function metadata(target: number, key: string, desc?: PropertyDescriptor): void; + function metadata(target: number, key: string, parameterIndex: number): void; + } + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (4 errors) ==== + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: Argument of type 'typeof C' is not assignable to parameter of type 'number'. + class C { + @dec x!: number; + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: No overload matches this call. +!!! error TS1434: Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. +!!! error TS1434: Argument of type 'C' is not assignable to parameter of type 'number'. +!!! error TS1434: Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. +!!! error TS1434: Argument of type 'C' is not assignable to parameter of type 'number'. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: No overload matches this call. +!!! error TS1434: Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. +!!! error TS1434: Argument of type 'C' is not assignable to parameter of type 'number'. +!!! error TS1434: Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. +!!! error TS1434: Argument of type 'C' is not assignable to parameter of type 'number'. + method(@dec x: number): string { return ""; } + + @dec + ~~~~ +!!! error TS1434: Unable to resolve signature of implicit decorator 'Reflect.metadata' from module 'foo' when called as an expression. +!!! error TS1434: No overload matches this call. +!!! error TS1434: Overload 1 of 3, '(target: number, key: string, desc?: PropertyDescriptor): void', gave the following error. +!!! error TS1434: Argument of type 'C' is not assignable to parameter of type 'number'. +!!! error TS1434: Overload 2 of 3, '(target: number, key: string, parameterIndex: number): void', gave the following error. +!!! error TS1434: Argument of type 'C' is not assignable to parameter of type 'number'. + get accessor(): string { return ""; } + } + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/customMetadataDecorator.importedNamespace.8.errors.txt b/tests/baselines/reference/customMetadataDecorator.importedNamespace.8.errors.txt new file mode 100644 index 0000000000000..04b0f429a9c06 --- /dev/null +++ b/tests/baselines/reference/customMetadataDecorator.importedNamespace.8.errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/decorators/decoratorMetadata/main.ts(1,1): error TS1435: Unable to import implicit decorator 'Reflect.metadata' from module 'foo' as this file is not a module. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(3,5): error TS1435: Unable to import implicit decorator 'Reflect.metadata' from module 'foo' as this file is not a module. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(7,5): error TS1435: Unable to import implicit decorator 'Reflect.metadata' from module 'foo' as this file is not a module. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(8,12): error TS1435: Unable to import implicit decorator 'Reflect.metadata' from module 'foo' as this file is not a module. +tests/cases/conformance/decorators/decoratorMetadata/main.ts(10,5): error TS1435: Unable to import implicit decorator 'Reflect.metadata' from module 'foo' as this file is not a module. + + +==== tests/cases/conformance/decorators/decoratorMetadata/global.d.ts (0 errors) ==== + declare module "foo" { + namespace Reflect { + const metadata: any; + } + } + declare const dec: any; +==== tests/cases/conformance/decorators/decoratorMetadata/main.ts (5 errors) ==== + @dec + ~~~~ +!!! error TS1435: Unable to import implicit decorator 'Reflect.metadata' from module 'foo' as this file is not a module. + class C { + @dec x!: number; + ~~~~ +!!! error TS1435: Unable to import implicit decorator 'Reflect.metadata' from module 'foo' as this file is not a module. + + constructor(x: number) {} + + @dec + ~~~~ +!!! error TS1435: Unable to import implicit decorator 'Reflect.metadata' from module 'foo' as this file is not a module. + method(@dec x: number): string { return ""; } + ~~~~ +!!! error TS1435: Unable to import implicit decorator 'Reflect.metadata' from module 'foo' as this file is not a module. + + @dec + ~~~~ +!!! error TS1435: Unable to import implicit decorator 'Reflect.metadata' from module 'foo' as this file is not a module. + get accessor(): string { return ""; } + } + \ No newline at end of file diff --git a/tests/baselines/reference/decoratorMetadata-jsdoc.errors.txt b/tests/baselines/reference/decoratorMetadata-jsdoc.errors.txt index a2af419361d64..e86fa2fd3136a 100644 --- a/tests/baselines/reference/decoratorMetadata-jsdoc.errors.txt +++ b/tests/baselines/reference/decoratorMetadata-jsdoc.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts(5,9): error TS8020: JSDoc types can only be used inside documentation comments. -tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts(7,9): error TS8020: JSDoc types can only be used inside documentation comments. -tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts(9,9): error TS8020: JSDoc types can only be used inside documentation comments. +tests/cases/conformance/decorators/decoratorMetadata/decoratorMetadata-jsdoc.ts(5,9): error TS8020: JSDoc types can only be used inside documentation comments. +tests/cases/conformance/decorators/decoratorMetadata/decoratorMetadata-jsdoc.ts(7,9): error TS8020: JSDoc types can only be used inside documentation comments. +tests/cases/conformance/decorators/decoratorMetadata/decoratorMetadata-jsdoc.ts(9,9): error TS8020: JSDoc types can only be used inside documentation comments. -==== tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts (3 errors) ==== +==== tests/cases/conformance/decorators/decoratorMetadata/decoratorMetadata-jsdoc.ts (3 errors) ==== declare var decorator: any; class X { diff --git a/tests/baselines/reference/decoratorMetadata-jsdoc.symbols b/tests/baselines/reference/decoratorMetadata-jsdoc.symbols index 260214db22a7c..2f3f0032db238 100644 --- a/tests/baselines/reference/decoratorMetadata-jsdoc.symbols +++ b/tests/baselines/reference/decoratorMetadata-jsdoc.symbols @@ -1,4 +1,4 @@ -=== tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts === +=== tests/cases/conformance/decorators/decoratorMetadata/decoratorMetadata-jsdoc.ts === declare var decorator: any; >decorator : Symbol(decorator, Decl(decoratorMetadata-jsdoc.ts, 0, 11)) diff --git a/tests/baselines/reference/decoratorMetadata-jsdoc.types b/tests/baselines/reference/decoratorMetadata-jsdoc.types index ef618b7cda05a..8b84763ef0f80 100644 --- a/tests/baselines/reference/decoratorMetadata-jsdoc.types +++ b/tests/baselines/reference/decoratorMetadata-jsdoc.types @@ -1,4 +1,4 @@ -=== tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts === +=== tests/cases/conformance/decorators/decoratorMetadata/decoratorMetadata-jsdoc.ts === declare var decorator: any; >decorator : any diff --git a/tests/baselines/reference/decoratorMetadata.js b/tests/baselines/reference/decoratorMetadata.js index 4e411154ec1fc..b15fee48df070 100644 --- a/tests/baselines/reference/decoratorMetadata.js +++ b/tests/baselines/reference/decoratorMetadata.js @@ -1,4 +1,4 @@ -//// [tests/cases/conformance/decorators/decoratorMetadata.ts] //// +//// [tests/cases/conformance/decorators/decoratorMetadata/decoratorMetadata.ts] //// //// [service.ts] export default class Service { diff --git a/tests/baselines/reference/decoratorMetadata.symbols b/tests/baselines/reference/decoratorMetadata.symbols index ab0ae42dbb32a..3602912db01e5 100644 --- a/tests/baselines/reference/decoratorMetadata.symbols +++ b/tests/baselines/reference/decoratorMetadata.symbols @@ -1,8 +1,8 @@ -=== tests/cases/conformance/decorators/service.ts === +=== tests/cases/conformance/decorators/decoratorMetadata/service.ts === export default class Service { >Service : Symbol(Service, Decl(service.ts, 0, 0)) } -=== tests/cases/conformance/decorators/component.ts === +=== tests/cases/conformance/decorators/decoratorMetadata/component.ts === import Service from "./service"; >Service : Symbol(Service, Decl(component.ts, 0, 6)) diff --git a/tests/baselines/reference/decoratorMetadata.types b/tests/baselines/reference/decoratorMetadata.types index c17703baeebd8..bddc67a6ff9ab 100644 --- a/tests/baselines/reference/decoratorMetadata.types +++ b/tests/baselines/reference/decoratorMetadata.types @@ -1,8 +1,8 @@ -=== tests/cases/conformance/decorators/service.ts === +=== tests/cases/conformance/decorators/decoratorMetadata/service.ts === export default class Service { >Service : Service } -=== tests/cases/conformance/decorators/component.ts === +=== tests/cases/conformance/decorators/decoratorMetadata/component.ts === import Service from "./service"; >Service : typeof Service diff --git a/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.js b/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.js index 0596ecfa12be6..7311caf61647e 100644 --- a/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.js +++ b/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.js @@ -1,4 +1,4 @@ -//// [tests/cases/conformance/decorators/decoratorMetadataWithTypeOnlyImport.ts] //// +//// [tests/cases/conformance/decorators/decoratorMetadata/decoratorMetadataWithTypeOnlyImport.ts] //// //// [service.ts] export class Service { diff --git a/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.symbols b/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.symbols index a36cba8c590e1..8c8c3f5dffe00 100644 --- a/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.symbols +++ b/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.symbols @@ -1,8 +1,8 @@ -=== tests/cases/conformance/decorators/service.ts === +=== tests/cases/conformance/decorators/decoratorMetadata/service.ts === export class Service { >Service : Symbol(Service, Decl(service.ts, 0, 0)) } -=== tests/cases/conformance/decorators/component.ts === +=== tests/cases/conformance/decorators/decoratorMetadata/component.ts === import type { Service } from "./service"; >Service : Symbol(Service, Decl(component.ts, 0, 13)) diff --git a/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.types b/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.types index 125380a21a9a0..beef9ff079115 100644 --- a/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.types +++ b/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.types @@ -1,8 +1,8 @@ -=== tests/cases/conformance/decorators/service.ts === +=== tests/cases/conformance/decorators/decoratorMetadata/service.ts === export class Service { >Service : Service } -=== tests/cases/conformance/decorators/component.ts === +=== tests/cases/conformance/decorators/decoratorMetadata/component.ts === import type { Service } from "./service"; >Service : Service diff --git a/tests/baselines/reference/extendArray.errors.txt b/tests/baselines/reference/extendArray.errors.txt index 824752820cb0c..1bdfe7055ec98 100644 --- a/tests/baselines/reference/extendArray.errors.txt +++ b/tests/baselines/reference/extendArray.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/extendArray.ts(7,19): error TS2304: Cannot find name '_element'. -tests/cases/compiler/extendArray.ts(7,32): error TS2304: Cannot find name '_element'. +tests/cases/compiler/extendArray.ts(7,19): error TS2552: Cannot find name '_element'. Did you mean 'Element'? +tests/cases/compiler/extendArray.ts(7,32): error TS2552: Cannot find name '_element'. Did you mean 'Element'? ==== tests/cases/compiler/extendArray.ts (2 errors) ==== @@ -11,9 +11,11 @@ tests/cases/compiler/extendArray.ts(7,32): error TS2304: Cannot find name '_elem interface Array { collect(fn:(e:_element) => _element[]) : any[]; ~~~~~~~~ -!!! error TS2304: Cannot find name '_element'. +!!! error TS2552: Cannot find name '_element'. Did you mean 'Element'? +!!! related TS2728 /.ts/lib.dom.d.ts:5249:13: 'Element' is declared here. ~~~~~~~~ -!!! error TS2304: Cannot find name '_element'. +!!! error TS2552: Cannot find name '_element'. Did you mean 'Element'? +!!! related TS2728 /.ts/lib.dom.d.ts:5249:13: 'Element' is declared here. } } diff --git a/tests/baselines/reference/importedModuleAddToGlobal.errors.txt b/tests/baselines/reference/importedModuleAddToGlobal.errors.txt index aed680b89aa92..0a864efd0f0ef 100644 --- a/tests/baselines/reference/importedModuleAddToGlobal.errors.txt +++ b/tests/baselines/reference/importedModuleAddToGlobal.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/importedModuleAddToGlobal.ts(15,23): error TS2503: Cannot find namespace 'b'. +tests/cases/compiler/importedModuleAddToGlobal.ts(15,23): error TS2811: Cannot find namespace 'b'. Did you mean 'B? ==== tests/cases/compiler/importedModuleAddToGlobal.ts (1 errors) ==== @@ -18,5 +18,6 @@ tests/cases/compiler/importedModuleAddToGlobal.ts(15,23): error TS2503: Cannot f import a = A; function hello(): b.B { return null; } ~ -!!! error TS2503: Cannot find namespace 'b'. +!!! error TS2811: Cannot find namespace 'b'. Did you mean 'B? +!!! related TS2728 tests/cases/compiler/importedModuleAddToGlobal.ts:8:8: 'B' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt b/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt index 2bf1f34d30df6..08d57bc1721c1 100644 --- a/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt +++ b/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts(11,10): error TS2694: Namespace '"tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. +tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts(11,10): error TS2809: Namespace 'c' from module 'tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError' has no exported member 'b'. ==== tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts (1 errors) ==== @@ -14,4 +14,4 @@ tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessE var x: c.b; ~ -!!! error TS2694: Namespace '"tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. \ No newline at end of file +!!! error TS2809: Namespace 'c' from module 'tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError' has no exported member 'b'. \ No newline at end of file diff --git a/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt b/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt index fef43dc4dedbc..3ea97375443a2 100644 --- a/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt +++ b/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts(16,17): error TS2694: Namespace '"tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. +tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts(16,17): error TS2809: Namespace 'c' from module 'tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError' has no exported member 'b'. ==== tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts (1 errors) ==== @@ -19,4 +19,4 @@ tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExp export var z: c.b.I; ~ -!!! error TS2694: Namespace '"tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. \ No newline at end of file +!!! error TS2809: Namespace 'c' from module 'tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError' has no exported member 'b'. \ No newline at end of file diff --git a/tests/baselines/reference/invalidInstantiatedModule.errors.txt b/tests/baselines/reference/invalidInstantiatedModule.errors.txt index 540f22f5951a2..518efeba11961 100644 --- a/tests/baselines/reference/invalidInstantiatedModule.errors.txt +++ b/tests/baselines/reference/invalidInstantiatedModule.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(2,18): error TS2300: Duplicate identifier 'Point'. tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(3,16): error TS2300: Duplicate identifier 'Point'. -tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(12,8): error TS2503: Cannot find namespace 'm'. +tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(12,8): error TS2811: Cannot find namespace 'm'. Did you mean 'M? ==== tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts (3 errors) ==== @@ -21,7 +21,8 @@ tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedMo var m = M2; var p: m.Point; // Error ~ -!!! error TS2503: Cannot find namespace 'm'. +!!! error TS2811: Cannot find namespace 'm'. Did you mean 'M? +!!! related TS2728 tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts:1:8: 'M' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/jsdocPropertyTagInvalid.errors.txt b/tests/baselines/reference/jsdocPropertyTagInvalid.errors.txt index f880d5657c886..7a3d9dca3b531 100644 --- a/tests/baselines/reference/jsdocPropertyTagInvalid.errors.txt +++ b/tests/baselines/reference/jsdocPropertyTagInvalid.errors.txt @@ -1,4 +1,4 @@ -/a.js(3,15): error TS2304: Cannot find name 'sting'. +/a.js(3,15): error TS2552: Cannot find name 'sting'. Did you mean 'String'? ==== /a.js (1 errors) ==== @@ -6,7 +6,8 @@ * @typedef MyType * @property {sting} [x] ~~~~~ -!!! error TS2304: Cannot find name 'sting'. +!!! error TS2552: Cannot find name 'sting'. Did you mean 'String'? +!!! related TS2728 /.ts/lib.es5.d.ts:527:13: 'String' is declared here. */ /** @param {MyType} p */ diff --git a/tests/baselines/reference/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.errors.txt b/tests/baselines/reference/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.errors.txt index 3380f7b5aabde..3b83f54518cee 100644 --- a/tests/baselines/reference/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.errors.txt +++ b/tests/baselines/reference/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.errors.txt @@ -1,7 +1,7 @@ -error TS18035: Invalid value for 'jsxFragmentFactory'. '234' is not a valid identifier or qualified-name. +error TS5067: Invalid value for 'jsxFragmentFactory'. '234' is not a valid identifier or qualified-name. -!!! error TS18035: Invalid value for 'jsxFragmentFactory'. '234' is not a valid identifier or qualified-name. +!!! error TS5067: Invalid value for 'jsxFragmentFactory'. '234' is not a valid identifier or qualified-name. ==== tests/cases/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.tsx (0 errors) ==== declare var h: any; diff --git a/tests/baselines/reference/parserUnfinishedTypeNameBeforeKeyword1.errors.txt b/tests/baselines/reference/parserUnfinishedTypeNameBeforeKeyword1.errors.txt index e78d878f27151..690604a7b307c 100644 --- a/tests/baselines/reference/parserUnfinishedTypeNameBeforeKeyword1.errors.txt +++ b/tests/baselines/reference/parserUnfinishedTypeNameBeforeKeyword1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(1,8): error TS2503: Cannot find namespace 'TypeModule1'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(1,8): error TS2811: Cannot find namespace 'TypeModule1'. Did you mean 'TypeModule2? tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(1,20): error TS1003: Identifier expected. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts (2 errors) ==== var x: TypeModule1. ~~~~~~~~~~~ -!!! error TS2503: Cannot find namespace 'TypeModule1'. +!!! error TS2811: Cannot find namespace 'TypeModule1'. Did you mean 'TypeModule2? !!! error TS1003: Identifier expected. module TypeModule2 { diff --git a/tests/baselines/reference/parserUnterminatedGeneric1.errors.txt b/tests/baselines/reference/parserUnterminatedGeneric1.errors.txt index 53a98b2d7f9e1..b5749ab3aceb0 100644 --- a/tests/baselines/reference/parserUnterminatedGeneric1.errors.txt +++ b/tests/baselines/reference/parserUnterminatedGeneric1.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric1.ts(2,23): error TS2304: Cannot find name 'IPromise'. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric1.ts(2,45): error TS2304: Cannot find name 'IPromise'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric1.ts(2,23): error TS2552: Cannot find name 'IPromise'. Did you mean 'Promise'? +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric1.ts(2,45): error TS2552: Cannot find name 'IPromise'. Did you mean 'Promise'? tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric1.ts(2,54): error TS1005: '>' expected. @@ -7,8 +7,8 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGener interface IQService { all(promises: IPromise < any > []): IPromise< ~~~~~~~~ -!!! error TS2304: Cannot find name 'IPromise'. +!!! error TS2552: Cannot find name 'IPromise'. Did you mean 'Promise'? ~~~~~~~~ -!!! error TS2304: Cannot find name 'IPromise'. +!!! error TS2552: Cannot find name 'IPromise'. Did you mean 'Promise'? !!! error TS1005: '>' expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserUnterminatedGeneric2.errors.txt b/tests/baselines/reference/parserUnterminatedGeneric2.errors.txt index e38a548f34c97..552a2fd708e18 100644 --- a/tests/baselines/reference/parserUnterminatedGeneric2.errors.txt +++ b/tests/baselines/reference/parserUnterminatedGeneric2.errors.txt @@ -10,8 +10,8 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGener tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(4,37): error TS2693: 'any' only refers to a type, but is being used as a value here. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(4,41): error TS1005: ';' expected. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(4,43): error TS2693: 'any' only refers to a type, but is being used as a value here. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(8,23): error TS2304: Cannot find name 'IPromise'. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(8,45): error TS2304: Cannot find name 'IPromise'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(8,23): error TS2552: Cannot find name 'IPromise'. Did you mean 'Promise'? +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(8,45): error TS2552: Cannot find name 'IPromise'. Did you mean 'Promise'? tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(8,54): error TS1005: '>' expected. @@ -49,8 +49,8 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGener interface IQService { all(promises: IPromise < any > []): IPromise< ~~~~~~~~ -!!! error TS2304: Cannot find name 'IPromise'. +!!! error TS2552: Cannot find name 'IPromise'. Did you mean 'Promise'? ~~~~~~~~ -!!! error TS2304: Cannot find name 'IPromise'. +!!! error TS2552: Cannot find name 'IPromise'. Did you mean 'Promise'? !!! error TS1005: '>' expected. \ No newline at end of file diff --git a/tests/baselines/reference/potentiallyUncalledDecorators.errors.txt b/tests/baselines/reference/potentiallyUncalledDecorators.errors.txt index 9028ebe0377eb..50a0b0bac96d1 100644 --- a/tests/baselines/reference/potentiallyUncalledDecorators.errors.txt +++ b/tests/baselines/reference/potentiallyUncalledDecorators.errors.txt @@ -5,8 +5,8 @@ tests/cases/compiler/potentiallyUncalledDecorators.ts(38,5): error TS1329: 'noAr tests/cases/compiler/potentiallyUncalledDecorators.ts(41,1): error TS1238: Unable to resolve signature of class decorator when called as an expression. Type 'OmniDecorator' is not assignable to type 'typeof B'. Type 'OmniDecorator' provides no match for the signature 'new (): B'. -tests/cases/compiler/potentiallyUncalledDecorators.ts(43,5): error TS1236: The return type of a property decorator function must be either 'void' or 'any'. - Unable to resolve signature of property decorator when called as an expression. +tests/cases/compiler/potentiallyUncalledDecorators.ts(43,5): error TS1240: Unable to resolve signature of property decorator when called as an expression. + The return type of a property decorator function must be either 'void' or 'any'. tests/cases/compiler/potentiallyUncalledDecorators.ts(44,5): error TS1241: Unable to resolve signature of method decorator when called as an expression. Type 'OmniDecorator' has no properties in common with type 'TypedPropertyDescriptor<() => void>'. tests/cases/compiler/potentiallyUncalledDecorators.ts(47,1): error TS1238: Unable to resolve signature of class decorator when called as an expression. @@ -17,22 +17,22 @@ tests/cases/compiler/potentiallyUncalledDecorators.ts(50,5): error TS1329: 'oneO tests/cases/compiler/potentiallyUncalledDecorators.ts(53,1): error TS1238: Unable to resolve signature of class decorator when called as an expression. Type 'OmniDecorator' is not assignable to type 'typeof D'. Type 'OmniDecorator' provides no match for the signature 'new (): D'. -tests/cases/compiler/potentiallyUncalledDecorators.ts(55,5): error TS1236: The return type of a property decorator function must be either 'void' or 'any'. - Unable to resolve signature of property decorator when called as an expression. +tests/cases/compiler/potentiallyUncalledDecorators.ts(55,5): error TS1240: Unable to resolve signature of property decorator when called as an expression. + The return type of a property decorator function must be either 'void' or 'any'. tests/cases/compiler/potentiallyUncalledDecorators.ts(56,5): error TS1241: Unable to resolve signature of method decorator when called as an expression. Type 'OmniDecorator' has no properties in common with type 'TypedPropertyDescriptor<() => void>'. tests/cases/compiler/potentiallyUncalledDecorators.ts(59,1): error TS1238: Unable to resolve signature of class decorator when called as an expression. Type 'OmniDecorator' is not assignable to type 'typeof E'. Type 'OmniDecorator' provides no match for the signature 'new (): E'. -tests/cases/compiler/potentiallyUncalledDecorators.ts(61,5): error TS1236: The return type of a property decorator function must be either 'void' or 'any'. - Unable to resolve signature of property decorator when called as an expression. +tests/cases/compiler/potentiallyUncalledDecorators.ts(61,5): error TS1240: Unable to resolve signature of property decorator when called as an expression. + The return type of a property decorator function must be either 'void' or 'any'. tests/cases/compiler/potentiallyUncalledDecorators.ts(62,5): error TS1241: Unable to resolve signature of method decorator when called as an expression. Type 'OmniDecorator' has no properties in common with type 'TypedPropertyDescriptor<() => void>'. tests/cases/compiler/potentiallyUncalledDecorators.ts(65,1): error TS1238: Unable to resolve signature of class decorator when called as an expression. Type 'OmniDecorator' is not assignable to type 'typeof F'. Type 'OmniDecorator' provides no match for the signature 'new (): F'. -tests/cases/compiler/potentiallyUncalledDecorators.ts(67,5): error TS1236: The return type of a property decorator function must be either 'void' or 'any'. - Unable to resolve signature of property decorator when called as an expression. +tests/cases/compiler/potentiallyUncalledDecorators.ts(67,5): error TS1240: Unable to resolve signature of property decorator when called as an expression. + The return type of a property decorator function must be either 'void' or 'any'. tests/cases/compiler/potentiallyUncalledDecorators.ts(68,5): error TS1241: Unable to resolve signature of method decorator when called as an expression. Type 'OmniDecorator' has no properties in common with type 'TypedPropertyDescriptor<() => void>'. @@ -94,8 +94,8 @@ tests/cases/compiler/potentiallyUncalledDecorators.ts(68,5): error TS1241: Unabl class B { @allRest foo: any; ~~~~~~~~ -!!! error TS1236: The return type of a property decorator function must be either 'void' or 'any'. -!!! error TS1236: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1240: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1240: The return type of a property decorator function must be either 'void' or 'any'. @allRest bar() { } ~~~~~~~~ !!! error TS1241: Unable to resolve signature of method decorator when called as an expression. @@ -124,8 +124,8 @@ tests/cases/compiler/potentiallyUncalledDecorators.ts(68,5): error TS1241: Unabl class D { @twoOptional foo: any; ~~~~~~~~~~~~ -!!! error TS1236: The return type of a property decorator function must be either 'void' or 'any'. -!!! error TS1236: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1240: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1240: The return type of a property decorator function must be either 'void' or 'any'. @twoOptional bar() { } ~~~~~~~~~~~~ !!! error TS1241: Unable to resolve signature of method decorator when called as an expression. @@ -140,8 +140,8 @@ tests/cases/compiler/potentiallyUncalledDecorators.ts(68,5): error TS1241: Unabl class E { @threeOptional foo: any; ~~~~~~~~~~~~~~ -!!! error TS1236: The return type of a property decorator function must be either 'void' or 'any'. -!!! error TS1236: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1240: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1240: The return type of a property decorator function must be either 'void' or 'any'. @threeOptional bar() { } ~~~~~~~~~~~~~~ !!! error TS1241: Unable to resolve signature of method decorator when called as an expression. @@ -156,8 +156,8 @@ tests/cases/compiler/potentiallyUncalledDecorators.ts(68,5): error TS1241: Unabl class F { @oneOptionalWithRest foo: any; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS1236: The return type of a property decorator function must be either 'void' or 'any'. -!!! error TS1236: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1240: Unable to resolve signature of property decorator when called as an expression. +!!! error TS1240: The return type of a property decorator function must be either 'void' or 'any'. @oneOptionalWithRest bar() { } ~~~~~~~~~~~~~~~~~~~~ !!! error TS1241: Unable to resolve signature of method decorator when called as an expression. diff --git a/tests/baselines/reference/primaryExpressionMods.errors.txt b/tests/baselines/reference/primaryExpressionMods.errors.txt index 0816c13b8972b..c947aaf0c6c89 100644 --- a/tests/baselines/reference/primaryExpressionMods.errors.txt +++ b/tests/baselines/reference/primaryExpressionMods.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/primaryExpressionMods.ts(7,8): error TS2709: Cannot use namespace 'M' as a type. -tests/cases/compiler/primaryExpressionMods.ts(11,8): error TS2503: Cannot find namespace 'm'. +tests/cases/compiler/primaryExpressionMods.ts(11,8): error TS2811: Cannot find namespace 'm'. Did you mean 'M? ==== tests/cases/compiler/primaryExpressionMods.ts (2 errors) ==== @@ -17,5 +17,6 @@ tests/cases/compiler/primaryExpressionMods.ts(11,8): error TS2503: Cannot find n var x2 = m.a; // Same as M.a var q: m.P; // Error ~ -!!! error TS2503: Cannot find namespace 'm'. +!!! error TS2811: Cannot find namespace 'm'. Did you mean 'M? +!!! related TS2728 tests/cases/compiler/primaryExpressionMods.ts:1:8: 'M' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/showConfig/Shows tsconfig for single option/metadataDecorator/tsconfig.json b/tests/baselines/reference/showConfig/Shows tsconfig for single option/metadataDecorator/tsconfig.json new file mode 100644 index 0000000000000..9b4297d0d0c3a --- /dev/null +++ b/tests/baselines/reference/showConfig/Shows tsconfig for single option/metadataDecorator/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "metadataDecorator": "someString" + } +} diff --git a/tests/baselines/reference/showConfig/Shows tsconfig for single option/metadataDecoratorImportSource/tsconfig.json b/tests/baselines/reference/showConfig/Shows tsconfig for single option/metadataDecoratorImportSource/tsconfig.json new file mode 100644 index 0000000000000..54be9109e083c --- /dev/null +++ b/tests/baselines/reference/showConfig/Shows tsconfig for single option/metadataDecoratorImportSource/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "metadataDecoratorImportSource": "someString" + } +} diff --git a/tests/baselines/reference/tscWatch/emit/emit-with-outFile-or-out-setting/with---outFile-and-multiple-declaration-files-in-the-program.js b/tests/baselines/reference/tscWatch/emit/emit-with-outFile-or-out-setting/with---outFile-and-multiple-declaration-files-in-the-program.js index 6704e5da50281..2790d2d586a3e 100644 --- a/tests/baselines/reference/tscWatch/emit/emit-with-outFile-or-out-setting/with---outFile-and-multiple-declaration-files-in-the-program.js +++ b/tests/baselines/reference/tscWatch/emit/emit-with-outFile-or-out-setting/with---outFile-and-multiple-declaration-files-in-the-program.js @@ -38,6 +38,11 @@ Output:: 1 namespace main.file4 { import DynamicMenu = Common.SomeComponent.DynamicMenu; export function foo(a: DynamicMenu.z) { } }    ~ + a/b/output/AnotherDependency/file1.d.ts:1:59 + 1 declare namespace Common.SomeComponent.DynamicMenu { enum Z { Full = 0, Min = 1, Average = 2, } } +    ~ + 'Z' is declared here. + [12:00:34 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emit/emit-with-outFile-or-out-setting/without---outFile-and-multiple-declaration-files-in-the-program.js b/tests/baselines/reference/tscWatch/emit/emit-with-outFile-or-out-setting/without---outFile-and-multiple-declaration-files-in-the-program.js index f67b7cb0e3202..678e7ccb6884a 100644 --- a/tests/baselines/reference/tscWatch/emit/emit-with-outFile-or-out-setting/without---outFile-and-multiple-declaration-files-in-the-program.js +++ b/tests/baselines/reference/tscWatch/emit/emit-with-outFile-or-out-setting/without---outFile-and-multiple-declaration-files-in-the-program.js @@ -38,6 +38,11 @@ Output:: 1 namespace main.file4 { import DynamicMenu = Common.SomeComponent.DynamicMenu; export function foo(a: DynamicMenu.z) { } }    ~ + a/b/output/AnotherDependency/file1.d.ts:1:59 + 1 declare namespace Common.SomeComponent.DynamicMenu { enum Z { Full = 0, Min = 1, Average = 2, } } +    ~ + 'Z' is declared here. + [12:00:36 AM] Found 1 error. Watching for file changes. diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.1.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.1.ts new file mode 100644 index 0000000000000..bbc6543e6b7c3 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.1.ts @@ -0,0 +1,23 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @filename: global.d.ts +declare const metadata: any; +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.2.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.2.ts new file mode 100644 index 0000000000000..02970e5b92407 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.2.ts @@ -0,0 +1,24 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @filename: global.d.ts +declare const metadat: any; +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.3.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.3.ts new file mode 100644 index 0000000000000..c64e7d2149d53 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.3.ts @@ -0,0 +1,23 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @filename: global.d.ts +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.4.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.4.ts new file mode 100644 index 0000000000000..4ca219d8b619b --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.4.ts @@ -0,0 +1,24 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @filename: global.d.ts +declare const metadata: number; +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.5.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.5.ts new file mode 100644 index 0000000000000..46a45675f2b90 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.5.ts @@ -0,0 +1,24 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @filename: global.d.ts +declare function metadata(): void; +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.6.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.6.ts new file mode 100644 index 0000000000000..d17dcf2d92158 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.6.ts @@ -0,0 +1,26 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @filename: global.d.ts +declare function metadata(target: Function): true; +declare function metadata(target: object, key: string, desc?: PropertyDescriptor): true; +declare function metadata(target: object, key: string, parameterIndex: number): true; +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.7.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.7.ts new file mode 100644 index 0000000000000..0e99970f075c1 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalIdentifier.7.ts @@ -0,0 +1,26 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @filename: global.d.ts +declare function metadata(target: number): void; +declare function metadata(target: number, key: string, desc?: PropertyDescriptor): void; +declare function metadata(target: number, key: string, parameterIndex: number): void; +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.1.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.1.ts new file mode 100644 index 0000000000000..c3e6160d069e8 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.1.ts @@ -0,0 +1,25 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @filename: global.d.ts +declare namespace Reflect { + const metadata: any; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.2.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.2.ts new file mode 100644 index 0000000000000..0371982d33e27 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.2.ts @@ -0,0 +1,26 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @filename: global.d.ts +declare namespace Reflect { + const metadat: any; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.3.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.3.ts new file mode 100644 index 0000000000000..226caec8d8901 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.3.ts @@ -0,0 +1,26 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @filename: global.d.ts +declare namespace Reflect { + const _: any; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.4.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.4.ts new file mode 100644 index 0000000000000..0cedd0381c6e6 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.4.ts @@ -0,0 +1,26 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @filename: global.d.ts +declare namespace Reflect { + const metadata: number; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.5.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.5.ts new file mode 100644 index 0000000000000..8c35222431369 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.5.ts @@ -0,0 +1,26 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @filename: global.d.ts +declare namespace Reflect { + function metadata(): void; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.6.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.6.ts new file mode 100644 index 0000000000000..4751fa100249f --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.6.ts @@ -0,0 +1,28 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @filename: global.d.ts +declare namespace Reflect { + function metadata(target: Function): true; + function metadata(target: object, key: string, desc?: PropertyDescriptor): true; + function metadata(target: object, key: string, parameterIndex: number): true; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.7.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.7.ts new file mode 100644 index 0000000000000..3739c9b732dd9 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.7.ts @@ -0,0 +1,28 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @filename: global.d.ts +declare namespace Reflect { + function metadata(target: number): void; + function metadata(target: number, key: string, desc?: PropertyDescriptor): void; + function metadata(target: number, key: string, parameterIndex: number): void; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.8.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.8.ts new file mode 100644 index 0000000000000..c3cfffae459cb --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.globalNamespace.8.ts @@ -0,0 +1,23 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @filename: global.d.ts +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.1.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.1.ts new file mode 100644 index 0000000000000..cd092b819fe4e --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.1.ts @@ -0,0 +1,27 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + const metadata: any; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.10.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.10.ts new file mode 100644 index 0000000000000..97335ba12aa33 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.10.ts @@ -0,0 +1,28 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + const metadata: any; +} +declare const dec: any; +// @filename: main.ts +declare const metadata: any; +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.2.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.2.ts new file mode 100644 index 0000000000000..6c0671666f9fb --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.2.ts @@ -0,0 +1,28 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + const metadat: any; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.3.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.3.ts new file mode 100644 index 0000000000000..77b5437cc8bf5 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.3.ts @@ -0,0 +1,28 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + const _: any; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.4.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.4.ts new file mode 100644 index 0000000000000..2f20432f9473d --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.4.ts @@ -0,0 +1,28 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + const metadata: number; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.5.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.5.ts new file mode 100644 index 0000000000000..28baa0300a160 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.5.ts @@ -0,0 +1,28 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + function metadata(): void; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.6.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.6.ts new file mode 100644 index 0000000000000..6e713ab657c86 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.6.ts @@ -0,0 +1,30 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + function metadata(target: Function): true; + function metadata(target: object, key: string, desc?: PropertyDescriptor): true; + function metadata(target: object, key: string, parameterIndex: number): true; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.7.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.7.ts new file mode 100644 index 0000000000000..10b18884b5137 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.7.ts @@ -0,0 +1,25 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.8.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.8.ts new file mode 100644 index 0000000000000..fc8ca97f6cc04 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.8.ts @@ -0,0 +1,27 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + const metadata: any; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.9.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.9.ts new file mode 100644 index 0000000000000..1853b528250a6 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedIdentifier.9.ts @@ -0,0 +1,30 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + function metadata(target: number): void; + function metadata(target: number, key: string, desc?: PropertyDescriptor): void; + function metadata(target: number, key: string, parameterIndex: number): void; +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.1.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.1.ts new file mode 100644 index 0000000000000..b76c68d522077 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.1.ts @@ -0,0 +1,29 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + namespace Reflect { + const metadata: any; + } +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.2.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.2.ts new file mode 100644 index 0000000000000..3642160039316 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.2.ts @@ -0,0 +1,30 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + namespace Reflect { + const metadat: any; + } +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.3.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.3.ts new file mode 100644 index 0000000000000..480de19af6073 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.3.ts @@ -0,0 +1,30 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + namespace Reflect { + const _: any; + } +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.4.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.4.ts new file mode 100644 index 0000000000000..d37ac04743a45 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.4.ts @@ -0,0 +1,30 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + namespace Reflect { + const metadata: number; + } +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.5.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.5.ts new file mode 100644 index 0000000000000..8fcbbb05ea3b5 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.5.ts @@ -0,0 +1,30 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + namespace Reflect { + function metadata(): void; + } +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.6.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.6.ts new file mode 100644 index 0000000000000..cd09fd27e2917 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.6.ts @@ -0,0 +1,32 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + namespace Reflect { + function metadata(target: Function): true; + function metadata(target: object, key: string, desc?: PropertyDescriptor): true; + function metadata(target: object, key: string, parameterIndex: number): true; + } +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.7.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.7.ts new file mode 100644 index 0000000000000..009f7c2de69fc --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.7.ts @@ -0,0 +1,32 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + namespace Reflect { + function metadata(target: number): void; + function metadata(target: number, key: string, desc?: PropertyDescriptor): void; + function metadata(target: number, key: string, parameterIndex: number): void; + } +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.8.ts b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.8.ts new file mode 100644 index 0000000000000..9538ac048d8ef --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata/customMetadataDecorator.importedNamespace.8.ts @@ -0,0 +1,29 @@ +// @target: es2019 +// @module: esnext +// @moduleResolution: node +// @noTypesAndSymbols: true +// @noEmit: true +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @metadataDecorator: Reflect.metadata +// @metadataDecoratorImportSource: foo +// @filename: global.d.ts +declare module "foo" { + namespace Reflect { + const metadata: any; + } +} +declare const dec: any; +// @filename: main.ts +@dec +class C { + @dec x!: number; + + constructor(x: number) {} + + @dec + method(@dec x: number): string { return ""; } + + @dec + get accessor(): string { return ""; } +} diff --git a/tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts b/tests/cases/conformance/decorators/decoratorMetadata/decoratorMetadata-jsdoc.ts similarity index 100% rename from tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts rename to tests/cases/conformance/decorators/decoratorMetadata/decoratorMetadata-jsdoc.ts diff --git a/tests/cases/conformance/decorators/decoratorMetadata.ts b/tests/cases/conformance/decorators/decoratorMetadata/decoratorMetadata.ts similarity index 100% rename from tests/cases/conformance/decorators/decoratorMetadata.ts rename to tests/cases/conformance/decorators/decoratorMetadata/decoratorMetadata.ts diff --git a/tests/cases/conformance/decorators/decoratorMetadataWithTypeOnlyImport.ts b/tests/cases/conformance/decorators/decoratorMetadata/decoratorMetadataWithTypeOnlyImport.ts similarity index 100% rename from tests/cases/conformance/decorators/decoratorMetadataWithTypeOnlyImport.ts rename to tests/cases/conformance/decorators/decoratorMetadata/decoratorMetadataWithTypeOnlyImport.ts