不能将类型“null”分配给类型“Prefab”



版本是3.1.1,直接复制都是错,这这这——

1赞

我自己常用
target : Prefab | null = null;
或者
target:Prefab = null as unknown as Prefab;

1赞

应该减少语法达到目的 这倒好 多出一些奇怪的语法,开始也特不习惯,有啥办法呢

{
“strict”: false,
/* Base configuration. Do not edit this field. */
“extends”: “./temp/tsconfig.cocos.json”,

/* Add your custom configuration here. */
“compilerOptions” :
{
“strictNullChecks”: false, //强制null检查
“suppressImplicitAnyIndexErrors”: true, //元素隐式
“experimentalDecorators”: true
}
}

2赞

我直接 用 target: Prefab = null!;

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。