USVString type definition
See original GitHub issueTypeScript Version: 3.2.0-dev.201xxxxx
Search Terms: USVString
Code
function example(uri: USVString) {
// Do some work
}
Expected behavior:
Until typescript version 3.0.3 USVString used to be an existing type defined in lib.dom.d.ts
in version 3.1, according to the breaking changes page, some vendor-specific types are removed from lib.d.ts, a full list of removed types is included.
USVString is not on that list, yet it’s type definition was also removed.
USVString is defined under webIDL, as can be seen here.
Actual behavior:
error TS2304: Cannot find name 'USVString'.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
USVString type definition · Issue #28775
Some of our modules as well as some external NPM modules we are using need USVString as a type. Even though I agree...
Read more >USVString
USVString corresponds to the set of all possible sequences of unicode scalar values. USVString maps to a String when returned in JavaScript; ...
Read more >USVString - Web APIs - W3cubDocs
A USVString is a sequence of Unicode scalar values. This definition differs from that of DOMString or the JavaScript String type in that...
Read more >USVString - Web APIs | MDN - Web technology for developers
A USVString is a sequence of Unicode scalar values. This definition differs from that of DOMString or the JavaScript String type in that...
Read more >String is USV String details
The WebAssembly Interface Types proposal also restricts string values to lists of Unicode Scalar Values, as polled in a recent CG meeting. Interfacing ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have been pretty much bothered with the way typescript handles
USVString
as aString
To me they don’t seem to be the same thinga USVString dose lots of conversion casting mostly anything to a string, it deals with
Symbol.toStringTag
,toString()
and defaulting values by doing something likeString(null_or_whatever)
Here are some example
TS throws for using fetch in this way…
https://github.com/microsoft/TypeScript/blob/cec2fda9a53620dc545a2c4d7b0156446ab145b4/lib/lib.dom.d.ts#L19650
it shouldn’t be a regular string. It should be a USVString instead!
Same thing with blobs! it’s totally legit to do:
new Blob([{}])
if you want to do something like this, you could provide a own custom class that has atoString
method and have it workingOur IDL-based generator just interprets
USVString
as an alias forstring
, because it effectively is. Do you still need atype USVString = string
alias in the lib? The lib itself stopped using it because it was rather pointless.