Skip to content

Commit

Permalink
fixed #cocos-engine/16594: Missing abstract keyword for AbstractedCon…
Browse files Browse the repository at this point in the history
…structor in cc.d.ts (#1)

* fixed #cocos-engine/16594: Missing `abstract` keyword for AbstractedConstructor in cc.d.ts

cocos/cocos-engine#16594

* Update version to 3.3.3

* Update npm-publish.yml

* Update snapshot

* Update ci script
  • Loading branch information
dumganhar authored Apr 19, 2024
1 parent ad9596b commit afe07e5
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 30 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/npm-publish.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -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 }}"
22 changes: 22 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

test/
source/
source/
.github/
.vscode/
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion source/recast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
3 changes: 2 additions & 1 deletion test/types/@types/globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

declare type Constructor<T = unknown> = new(...args: any[]) => T;
declare type Constructor<T = unknown> = new(...args: any[]) => T;
declare type AbstractedConstructor<T = unknown> = abstract new (...args: any[]) => T;
3 changes: 2 additions & 1 deletion test/types/__snapshots__/types.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ exports[`From triple slash directive 1`] = `
export class Component {
}
export class Node {
getComponent<T extends Component>(constructor: __private._types_globals__Constructor<T>): T | null;
getComponent<T extends Component>(constructor: __private._types_globals__Constructor<T> | __private._types_globals__AbstractedConstructor<T>): T | null;
}
export namespace __private {
export type _types_globals__Constructor<T = unknown> = new (...args: any[]) => T;
export type _types_globals__AbstractedConstructor<T = unknown> = abstract new (...args: any[]) => T;
}
export {};
}
Expand Down
2 changes: 1 addition & 1 deletion test/types/input.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ declare module "index" {
export class Component {}

export class Node {
getComponent<T extends Component>(constructor: Constructor<T>): T | null;
getComponent<T extends Component>(constructor: Constructor<T> | AbstractedConstructor<T>): T | null;
}
}

0 comments on commit afe07e5

Please sign in to comment.