Coder Social home page Coder Social logo

Comments (2)

lrhn avatar lrhn commented on July 3, 2024 1

It's intended.
The only reason implements Object looks weird is that you're not used to needing to implement Object, because all classes (other than Null) are automatically subtypes of Object, and all record and function types are subtypes of `Object.

There are very few types in the pre-extension-type type system that don't automatically implement Object.
The one exception is type variables, a foo<T>() { ... T ...} introduces a type which is not a subtype of Object. To make sure that it is, you have to write <T extends Object>.
You can sometimes think of extension types in the same way. Extension types don't automatically become subtypes of Object, because they are types, not classes. And if you want them to, you have to add implements Object.
And you can only do that if the representation type is itself a subtype of Object, which it doesn't have to be.

An extension type like:

extension type const Opt<T>._(({T value})? _) {
  const Opt.value(T value) : this._((value: value));
  const Opt.none() : this._(null);
}

has a nullable representation type, and cannot implement Object.

from sdk.

iapicca avatar iapicca commented on July 3, 2024

An extension type like:

extension type const Opt<T>._(({T value})? _) {
  const Opt.value(T value) : this._((value: value));
  const Opt.none() : this._(null);
}

has a nullable representation type, and cannot implement Object.

yeah, makes sense thank you for your answer @lrhn

from sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.