Error Compiling C++ Code When I'm Using VS CODE

So I am trying to compile these codes in unreal editor by hitting compile and I am getting a compile error,
I am using visual studio code as my editor, also when I close the project, I wont be able to open it again saying.

The game module 'projectName' cannotbe found. Please ensure that this module exists and that it is compiled.

I have visual studio 2017 installed and when I use that along with unreal everything works fine, but it is too heavy and I want to switch to vs code

CoobActor.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "CoobActor.generated.h"

UCLASS()
class TRYCOOBCODE_API ACoobActor : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	ACoobActor();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	UPROPERTY(EditAnywhere)
	UStaticMeshComponent * Mesh;
	
};

CoobActor.cpp

#include "CoobActor.h"


// Sets default values
ACoobActor::ACoobActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	Mesh = CreateDefaultSubobject<UStaticMeshComponent>("MyMesh");
}

// Called when the game starts or when spawned
void ACoobActor::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void ACoobActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	FVector newloc = GetActorLocation();
	newloc.Z += 0.5f;
	SetActorLocation(newloc);
}

Compile Error

 - Compiling game modules for hot reload
 - Building 3 actions with 8 processes...
 -   [1/3] CoobActor.cpp
 -    C:\Program Files\Epic Games\UE_4.20\Engine\Source\Runtime\CoreUObject\Public\UObject/Object.h(84) : error C2027: use of undefined type 'UStaticMeshComponent'
 -   C:\Program Files\Epic Games\UE_4.20\Engine\Source\Runtime\CoreUObject\Public\Templates/Casts.h(348): note: see declaration of 'UStaticMeshComponent'
 -   C:\Users\FBC-PC02\Documents\Unreal Projects\tryCoobCode\Source\tryCoobCode\CoobActor.cpp(11): note: see reference to function template instantiation 'TReturnType *UObject::CreateDefaultSubobject<UStaticMeshComponent>(FName,bool)' being compiled
 -           with
 -           [
 -               TReturnType=UStaticMeshComponent
 -           ]
 -    C:\Program Files\Epic Games\UE_4.20\Engine\Source\Runtime\CoreUObject\Public\UObject/Object.h(85) : error C2440: 'static_cast': cannot convert from 'UObject *' to 'TReturnType *'
 -           with
 -           [
 -               TReturnType=UStaticMeshComponent
 -           ]
 -   C:\Program Files\Epic Games\UE_4.20\Engine\Source\Runtime\CoreUObject\Public\UObject/Object.h(85): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
 - ERROR: UBT ERROR: Failed to produce item: C:\Users\FBC-PC02\Documents\Unreal Projects\tryCoobCode\Binaries\Win64\UE4Editor-tryCoobCode-2800.dll
 -        (see ../Programs/UnrealBuildTool/Log.txt for full exception trace)
 - Total build time: 6.42 seconds (Parallel executor: 0.00 seconds)

Hey,

I think that’s simple. use of undefined type ‘UStaticMeshComponent’ Compiler don’t know what is UStaticMeshComponent, you need to include it’s header inside file where are you using it so it’s in this case CoobActor.h and CoobActor.cpp.

PS: You can find any header you need in engine project or by typing for example: UStaticMeshComponent UE API, in this case you need to add at top of both files #include

If it will not fix all problems let me know in coment.