Skip to content

(3.8.7 extension) the *this* in main.ts export const methods changes? #19116

@cinast

Description

@cinast

Cocos Creator version

3.8.7

System information

win11

Issue description

Image Image Image

in methods.openImportSVG I found this is not methods but a Package obj like object
I sreached in whole range of project, include cc.d.ts and similar d.ts
and ur doc seems have no introdution about this and no record at github (sreached)

I wonder why

// this of methods
let Package: {
    json: PackageJSON;
    panels: [];
    enabled: true;
    invalid: false;
    path: "";
    module: {
        load: [Function];
        unload: [Function];
        methods: { String: Function };
    };
    [K: string]: any;
};

Relevant error log output

2025-12-28 11:58:25 - log: Package {
json: {
'$schema': './@types/schema/package/index.json',
package_version: 2,
name: 'cocos-svg-series',
version: '1.0.0',
author: 'Cinast',
editor: '>=3.0.0',
scripts: {
preinstall: 'node ./scripts/preinstall.js',
build: 'tsc',
watch: 'tsc -w'
},
description: 'i18n:cocos-svg-series.description',
main: './dist/main.js',
panels: {},
contributions: {
importer: [Object],
menu: [Array],
messages: [Object],
shortcuts: [Array],
'asset-db': [Object],
scene: [Object]
},
devDependencies: {
'@cocos/creator-types': '^3.8.7',
'@types/node': '^18.17.1',
typescript: '^5.9.3'
},
dependencies: { flubber: '^0.4.2', 'svg.js': '^2.7.1' },
debug: false
},
panels: [],
enabled: true,
invalid: false,
path: 'C:\Users\aaeow\Desktop\code\store\Cocos\the_silent_mill\extensions\cocos-svg-series',
module: {
methods: {
openImportSVG: [AsyncFunction: openImportSVG],
openImportSVGBatch: [AsyncFunction: openImportSVGBatch],
importSVGFile: [AsyncFunction: importSVGFile],
importSVGBatch: [AsyncFunction: importSVGBatch],
getSVGPreview: [AsyncFunction: getSVGPreview],
refreshAssetDatabase: [AsyncFunction: refreshAssetDatabase],
refreshAssetDatabaseMultiple: [AsyncFunction: refreshAssetDatabaseMultiple],
isValidSVG: [Function: isValidSVG],
parseSVGInfo: [Function: parseSVGInfo],
parseDimension: [Function: parseDimension],
getOrCreateUUID: [AsyncFunction: getOrCreateUUID],
generateUUID: [Function: generateUUID],
getRelativePath: [Function: getRelativePath],
getCommonDirectory: [Function: getCommonDirectory]
},
load: [Function: load],
unload: [Function: unload]
}
}
2025-12-28 11:58:25 - log: undefined
2025-12-28 11:58:25 - log: {}
2025-12-28 11:58:25 - error: 打开导入对话框失败: TypeError: this.importSVGFile is not a function
at Package.openImportSVG (C:\Users\aaeow\Desktop\code\store\Cocos\the_silent_mill\extensions\cocos-svg-series\source\main.ts:27:44)
at C:\ProgramData\cocos\editors\Creator\3.8.7\resources\app.asar\node_modules@editor\package\dist\browser\index.js:1:3396

Steps to reproduce

  1. make a blank extension
  2. main.ts to package.json.main
  3. export const methods = {}
  4. methods.test = ()=>{console.log(this)}

Minimal reproduction project

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds TriageNeeds to be assigned by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions