Skip to content
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

Typescript Error: Noise' incorrectly extends base class 'Oscillator' #2605

Closed
3 of 17 tasks
troysandal opened this issue Jan 27, 2018 · 6 comments
Closed
3 of 17 tasks

Comments

@troysandal
Copy link

troysandal commented Jan 27, 2018

Nature of issue?

  • Found a bug
  • Existing feature enhancement
  • New feature request

Most appropriate sub-area of p5.js?

  • Color
  • Core
  • Data
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Other - Typescript compile errors in p5.d.ts

Which platform were you using when you encountered this?

  • Mobile/Tablet (touch devices)
  • Desktop/Laptop
  • Others (specify if possible)

Details about the bug:

  • p5.js version: 0.6.0

  • node.js version: 8.9.4

  • npm version: 3.1.0

  • Web browser and version: NA

  • Operating System: macOS 10.13.2

  • Steps to reproduce this:

git clone [email protected]:troysandal/p5js-typescript-fusebox
cd p5js-typescript-fusebox
npm i && npm run compile

I'm trying to get a basic p5Js template working with Typescript and Fusebox. In doing so I'm getting a compile errors in p5.d.ts below. You can fix the constants by inserting ///<reference path="p5.global-mode.d.ts" /> at the top of p5.d.ts. For the last error re: Noise I looked at the definition of Oscillator and Noise and found that Noise doesn't even override Oscillator::amp() so why they have different types I have no idea, but they do.

[UPDATE] - Looks like the issues is with yuidocs not giving us a return type for the overloaded method???

node_modules/p5/lib/p5.d.ts(557,19): error TS2304: Cannot find name 'COLOR_MODE'.
node_modules/p5/lib/p5.d.ts(828,87): error TS2304: Cannot find name 'ARC_MODE'.
node_modules/p5/lib/p5.d.ts(1075,21): error TS2304: Cannot find name 'ELLIPSE_MODE'.
node_modules/p5/lib/p5.d.ts(1122,18): error TS2304: Cannot find name 'RECT_MODE'.
node_modules/p5/lib/p5.d.ts(1145,18): error TS2304: Cannot find name 'STROKE_CAP'.
node_modules/p5/lib/p5.d.ts(1157,20): error TS2304: Cannot find name 'STROKE_JOIN'.
node_modules/p5/lib/p5.d.ts(1874,49): error TS2304: Cannot find name 'RENDERER'.
node_modules/p5/lib/p5.d.ts(1908,51): error TS2304: Cannot find name 'RENDERER'.
node_modules/p5/lib/p5.d.ts(1949,19): error TS2304: Cannot find name 'BLEND_MODE'.
node_modules/p5/lib/p5.d.ts(2331,21): error TS2304: Cannot find name 'BEGIN_KIND'.
node_modules/p5/lib/p5.d.ts(2412,19): error TS2304: Cannot find name 'END_MODE'.
node_modules/p5/lib/p5.d.ts(3333,19): error TS2304: Cannot find name 'IMAGE_MODE'.
node_modules/p5/lib/p5.d.ts(3407,136): error TS2304: Cannot find name 'BLEND_MODE'.
node_modules/p5/lib/p5.d.ts(3542,22): error TS2304: Cannot find name 'FILTER_TYPE'.
node_modules/p5/lib/p5.d.ts(4581,19): error TS2304: Cannot find name 'ANGLE_MODE'.
node_modules/p5/lib/p5.d.ts(4607,25): error TS2304: Cannot find name 'HORIZ_ALIGN'.
node_modules/p5/lib/p5.d.ts(4607,50): error TS2304: Cannot find name 'VERT_ALIGN'.
node_modules/p5/lib/p5.d.ts(4677,23): error TS2304: Cannot find name 'THE_STYLE'.
node_modules/p5/lib/p5.d.ts(6976,49): error TS2304: Cannot find name 'GRAPHICS_RENDERER'.
node_modules/p5/lib/p5.d.ts(7380,24): error TS2304: Cannot find name 'FILTER_TYPE'.
node_modules/p5/lib/p5.d.ts(7413,138): error TS2304: Cannot find name 'BLEND_MODE'.
node_modules/p5/lib/p5.d.ts(10265,9): error TS2415: Class 'Noise' incorrectly extends base class 'Oscillator'.
  Types of property 'amp' are incompatible.
    Type '(volume: number | object, rampTime?: number, timeFromNow?: number) => void' is not assignable to type '(vol: number | object,rampTime?: number, timeFromNow?: number) => AudioParam'.
      Type 'void' is not assignable to type 'AudioParam'.

Feature enhancement details:

New feature details:

@Spongman
Copy link
Contributor

(this should probably be moved to the p5.sound repo)

the issue is that the Noise class overrides the Oscillator class, but it also includes doc comments for the overridden methods (even though some of these aren't even implemented in Oscillator) and it seems as though, over time, the overridden docs have gotten out-of-sync with the base class' docs.

i'm going to suggest removing the docs from the derived class for now.

@Spongman
Copy link
Contributor

@therewasaguy has merged processing/p5.js-sound#248, so the sound noise amp definitions should be fixed in the next release. the constant definitions in non-global mode will require another fix.

@lmccart lmccart closed this as completed Feb 6, 2018
@troysandal
Copy link
Author

@Spongman thanks for letting me know, do you need me to submit a new issue for the constant definitions?

@TeemuKoivisto
Copy link

Hello, this bug is still not resolved as of today with "p5": "^0.6.1". I am still receiving Class 'Noise' incorrectly extends base class 'Oscillator'. Types of property 'amp' are incompatible. error.

Anyone care to fix this?

@limzykenneth
Copy link
Member

@TeemuKoivisto Hi, can you file an issue over at https://github.com/processing/p5.js-sound as the source code for p5.sound (Noise, Oscillator, etc) are all maintained there. Thanks.

@TeemuKoivisto
Copy link

@limzykenneth Hi and first thanks for the quick reply. Now that I recloned my repo it actually throws (555,19): Cannot find name 'COLOR_MODE'.. I dunno how I got that Class 'Noise'-error, I guess I did something with the typings. As a quick fix I manually remove the p5.d.ts-file. But does this error also belong to the p5.sound?

Here's the repo if you want to see it for yourself: https://github.com/TeemuKoivisto/pitch-detection.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants