Typescript declaration file (documentation and static typing) #179
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the first draft of a declaration file in typescript that regroups all the documentations for the public items available when importing $rdf, and also defines the types required and returned from the available functions and methods.
This change will only consist on adding the index.d.ts file in the main folder and the
"types": "./index.d.ts"
line in the package.json, there is no need to include a typescript library in the project for this to work.
In most IDEs when using typescript this provides strong, statically typed checks at compile time, aside from more fine grained documentation.
In vscode and visualstudio the documentations and type informations will also be available in .js files.
This approach will keep the documentation separate so it can be distributed aside the babeled or minified version and still work.
I could publish this in the definitelyTyped repository if you do not wish to have it inside your project, but that will require some more steps on the user's side while this way is much cleaner.
I have introduced a couple of alias types
because some methods (statementsMatching and similar) were becoming too verbose to read. Nodeable just indicates things that are accepted from the
Node.fromValue()
(it also allows for proper checking of the circular definition, as Nodeable can be an array of Nodeable)I haven't been too strict on the typing of most methods cause that would require a lot of manual inspection, and if I'm wrong the method would not work in typescript.
Also, tagging class members and methods as private will surely improve the code usability through intellsense but again I'm not completely sure which ones are only intended for internal usage.