You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Perf issues, poor display - why are we supporting this?
Incidental behavior that felt more correct from a perf fix.
But nobody asked for this feature...
...well, somebody did! They asked if it's something they could depend on when they discovered it.
Type display is orthogonal (plus you can add an alias which looks much better).
Tagged strings are taking a bit too much of a life of their own if we really support this. We would prefer not to embed more and more and more support.
You could imagine the use cases - a cache key that's written as a `${TypeId}|TypeId`.
Part of this really has to do with optimization. Regardless of the direction, all these scenarios need to be done performantly.
Even if we had tagged types, what would we do differently here? You'd still end up with a perf bomb if we handled things correctly, right?
The examples like type S1 = `xyz${ "hello" & { __someTag: void } }`; are not realistic, it's stuff closer to FilePath - places where you want a nominal string.
But FilePath is not an inhabited type, you are sort of lying to the type system.
Allow Intersections As Valid Types for Template Literal Placeholders
Error on Value/Import Alias Merging in
isolatedModules
#56354
isolatedModules
.isolatedModules
(andverbatimModuleSyntax
), but is pretty easy to fix - add atype
modifier.import { type writeFile } from "fs";
Preserving Tags on Primitives in Template String Types
#54648
TypeScript preserves these branded strings instead of just producing the string literal type
"xyzhello"
.History
const
template literal #54648 and says "hey is intended?"Perf issues, poor display - why are we supporting this?
Incidental behavior that felt more correct from a perf fix.
But nobody asked for this feature...
Type display is orthogonal (plus you can add an alias which looks much better).
Tagged strings are taking a bit too much of a life of their own if we really support this. We would prefer not to embed more and more and more support.
You could imagine the use cases - a cache key that's written as a
`${TypeId}|TypeId`
.Part of this really has to do with optimization. Regardless of the direction, all these scenarios need to be done performantly.
"People don't really use tagged primitive types, we shouldn't support them here" is pretty inconsistent with lots of our design decisions! They are supported as a first-class citizen in index signatures, for example.
Even if we had tagged types, what would we do differently here? You'd still end up with a perf bomb if we handled things correctly, right?
The examples like
type S1 = `xyz${ "hello" & { __someTag: void } }`;
are not realistic, it's stuff closer toFilePath
- places where you want a nominalstring
.But
FilePath
is not an inhabited type, you are sort of lying to the type system.Allow Intersections As Valid Types for Template Literal Placeholders
#54188
"abc" | "def" | string & {}
to describe an open-ended string union. Useful for tooling.`prefix${"abc" | "def" | string & {}}`
, so Allow intersections to be used as valid types for template literal placeholders #54188 was opened up.`prefix${string}`
."prefixabc" | "prefixdef" | (`prefix${string}` & {})
.Hacks to Get (-)Infinity Types
#56301
Infinity
, but you can hack around it.PositiveInfinity
is represented asnumber
because1e999
is unrepresentable.NegativeInfinity
and now say it's-1e999
which is-Infinity
.Infinity
in the type system?-
operator in the type system.-1
is a literal type, but-(1)
is not.Infinity
types?Array.prototype.flat
- legit!function testSomething(n: 0 | 1 | Infinity): void
- this is a decent jokefunction sleepSync(timeout: Infinity): never
- this is a good jokeThe text was updated successfully, but these errors were encountered: