mirror of
https://github.com/aphrody-labs/oxc.git
synced 2026-10-14 22:29:17 +00:00
fix(parser): include generator marker in overload diagnostic span (#27313)
Include the generator `*` in TS1222 diagnostic spans for class method overload signatures. Use the earlier of the function start and generator marker so function declaration spans retain their existing start.
This commit is contained in:
1 parent
4359a66953
commit
2ff6fb51da
2 files changed
+7
-5
No files matched your search
@@ -350,7 +350,9 @@ impl<'a, C: Config> ParserImpl<'a, C> {
|
||||
if ctx.has_ambient() {
|
||||
self.error(diagnostics::generator_in_ambient_context(self.end_span(generator)));
|
||||
} else if body.is_none() {
|
||||
self.error(diagnostics::overload_signature_generator(self.end_span(start)));
|
||||
self.error(diagnostics::overload_signature_generator(
|
||||
self.end_span(start.min(generator)),
|
||||
));
|
||||
}
|
||||
}
|
||||
self.verify_modifiers(
|
||||
|
||||
@@ -21647,18 +21647,18 @@ Expect to Parse: tasks/coverage/typescript/tsc/testdata/tests/cases/conformance/
|
||||
╰────
|
||||
|
||||
× TS(1222): An overload signature cannot be declared as a generator.
|
||||
╭─[typescript/tsc/testdata/tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts:2:7]
|
||||
╭─[typescript/tsc/testdata/tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts:2:5]
|
||||
1 │ class C {
|
||||
2 │ *f(s: string): Iterable<any>;
|
||||
· ───────────────────────────
|
||||
· ─────────────────────────────
|
||||
3 │ *f(s: number): Iterable<any>;
|
||||
╰────
|
||||
|
||||
× TS(1222): An overload signature cannot be declared as a generator.
|
||||
╭─[typescript/tsc/testdata/tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts:3:7]
|
||||
╭─[typescript/tsc/testdata/tests/cases/conformance/es6/yieldExpressions/generatorOverloads3.ts:3:5]
|
||||
2 │ *f(s: string): Iterable<any>;
|
||||
3 │ *f(s: number): Iterable<any>;
|
||||
· ───────────────────────────
|
||||
· ─────────────────────────────
|
||||
4 │ *f(s: any): Iterable<any> { }
|
||||
╰────
|
||||
|
||||
|
||||
Reference in new issue
Block a user