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
ἔρως
ἔρως3mo ago
what? what do you mean "file that doesn't exist?" also, why are you using jsdoc for typescript?
abdelrahman
abdelrahman3mo ago
it was a try
ἔρως
ἔρως3mo ago
what are you trying to do?
abdelrahman
abdelrahman3mo ago
i have a component a my pkg accessing wathqny.config that file not is not there but it is one the site
ἔρως
ἔρως3mo ago
.config isn't a valid extension
abdelrahman
abdelrahman3mo ago
it is a ts file you don't have to add the type ex in js/ts
ἔρως
ἔρως3mo ago
you're trying to load a file called "wathqny.config.ts"?
abdelrahman
abdelrahman3mo ago
i am using that file already but i have jsut type problem
ἔρως
ἔρως3mo ago
so, whats the problem? which type problem?
abdelrahman
abdelrahman3mo ago
i want to load the type for a file that dosen't exits import type { WathqnyConfig as WathqnyConfigType } from "wtqtypes";
ἔρως
ἔρως3mo ago
show us the problem show us error messages, compilation errors ... something
abdelrahman
abdelrahman3mo ago
No description
ἔρως
ἔρως3mo ago
you have to create the file then also, why are you importing types manually? wouldnt a .d.ts file be enough?
abdelrahman
abdelrahman3mo ago
because the file is not there the types is my own types
ἔρως
ἔρως3mo ago
what do those files have?
dysbulic 🐙
dysbulic 🐙3mo 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
abdelrahman3mo ago
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
ἔρως
ἔρως3mo ago
what even are you trying to do?
abdelrahman
abdelrahman3mo ago
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
ἔρως
ἔρως3mo 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
abdelrahman3mo ago
the WathqnyConfigType already comes from .d.ts
ἔρως
ἔρως3mo ago
so, you're importing the .d.ts file?
Want results from more Discord servers?
Add your server
More Posts