Skip to content

Latest commit

 

History

History
49 lines (38 loc) · 1.42 KB

README.md

File metadata and controls

49 lines (38 loc) · 1.42 KB

loopback-type-definitions

Typescript definitions for loopback ⚠️ WORK IN PROGRESS ⚠️

Usage

Eventually, these will/should be added to the typings registry and installed thus.

The current hacky solution is:

  1. Use VS Code or a tool that recognizes typescript definitions in JavaScript projects
  2. Create VS Code jsconfig.json
  3. Copy these .d.ts files into your project (e.g. in a directory named /types). VS Code will automatically include them as long as you didn't exclude that directory in step 1.i
  4. Indicate that your variable is a certain type using jsdoc annotations. TODO: add link to strongblog post once it's up:

Video explanation

Video demonstrating the process described on this page

Example

/models/Customer.json

/**
 * @param {Loopback.ModelConstructor} Customer
 * @return {Loopback.ModelConstructor}
 */
module.exports = function(Customer){
  //...
  return Customer;
};

/server/model-config.js

/** 
 * @type {Loopback.ModelConfig}
 */
var conf;

conf = {
  'Customer' : {
    datasource : process.env.CUSTOMER_DATASOURCE
  }
};

module.exports = conf;

model-config.js with type-hints