diff --git a/lib/tsc.js b/lib/tsc.js index 39072b67866b05bff0fca39c225096d3aac8bf77..ea0cdd4900074f1f9bee0a2d06e297f22433a04b 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -72554,14 +72554,14 @@ function createTypeChecker(host, isTypeCheckerForLinter = false) { }); } function checkAnnotation(annotation, annotationsSet) { + if (compilerOptions.isCompileJsHar && inModuleRootPath(annotation)) { + grammarErrorOnNode(annotation, Diagnostics.Annotations_are_not_supported_in_Hars_compiled_to_JavaScript_files); + } const signature = getResolvedSignature(annotation); const returnType = getReturnTypeOfSignature(signature); if (isErrorType(returnType)) { return; } - if (compilerOptions.isCompileJsHar && inModuleRootPath(annotation)) { - grammarErrorOnNode(annotation, Diagnostics.Annotations_are_not_supported_in_Hars_compiled_to_JavaScript_files); - } const annotatedDecl = annotation.parent; if (!isClassDeclaration(annotatedDecl) && !isMethodDeclaration(annotatedDecl)) { const nodeStr = getTextOfNode(annotatedDecl, false); diff --git a/lib/tsserver.js b/lib/tsserver.js index 820f270c095944e00c04b0a39e65aef68b4afc36..7addbe066fa77afb95adf84f80d6a09b028231e1 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -75100,14 +75100,14 @@ function createTypeChecker(host, isTypeCheckerForLinter = false) { }); } function checkAnnotation(annotation, annotationsSet) { + if (compilerOptions.isCompileJsHar && inModuleRootPath(annotation)) { + grammarErrorOnNode(annotation, Diagnostics.Annotations_are_not_supported_in_Hars_compiled_to_JavaScript_files); + } const signature = getResolvedSignature(annotation); const returnType = getReturnTypeOfSignature(signature); if (isErrorType(returnType)) { return; } - if (compilerOptions.isCompileJsHar && inModuleRootPath(annotation)) { - grammarErrorOnNode(annotation, Diagnostics.Annotations_are_not_supported_in_Hars_compiled_to_JavaScript_files); - } const annotatedDecl = annotation.parent; if (!isClassDeclaration(annotatedDecl) && !isMethodDeclaration(annotatedDecl)) { const nodeStr = getTextOfNode(annotatedDecl, false); diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 59049891dce63bab869cc1d007b9b030aa519fbe..4f7786c15acff732fbe0657b24c99ba9e0674f65 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -75002,14 +75002,14 @@ function createTypeChecker(host, isTypeCheckerForLinter = false) { }); } function checkAnnotation(annotation, annotationsSet) { + if (compilerOptions.isCompileJsHar && inModuleRootPath(annotation)) { + grammarErrorOnNode(annotation, Diagnostics.Annotations_are_not_supported_in_Hars_compiled_to_JavaScript_files); + } const signature = getResolvedSignature(annotation); const returnType = getReturnTypeOfSignature(signature); if (isErrorType(returnType)) { return; } - if (compilerOptions.isCompileJsHar && inModuleRootPath(annotation)) { - grammarErrorOnNode(annotation, Diagnostics.Annotations_are_not_supported_in_Hars_compiled_to_JavaScript_files); - } const annotatedDecl = annotation.parent; if (!isClassDeclaration(annotatedDecl) && !isMethodDeclaration(annotatedDecl)) { const nodeStr = getTextOfNode(annotatedDecl, false); diff --git a/lib/typescript.js b/lib/typescript.js index 808d2020f9a519cd159e39c943e91c98b710fcc3..ad0cfa03dd12bcb68f3754a87893a3e3668250af 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -75160,14 +75160,14 @@ function createTypeChecker(host, isTypeCheckerForLinter = false) { }); } function checkAnnotation(annotation, annotationsSet) { + if (compilerOptions.isCompileJsHar && inModuleRootPath(annotation)) { + grammarErrorOnNode(annotation, Diagnostics.Annotations_are_not_supported_in_Hars_compiled_to_JavaScript_files); + } const signature = getResolvedSignature(annotation); const returnType = getReturnTypeOfSignature(signature); if (isErrorType(returnType)) { return; } - if (compilerOptions.isCompileJsHar && inModuleRootPath(annotation)) { - grammarErrorOnNode(annotation, Diagnostics.Annotations_are_not_supported_in_Hars_compiled_to_JavaScript_files); - } const annotatedDecl = annotation.parent; if (!isClassDeclaration(annotatedDecl) && !isMethodDeclaration(annotatedDecl)) { const nodeStr = getTextOfNode(annotatedDecl, false); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bd13f3bfd1483b3b8a9dc3ec2c934d9fd1c383b6..f6928fb44027687c80fd1f26943167c9b933a49c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -39985,17 +39985,17 @@ export function createTypeChecker(host: TypeCheckerHost, isTypeCheckerForLinter: /** Check the annotation of a node */ function checkAnnotation(annotation: Annotation, annotationsSet: Set): void { + // In the har package where the compiled output is a JavaScript file, the use of annotations is prohibited. + if (compilerOptions.isCompileJsHar && inModuleRootPath(annotation)) { + grammarErrorOnNode(annotation, Diagnostics.Annotations_are_not_supported_in_Hars_compiled_to_JavaScript_files); + } + const signature = getResolvedSignature(annotation); const returnType = getReturnTypeOfSignature(signature); if (isErrorType(returnType)) { return; } - // In the har package where the compiled output is a JavaScript file, the use of annotations is prohibited. - if (compilerOptions.isCompileJsHar && inModuleRootPath(annotation)) { - grammarErrorOnNode(annotation, Diagnostics.Annotations_are_not_supported_in_Hars_compiled_to_JavaScript_files); - } - const annotatedDecl = annotation.parent; // Only classes or methods must be annotated if (!isClassDeclaration(annotatedDecl) && !isMethodDeclaration(annotatedDecl)) { @@ -44903,7 +44903,7 @@ export function createTypeChecker(host: TypeCheckerHost, isTypeCheckerForLinter: return checkClassDeclaration(node as ClassDeclaration); case SyntaxKind.StructDeclaration: return checkStructDeclaration(node as StructDeclaration); - case SyntaxKind.AnnotationDeclaration: + case SyntaxKind.AnnotationDeclaration: return checkAnnotationDeclaration(node as AnnotationDeclaration); case SyntaxKind.InterfaceDeclaration: return checkInterfaceDeclaration(node as InterfaceDeclaration);