Comments (4)
You can use !
to bypass linter:
class Point {
x!: i32;
y!: i32;
}
or
class Point {
x: i32 = 0;
y: i32 = 0;
}
from assemblyscript.
That's PEDANTIC. You can safely ignore that.
from assemblyscript.
@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.
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)
- incorrect variable resolving for class default initializer
- asc crash when use same name in class and namespace HOT 1
- missing diagnose for interface with initialized field
- compiler crash HOT 1
- Hello HOT 1
- AS supports WASMGC? HOT 6
- Blazor Web App (Server) .NET8.0 call Web API with MVC HOT 1
- Compiler failing at optimization step with a big .ts file HOT 13
- The results of arithmetic operations with u8 are not truncated to 8 bits, when assigned to f64 HOT 1
- Stale Memory Reads HOT 17
- I look at the source code and find that there is code related to wasmGC, will wasmGC be supported soon? HOT 1
- npx asinit .
- Incorrect overriden function call HOT 2
- `env` module isn't imported, using `moduleImports` and `--importMemory` together
- I hope compiling to native binary was added for AssemblyScript. HOT 1
- Loop and variable bug HOT 2
- as crash when try to alloc large data HOT 2
- crash when shifting BigInt HOT 1
- Can't get export info in transform without reloading the module HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from assemblyscript.