Skip to content

Conversation

@Hajime-san
Copy link

closes #7442

Importing example from OpenAPI3 document needs this feature.

type Value,
} from "../core/types.js";
import { getEncode, resolveEncodedName, type EncodeData } from "./decorators.js";
import { uint8ArrayToBase64 } from "./Uint8ArrayBase64Polyfill.js";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't want to copy and paste the polyfill, I can also install a polyfill library.

* const bytes = bytes.fromString("TypeSpec");
* ```
*/
init fromString(value: string);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we have this constructor it should be more explicit on what is the string(include the encoding)

cc @witemple-msft what do you think? this also could be a good use case for a parameterized constructor

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late reply.
I've added the parameter of character code as the second argument. Are there any other character codes that should be supported?

@microsoft-github-policy-service microsoft-github-policy-service bot added the compiler:core Issues for @typespec/compiler label Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:core Issues for @typespec/compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support examples for bytes

2 participants