LiteralTypeInference

0.2.0

🤔 swift-syntax extension to infer types from expressions based on literal information
p-x9/swift-literal-type-inference

What's New

v0.2.0

2024-05-04T22:54:46Z

What's Changed

  • Support swift-syntax version 510.0.0 by @p-x9 in #1

New Contributors

  • @p-x9 made their first contribution in #1

Full Changelog: 0.1.0...0.2.0

LiteralTypeInference

swift-syntax extension to infer types from expressions based on literal information.

Github issues Github forks Github stars Github top language

Usage

Implemented as an extension of the ExprSyntaxProtocol.

The type inferred from literal information can be obtained from the inferredType property.

import SwiftSyntax
import SwiftSyntaxBuilder
import LiteralTypeInference


let expr: ExprSyntax = """
[
    "item1": [
        (1, 2.0, "3", true),
        (1.0, 2, "7", false),
        (nil, nil, nil, false)
    ],
    "item2": [],
    "item3": [
        (1, 2, "3", true)
    ]
]
"""

// Get the type of expr from the `inferredType` property
let type = expr.inferredType

print(type?.formatted().description)
// => [String: [(Double?, Double?, String?, Bool)]]

License

LiteralTypeInference is released under the MIT License. See LICENSE

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

Last updated: Sat Oct 19 2024 21:03:35 GMT-0900 (Hawaii-Aleutian Daylight Time)