mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
test(isolated-declarations): arrow function unions in return signature (#5973)
This commit is contained in:
parent
cd34f07e09
commit
d6cbbe723c
4 changed files with 40 additions and 0 deletions
|
|
@ -9,3 +9,7 @@ const B = () => { return B };
|
|||
const C = function () {}
|
||||
|
||||
const D = () => `${''}`;
|
||||
|
||||
const E = (): (() => void) | undefined => {
|
||||
return () => {};
|
||||
}
|
||||
|
|
|
|||
24
crates/oxc_isolated_declarations/tests/fixtures/function-signatures.ts
vendored
Normal file
24
crates/oxc_isolated_declarations/tests/fixtures/function-signatures.ts
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// All of these are valid function signatures under isolatedDeclarations
|
||||
export function A(): void {
|
||||
return;
|
||||
}
|
||||
|
||||
export function B(): (() => void) | undefined {
|
||||
return () => {};
|
||||
}
|
||||
|
||||
// There should be no declaration for the implementation signature, just the
|
||||
// two overloads.
|
||||
export function C(x: string): void
|
||||
export function C(x: number): void
|
||||
export function C(x: string | number): void {
|
||||
return;
|
||||
}
|
||||
|
||||
// private, not emitted
|
||||
function D(a, b): void {
|
||||
return;
|
||||
}
|
||||
function E(a: number, b: string) {
|
||||
return `${a} ${b}`;
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ declare function A(): unknown;
|
|||
declare const B: unknown;
|
||||
declare const C: unknown;
|
||||
declare const D: () => string;
|
||||
declare const E: () => (() => void) | undefined;
|
||||
|
||||
|
||||
==================== Errors ====================
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/function-signatures.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
export declare function A(): void;
|
||||
export declare function B(): (() => void) | undefined;
|
||||
export declare function C(x: string): void;
|
||||
export declare function C(x: number): void;
|
||||
Loading…
Reference in a new issue