You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.9.2
Plugin version
2.1.1
Node.js version
16.13.0
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
22.04
Description
Hi.
I stumbled over the example code of the fastify docs, similar to the closed issue #12. There is a TypeScript Playground Link given where everything is expected to be properly configured. As I were unable to extract all desired information, I moved to codesandbox with the given code I had to add the dependencies there.
import { JsonSchemaToTsProvider } from "@fastify/type-provider-json-schema-to-ts";
import fastify from "fastify";
const server = fastify().withTypeProvider<JsonSchemaToTsProvider>();
server.get(
"/route",
{
schema: {
querystring: {
type: "object",
properties: {
foo: { type: "number" },
bar: { type: "string" }
},
required: ["foo", "bar"]
}
} as const
},
(request) => {
const { bar } = request.query;
bar.push("foo"); // I'd expect this to fail with `error TS2339: Property 'push' does not exist on type string`
}
);
as you can see, the desired unwrapping does not take place. Instead it says: "property bar does not exist on type unkndown" What am I doing wrong? Or did it break with the new TS version that has been released (our assumption)?
Steps to Reproduce
Use code outlined above. Ensure to use Typescript Version 4.8.4.
Or see the live example at codesandbox
Expected Behavior
No response
The text was updated successfully, but these errors were encountered:
s10z
changed the title
Property bar does not exist on type in the docs example
Property bar does not exist on type in the docs example using TS4.8.4
Nov 14, 2022
Prerequisites
Fastify version
4.9.2
Plugin version
2.1.1
Node.js version
16.13.0
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
22.04
Description
Hi.
I stumbled over the example code of the fastify docs, similar to the closed issue #12. There is a TypeScript Playground Link given where everything is expected to be properly configured. As I were unable to extract all desired information, I moved to codesandbox with the given code I had to add the dependencies there.
Final the setup is:
package.json
tsconfig.json
and index.ts
as you can see, the desired unwrapping does not take place. Instead it says: "property bar does not exist on type unkndown" What am I doing wrong? Or did it break with the new TS version that has been released (our assumption)?
Steps to Reproduce
Use code outlined above. Ensure to use Typescript Version 4.8.4.
Or see the live example at codesandbox
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: