Cycling74 / n4m-examples

Repository of examples using Node For Max authored by Cycling '74

Home Page:http://cycling74.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typescript for Node for Max

geofholbrook opened this issue · comments

Nature of issue?

  • Found a bug in an example
  • Existing example enhancement
  • Suggest a new example

New example details:

This may not fit in here ... it's a more general request about Typescript! I wonder if anyone has taken a crack at a declaration file for Node for Max? Ideally it would get published to the DefinitelyTyped repository, as @types/node-for-max. Then there could be another category of examples in here, that show how to write .ts files.

I 100% agree. I've filed an issue internally to offer types for Node For Max and I assume we'll then highlight that in the core examples.

Any updates on this?

We couldn't avoid noticing that there are types inplace Cycling '74/Max 8/resources/packages/Node for Max/source/@types\max-api.d.ts but it would be great to have some guidance on how are they intended to be used.

Update 04-04-2023: I am afraid max-api.d.ts in their current form in Max 8.3 can't be used, but maybe I didn't manage the typescript compiler to swallow them.

Hi @FrancescElies - I've submitted a PR with updated / fixed type definitions here: DefinitelyTyped/DefinitelyTyped#65005

Once that is merged you should be able to install @types/max-api. There is an existing version on NPM that @geofholbrook worked on but after testing it locally I've identified a few mismatches in the parameter signatures and the way the API is exported that made it a bit troublesome to use. In the meantime I'd recommend to just grab the type definitions from the Pull Request and using them in your local project:

declare module "max-api" {
  // Content of the file on DefinitelyTyped
  // Just make sure to drop the "declare" in front of "namespace MaxAPIStatic"
}

I also have a simple, local example that I'll make available once the updated definitions have been published.

@fde31 thanks! we are already on the way to integrate them on our side and as soon as the pr is merged we will switcht to the npm package with npm i @types/max-api -D

@fde31 Great to see @types/max-api updated! I approved the PR as "owner" but you should take primary ownership obviously.

@types/max-api v2.0.0 is published on NPM and PR #39 adds an example that demonstrates the basics of TS usage in https://github.com/Cycling74/n4m-examples/tree/master/typescript