Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design Meeting Notes, 11/15/2023 #56437

Closed
DanielRosenwasser opened this issue Nov 16, 2023 · 0 comments
Closed

Design Meeting Notes, 11/15/2023 #56437

DanielRosenwasser opened this issue Nov 16, 2023 · 0 comments
Labels
Design Notes Notes from our design meetings

Comments

@DanielRosenwasser
Copy link
Member

Error on Value/Import Alias Merging in isolatedModules

#56354

// @isolatedModules: true

import { writeFile } from "fs";

const writeFile = ...;
  • Some compilers say that if an import exists with the same name as a module-local value binding, the import must be a type (and thus can be elided).
  • Seems kind of questionable.
  • isolatedModules error on alias merging with local value #56354 changes the behavior to error under isolatedModules.
  • It's a breaking change under isolatedModules (and verbatimModuleSyntax), but is pretty easy to fix - add a type modifier.
    • import { type writeFile } from "fs";
  • Not much seems to break.
  • We vote yes, make the change for 5.4.

Preserving Tags on Primitives in Template String Types

#54648

type S1 = `xyz${ "hello" & { __someTag: void } }`;

Allow Intersections As Valid Types for Template Literal Placeholders

#54188

  • Libraries (like csstype) use "abc" | "def" | string & {} to describe an open-ended string union. Useful for tooling.
  • People ended up wanting to preserve these in literal types like `prefix${"abc" | "def" | string & {}}`, so Allow intersections to be used as valid types for template literal placeholders #54188 was opened up.
  • If you preserve the intersection, you can still get tooling benefits. If you don't, then the entire type will be subsumed by `prefix${string}`.
  • There is a way to manually preserve as "prefixabc" | "prefixdef" | (`prefix${string}` & {}).
  • We don't like this, but it's the best we have.

Hacks to Get (-)Infinity Types

#56301

type PositiveInfinity = 1e999;
type NegativeInfinity = -1e999;

type TypeofInfinity = typeof Infinity;
type TypeofNaN = typeof NaN;
  • We have not permitted Infinity, but you can hack around it.
  • In 5.3, PositiveInfinity is represented as number because 1e999 is unrepresentable.
  • Missed a case for negation so in TypeScript 5.3, we do the wrong thing for NegativeInfinity and now say it's -1e999 which is -Infinity.
  • Can we just support Infinity in the type system?
    • Well we don't have a - operator in the type system. -1 is a literal type, but -(1) is not.
  • Are people actually using these Infinity types?
  • Conclusion: Let's revert and try to work out how Infinity works in the type system.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design Notes Notes from our design meetings
Projects
None yet
Development

No branches or pull requests

2 participants