Skip to content

Basic Typescript Type Definitions #96

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

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from

Conversation

arcsector
Copy link

@arcsector arcsector commented May 17, 2020

Summary

This PR serves to give basic support for Typescript to the SDK based off of the JSDoc spec, as well as suggesting configurations for devs looking to port their modules and code to Typescript.

Purpose

This PR is meant to assist with Typescript libraries looking to implement the SDK. This will further enable and widen the Splunk Dev community, as well as allow people to better understand the inner workings of the library.

Additions and Changes

  • .gitignore
    • .vscode/ folder ignore for development
  • README.md
    • Requirements
    • Typescript installation snippet
    • Typescript Service snippet
    • Recommended tsconfig.json example
    • Typescript /dist description
    • Typescript Link
  • /dist
    • Typescript definition files based on JSDoc
  • tsconfig.json
    • Compiler options and exclusions/inclusions for compiling Typescript type definitions
  • package.json
    • Adding types key to tell Typescript where the Typescript files are supposed to be read from
  • tslint.json
    • Establishes basic rules for Typescript linter

PKing70 and others added 18 commits March 23, 2020 22:01
Revise link to contact us (no more support@splunk.com).
Update contact us information (no more support@splunk.com). Addresses SCP-16043
Support portal link
Fix links to contribution guidelines.
Revise link to contact us (no more support@splunk.com).
Fix links to contribution guidelines.
- Typescript installation snippet
- Typescript Service snippet
- Recommended tsconfig.json example
- Typescript /dist description
- Typescript Link
- Adding tests/ to typedefs
- bringing tests/ directory to standard for comilation
- removing index.ts because it's not needed
- adding tslint.json to help with linting config
- adding .tgz to .gitignore
@arcsector
Copy link
Author

arcsector commented May 18, 2020

What do i have to do to replicate the CI test? It really seems like the issue is mostly related to all the ES5-compatible exporting that you have to do in order to get Typescript to recognize the classes we're exporting (the export { Object }; at the end of each object file). Not sure what settings are causing the build to fail in the npm sdkdo hint command, but on my machine it gives a completely different error:

PS E:\Github_Repos\splunk-sdk-javascript> node sdkdo hint
E:\Github_Repos\splunk-sdk-javascript\sdkdo:26
        throw ex;
        ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at validateString (internal/validators.js:112:11)
    at Object.join (path.js:375:7)
    at Object.interpret (E:\Github_Repos\splunk-sdk-javascript\node_modules\jshint\lib\cli.js:72:34)
    at Command.hint (E:\Github_Repos\splunk-sdk-javascript\bin\cli.js:762:16)
    at Command.<anonymous> (E:\Github_Repos\splunk-sdk-javascript\contrib\commander.js:308:8)
    at Command.parseArgs (E:\Github_Repos\splunk-sdk-javascript\contrib\commander.js:480:12)
    at Command.parse (E:\Github_Repos\splunk-sdk-javascript\contrib\commander.js:427:15)
    at E:\Github_Repos\splunk-sdk-javascript\bin\cli.js:841:13
    at Object.<anonymous> (E:\Github_Repos\splunk-sdk-javascript\bin\cli.js:846:3) {
  code: 'ERR_INVALID_ARG_TYPE'
}

And then, when running node jshint .

PS E:\Github_Repos\splunk-sdk-javascript> node jshint .
internal/modules/cjs/loader.js:796
    throw err;
    ^

Error: Cannot find module 'E:\Github_Repos\splunk-sdk-javascript\jshint'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Not really sure how to make the CI build succeed if I can't troubleshoot locally...

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

Successfully merging this pull request may close these issues.

None yet

2 participants