Reputation: 11830
I have spent about an hour trying to figure out this error but haven't had any luck.
I have types index.d.ts
in folder types. The content of the types looks like this
export interface tag {
created_at: string
id: number
name: string
}
export interface task {
created_at: string
id: number
title: string
updated_at: string
tags: tag[]
}
export interface allTaksAndTags {
tags: tag[]
tasks: task[]
}
When I am trying to import them, I am getting following error
Failed to compile.
./src/components/task.tsx Module not found: Can't resolve '../types/index' in '/Users/h/Desktop/timetracking/src/components'
I have attached below the screenshot, Can someone help me in figuring out what I am doing wrong here?
Upvotes: 0
Views: 324
Reputation: 8459
Type definition files are not meant to be used like that.
Remove d.ts
in your index file and change its name as index.ts
Type definition files are automatically generated when you build your typescript project.
Upvotes: 3