Comments (4)
Yeah, the pattern used with DeclareConstructor makes this a sticky issue to resolve.
It's usage should be OK with declare
, but I was trying to extend Evented
like a class
export default class<T> extends Evented implements StateMachineEvents<T> {
Which results in the error
error TS2510: Base constructors must all have the same return type.
The error may be due to Evented having two different constructors:
interface EventedConstructor extends _base.DeclareConstructor<Evented> {
new (params?: Object): Evented;
}
interface DeclareConstructor<T> {
new (...args: any[]): T & DeclareCreatedObject;
I was able to resolve by "fixing" the typings
export interface FixedEventedConstructor {
new (params?: Object): dojo.Evented;
}
export const FixedEvented: FixedEventedConstructor = <any> Evented;
I haven't had a chance to play with TypeScript 2.2. Hopefully we'll be able to define mixin classes as purely ambient declarations that return functional constructors. If we have to apply it as a pattern in code and actually have to return a class that extends from a declare statement, I would be concerned about losing the metadata added by declare to allow for functional chaining via inherited
. Hopefully it'll be the former and we'll have a good way of declaring define
.
Anyway, all of this created a rabbit hole I knew I didn't want to go down on my own.
from typings.
@mmckenziedev have you run into an issue with this yet?
from typings.
@dylans I haven't had problems using Declare to mix this in to other classes.
I agree that technically this class is an ES5 class and shouldn't use DeclareConstructor. However, in practice, if you're using Declare to create a new class and you try to mix this in, if it is not a DeclareConstructor then it won't work properly due to the way Declare is defined.
_base.d.ts#L620
If it's not breaking anything I would prefer to leave this as it is for now. When Typescript 2.2 comes out, and we can finally have a better expression syntax for mixins, then we could refactor the way Declare works.
https://github.com/Microsoft/TypeScript/wiki/Roadmap#22-february-2017
microsoft/TypeScript#13743
from typings.
This issue bit me as well. Is #113 (comment) the prescribed way around it for now?
from typings.
Related Issues (20)
- Add widget example HOT 5
- Missing Grunt task configuration options causes build to fail HOT 1
- Update "basicApp" example to include translation bundles
- Cannot find name ActiveXObject HOT 5
- Compile errors with TypeScript 2.4.1 HOT 3
- Issues with noimplicitany and dijit
- Typo in NumberFormatOptions definition HOT 1
- Module name dgrid/extensions/Dnd has incorrect case HOT 1
- Typings for dstore/Tree are missing HOT 1
- Intern and leadfoot cause error TS2307: Cannot find module 'dojo/Promise'.
- Errors with Typescript 2.6 using --strictFunctionTypes HOT 1
- Property 'inherited' does not exist on type <...> HOT 1
- Is the dojo/fx/Toggler functional? HOT 1
- ComboBox incorrectly typed
- declareDecorator does not bring along getters and setters
- dojox/widget/Standby typings are missing
- Incorrect declare typings
- EventedConstructor has two constructors of different types HOT 4
- Adding dojox/rpc/Service
- DocumentEvent - Cannot find name DocumentEvent HOT 1
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 typings.