Don't prevent going to next stage when a warning is elevated to an error (#2983)
fix #2972
This commit is contained in:
Родитель
128a508c25
Коммит
00996bbe30
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
|
||||
changeKind: fix
|
||||
packages:
|
||||
- "@typespec/compiler"
|
||||
---
|
||||
|
||||
Warnings converted to error with `warn-as-error` do not prevent compilation from moving to the next stage like regular warnings
|
|
@ -288,6 +288,7 @@ export async function compile(
|
|||
const loadedLibraries = new Map<string, TypeSpecLibraryReference>();
|
||||
const sourceFileLocationContexts = new WeakMap<SourceFile, LocationContext>();
|
||||
let error = false;
|
||||
let continueToNextStage = true;
|
||||
|
||||
const logger = createLogger({ sink: host.logSink });
|
||||
const tracer = createTracer(logger, { filter: options.trace });
|
||||
|
@ -383,7 +384,7 @@ export async function compile(
|
|||
program.checker = createChecker(program);
|
||||
program.checker.checkProgram();
|
||||
|
||||
if (program.hasError()) {
|
||||
if (!continueToNextStage) {
|
||||
return program;
|
||||
}
|
||||
// onValidate stage
|
||||
|
@ -392,7 +393,7 @@ export async function compile(
|
|||
validateRequiredImports();
|
||||
|
||||
await validateLoadedLibraries();
|
||||
if (program.hasError()) {
|
||||
if (!continueToNextStage) {
|
||||
return program;
|
||||
}
|
||||
|
||||
|
@ -1049,6 +1050,10 @@ export async function compile(
|
|||
return;
|
||||
}
|
||||
|
||||
if (diagnostic.severity === "error") {
|
||||
continueToNextStage = false;
|
||||
}
|
||||
|
||||
if (diagnostic.severity === "warning" && diagnostic.target !== NoTarget) {
|
||||
mutate(diagnostic).codefixes ??= [];
|
||||
mutate(diagnostic.codefixes).push(createSuppressCodeFix(diagnostic.target, diagnostic.code));
|
||||
|
|
Загрузка…
Ссылка в новой задаче