How to type ASCII symbols using Typescript?

Viewed 40

I have series of similar functions that use ASCII symbols internally to perform checks

if (x.charCodeAt(pos) === 0x5f) { 
    // do something...
} 

Now I’m trying to refactor these functions abstracting them into a reusable “parent” function that is supposed to receive a particular ASCII symbol as an argument.

// function definition:
function reusable(ASCIISymbol) {
    if (x.charCodeAt(pos) === ASCIISymbol) { 
        // do something... 
    } 
}

// function call:
reusable(0x5f)

My doubt is how to correctly type ASCIISymbol using Typescript?

function reusable(ASCIISymbol: ???) { ... } 
0 Answers
Related