diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml deleted file mode 100644 index ca4af39..0000000 --- a/.github/workflows/npm-publish.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: npm-publish -on: - push: - branches: - - master -jobs: - npm-publish: - name: npm-publish - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 12 - - run: npm install - - id: publish - uses: JS-DevTools/npm-publish@v1 - with: - token: ${{ secrets.NPM_AUTH_TOKEN }} - - if: steps.publish.outputs.type != 'none' - run: | - echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}" diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..efe385e --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,30 @@ +name: Publish + +on: + release: + types: [published] + +jobs: + publish: + name: "Publish to npm registry" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '18.17.0' + + - run: npm ci + - run: npm run build + - run: npm test + + - id: publish + uses: JS-DevTools/npm-publish@4b07b26a2f6e0a51846e1870223e545bae91c552 + if: github.event_name == 'release' + with: + token: ${{ secrets.NPM_PUBLISH_FOR_PUBLIC_REPO }} + registry: "https://registry.npmjs.org" + + - if: steps.publish.outputs.type != 'none' + run: | + echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..6bc63a2 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,22 @@ +name: test +run-name: ${{ github.actor }} - test +on: [pull_request, push] +jobs: + test: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '18.17.0' + + - run: node --version + - run: npm --version + + - run: npm ci + - run: npm run build + - run: npm run test diff --git a/.npmignore b/.npmignore index e2e2d02..a1d6596 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,5 @@ test/ -source/ \ No newline at end of file +source/ +.github/ +.vscode/ \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 098994e..b70cc2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tfig", - "version": "3.3.1", + "version": "3.3.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tfig", - "version": "3.3.1", + "version": "3.3.3", "license": "MIT", "dependencies": { "fs-extra": "^7.0.1", diff --git a/package.json b/package.json index ba3453d..7b39f54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tfig", - "version": "3.3.2", + "version": "3.3.3", "description": "Yet another tool to generate .d.ts bundle.", "main": "build/gift.js", "types": "build/gift.d.ts", diff --git a/source/recast.ts b/source/recast.ts index f8988e5..a95b38d 100644 --- a/source/recast.ts +++ b/source/recast.ts @@ -769,7 +769,7 @@ export function recastTopLevelModule({ ); } else if (ts.isConstructorTypeNode(type)) { return nodeFactor.createConstructorTypeNode( - undefined, + recastModifiers(type.modifiers), recastTypeParameterArray(type.typeParameters), recastParameterArray(type.parameters), // parameters recastTypeNode(type.type), diff --git a/test/types/@types/globals.d.ts b/test/types/@types/globals.d.ts index 85d55d4..126552f 100644 --- a/test/types/@types/globals.d.ts +++ b/test/types/@types/globals.d.ts @@ -1,2 +1,3 @@ -declare type Constructor = new(...args: any[]) => T; \ No newline at end of file +declare type Constructor = new(...args: any[]) => T; +declare type AbstractedConstructor = abstract new (...args: any[]) => T; \ No newline at end of file diff --git a/test/types/__snapshots__/types.test.ts.snap b/test/types/__snapshots__/types.test.ts.snap index 82a04c9..4516053 100644 --- a/test/types/__snapshots__/types.test.ts.snap +++ b/test/types/__snapshots__/types.test.ts.snap @@ -5,10 +5,11 @@ exports[`From triple slash directive 1`] = ` export class Component { } export class Node { - getComponent(constructor: __private._types_globals__Constructor): T | null; + getComponent(constructor: __private._types_globals__Constructor | __private._types_globals__AbstractedConstructor): T | null; } export namespace __private { export type _types_globals__Constructor = new (...args: any[]) => T; + export type _types_globals__AbstractedConstructor = abstract new (...args: any[]) => T; } export {}; } diff --git a/test/types/input.d.ts b/test/types/input.d.ts index 7cd273e..8e4b691 100644 --- a/test/types/input.d.ts +++ b/test/types/input.d.ts @@ -4,6 +4,6 @@ declare module "index" { export class Component {} export class Node { - getComponent(constructor: Constructor): T | null; + getComponent(constructor: Constructor | AbstractedConstructor): T | null; } }