fritz_da_silva
fritz_da_silva

Reputation: 101

Typescript type/interface for strings of a given length

Say my function f takes an argument, x, of type string. But not any string, only strings of length n.

Is it possible to enforce this using the type system?

Upvotes: 4

Views: 1495

Answers (1)

toskv
toskv

Reputation: 31600

No, it is not possible to do this in Typescript as types.

Upvotes: 2

Related Questions