Skip to content
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

fix(isolated-declarations): Report uninferrable types in arrays #6084

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion crates/oxc_isolated_declarations/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ impl<'a> IsolatedDeclarations<'a> {
}
_ => self
.transform_expression_to_ts_type(element.to_expression())
.map(TSTupleElement::from),
.map(TSTupleElement::from)
.or_else(|| {
self.error(inferred_type_of_expression(element.span()));
None
}),
}
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ const unaryB = -1_2n;
const unaryC = +"str"
const unaryD = typeof "str"
const unaryE = {E: -"str"} as const
const unaryF = [+"str"] as const
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ declare const unaryB = -1_2n;
declare const unaryC: unknown;
declare const unaryD: unknown;
declare const unaryE: {};
declare const unaryF: readonly [];


==================== Errors ====================
Expand Down Expand Up @@ -41,6 +42,14 @@ declare const unaryE: {};
17 | const unaryD = typeof "str"
18 | const unaryE = {E: -"str"} as const
: ^^^^^^
19 | const unaryF = [+"str"] as const
`----

x TS9013: Expression type can't be inferred with --isolatedDeclarations.
,-[19:17]
18 | const unaryE = {E: -"str"} as const
19 | const unaryF = [+"str"] as const
: ^^^^^^
`----


Expand Down