javascript - Cannot find Dojo dijit/form/xxx inside of TypeScript class -


my problem

i've been successful creating typescript classes import dojo classes array, lang, deferred, on, dom-construct, , of that. first time, i'm trying pull of dijit stuff. specifically, dijit/form/horizontalslider , dijit/form/verticalslider. but, when compile, keep getting:

error ts2304: cannot find name 'horizontalslider' 

my code

i've got project-wide tsd.d.ts looks this:

/// <reference path="./dojo/dijit.d.ts" /> /// <reference path="./dojo/dojo.d.ts" /> 

i'm using dts mayhem, because better typings @ definitelytyped (https://github.com/sitepen/mayhem/tree/master/typings/dojo). here's definition horizontalslider:

declare module 'dijit/form/horizontalslider' {     import _formvaluewidget = require('dijit/form/_formvaluewidget');     interface horizontalslider extends _formvaluewidget {     }     export = horizontalslider; } 

edit: clarify syntax, based on ryan cavanaugh's response, here dropdownbutton same dts:

declare module 'dijit/form/dropdownbutton' {     import button = require('dijit/form/button');     interface dropdownbutton extends button {     }     var dropdownbutton:{         new (kwargs?:object, srcnoderef?:htmlelement):dropdownbutton;     };     export = dropdownbutton; } 

finally, in class, things should, this:

/// <reference path="./../typings/tsd.d.ts" />  import horizontalslider = require('dijit/form/horizontalslider');  class mydijit {     constructor() {         var foo = new horizontalslider(...);     } } 

and, dreaded ts2304.

what i've tried

it seems compiler can't see dijit dts. so, tried adding dts grunt-typescript task.

typescript: {     build: {     src: ['src/**/*.ts', 'typings/tsd.d.ts'],     options: {         module: 'amd',         target: 'es3',         sourcemap: true,         declaration: false     } } 

i tried updating tsconfig.json

{     "compileroptions": {         "declaration": false,         "module": "amd",         "noimplicitany": true,         "target": "es3",         "filesglob": [             "./src/**/*.ts",             "./typings/tsd.d.ts"         ]     } } 

that didn't help, either! lastly, thinking compiler stripping classes being unused, tried this:

/// <amd-dependency path="dijit/form/horizontalslider"/> 

and, no luck. so, here on stack overflow hoping someday has gotten dijit/form/xxx compile inside of typescript class. there's 1 similar question, not quite same: typescript cannot find name though referenced

declare module 'dijit/form/horizontalslider' {     import _formvaluewidget = require('dijit/form/_formvaluewidget');     interface horizontalslider extends _formvaluewidget {     }     export = horizontalslider; } 

what have here module exports type (not value), hence cannot new (see "difference between declare class , interface"). seems want module exports class instead:

declare module 'dijit/form/horizontalslider' {     import _formvaluewidget = require('dijit/form/_formvaluewidget');     class horizontalslider extends _formvaluewidget { // interface -> class     }     export = horizontalslider; } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -