GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Object strict literal assigment checking is omitted for the empty type · Issue #4463 · microsoft/TypeScript

Object strict literal assigment checking is omitted for the empty type #4463

New issue
Copy link
New issue
Copy link
Closed
Closed
Object strict literal assigment checking is omitted for the empty type#4463
Copy link
Labels
By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadDeprecated - use "Working as Intended" or "Design Limitation" instead

Description

@zpdDG4gta8XKpMCd
ZpdDG4gta (zpdDG4gta8XKpMCd)
opened on Aug 26, 2015
Issue body actions

in #3823

interface A {
}
var a : A = { // valid code, but expected a problem in 1.6, since x, y, z don't belong to A 
    x: 1,
    y: 2,
    z: 3
};

Activity

  1. danquirk commented on Aug 26, 2015

    @danquirk
    Dan Quirk (danquirk)
    on Aug 26, 2015
    Member
    More actions

    Ryan had proposed a rule that would error here if A at least had some optional members, but not if it was empty. I'm not sure what the rationale was for not erroring against empty types as well: #3842

  2. Ryan Cavanaugh (RyanCavanaugh)
    added
    By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadDeprecated - use "Working as Intended" or "Design Limitation" instead
    on Aug 26, 2015
  3. RyanCavanaugh commented on Aug 26, 2015

    @RyanCavanaugh
    Ryan Cavanaugh (RyanCavanaugh)
    on Aug 26, 2015
    Member
    More actions

    Lots of people use {} in place of any because they don't want accidental anys creeping in, but still want something that's assignable from anything. Erroring on object literals assigned to {} is kind of pointless because, if we did, there would be nothing valid you could have written -- if you really wanted a type that couldn't be assigned from any non-null/undefined value, void is there.

  4. Ryan Cavanaugh (RyanCavanaugh)
    closed this as completedon Aug 26, 2015
  5. zpdDG4gta8XKpMCd commented on Aug 26, 2015

    @zpdDG4gta8XKpMCd
    ZpdDG4gta (zpdDG4gta8XKpMCd)
    on Aug 26, 2015
    Author
    More actions

    Are values of void now officially a part of the language? Thought they were leaving.

  6. RyanCavanaugh commented on Aug 26, 2015

    @RyanCavanaugh
    Ryan Cavanaugh (RyanCavanaugh)
    on Aug 26, 2015
    Member
    More actions

    The void type isn't going anywhere. The only thing we've been warning people of using the crazy number|void thing to fake non-nullability.

  7. zpdDG4gta8XKpMCd commented on Aug 26, 2015

    @zpdDG4gta8XKpMCd
    ZpdDG4gta (zpdDG4gta8XKpMCd)
    on Aug 26, 2015
    Author
    More actions

    Can's say I see your point:

    The void type isn't going anywhere.

    Fine, since it's just a type let's keep it. I was talking about values of type void which sort of don't make sense since void by definition represents a lack of value. The only type that doesn't have a value yet is assignable from null and undefined (what might this mean?).

    warning people of using the crazy number|void thing

    Why would you warn? With all what's above number|void seems 100% legit (void is just another type that, hm, has values, remember?). Although I agree as far as making sense it fails, just like the idea of a legit value of void does.

    thing to fake non-nullability

    Business sees value in it and wants it. I would not call it faking unless proven otherwise. If number|void gives hard feelings how about a memberless enum?

    const enum Nothing {}

    Ugh, Nothing | number don't play nice together, dang, lets go back to void.

  8. zpdDG4gta8XKpMCd commented on Aug 26, 2015

    @zpdDG4gta8XKpMCd
    ZpdDG4gta (zpdDG4gta8XKpMCd)
    on Aug 26, 2015
    Author
    More actions

    just thought you guys might be interested https://github.com/aleksey-bykov/by-design-script/blob/master/README.md#literal-strictness

  9. microsoft
    locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.