Skip to content

Fix some type issues in tilemap module - #18255

Merged
minggo merged 1 commit into
cocos:v3.8.6from
dumganhar:386-fix-type-tilemap
Feb 5, 2025
Merged

Fix some type issues in tilemap module#18255
minggo merged 1 commit into
cocos:v3.8.6from
dumganhar:386-fix-type-tilemap

Conversation

@dumganhar

Copy link
Copy Markdown
Contributor

Re: #

Changelog


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.

@github-actions

Copy link
Copy Markdown

👍 Package size ⤵ -63 bytes, old: 5225108, new: 5225045

Interface Check Report

This pull request does not change any public interfaces !

@dumganhar
dumganhar requested a review from minggo February 5, 2025 05:52
const _vec3_temp2 = new Vec3();
const _tempRowCol = { row: 0, col: 0 };

function isTiledSubNodeData (data: TiledRenderData | TiledSubNodeData): data is TiledSubNodeData {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

data is TiledSubNodeData: What does this code mean?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's similar with the PR #18264
Basically, this is a typescript syntax that if the function returns true, then the data is a TiledSubNodeData type. This could avoid type convertion in if logic. For example:

class Base {
}

class TiledSubNodeData extends Base {
   hello();
}

const pBase: Base = new TiledSubNodeData();

if (isTiledSubNodeData(pBase)) { // pBase is Base type, but it's an instance of TiledSubNodeData, so this function return true. And pBase will be treated as a TiledSubNodeData instance.

    pBase.hello(); // No need to convert it to TiledSubNodeData by `(pBase as TiledSubNodeData).hello();`

}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

WeChatc6cd4e02e0a618a1c2e18035889dac7a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Got it, thanks.

@minggo
minggo merged commit 18d8011 into cocos:v3.8.6 Feb 5, 2025
cocos-robot pushed a commit to cocos-robot/engine that referenced this pull request Feb 5, 2025
dumganhar pushed a commit that referenced this pull request Feb 5, 2025
…18275)

Co-authored-by: cocos-robot <cocos-robot@cocos.com>
@dumganhar

Copy link
Copy Markdown
Contributor Author

@cocos-robot run test cases

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.

2 participants