how i can add type to file that doesn't not exits

import type { WathqnyConfig as WathqnyConfigType } from "wtqtypes";

/** @type {import('wtqtypes').WathqnyConfig} */
import WathqnyConfig from "/wathqny.config";
import type { WathqnyConfig as WathqnyConfigType } from "wtqtypes";

/** @type {import('wtqtypes').WathqnyConfig} */
import WathqnyConfig from "/wathqny.config";
how i can add type to file that doesn't not exits
22 Replies
ἔρως
ἔρως2y ago
what? what do you mean "file that doesn't exist?" also, why are you using jsdoc for typescript?
!Abdelrahman Abdelfattah
it was a try
ἔρως
ἔρως2y ago
what are you trying to do?
!Abdelrahman Abdelfattah
i have a component a my pkg accessing wathqny.config that file not is not there but it is one the site
ἔρως
ἔρως2y ago
.config isn't a valid extension
!Abdelrahman Abdelfattah
it is a ts file you don't have to add the type ex in js/ts
ἔρως
ἔρως2y ago
you're trying to load a file called "wathqny.config.ts"?
!Abdelrahman Abdelfattah
i am using that file already but i have jsut type problem
ἔρως
ἔρως2y ago
so, whats the problem? which type problem?
!Abdelrahman Abdelfattah
i want to load the type for a file that dosen't exits import type { WathqnyConfig as WathqnyConfigType } from "wtqtypes";
ἔρως
ἔρως2y ago
show us the problem show us error messages, compilation errors ... something
ἔρως
ἔρως2y ago
you have to create the file then also, why are you importing types manually? wouldnt a .d.ts file be enough?
!Abdelrahman Abdelfattah
because the file is not there the types is my own types
ἔρως
ἔρως2y ago
what do those files have?
dys 🐙
dys 🐙2y ago
That leading / on /wathqny.config will cause it to look in the root of the filesystem. If you want the current directory, use ./.
!Abdelrahman Abdelfattah
import type { WathqnyConfig as WathqnyConfigType } from "wtqtypes";

// @ts-ignore
import untypedWathqnyConfig from "/wathqny.config";

const WathqnyConfig: WathqnyConfigType = untypedWathqnyConfig;
import type { WathqnyConfig as WathqnyConfigType } from "wtqtypes";

// @ts-ignore
import untypedWathqnyConfig from "/wathqny.config";

const WathqnyConfig: WathqnyConfigType = untypedWathqnyConfig;
this is the solution
ἔρως
ἔρως2y ago
what even are you trying to do?
!Abdelrahman Abdelfattah
i was trying to get a types for my component that i am using it in my site where wathqny.config because of that file doesn't not exits for the typescript lang server but for compile it works
ἔρως
ἔρως2y ago
how about you create a .d.ts file with the types you need? for example, your "untyped" file could have a .d.ts counterpart that describes the data types
!Abdelrahman Abdelfattah
the WathqnyConfigType already comes from .d.ts
ἔρως
ἔρως2y ago
so, you're importing the .d.ts file?

Did you find this page helpful?