Comments (3)
If I could give some input, the best of my efforts is to use the following:
declare class Base {
workBase();
static Sub: typeof Base$Sub;
}
declare class Base$Sub {
workBaseSub();
}
declare class Derived extends Base {
workDerived();
static Sub: typeof Base.Sub & typeof Derived$Sub; // halt type-check only if there are conflicts with base classes, or just return any & Derived$Sub
}
declare class Derived$Sub {
workDerivedSub();
}
It however promises classes to be exposed as Base$Sub / Derived$Sub (this is valid JS identifier).
It can be then used as:
var b = new Base();
b.workBase();
var bs = new Base.Sub(); // Please note this approach still supports the dot subclass
bs.workBaseSub();
var d = new Derived();
d.workDerived();
d.workBase();
var ds = new Derived.Sub(); // Please note this approach still supports the dot subclass
// The Derived.Sub is magically resolved as Derived$Sub, although IMO this is a TS type system bug. we will probably have to use `any` if they fix this.
ds.workDerivedSub();
And then it would require us to use Derived$Sub when we refer to such conflicting nested classes.
from android-dts-generator.
There is an issue with the current representation of sub-classes in the typescript definition files.
Imagine this simplified example:
declare module A {
export class Class1 {
}
export module Class1 {
export class SubClass {
public methodBase(): void;
}
}
}
declare module B {
export class Class2 extends A.Class1 {
}
export module Class2 {
export class SubClass {
}
}
}
Currently Class2
blows up with:
[ts] Class static side 'typeof Class2' incorrectly extends base class static side 'typeof Class1'.
Types of property 'SubClass' are incompatible.
Type 'typeof B.Class2.SubClass' is not assignable to type 'typeof A.Class1.SubClass'.
Type 'B.Class2.SubClass' is not assignable to type 'A.Class1.SubClass'.
Property 'methodBase' is missing in type 'SubClass'.
Which means, SubClass
in Class2
can't have the same name as SubClass
in Class1
. At least not with the current syntax using module
or namespace
syntax, the way we do currently. This is a typescript compiler limitation. Unfortunately java compiler has no such issues.
This example is simplification of the android framework structure.
Class1
represents android.view.View
SubClass
in Class1
represents: AccessibilityDelegate
Class2
represents android.support.v4.widget.NestedScrollView
SubClass
in Class2
represents: AccessibilityDelegate
In the real scenario android.support.v4.widget.NestedScrollView
inherits indirectly android.view.View
, but the result is the same.
from android-dts-generator.
Closing this as I consider it resolved. Type inheritance is clear in the current state of the generated typings. The android.view.ViewGroup
class for example will extend android.view.View
and implement android.viewViewParent
, as well as android.view.ViewManager
, and declare their public members
from android-dts-generator.
Related Issues (20)
- Error: Unable to access jarfile buildlibsdts-generator.jar HOT 1
- Java class with static member and public nested/inner class collide
- Add tests
- [Windows] gradlew extractAllJars fails due to invalid symbols in file paths HOT 6
- Error on Iterable and other generics and base-classes HOT 3
- Error when trying to generate definitions HOT 2
- some classes are missing there parent class HOT 3
- Add @deprecation to deprecated java methods
- Invalid byte tag in constant pool: 19 HOT 13
- Update readme
- Error java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
- some generic classes are not reported as generic
- remove ofuscated classes
- ./gradlew jar not working HOT 3
- Support generic (non-Android) uses HOT 1
- Could you please add a license to the repo? HOT 1
- Recover method parameter names for generated files
- Resolve generics properly and don't include unnamed modules
- Sometimes types generates `any<...>` which breaks tsc
- dont add some namespace using forbidden words in javascript
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 android-dts-generator.