Skip to content

Design Meeting Notes, 11/15/2023 #56437

Closed
@DanielRosenwasser

Description

@DanielRosenwasser

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design NotesNotes from our design meetings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions