mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 19:51:53 +00:00
Move all packages to a types directory
This commit is contained in:
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// Type definitions for JSDataAngular v2.1.0
|
||||
// Project: https://github.com/js-data/js-data-angular
|
||||
// Definitions by: Stefan Steinhart <https://github.com/reppners>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="js-data" />
|
||||
/// <reference types="angular" />
|
||||
|
||||
import * as JSData from 'js-data';
|
||||
import * as ng from 'angular';
|
||||
|
||||
declare module 'js-data' {
|
||||
|
||||
interface DSProvider {
|
||||
defaults:DSConfiguration;
|
||||
}
|
||||
|
||||
interface DS {
|
||||
bindAll<T>(resourceName:string, params:DSFilterParams, scope:ng.IScope, expr:string, cb?:(err:DSError, items:Array<T & DSInstanceShorthands<T>>)=>void):Function;
|
||||
bindOne<T>(resourceName:string, id:string | number, scope:ng.IScope, expr:string, cb?:(err:DSError, item:T & DSInstanceShorthands<T>)=>void):Function;
|
||||
}
|
||||
|
||||
interface DSResourceDefinition<T> {
|
||||
bindAll(params:DSFilterParams, scope:ng.IScope, expr:string, cb?:(err:DSError, items:Array<T & DSInstanceShorthands<T>>)=>void):Function;
|
||||
bindOne(id:string | number, scope:ng.IScope, expr:string, cb?:(err:DSError, item:T & DSInstanceShorthands<T>)=>void):Function;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import * as JSData from 'js-data';
|
||||
import * as ng from 'angular';
|
||||
import * as angular from 'angular';
|
||||
|
||||
interface IUser {
|
||||
|
||||
}
|
||||
|
||||
interface CustomScope extends ng.IScope {
|
||||
|
||||
comments: Array<any>;
|
||||
user: IUser;
|
||||
users: Array<IUser>;
|
||||
}
|
||||
|
||||
angular.module('myApp')
|
||||
.controller('commentsCtrl', function ($scope:CustomScope, store:JSData.DS, Comment:JSData.DSResourceDefinition<any>, User:JSData.DSResourceDefinition<any>) {
|
||||
|
||||
Comment.findAll().then(function (comments) {
|
||||
$scope.comments = comments;
|
||||
});
|
||||
|
||||
// shortest version
|
||||
User.bindOne(1, $scope, 'user');
|
||||
|
||||
// short version
|
||||
store.bindOne('user', 1, $scope, 'user');
|
||||
|
||||
// long version
|
||||
$scope.$watch(function () {
|
||||
return store.lastModified('user', 1);
|
||||
}, function () {
|
||||
$scope.user = store.get<IUser>('user', 1);
|
||||
});
|
||||
|
||||
var params = {
|
||||
where: {
|
||||
age: {
|
||||
'>': 30
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// shortest verions
|
||||
User.bindAll(params, $scope, 'users');
|
||||
|
||||
// short version
|
||||
store.bindAll('user', params, $scope, 'users');
|
||||
|
||||
// long version
|
||||
$scope.$watch(function () {
|
||||
return store.lastModified('user');
|
||||
}, function () {
|
||||
$scope.users = store.filter('user', params);
|
||||
});
|
||||
});
|
||||
|
||||
angular.module('myApp')
|
||||
.run(function (DS:JSData.DS) {
|
||||
// We don't register the "User" resource
|
||||
// as a service, so it can only be used
|
||||
// via DS.<method>('user', ...)
|
||||
// The advantage here is that this code
|
||||
// is guaranteed to be executed, and you
|
||||
// only ever have to inject "DS"
|
||||
DS.defineResource('user');
|
||||
})
|
||||
.factory('Comment', function (DS:JSData.DS) {
|
||||
// This code won't execute unless you actually
|
||||
// inject "Comment" somewhere in your code.
|
||||
// Thanks Angular...
|
||||
// Some like injecting actual Resource
|
||||
// definitions, instead of just "DS"
|
||||
return DS.defineResource('comment');
|
||||
});
|
||||
|
||||
angular.module('myApp')
|
||||
.config(function (DSProvider:JSData.DSProvider) {
|
||||
DSProvider.defaults.basePath = '/myApi'; // etc.
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"js-data-angular-tests.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user