-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't access role from CreeperMemory #146
Comments
You have to update the types.d.ts file to include the role, which will be a
string. You'll also need to use === per ESLint.
Best regards,
Derek
Derek R. Austin, PT, DPT, MS, BCTMB, LMT, CSCS
Read my blog on Medium: https://medium.com/@DoctorDerek
Join me on LinkedIn: https://www.linkedin.com/in/derek-austin/
…On Wed, Sep 30, 2020, 2:03 PM JQE ***@***.***> wrote:
I setup the starter kit, and it works, then i start to add code.
I am now using the simplest thing i can think of
for (var name in Game.creeps) { if (Game.creeps[name].memory.role ==
"Harvester") { console.log("Harvester"); } }
When running this through the tester (or in game) i get the following error
`src/main.ts:15:34 - error TS2339: Property 'role' does not exist on type
'CreepMemory'.
15 if (Game.creeps[name].memory.role == "Harvester") {`
If i remove the interface definition from @types/screeps then it works. It
seems that for some reason i can't merge the types using the types.d.ts.
I am new to typescript definitions, anyone got any advice?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#146>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMV42QXC4EKFPYLWRGWZYNLSIN6HVANCNFSM4R7O4KUQ>
.
|
It is in the types.d.the by default.
The === is irrelevant as it won’t compile as it doesn’t see the role. Removing the interface definition from the screens types fixes it.
Sent from my iPhone
On Oct 1, 2020, at 4:50 PM, Dr. Derek Austin <notifications@github.com> wrote:
You have to update the types.d.ts file to include the role, which will be a
string. You'll also need to use === per ESLint.
Best regards,
Derek
Derek R. Austin, PT, DPT, MS, BCTMB, LMT, CSCS
Read my blog on Medium: https://medium.com/@DoctorDerek
Join me on LinkedIn: https://www.linkedin.com/in/derek-austin/
On Wed, Sep 30, 2020, 2:03 PM JQE ***@***.***> wrote:
I setup the starter kit, and it works, then i start to add code.
I am now using the simplest thing i can think of
for (var name in Game.creeps) { if (Game.creeps[name].memory.role ==
"Harvester") { console.log("Harvester"); } }
When running this through the tester (or in game) i get the following error
`src/main.ts:15:34 - error TS2339: Property 'role' does not exist on type
'CreepMemory'.
15 if (Game.creeps[name].memory.role == "Harvester") {`
If i remove the interface definition from @types/screeps then it works. It
seems that for some reason i can't merge the types using the types.d.ts.
I am new to typescript definitions, anyone got any advice?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#146>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMV42QXC4EKFPYLWRGWZYNLSIN6HVANCNFSM4R7O4KUQ>
.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#146 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAHT7ENRFIURXUOVOH5WSYDSIT2S7ANCNFSM4R7O4KUQ>.
|
Interfaces are merged by the TS processor. Effectively,
and
should become merged into one definition for Something that could be breaking this would be using I just did a fresh clone from the repo and pasted your initial for loop into What is the content of your |
OK. Node version v10.19.0 npm version 6.14.4 yarn version 1.22.5
add
contents of types.d.ts
contents of package.json
|
Thanks for the additional detail. I didn't fully understand that you were having troubles with running the test script. I had only tested the build script, which worked. I've been able to reproduce the error with I suspect then this might be related to the recent changes merging #144 . I'll continue to investigate. In the meantime, you should be able to run the build script. |
The build script does complete. However it doesn’t run on the server. Same error.
…Sent from my iPhone
On Oct 2, 2020, at 12:46 PM, Skyler Kehren <notifications@github.com> wrote:
Thanks for the additional detail. I didn't fully understand that you were having troubles with running the test script. I had only tested the build script, which worked.
I've been able to reproduce the error with npm test and yarn test. Running npm run build and yarn run build both work.
I suspect then this might be related to the recent changes merging #144<#144> . I'll continue to investigate. In the meantime, you should be able to run the build script.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#146 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAHT7ELTLYVAM4ENFB7NE7DSIYGWTANCNFSM4R7O4KUQ>.
|
Well, by the time the script is running on the server, it is plain JS and types have nothing to do with it. If you're getting a runtime error because a All of the |
It turns out you are correct. I thought I had tried running the code on the server, however it would appear i did not. It runs properly. Just the tests fail. |
I setup the starter kit, and it works, then i start to add code.
I am now using the simplest thing i can think of
for (var name in Game.creeps) { if (Game.creeps[name].memory.role == "Harvester") { console.log("Harvester"); } }
When running this through the tester (or in game) i get the following error
`src/main.ts:15:34 - error TS2339: Property 'role' does not exist on type 'CreepMemory'.
15 if (Game.creeps[name].memory.role == "Harvester") {`
If i remove the interface definition from @types/screeps then it works. It seems that for some reason i can't merge the types using the types.d.ts.
I am new to typescript definitions, anyone got any advice?
The text was updated successfully, but these errors were encountered: