[TypeScript] Type check accross files
See original GitHub issueCurrently:
// server/index.js
app.get("*", async (req) => {
const pageContextInit = {
url: req.url,
someInitProp: 'hello :-)'
}
const pageContext = await renderPage(pageContextInit)
// TS complains that `someNewProp` is not defined on `pageContext`
console.log(pageContext.someNewProp) // prints `42`
});
// some.page.server.js
import type { PageContextBuiltIn } from "vite-plugin-ssr";
epxort async function onBeforeRender(pageContext: PageContextBuiltIn) {
// TS complains that `someInitProp` is not defined on `pageContext`
console.log(pageContext.someInitProp) // prints `hello :-)`
return {
pageContext: {
someNewProp: 42
},
};
}
How can we improve the situation?
AFAICT, something like Next.js’ utility types don’t add any value compared to vite-plugin-ssr
’s PageContextBuiltIn
.
Contribution welcome.
CC @stouffi
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:11 (10 by maintainers)
Top Results From Across the Web
Documentation - Type Checking JavaScript Files - TypeScript
Here are some notable differences on how checking works in .js files compared to .ts files. Properties are inferred from assignments in class...
Read more >Type Checking JavaScript Files
Type Checking JavaScript Files ... TypeScript 2.3 and later support type-checking and reporting errors in .js files with --checkJs . You can skip...
Read more >Methods for TypeScript runtime type checking - LogRocket Blog
Explore five methods of performing TypeScript type checks at runtime in this post and learn each of their advantages and disadvantages.
Read more >Type-Checking JavaScript Files with --checkJs in TypeScript
The idea behind the blocklist approach is to type-check every JavaScript file by default. This can be achieved by setting the --checkJs compiler ......
Read more >How to type check a single file from command line, using the ...
Write a script that generates a temporary tsconfig.json file that extends your original tsconfig.json and sets files to just the file you want....
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
I guess we’d need to try. PR welcome.
There doesn’t seem to be a way to achieve this; see disucssion at https://github.com/brillout/vite-plugin-ssr/pull/219.