-
-
Notifications
You must be signed in to change notification settings - Fork 456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various Isolated declarations fixes #3976
Changes from all commits
4041a78
bc09ef8
f32c175
ba38c13
33188ed
c3caf92
3a183fb
8fd3ae9
0cc038b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,3 +139,8 @@ pub fn type_containing_private_name(name: &str, span: Span) -> OxcDiagnostic { | |
)) | ||
.with_label(span) | ||
} | ||
|
||
pub fn destructuring_export(span: Span) -> OxcDiagnostic { | ||
OxcDiagnostic::error("TS9999: Not supported yet") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to give feedback, that a certain transformation is not supported yet, instead of silently generating wrong There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, can you provide the examples that need to report this error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Methods in abstract classes could be empty, and it is recognized as overloading:
->
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is a bug. Our goal is to keep the output the same as TypeScript, including diagnostics. if it's not the same, it's considered a bug. So we should report
This code seems to be incorrect. TypeScript Playground. We assume that the transforms code is correct There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the first case is fixed in #4025, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes!! |
||
.with_label(span) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,13 @@ mod tests { | |
|
||
let ret = IsolatedDeclarations::new(&allocator).build(&program); | ||
let actual = CodeGenerator::new().build(&ret.program).source_text; | ||
let expected_program = Parser::new(&allocator, expected, source_type).parse().program; | ||
let expected = CodeGenerator::new().build(&expected_program).source_text; | ||
// let expected_program = Parser::new(&allocator, expected, source_type).parse().program; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO revert |
||
// let expected = CodeGenerator::new().build(&expected_program).source_text; | ||
|
||
println!("program {:#?}", program); | ||
println!("ret errors {:#?}", ret.errors); | ||
println!("ret program {:#?}", ret.program); | ||
println!("actual {:#?}", actual); | ||
assert_eq!(actual.trim(), expected.trim()); | ||
} | ||
|
||
|
@@ -157,7 +161,7 @@ export function foo(a: any): number { | |
transform_dts_test( | ||
"export class Foo { declare a: string }", | ||
"export declare class Foo { | ||
a: string; | ||
\ta: string; | ||
}", | ||
); | ||
} | ||
|
@@ -382,4 +386,61 @@ export function foo(a: any): number { | |
fn dts_default_export_all() { | ||
transform_dts_test("export * as foo from \"foo\";", "export * as foo from \"foo\";"); | ||
} | ||
|
||
#[test] | ||
fn dts_class_type_param() { | ||
transform_dts_test( | ||
"export class A<T> extends B<T> implements C<T>{};", | ||
"export declare class A<T> extends B<T> implements C<T> {}", | ||
); | ||
} | ||
|
||
#[test] | ||
fn dts_fn_type_param() { | ||
transform_dts_test( | ||
"export default function<T>(arg1: T) {}", | ||
"export default function<T>(arg1: T);", | ||
); | ||
} | ||
|
||
#[test] | ||
fn dts_destructed_export() { | ||
transform_dts_test("export const {a} = b()", "export declare const a: unknown;"); | ||
} | ||
|
||
#[test] | ||
fn dts_tuple_optional_item() { | ||
transform_dts_test( | ||
"export const a: [x?: number | null] = [null]", | ||
"export declare const a: [x?: ((number) | (null))];\n", | ||
); | ||
} | ||
|
||
#[test] | ||
fn dts_abstract_class_methods() { | ||
transform_dts_test( | ||
"export abstract class A { b(): boolean; c(): void {};}", | ||
"export declare abstract class A {\n\tb(): boolean;\n\tc(): void;\n}\n", | ||
); | ||
} | ||
|
||
#[test] | ||
fn dts_class_field_literal() { | ||
transform_dts_test( | ||
"export class A {readonly type = 'frame'}", | ||
"export declare class A {\n\treadonly type: 'frame';\n}\n", | ||
); | ||
transform_dts_test( | ||
"export class A {type = 'frame'}", | ||
"export declare class A {\n\ttype: string;\n}\n", | ||
); | ||
} | ||
|
||
#[test] | ||
fn dts_global_declare_refs() { | ||
transform_dts_test( | ||
"import A from ''; declare global {a: A}", | ||
"import A from '';\ndeclare global {\n\ta: A;\n}\n", | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO either fix, or uncomment