Open clagiordano opened 4 years ago
Amazing, much needed!
How can I help?
We only need to create a file for every missing definition that export a definition like this:
Broadcast.d.ts
export namespace Broadcast {
let sampleProperty: type;
function methodSignature(arg1: type, arg2: type);
}
on index.d.ts
add an export for every definition class or group like this:
export { Broadcast, Broadcastable } from './types/Broadcast';
EDIT:
there are too many documented modes to do this but after a lot of tests, a better way to write a definition seems something like that:
export declare class SampleClass extends someBaseClass {
sampleProperty: sampleType;
sampleMethod(sampleArg: sampleType): sampleReturnType;
}
The last example allow to declare: class, extended class, properties and methods, also allow declaration of functions i.e. Scriptable
or Metadatable
export declare function MyFunction(sampleArg: sampleType): sampleReturnType;
I'll be trying to pull this into my fork at some point this weekend so I can contribute & test it 😻
Thanks @seanohue it would really helpful!
Having those autocompletions and typing from the .d.ts or ts-core is AMAZING!
This PR add a folder
types
with one definition file for every src classes, with same name as original class and a.d
suffix, these definition are exposed using anindex.d.ts
on repository root that import and re export all available definitions.These additions allow an editor like vscode to automatically suggest methods, properties and arguments, making more easier especially for new users the core classes usages.
I hope that this work could be considered useful.
Available definitions:
Some working examples:
Methods list:
Function argument list:
This PR also add
typescript
and@types/node
as dev dependency to validate definitions file using this command: