You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importtestfrom"ava";import{isAssignableToValue,toSimpleType}from"../src";import{Project}from"ts-morph";import*astsfrom"typescript";functiongetType(source: string): [ts.Type,ts.TypeChecker]{constproject=newProject({compilerOptions: {strict: true}});consttypeChecker=project.getTypeChecker().compilerObject;project.createSourceFile("test.ts",source);constsourceFile=project.getSourceFile("test.ts")!;consttypeAlias=sourceFile.getTypeAlias("Type");if(!typeAlias)thrownewError("type not found");return[typeAlias.getType().compilerType,typeChecker];}test("number[]",t=>{const[type,typeChecker]=getType("type Type = number[]");t.truthy(isAssignableToValue(type,[1,2,3],typeChecker));t.truthy(isAssignableToValue(type,[],typeChecker));t.falsy(isAssignableToValue(type,[undefined],typeChecker));});
The text was updated successfully, but these errors were encountered:
Reproduction
The text was updated successfully, but these errors were encountered: