File tree 4 files changed +42
-2
lines changed
4 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -419,6 +419,24 @@ jobs:
419
419
await printStuff()
420
420
` ` `
421
421
422
+ # ## Use scripts with jsDoc support
423
+
424
+ If you want type support for your scripts, you could use the command below to install the
425
+ ` github-script` type declaration.
426
+ ` ` ` sh
427
+ $ npm i -D @types/github-script@github:actions/github-script
428
+ ` ` `
429
+
430
+ And then add the `jsDoc` declaration to your script like this :
431
+ ` ` ` js
432
+ // @ts-check
433
+ /** @param {import('@types/github-script').AsyncFunctionArguments} AsyncFunctionArguments */
434
+ export default async ({ core, context }) => {
435
+ core.debug("Running something at the moment");
436
+ return context.actor;
437
+ };
438
+ ` ` `
439
+
422
440
# ## Use env as input
423
441
424
442
You can set env vars to use them in your script :
Original file line number Diff line number Diff line change 5
5
"author" : " GitHub" ,
6
6
"license" : " MIT" ,
7
7
"main" : " dist/index.js" ,
8
+ "types" : " types/async-function.d.ts" ,
8
9
"private" : true ,
9
10
"scripts" : {
10
- "build" : " ncc build src/main.ts" ,
11
+ "build" : " npm run build:types && ncc build src/main.ts" ,
12
+ "build:types" : " tsc src/async-function.ts -t es5 --declaration --allowJs --emitDeclarationOnly --outDir types" ,
11
13
"format:check" : " prettier --check src __test__" ,
12
14
"format:write" : " prettier --write src __test__" ,
13
15
"lint" : " eslint src __test__" ,
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import fetch from 'node-fetch'
8
8
9
9
const AsyncFunction = Object . getPrototypeOf ( async ( ) => null ) . constructor
10
10
11
- type AsyncFunctionArguments = {
11
+ export declare type AsyncFunctionArguments = {
12
12
context : Context
13
13
core : typeof core
14
14
github : InstanceType < typeof GitHub >
Original file line number Diff line number Diff line change
1
+ /// <reference types="node" />
2
+ import * as core from '@actions/core' ;
3
+ import * as exec from '@actions/exec' ;
4
+ import { Context } from '@actions/github/lib/context' ;
5
+ import { GitHub } from '@actions/github/lib/utils' ;
6
+ import * as glob from '@actions/glob' ;
7
+ import * as io from '@actions/io' ;
8
+ import fetch from 'node-fetch' ;
9
+ export declare type AsyncFunctionArguments = {
10
+ context : Context ;
11
+ core : typeof core ;
12
+ github : InstanceType < typeof GitHub > ;
13
+ exec : typeof exec ;
14
+ glob : typeof glob ;
15
+ io : typeof io ;
16
+ fetch : typeof fetch ;
17
+ require : NodeRequire ;
18
+ __original_require__ : NodeRequire ;
19
+ } ;
20
+ export declare function callAsyncFunction < T > ( args : AsyncFunctionArguments , source : string ) : Promise < T > ;
You can’t perform that action at this time.
0 commit comments