M
M
Mark Berezovsky2021-02-08 22:38:56
typescript
Mark Berezovsky, 2021-02-08 22:38:56

How to create a byte type using TypeScript?

Greetings.
We need a type that only accepts an integer between 0 and 255.

let n: byte = 128; // ok
let n: byte = 256; // error
let n: byte = 16.4; // error

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WbICHA, 2021-02-08
@soiran

https://stackoverflow.com/questions/39494689/is-it...
Briefly: write in the console

new Array(256).fill(0).map((_, i) => i).join(" | ")
and copy the result to type byte.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question