screeps-server-mockup
screeps-server-mockup copied to clipboard
Could not find package declaration
Thanks for this great project! but I have a question about ts types.
When I used this package in my ts project, I noticed that tsc did not give type hits.
After searching, I found the reason was that after the package was published to npm, the types
field was missing in package.json
. I added "types": "dist/src/main.d.ts"
in node_modules\screeps-server-mockup\package.json
to fix this problem temporarily.
But this is not a good solution. I tried to add files
and include
in the tsconfig.json
of my project to solve this problem, as follows,but nothing happened.
{
"compilerOptions": {
...
},
"files": [
"node_modules/screeps-server-mockup/dist/src/main.d.ts"
],
"include": [
"node_modules/screeps-server-mockup/**/*.d.ts",
"src/**/*.ts"
]
}
So there has any better suggestions or solutions for this problem?
I had to add the @types/screeps package to get types.
As I understand it, the @types packages were created for exactly this problem: types not exported by other npm packages.
Screenshot: [image: image.png]
Best regards, Derek
Derek R. Austin, PT, DPT, MS, BCTMB, LMT, CSCS
[image: Headshot of Doctor Derek smiling and waving at the camera.] https://www.doctorderek.com/ Dr. Derek Austin 🥳 SEO & Web Performance Expert https://doctorderek.com/ DoctorDerek.com https://doctorderek.com/ https://www.linkedin.com/in/derek-austin LinkedIn.com/in/Derek-Austin https://www.linkedin.com/in/derek-austin https://twitter.com/AskDoctorDerek Twitter.com/AskDoctorDerek https://twitter.com/AskDoctorDerek Read my blog: https://doctorderek.medium.com/ Medium.com/@DoctorDerek https://doctorderek.medium.com/
On Thu, Mar 11, 2021 at 9:15 PM huang puguang @.***> wrote:
Thanks for this great project! but I have a question about ts types.
When I used this package in my ts project, I noticed that tsc did not give type hits.
After searching, I found the reason was that after the package was published to npm, the types field was missing in package.json. I added "types": "dist/src/main.d.ts" in node_modules\screeps-server-mockup\package.json to fix this problem temporarily.
But this is not a good solution. I tried to add files and include in the tsconfig.json of my project to solve this problem, as follows,but nothing happened.
{ "compilerOptions": { ... }, "files": [ "node_modules/screeps-server-mockup/dist/src/main.d.ts" ], "include": [ "node_modules/screeps-server-mockup//*.d.ts", "src//*.ts" ] }
So there has any better suggestions or solutions for this problem?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/screepers/screeps-server-mockup/issues/46, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMV42QTF6HVX4RFSCHRNJE3TDF2K7ANCNFSM4ZBM42ZQ .
I had to add the @types/screeps package to get types.
As I understand it, the @types packages were created for exactly this problem: types not exported by other npm packages.
I had to add the @types/screeps package to get types.
As I understand it, the @types packages were created for exactly this problem: types not exported by other npm packages.
Thanks for reply, @types/screeps
provide declaration of in-game api. (I've already used it), but my issue is that I can't get the type hits of screeps-server-mockup
like below:
import { ScreepsServer } from 'screeps-server-mockup'
const server = new ScreepsServer()
server.world. // should show the api I can use, such as `addBot` or `addRoom`
The declaration here is provided by node_modules\screeps-server-mockup\dist\src\main.d.ts
instead of @type/screeps
. But in normal circumstances, I cannot access mockup declaration file.
You could take a look at the typescript conversion branch of this project. Last I looked at it, it was looking quite good but didn't get to merging it into main and publishing an update.