Comments (5)
What I did was add:
/// <reference types="nakama-runtime" />
To the top of my index.ts
file for the server, which brought in the imports without a tsconfig change.
I debated adding export = nkruntime
at the end of the .d.ts in this file and then submitting those changes here which would allow for import type nkruntime from "nakama-runtime"
. But if all of the globals are always in the runtime, then it felt like allowing for the import is a bit unrealistic and left it at that.
from nakama-common.
@MarcusRiemer Happy to take on this advice. Can you explain what you mean by dangerous about adding to the typeRoots? I'm not a TypeScript export so any help is appreciated.
from nakama-common.
"Dangerous" in the sense of "Marcus was once bitten by a globally declared conflicting var Observable: any
that some unrelated package provided and therefor forgot to import RxJS after copy and pasting stuff around which led to surprising errors at runtime".
If I understand correctly the nkruntime
functions are exposed to Typescript but are implemented in Go? So they are guaranteed to be available, even though there is no visible implementation? In that case the type only imports should perfectly fit this usecase, as they are purely compile time constructs and therefore never surface in the compiled JavaScript.
from nakama-common.
fwiw: I ran through most of the Typescript setup process (including Rollup, excluding building via docker) with the import type { nkruntime } from "nakama-runtime";
and the hacked index.d.ts
and everything seems to work fine. I was a little puzzled that everything also works with the normal import
statement which is probably due to the fact that all callbacks receive the relevant instances as arguments anyway. So I guess its possible to just use a normal import
, but I will see what happens if I try to do some more interesting things.
from nakama-common.
That's also how I solved it (with the old style reference)
from nakama-common.
Related Issues (20)
- HttpMethod no "DELETE" HOT 3
- Wasm HOT 6
- Version 1.28.0 in package.json for v1.28.1 release
- Typescript type mismatch for nkruntime.Context.vars HOT 1
- index.d.ts: MatchInitFunction params wrong type + documentation update required HOT 2
- [TS] Nakama-Project-Template Typescript compile npx tsc fails On MatchSignal is missing in type... HOT 5
- Typescript: Error create tournament? HOT 5
- [TS] Feature request: allow the user to specify the state type for the Authoritative Multiplayer matches HOT 1
- Add missing function declarations to Typescript HOT 1
- [TS] Fix wrong binary array data declaration HOT 2
- [BUG] registerAfterDeleteNotifications HOT 3
- TypeScript: wrong field name in ValidatedPurchase HOT 1
- [GO] fix the response result for the WalletUpdate function HOT 3
- [GO] fix some error messages HOT 1
- Typo in authenticateGameCenter method
- [TS] hmacSha256Hash base64Url encoding issue HOT 3
- [TS] `recorded` Parameter not exposed in `accountDeleteId`
- [TS] base64UrlEncode vs base64Encode HOT 1
- nkruntime.accountExportId returns a Uint8Array instead of a string HOT 1
- [TS] Problem with base64UrlDecode (wrong length) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nakama-common.