Skip to content

Commit 32da211

Browse files
authored
Remove string enum type mentions from JS & TS (#4175)
1 parent c625644 commit 32da211

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@
1313

1414
### Changed
1515

16-
* Sting enums are no longer generate TypeScript types.
16+
* String enums are no longer generate TypeScript types.
1717
[#4174](https://github.com/rustwasm/wasm-bindgen/pull/4174)
1818

1919
### Fixed
2020

2121
* Fixed generated setters from WebIDL interface attributes binding to wrong JS method names.
2222
[#4170](https://github.com/rustwasm/wasm-bindgen/pull/4170)
2323

24+
* Fix string enums showing up in JS documentation and TypeScript bindings without corresponding types.
25+
[#4175](https://github.com/rustwasm/wasm-bindgen/pull/4175)
26+
2427
--------------------------------------------------------------------------------
2528

2629
## [0.2.94](https://github.com/rustwasm/wasm-bindgen/compare/0.2.93...0.2.94)

crates/cli-support/src/js/binding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,7 @@ fn adapter2ts(ty: &AdapterType, dst: &mut String) {
14411441
AdapterType::NamedExternref(name) => dst.push_str(name),
14421442
AdapterType::Struct(name) => dst.push_str(name),
14431443
AdapterType::Enum(name) => dst.push_str(name),
1444-
AdapterType::StringEnum(name) => dst.push_str(name),
1444+
AdapterType::StringEnum => dst.push_str("any"),
14451445
AdapterType::Function => dst.push_str("any"),
14461446
}
14471447
}

crates/cli-support/src/wit/incoming.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl InstructionBuilder<'_, '_> {
110110
},
111111
Descriptor::StringEnum { name, invalid, .. } => {
112112
self.instruction(
113-
&[AdapterType::StringEnum(name.clone())],
113+
&[AdapterType::StringEnum],
114114
Instruction::StringEnumToWasm {
115115
name: name.clone(),
116116
invalid: *invalid,
@@ -312,7 +312,7 @@ impl InstructionBuilder<'_, '_> {
312312
hole,
313313
} => {
314314
self.instruction(
315-
&[AdapterType::StringEnum(name.clone()).option()],
315+
&[AdapterType::StringEnum.option()],
316316
Instruction::OptionStringEnumToWasm {
317317
name: name.clone(),
318318
invalid: *invalid,

crates/cli-support/src/wit/outgoing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl InstructionBuilder<'_, '_> {
295295
name: name.clone(),
296296
hole: *hole,
297297
},
298-
&[AdapterType::StringEnum(String::from(name)).option()],
298+
&[AdapterType::StringEnum.option()],
299299
);
300300
}
301301
Descriptor::RustStruct(name) => {
@@ -538,7 +538,7 @@ impl InstructionBuilder<'_, '_> {
538538
Instruction::WasmToStringEnum {
539539
name: name.to_string(),
540540
},
541-
&[AdapterType::StringEnum(String::from(name))],
541+
&[AdapterType::StringEnum],
542542
);
543543
}
544544

crates/cli-support/src/wit/standard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub enum AdapterType {
8686
Option(Box<AdapterType>),
8787
Struct(String),
8888
Enum(String),
89-
StringEnum(String),
89+
StringEnum,
9090
NamedExternref(String),
9191
Function,
9292
NonNull,

crates/cli/tests/reference/enums.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ export function enum_echo(color: Color): Color;
1212
export function option_enum_echo(color?: Color): Color | undefined;
1313
/**
1414
* @param {Color} color
15-
* @returns {ColorName}
15+
* @returns {any}
1616
*/
17-
export function get_name(color: Color): ColorName;
17+
export function get_name(color: Color): any;
1818
/**
19-
* @param {ColorName | undefined} [color]
20-
* @returns {ColorName | undefined}
19+
* @param {any | undefined} [color]
20+
* @returns {any | undefined}
2121
*/
22-
export function option_string_enum_echo(color?: ColorName): ColorName | undefined;
22+
export function option_string_enum_echo(color?: any): any | undefined;
2323
/**
2424
* A color.
2525
*/

crates/cli/tests/reference/enums.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ export function option_enum_echo(color) {
4646

4747
/**
4848
* @param {Color} color
49-
* @returns {ColorName}
49+
* @returns {any}
5050
*/
5151
export function get_name(color) {
5252
const ret = wasm.get_name(color);
5353
return __wbindgen_enum_ColorName[ret];
5454
}
5555

5656
/**
57-
* @param {ColorName | undefined} [color]
58-
* @returns {ColorName | undefined}
57+
* @param {any | undefined} [color]
58+
* @returns {any | undefined}
5959
*/
6060
export function option_string_enum_echo(color) {
6161
const ret = wasm.option_string_enum_echo(color == undefined ? 4 : ((__wbindgen_enum_ColorName.indexOf(color) + 1 || 4) - 1));

0 commit comments

Comments
 (0)