New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preparing a set of independent typings #19
Comments
I'm sorry, I'm not sure what the question is. What incompatibilities have you run into? |
I think that you should install the typings install -S github:phreed/npm-webgme#5a79adcf0051c6fc8b0b0500c4f7dcd56fdebdd4 This will install the definitions in @blakeembrey I think he's just looking for the command to install the definitions (maybe we should an example of installation from github in the |
I am working through the process of preparing a set of typings independent of the source javascript. |
The next puzzle is how to get the imports to align with the definitions and source. The JavaScript for which the TypeScript descriptions are being created. /**
* Serializes this object to a JSON representation.
*
* @returns {object}
*/
PluginConfig.prototype.serialize = function () {
var keys = Object.keys(this);
... https://github.com/webgme/webgme/blob/master/src/plugin/PluginConfig.js A candidate import for the libraryimport PluginConfig = require("plugin/PluginConfig"); https://github.com/phreed/webgme-immortals/blob/typescript/src/plugins/push/push.ts The attempt to describe the classdeclare module plugin {
interface PluginConfig {
serialize(): any;
}
interface PluginBase {
activeNode: any;
activeSelection: any[];
blobClient: any;
... https://github.com/phreed/npm-webgme/blob/master/index.d.ts These are inconsistent. |
I'll just start with a little advice if you use TS, you can use the ES6 syntax for your imports: import * as PluginConfig from "plugin/PluginConfig"; And just another note: Now, back to your problem: Why isn't the import Anyway, given your definition, you should be able to consume it as: import * as webgme from "webgme";
webgme.addCommitToResult("status"); // this is now type-checked
// ... |
Correct. I have not found a simple description of how the import, usage and type-description work together. Here is an example (some repetition from the post above). A JavaScript 'plugin/PluginConfig.js' for which the TypeScript descriptions are being created.Here is one plugin module, there are others. define([], function () {
'use strict';
var PluginConfig = function (config) {
if (config) {
var keys = Object.keys(config);
for (var i = 0; i < keys.length; i += 1) {
this[keys[i]] = config[keys[i]];
}
}
};
PluginConfig.prototype.serialize = function () {
var keys = Object.keys(this);
var result = {};
for (var i = 0; i < keys.length; i += 1) {
result[keys[i]] = this[keys[i]];
}
return result;
};
return PluginConfig;
}); https://github.com/webgme/webgme/blob/master/src/plugin/PluginConfig.js A candidate import from the library.This is apparently wrong but I do not know why. import PluginConfig = require("plugin/PluginConfig");
let pb = new PluginConfig(config); https://github.com/phreed/webgme-immortals/blob/typescript/src/plugins/push/push.ts import * as webgme from "webgme";
webgme.addCommitToResult("status"); ...would even work as 'webgme' is a module/namespace and 'addCommitToResult("status")' An attempt to describe the classI am pretty sure my type description is wrong. Is there a good example of a similar project that I could look at? |
Actually, don't do that. The interop capability would cost you. I used to also advice the same, but now I have changed my mind. See: |
#25 resolved the issues. |
I have a framework library written in javascript.
https://github.com/webgme/webgme
The documentation looks reasonable.
https://editor.webgme.org/docs/source/PluginBase.html
As a first step in prepaing to use typing, I made a typing project and filled in a few interfaces by hand.
https://github.com/phreed/npm-webgme
I have a project that uses the webgme library.
https://github.com/phreed/webgme-immortals
That is being converted to use TypeScript.
Include the typing descriptions that are in phreed/npm-webgme into phreed/webgme-immortals.
How do I configure a project including the type definitions, to be used by a typescript project?
The text was updated successfully, but these errors were encountered: