How typesafe can a remote be with Typescript?
See original GitHub issueUpdate from @ScriptedAlchemy - https://www.npmjs.com/package/@module-federation/typescript has been released
I can see a disadvantage using remotes libraries vs the classical libraries where e.g. typescript can be used to enforce strong types. The current typescript example defines a generic app2/Button
which is similar defining a any
type.
As the remote var does not have type, I don’t see a way to benefit from the app2
types in app1
. Any idea on this?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:50
- Comments:82 (24 by maintainers)
Top Results From Across the Web
TypeScript Types for Federated Modules and Microfrontends
Microfrontends aren't the only thing you can use module federation for, but it's certainly ... How typesafe can a remote be with Typescript?...
Read more >How to keep types while using module federation? | by Josh Lin
How typesafe can a remote be with Typescript ? May 5… github.com. That is a good question, let's break it down first. module...
Read more >Translating API responses into type-safe interfaces with ...
Translating API responses into type-safe interfaces with TypeScript ... HTTP APIs using JSON as a data exchange format are characterized by a ...
Read more >Type safe client-side queries in TypeScript - ITNEXT
Since we want our queries to support looking up fields from a remote source, we could add a with_field method. This method will...
Read more >Building an end-to-end typesafe API — without GraphQL
As TypeScript approaches near-universal adoption in the JS ecosystem, that means most GraphQL-based projects will soon be TypeScript-based ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ill raise this with Microsoft - they will have to support federation since they are going to be using it heavily
What I have done is use node to generate a .d.ts file, that are loaded by our global.d.ts file.
So each Remote outputs a .d.ts file that go
declare module "dlaWidgets/Widets" {}
, with using the ts.createProgram you can tap into the typeChecker stuff that i use to print its public api. Kinda like getting tsc to ouput definition files, but instead spit them into a single file.Then each of my hosts import this .d.ts file, which I have registered in a global.d.ts, that all of my projectReferenced monorepo apps include.
So there is a small disconnect between a webpack config, and the types. But any exposed things, are automagically available with types in my entire app. So ts might say its a valid import, but just need to actially configure it with webpack also.
Working on open sourcing this generative thing - just gotta make sure it works in all use cases.