无法在 F# 中声明类型,错误 FS0010,错误 FS3118

Cannot declare type in F#, Error FS0010, Error FS3118

我在使用 F# 声明 Visual Studio 中的类型时遇到问题。我一输入 type 关键字,一输入 'type'.

就出现两个错误

main中let关键字下的错误是 Error FS3118 Incomplete value or function definition. If this is in an expression, the body of the expression must be indented to the same column as the 'let' keyword.

[<EntryPoint>]
let main argv =
    let x = 7

    type Book = { Name: string; Author: string; Rating: int; ISBN: string;}
    
    0 // return an integer exit code

type关键字下的错误是 Error FS0010 Incomplete structured construct at or before this point in expression

我一直在尝试修复此问题,但 FS0010 错误的主要修复只是正确缩进代码的建议。我知道代码缩进正确,因为如果我去掉 type 关键字并只执行 let x = 7,它就可以正常工作。

我正在使用 Visual Studio 2019。希望得到一些帮助!

在函数前声明类型。

错误消息可能更有帮助

type Book = { Name: string; Author: string; Rating: int; ISBN: string;}

[<EntryPoint>]
let main argv =
    let x = 7
    
    0