question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TypeScript] Type check accross files

See original GitHub issue

Currently:

// 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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
brilloutcommented, Nov 3, 2021

I guess we’d need to try. PR welcome.

0reactions
brilloutcommented, Feb 28, 2022

There doesn’t seem to be a way to achieve this; see disucssion at https://github.com/brillout/vite-plugin-ssr/pull/219.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found