Skip to content

Commit 615a77b

Browse files
SkyZeroZxthePunderWoman
authored andcommitted
refactor(compiler-cli): update error message links to versioned docs (#66374)
Error message links now point to the archived documentation site (v*.angular.dev) so that referenced content matches the framework version in use. See #44650 PR Close #66374
1 parent 450b4c1 commit 615a77b

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

packages/compiler-cli/src/ngtsc/core/src/compiler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ import {DiagnosticCategoryLabel, NgCompilerAdapter, NgCompilerOptions} from '../
127127
import {coreVersionSupportsFeature} from './feature_detection';
128128
import {angularJitApplicationTransform} from '../../transform/jit';
129129
import {untagAllTsFiles} from '../../shims';
130+
import {DOC_PAGE_BASE_URL} from '../../diagnostics/src/error_details_base_url';
130131

131132
/**
132133
* State information about a compilation which is only generated once some data is requested from
@@ -1777,7 +1778,7 @@ One of the following actions is required:
17771778
2. Remove "strictTemplates" or set it to 'false'.
17781779
17791780
More information about the template type checking compiler options can be found in the documentation:
1780-
https://angular.dev/tools/cli/template-typecheck
1781+
${DOC_PAGE_BASE_URL}/tools/cli/template-typecheck
17811782
`.trim(),
17821783
});
17831784
}

packages/compiler-cli/src/ngtsc/diagnostics/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ export {
1717
makeRelatedInformation,
1818
} from './src/error';
1919
export {ErrorCode} from './src/error_code';
20-
export {ERROR_DETAILS_PAGE_BASE_URL} from './src/error_details_base_url';
20+
export {ERROR_DETAILS_PAGE_BASE_URL, DOC_PAGE_BASE_URL} from './src/error_details_base_url';
2121
export {ExtendedTemplateDiagnosticName} from './src/extended_template_diagnostic_name';
2222
export {ngErrorCode, replaceTsWithNgInErrors} from './src/util';

packages/compiler-cli/src/ngtsc/diagnostics/src/error_details_base_url.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88

99
import {VERSION} from '@angular/compiler';
1010

11+
export const DOC_PAGE_BASE_URL: string = (() => {
12+
const full = VERSION.full;
13+
const isPreRelease =
14+
full.includes('-next') || full.includes('-rc') || full === '0.0.0' + '-PLACEHOLDER';
15+
const prefix = isPreRelease ? 'next' : `v${VERSION.major}`;
16+
return `https://${prefix}.angular.dev`;
17+
})();
18+
1119
/**
1220
* Base URL for the error details page.
1321
*
@@ -16,6 +24,5 @@ import {VERSION} from '@angular/compiler';
1624
* - packages/core/src/error_details_base_url.ts
1725
*/
1826
export const ERROR_DETAILS_PAGE_BASE_URL: string = (() => {
19-
const versionSubDomain = VERSION.major !== '0' ? `v${VERSION.major}.` : '';
20-
return `https://${versionSubDomain}angular.dev/errors`;
27+
return `${DOC_PAGE_BASE_URL}/errors`;
2128
})();

packages/compiler-cli/src/ngtsc/typecheck/extended/checks/invalid_banana_in_box/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
import {AST, TmplAstBoundEvent, TmplAstNode} from '@angular/compiler';
1010
import ts from 'typescript';
1111

12-
import {ErrorCode, ExtendedTemplateDiagnosticName} from '../../../../diagnostics';
12+
import {
13+
ErrorCode,
14+
ExtendedTemplateDiagnosticName,
15+
DOC_PAGE_BASE_URL,
16+
} from '../../../../diagnostics';
1317
import {NgTemplateDiagnostic} from '../../../api';
1418
import {TemplateCheckFactory, TemplateCheckWithVisitor, TemplateContext} from '../../api';
1519

@@ -36,7 +40,7 @@ class InvalidBananaInBoxCheck extends TemplateCheckWithVisitor<ErrorCode.INVALID
3640
const diagnostic = ctx.makeTemplateDiagnostic(
3741
node.sourceSpan,
3842
`In the two-way binding syntax the parentheses should be inside the brackets, ex. '${expectedBoundSyntax}'.
39-
Find more at https://angular.dev/guide/templates/two-way-binding`,
43+
Find more at ${DOC_PAGE_BASE_URL}/guide/templates/two-way-binding`,
4044
);
4145
return [diagnostic];
4246
}

packages/compiler-cli/src/ngtsc/typecheck/src/oob.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {TemplateDiagnostic, TypeCheckId} from '../api';
3939
import {makeTemplateDiagnostic} from '../diagnostics';
4040

4141
import {TypeCheckSourceResolver} from './tcb_util';
42+
import {DOC_PAGE_BASE_URL} from '../../diagnostics/src/error_details_base_url';
4243

4344
/**
4445
* Collects `ts.Diagnostic`s on problems which occur in the template which aren't directly sourced
@@ -514,7 +515,7 @@ export class OutOfBandDiagnosticRecorderImpl implements OutOfBandDiagnosticRecor
514515
): void {
515516
const mapping = this.resolver.getTemplateSourceMapping(id);
516517
const errorMsg = `The property and event halves of the two-way binding '${input.name}' are not bound to the same target.
517-
Find more at https://angular.dev/guide/templates/two-way-binding#how-two-way-binding-works`;
518+
Find more at ${DOC_PAGE_BASE_URL}/guide/templates/two-way-binding`;
518519

519520
const relatedMessages: {text: string; start: number; end: number; sourceFile: ts.SourceFile}[] =
520521
[];

0 commit comments

Comments
 (0)