mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(isolated_declarations): try fix new line issue
This commit is contained in:
parent
ee748b0c05
commit
9b3f763a49
23 changed files with 55 additions and 2 deletions
|
|
@ -29,7 +29,8 @@ fn transform(path: &Path, source_text: &str) -> String {
|
|||
.build(&id_ret.program)
|
||||
.source_text;
|
||||
|
||||
let mut snapshot = format!("==================== .D.TS ====================\n\n{code}\n\n");
|
||||
let mut snapshot =
|
||||
format!("```\n==================== .D.TS ====================\n\n{code}\n\n");
|
||||
if !id_ret.errors.is_empty() {
|
||||
let source = Arc::new(source_text.to_string());
|
||||
let error_messages = id_ret
|
||||
|
|
@ -41,7 +42,7 @@ fn transform(path: &Path, source_text: &str) -> String {
|
|||
.join("\n");
|
||||
|
||||
snapshot.push_str(&format!(
|
||||
"==================== Errors ====================\n\n{error_messages}\n\n"
|
||||
"==================== Errors ====================\n\n{error_messages}\n\n```"
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/arrow-function-return-type.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
declare function A(): unknown;
|
||||
|
|
@ -38,3 +39,6 @@ declare const D: () => string;
|
|||
: ^
|
||||
10 |
|
||||
`----
|
||||
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/as-const.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
declare const F: {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/async-function.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
declare function asyncFunctionGood(): Promise<number>;
|
||||
|
|
@ -44,3 +45,6 @@ declare class AsyncClassBad {
|
|||
: ^^^^^^
|
||||
26 | return 42;
|
||||
`----
|
||||
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/class.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
export declare class Foo {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/declare-global.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
declare function MyFunction(): string;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/eliminate-imports.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
import { AExtend, BExtend, Type, CImplements1, CImplements2, CType, ThisType1, ThisType2 } from "mod";
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/empty-export.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
type A = string;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/empty-export2.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/expando-function.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
export declare function foo(): void;
|
||||
|
|
@ -60,3 +61,6 @@ export default qux;
|
|||
: ^^^^^^^^^^
|
||||
11 | }
|
||||
`----
|
||||
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/function-overloads.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
declare function a(a: number): number;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/function-parameters.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
export declare function fnDeclGood(p?: T, rParam?: string): void;
|
||||
|
|
@ -73,3 +74,6 @@ export declare function withUnknown(a: unknown, b: string): void;
|
|||
: ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
27 | return 2;
|
||||
`----
|
||||
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/generator.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
declare function generatorGood(): Generator<number>;
|
||||
|
|
@ -33,3 +34,6 @@ declare class GeneratorClassBad {
|
|||
: ^^^^^^
|
||||
22 | yield 50;
|
||||
`----
|
||||
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/infer-expression.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
declare const n: number;
|
||||
|
|
@ -41,3 +42,6 @@ declare const unaryE: {};
|
|||
18 | const unaryE = {E: -"str"} as const
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/infer-return-type.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
declare function foo(): number;
|
||||
|
|
@ -21,3 +22,6 @@ declare function quux(): string;
|
|||
: ^^^
|
||||
15 | if (a) {
|
||||
`----
|
||||
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/infer-template-literal.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
export declare const CSS_VARS_HELPER = "useCssVars";
|
||||
|
|
@ -33,3 +34,6 @@ export declare let BAD2: unknown;
|
|||
14 | export let BAD2 = `useCssV${v}ars` as const
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/mapped-types.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
import { K } from "foo";
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/module-declaration.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
import "foo";
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/non-exported-binding-elements.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
export declare function foo(): number;
|
||||
|
|
@ -53,3 +54,6 @@ export declare const;
|
|||
: ^
|
||||
10 | export { c, d, e }
|
||||
`----
|
||||
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/readonly.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
export declare const EMPTY_OBJ: { readonly [key: string]: any };
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/set-get-accessor.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
declare class Cls {
|
||||
|
|
@ -28,3 +29,6 @@ declare class ClsBad {
|
|||
: ^
|
||||
22 | return;
|
||||
`----
|
||||
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/signatures.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
export interface X {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/strip-internal.ts
|
||||
---
|
||||
```
|
||||
==================== .D.TS ====================
|
||||
|
||||
declare class StripInternalClassFields {}
|
||||
|
|
|
|||
Loading…
Reference in a new issue