Giter Site home page Giter Site logo

Comments (4)

MaxGraey avatar MaxGraey commented on June 9, 2024 5

You can use ! to bypass linter:

class Point {
  x!: i32;
  y!: i32;
}

or

class Point {
  x: i32 = 0;
  y: i32 = 0;
}

from assemblyscript.

CountBleck avatar CountBleck commented on June 9, 2024 1

That's PEDANTIC. You can safely ignore that.

from assemblyscript.

a-skua avatar a-skua commented on June 9, 2024

@MaxGraey
Thanks for the info!
However, it seems that ! is not currently supported in AS.

PEDANTIC AS906: Unnecessary definite assignment.
    :
 19 │ x!: i32;
    │ ~
    └─ in assembly/index.ts(19,3)

PEDANTIC AS906: Unnecessary definite assignment.
    :
 20 │ y!: i32;
    │ ~
    └─ in assembly/index.ts(20,3)

Therefore, it would be written like this.

class Point {
  x: i32 = 0;
  y: i32 = 0;
}

But what I want to do here is not initializing with zero, but defining a type.
I understand that AS is like TS but is a different language. How closely do you intend to mimic TS syntax?

https://www.assemblyscript.org/compiler.html#host-bindings

Type Strategy Description
Object Copy If a plain object. That is: Has no constructor or non-public fields.
Object By reference If not a plain object. Passed as an opaque reference counted pointer.

This proposal arose from the observation that "no constructor" classes are treated differently than regular classes, prompting the question of whether we could adopt a writing style closer to TS.

I'm now thinking that supporting ! instead of type aliases would also be acceptable.

class Point {
  x!: i32;
  y!: i32;
}

from assemblyscript.

a-skua avatar a-skua commented on June 9, 2024

I see, I misunderstood PEDANTIC as a build failure. It's already supported.
The issue is resolved, so I'll close this. Thank you for your help!

from assemblyscript.

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.