Coder Social home page Coder Social logo

typings's Introduction

dojo/typings

Build Status npm version

This is a repository of Dojo 1 TypeScript Typings (including Dijit and DojoX).

Currently, this reopsitory does not include all the typings for Dijit and DojoX, although Dojo is currently fully covered. The aim is to cover all of Dijit and continue to accept any community contributions for DojoX.

For other packages, because Dojo 2 is built on TypeScript and therefore its typings are inherit in its distrubution. The goal for affiliated Dojo 1 projects (like dgrid and dstore is that they will include typings as part of their repository.

Usage

Because Dojo, Dijit and DojoX are such large and complex code bases, the repository tries to break it down into easier to maintain pieces that also allow easy additions, modifications, etc.

Each major namespace is broken down into dojo, dijit and dojox directories, having the major version number in a sub directory within. Currently only Dojo 1.11 is included. These typings should work for most older versions of Dojo post 1.7, though it may include some functionality that is not present in those older releases.

The ambient declarations that mirror the Dojo namespaces are indexed via the index.d.ts file located in each directory and the ambient module names are then declared in a single file for the namespace called modules.d.ts. To utilise in a project, where you are going to import several modules via an AMD loader, you would likely just need to reference the modules.d.ts. If you need to modify the names of the ambient modules to match your runtime environment, then you would copy the modules.d.ts and rename all the modules as required.

Basic usage would be to include the index.d.ts and likely modules.d.ts in files used either by tsc or in your tsconfig.json or referenced within your TypeScript files. The wiki contains some basic how to instructions.

The easiest way to install the typings is via npm:

> npm install dojo-typings --save-dev

Building

The repository has a Gruntfile.js and a development dependency of grunt that can help validate any changes to the typings. After cloning the repository and running npm install, you can then run grunt or grunt dev which will compile the files with tsc as well as run tslint against the core files.

Examples

There are examples of how to use the typings in a TypeScript project located in the examples directory of this repository.

Limitations

Typings are global

At the time of this writing (TypeScript 1.7/1.8), typings are global and absolute. In order to change module resolution from dojo/... the modules.d.ts will need to be updated.

String Literals

The current typings are build around TypeScript 1.7. TypeScript 1.8 introduced string literal types and there are improvements that can be made to the typings, several of them noted as comments in the existing typings.

Note while the repository currently uses TypeScript 1.8 as its development dependency we haven't started using the string literals yet, as TypeScript 1.8 isn't yet GA.

AMD Plugin Globbing

Currently, TypeScript does not support globbing of AMD modules. There is an open ticket for this type of support (see Microsoft/TypeScript#5787). Until that is done, in order to use a plugin properly, you will have to declare the ambient module in a projects .d.ts. For example to use dojo/text you would want to do something like this:

declare module 'dojo/text!./path/to/some.html' {
    const some: string;
    export = some;
}

Contributing

Contributions to this repository are very much welcomed! If you wish to contribute to this repository, please see our Contributing Guidelines.

typings's People

Contributors

kitsonk avatar bitranch avatar dasa avatar jcfranco avatar jkieboom avatar agubler avatar cdschmitz avatar jacobroufa avatar matt-gadd avatar ycabon avatar

Watchers

Mangala Khalsa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.