@@ -1628,40 +1628,32 @@ export function make(
16281628 ( [ Identifier , Service ] ) => ( { Identifier, Service } )
16291629 )
16301630
1631- const serviceVarianceStruct = (
1632- type : ts . Type ,
1633- atLocation : ts . Node
1634- ) =>
1635- Nano . map (
1636- Nano . all (
1637- varianceStructInvariantType ( type , atLocation , "_Identifier" ) ,
1638- varianceStructInvariantType ( type , atLocation , "_Service" )
1639- ) ,
1640- ( [ Identifier , Service ] ) => ( { Identifier, Service } )
1641- )
1642-
16431631 const serviceType = Nano . cachedBy (
16441632 Nano . fn ( "TypeParser.serviceType" ) ( function * (
16451633 type : ts . Type ,
16461634 atLocation : ts . Node
16471635 ) {
1636+ // v4 only
1637+ if ( supportedEffect ( ) !== "v4" ) return yield * typeParserIssue ( "v4 only" )
16481638 // should be pipeable
16491639 yield * pipeableType ( type , atLocation )
1650- // get the properties to check (exclude non-property and optional properties)
1651- const propertiesSymbols = typeChecker . getPropertiesOfType ( type ) . filter ( ( _ ) =>
1652- _ . flags & ts . SymbolFlags . Property && ! ( _ . flags & ts . SymbolFlags . Optional ) && _ . valueDeclaration
1653- )
1654- // early exit
1655- if ( propertiesSymbols . length === 0 ) {
1656- return yield * typeParserIssue ( "Type has no tag variance struct" , type , atLocation )
1640+ // Effect v4 beta.43 switched ServiceMap keys from nested variance markers
1641+ const typeIdSymbol = typeChecker . getPropertyOfType ( type , "~effect/ServiceMap/Service" )
1642+ if ( ! typeIdSymbol ) {
1643+ return yield * typeParserIssue ( "Type has no service key type id" , type , atLocation )
16571644 }
1658- // try to put typeid first (heuristic to optimize hot path)
1659- propertiesSymbols . sort ( ( a , b ) => ts . symbolName ( b ) . indexOf ( "TypeId" ) - ts . symbolName ( a ) . indexOf ( "TypeId" ) )
1660- // has a property symbol which is a service variance struct
1661- return yield * Nano . firstSuccessOf ( propertiesSymbols . map ( ( propertySymbol ) => {
1662- const propertyType = typeChecker . getTypeOfSymbolAtLocation ( propertySymbol , atLocation )
1663- return serviceVarianceStruct ( propertyType , atLocation )
1664- } ) )
1645+ const identifierSymbol = typeChecker . getPropertyOfType ( type , "Identifier" )
1646+ if ( ! identifierSymbol ) {
1647+ return yield * typeParserIssue ( "Type has no 'Identifier' property" , type , atLocation )
1648+ }
1649+ const serviceSymbol = typeChecker . getPropertyOfType ( type , "Service" )
1650+ if ( ! serviceSymbol ) {
1651+ return yield * typeParserIssue ( "Type has no 'Service' property" , type , atLocation )
1652+ }
1653+ return ( {
1654+ Identifier : typeChecker . getTypeOfSymbolAtLocation ( identifierSymbol , atLocation ) ,
1655+ Service : typeChecker . getTypeOfSymbolAtLocation ( serviceSymbol , atLocation )
1656+ } )
16651657 } ) ,
16661658 "TypeParser.serviceType" ,
16671659 ( type ) => type
@@ -1672,6 +1664,8 @@ export function make(
16721664 type : ts . Type ,
16731665 atLocation : ts . Node
16741666 ) {
1667+ // v4 only
1668+ if ( supportedEffect ( ) !== "v3" ) return yield * typeParserIssue ( "v3 only" )
16751669 // should be pipeable
16761670 yield * pipeableType ( type , atLocation )
16771671 // get the properties to check (exclude non-property and optional properties)
0 commit comments