Skip to content
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

support @types/cc-ambient-types #16215

Merged
merged 5 commits into from
Sep 11, 2023
Merged

support @types/cc-ambient-types #16215

merged 5 commits into from
Sep 11, 2023

Conversation

PPpro
Copy link
Contributor

@PPpro PPpro commented Sep 7, 2023

Re: #15910

Changelog

  • support @types/cc-ambient-types module to provide global types definition for all modules

Why we need this module ?

Before, we reference all the types in one root tsconfig.json, now we have more and more separate modules and each module has their own tsconfig.json, but the types config cannot be extended from the root tsconfig.json because the reference path is relative path.
If we don't provide this @types/cc-ambient-types module, we need to config types in each module's tsconfig.json, which would be much more cumbersome.

Breaking Change

  • remove npm run build-declaration and npm run build-const workflow and merge them into npm run build workflow
  • npm run build doesn't build engine anymore which is meaningless
  • npm run build will automatically run after npm i
  • npm run build will run all the modules build task with turbo build, and run the root build task with npm run build-root
  • in the future, we also want to remove gulp build-debug-infos && npm run bundle-adapter && npm run fetch-ral workflow, we only need one npm run build command to finish all the build tasks.

CI Failed Analysis

The interface check failed because the diff content is out of the maximum of string 65536.

Here are the interface compare data, most of the diff comes from the private type which is named as path. We can ignore these diff.
before.zip
after.zip
image

the <Native>Generate Code failure is fix here #16214 d3231a1


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

@PPpro PPpro closed this Sep 7, 2023
@PPpro PPpro reopened this Sep 7, 2023
@github-actions
Copy link

github-actions bot commented Sep 7, 2023

@PPpro ❗ There was an error during the execution of the tasks. Please check the logs for more details.

@PPpro PPpro marked this pull request as draft September 7, 2023 12:43
@PPpro PPpro marked this pull request as ready for review September 7, 2023 13:14
@PPpro PPpro requested review from minggo and shrinktofit September 7, 2023 13:14
"node": "./src/index.d.ts",
"types": "./src/index.d.ts"
},
"./query": "./scripts/query.js"
Copy link
Contributor Author

@PPpro PPpro Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we add this query export to provide some interface to query info of the module, such as getDtsFiles()

let dtsFiles = require('@types/cc-ambient-types/query').getDtsFiles();
dtsFiles = dtsFiles.map(file => ps.join(buildOutput, ps.relative(engineRoot, file)).slice(0, -'.d.ts'.length));

Comment on lines +1 to +30
/* eslint-disable @typescript-eslint/triple-slash-reference */
// default ambient types
/// <reference path="../lib/consts.d.ts"/>
/// <reference path="./editor-extends.d.ts"/>
/// <reference path="./globals.d.ts"/>
/// <reference path="./jsb.d.ts"/>
/// <reference path="./webGL.extras.d.ts"/>
/// <reference path="./webGL2.extras.d.ts"/>

// node_modules types
/// <reference path="../../../node_modules/@cocos/cannon/CANNON.d.ts"/>

// pal types
/// <reference path="./pal/audio.d.ts"/>
/// <reference path="./pal/input.d.ts"/>
/// <reference path="./pal/minigame.d.ts"/>
/// <reference path="./pal/pacer.d.ts"/>
/// <reference path="./pal/screen-adapter.d.ts"/>
/// <reference path="./pal/system-info.d.ts"/>
/// <reference path="./pal/wasm.d.ts"/>
/// <reference path="./pal/image.d.ts"/>

// external types
/// <reference path="../../../native/external/emscripten/external-wasm.d.ts"/>
/// <reference path="../../../native/external/emscripten/bullet/bullet.d.ts"/>
/// <reference path="../../../native/external/emscripten/physx/physx.d.ts"/>
/// <reference path="../../../native/external/emscripten/webgpu/webgpu.d.ts"/>
/// <reference path="../../../native/external/emscripten/spine/spine.d.ts"/>
/// <reference path="../../../native/external/emscripten/meshopt/meshopt_decoder.d.ts"/>
/// <reference path="../../../native/external/emscripten/box2d/box2d.d.ts"/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we add types reference here

static load (url: string, opts?: import('pal/audio/type').AudioLoadOptions): Promise<AudioPlayer>;
static load (url: string, opts?: import('../../../../pal/audio/type').AudioLoadOptions): Promise<AudioPlayer>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these relative paths could be fixed after they are modularized

"./@types/pal/pacer",
"./@types/pal/wasm",
"./@types/pal/image",
"cc-ambient-types",
Copy link
Contributor Author

@PPpro PPpro Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we solve the relative path issue in this way, see https://www.typescriptlang.org/tsconfig#types

@minggo minggo merged commit 471fe46 into cocos:develop Sep 11, 2023
@PPpro PPpro deleted the dev-types branch September 11, 2023 07:12
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.

3 participants