mirror of
https://gitee.com/openharmony/developtools_ace_ets2bundle
synced 2024-11-27 10:41:03 +00:00
fix validate @Component member type for classA | null| undefined. Signed-off-by: lihong <lihong67@huawei.com> Change-Id: Ia7daa13f1643280c3bf079655026837bc09a8ca2
This commit is contained in:
parent
9c766b063b
commit
1683e70a3c
@ -354,12 +354,14 @@ async function transform(code: string, id: string) {
|
||||
|
||||
// init TypeChecker to run binding
|
||||
globalProgram.checker = tsProgram.getTypeChecker();
|
||||
globalProgram.strictChecker = tsProgram.getLinterTypeChecker();
|
||||
targetSourceFile = tsProgram.getSourceFile(id)!;
|
||||
storedFileInfo.reUseProgram = false;
|
||||
collectAllFiles(tsProgram);
|
||||
} else {
|
||||
if (!storedFileInfo.reUseProgram) {
|
||||
globalProgram.checker = globalProgram.program.getTypeChecker();
|
||||
globalProgram.strictChecker = globalProgram.program.getLinterTypeChecker();
|
||||
}
|
||||
storedFileInfo.reUseProgram = true;
|
||||
}
|
||||
|
@ -464,8 +464,8 @@ function isForbiddenTypeToComponentV1(type: ts.Type): boolean {
|
||||
function isForbiddenAssignToComponentV2(item: ts.PropertyAssignment, itemName: string,
|
||||
info: ChildAndParentComponentInfo): boolean {
|
||||
if (!info.parentStructInfo.isComponentV2 && info.updatePropsDecoratorsV2.includes(itemName) &&
|
||||
isObervedProperty(item.initializer, info) && globalProgram.checker) {
|
||||
const type: ts.Type = globalProgram.checker.getTypeAtLocation(item.initializer);
|
||||
isObervedProperty(item.initializer, info) && globalProgram.strictChecker) {
|
||||
const type: ts.Type = globalProgram.strictChecker.getTypeAtLocation(item.initializer);
|
||||
return !isAllowedTypeToComponentV2(type);
|
||||
}
|
||||
return false;
|
||||
|
@ -963,6 +963,7 @@ class SpecialArkTSFileInfo extends TSFileInfo {
|
||||
export function setChecker(): void {
|
||||
if (globalProgram.program) {
|
||||
globalProgram.checker = globalProgram.program.getTypeChecker();
|
||||
globalProgram.strictChecker = globalProgram.program.getLinterTypeChecker();
|
||||
} else if (globalProgram.watchProgram) {
|
||||
globalProgram.checker = globalProgram.watchProgram.getCurrentProgram().getProgram().getTypeChecker();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user