-
-
Notifications
You must be signed in to change notification settings - Fork 485
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(isolated-declarations): transform const expression correctly
- Loading branch information
Showing
4 changed files
with
92 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
crates/oxc_isolated_declarations/tests/fixtures/as-const.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const F = { | ||
string: `string`, | ||
templateLiteral: `templateLiteral`, | ||
number: 1.23, | ||
bigint: -1_2_3n, | ||
boolean: true, | ||
null: null, | ||
undefined: undefined, | ||
function(a: string): void {}, | ||
arrow: (a: string): void => {}, | ||
object: { | ||
a: `a`, | ||
b: `b` | ||
}, | ||
array: [`a`, , { b: `\n` }], | ||
} as const |
22 changes: 22 additions & 0 deletions
22
crates/oxc_isolated_declarations/tests/snapshots/as-const.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
source: crates/oxc_isolated_declarations/tests/mod.rs | ||
input_file: crates/oxc_isolated_declarations/tests/fixtures/as-const.ts | ||
--- | ||
==================== .D.TS ==================== | ||
|
||
declare const F: { | ||
readonly string: 'string'; | ||
readonly templateLiteral: 'templateLiteral'; | ||
readonly number: 1.23; | ||
readonly bigint: -1_2_3n; | ||
readonly boolean: true; | ||
readonly null: null; | ||
readonly undefined: undefined; | ||
readonly function: (a: string) => void; | ||
readonly arrow: (a: string) => void; | ||
readonly object: { | ||
readonly a: 'a'; | ||
readonly b: 'b'; | ||
}; | ||
readonly array: readonly ['a', undefined, { readonly b: '\n'}]; | ||
}; |