Header menu logo G-Research F# Analyzers

TypeAnnotateStringFunction

Problem

Using the string function can catch you off guard when refactoring types.

let v = 1 // Changing the type won't affect `s`
let s = string v

Fix

Add an explicit type annotation:

let v = 1 // Changing the type will affect `s`
let s = string<int> v
val v: int
val s: string
Multiple items
val string: value: 'T -> string

--------------------
type string = System.String
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int

Type something to start searching.