Skip to content

Commit

Permalink
typescript: missing p5 constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Spongman committed Nov 30, 2017
1 parent fa9c79a commit e285007
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ var constants = require('./constants');
* "global" - all properties and methods are attached to the window
* "instance" - all properties and methods are bound to this p5 object
*
* @class p5
* @constructor
* @param {function} sketch a closure that can set optional preload(),
* setup(), and/or draw() properties on the
* given p5 instance
* @param {HTMLElement|boolean} [node] element to attach canvas to, if a
* @param {HTMLElement|Boolean} [node] element to attach canvas to, if a
* boolean is passed in use it as sync
* @param {boolean} [sync] start synchronously (optional)
* @param {Boolean} [sync] start synchronously (optional)
* @return {p5} a p5 instance
*/
var p5 = function(sketch, node, sync) {
Expand Down
9 changes: 4 additions & 5 deletions tasks/typescript/generate-typescript-annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function mod(yuidocs, localFileame, globalFilename, sourcePath) {

var EXTERNAL_TYPES = [
'HTMLCanvasElement',
'HTMLElement',
'Float32Array',
'AudioParam',
'AudioNode',
Expand Down Expand Up @@ -273,12 +274,9 @@ function mod(yuidocs, localFileame, globalFilename, sourcePath) {

function generateClassConstructor(className) {
var classitem = yuidocs.classes[className];

if (!classitem.is_constructor) {
throw new Error(className + ' is not a constructor');

This comment has been minimized.

Copy link
@Zalastax

Zalastax Nov 30, 2017

Member

Why don't we want to throw an error any longer? I would expect us to emit some kind of warning here.

This comment has been minimized.

Copy link
@Spongman

Spongman Nov 30, 2017

Author Contributor

because it's OK for a class not to have a constructor. for example p5.dom and p5.sound don't have constructors.

if (classitem.is_constructor) {
generateClassMethod(className, classitem);
}

generateClassMethod(className, classitem);
}

function generateClassProperty(className, classitem) {
Expand Down Expand Up @@ -346,6 +344,7 @@ function mod(yuidocs, localFileame, globalFilename, sourcePath) {
emit('// Properties from ' + className);
emit.sectionBreak();

generateClassConstructor(className);
generateClassProperties(className);
}

Expand Down

0 comments on commit e285007

Please sign in to comment.