Typescript definitions for loopback
Eventually, these will/should be added to the typings registry and installed thus.
The current hacky solution is:
- Use VS Code or a tool that recognizes typescript definitions in JavaScript projects
- Create VS Code
jsconfig.json
- 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 - Indicate that your variable is a certain type using jsdoc annotations. TODO: add link to strongblog post once it's up:
- see example below
/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;