mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(isolated-declarations): Report uninferrable types in arrays (#6084)
This commit is contained in:
parent
87595286ce
commit
418ae25f3d
3 changed files with 15 additions and 1 deletions
|
|
@ -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
|
||||
}),
|
||||
}
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 ====================
|
||||
|
|
@ -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
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue