Comments (1)
It looks like this is the expected behavior with types that define get
/set
methods (both by Object.defineProperties and es6 class
definitions):
class Foo {
get label() {
return 1;
}
}
a = {...new Foo()}
a.label
yield undefined. If the get/set method is on an object rather than a type, the value is returned as expected:
var a = {
get b() { return 'b' },
};
var b = { ...a }
b.b
returns the string "b"
.
Typescript understands this, but only to a point - classes are understood to have get methods that won't be enumerable, but once you add an interface into the picture, it no longer works:
interface IFoo {
get label(): string;
}
class Foo implements IFoo {
get label() {
return 'foo';
}
}
const foo = new Foo();
const ifoo: IFoo = new Foo();
const a = { ...foo };
const b = { ...ifoo };
In the above, a
is recognized to have no properties, but as of 5.4.5, TS believes that b
has a label
string, whereas in reality it is undefined.
The https://github.com/Vertispan/jsinterop-ts-defs/ project is already emitting as correct of TS as we can, with the equivelent of the interface IFoo
above having get/set methods on it. In theory something like microsoft/TypeScript#9726 could provide a way to explicitly indicate that these property accessors aren't enumerable, but from the TS example above, I'm inclined to think this might just be a bug in TS rather than a missing feature.
We could make a feature request at https://github.com/google/jsinterop-annotations/ to specify a new JsProperty#enumerable
, but it might need to be tri-state, or specific to decorating methods rather than properties (since Java fields would be enumerable by default, as they are properties on the underlying js object, while java methods would not be enumerable, since they are on the class).
I'll leave this open for later discussion, but at this time we're not considering this to be a bug.
from gwt.
Related Issues (20)
- SDM BindException: Address already in use
- GWT compiling issue in java 11 HOT 2
- Spurious incremental CompilerTest failure
- GWT 2.11 and Jetty 9.4.54.v20240208 error running in IntelliJ 2024.1 Ultimate HOT 3
- SDM (Super Dev Mode) does not work with a strong CSP (Content Security Policy)
- Draft compile with compiler.stackMode=strip seems to break stack trace deobfuscation with sourcemaps HOT 1
- Upgrade to HtmlUnit 3.9.0 or 4.1.0 HOT 2
- Upgrade icu4j to a version > 63.1
- Memory leak in stored exceptions HOT 8
- Issue with com.google.gwt.i18n.client.TimeZone in GWT 2.11 for Africa/Cairo Time Zone HOT 4
- Add Java 9 BigInteger methods sqrt and sqrtAndRemainder
- GWT from 2.9 to 2.11 Migration Issue Could not find com.google.gwt:gwt-codeserver:2.11.0. HOT 1
- Remove onLoadErrorFn/onPropertyErrorFn, or make them easier to disable
- Upgrading to GWT 2.10.1 is causing IncompatibleRemoteServiceException HOT 1
- GWT Issue with JDK 17 HOT 1
- Whitespace check inconsistency HOT 2
- closure-compiler build requires extra annotations to scan classes HOT 1
- Annotating an interface method with @JsProperty can produce runtime errors if jsinterop exports are not enabled HOT 1
- java.lang.Math is missing nextUp, nextDown, nextAfter emulation
- Upgrade from gwt 2.0.0 to 2.11.0 erroring out HOT 4
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 gwt.