After upgrading to 0.32.5 from 0.31.28 I'm getting a new typescript error.
Looking at the breaking changes in the release notes did not help me identify what could be the cause.
Consider this trimmed down version of my code:
import { Type } from '@sinclair/typebox';
import type { StaticDecode, TSchema } from '@sinclair/typebox';
type EnvSpec = Record<Uppercase<string>, TSchema>;
const schemaFromSpec = <T extends EnvSpec>(spec: T) =>
Type.Partial(Type.Object(spec));
type EnvType<T extends EnvSpec> = StaticDecode<
ReturnType<typeof schemaFromSpec<T>>
>;
export const envLoaderFactory =
<T extends EnvSpec>(spec: T) =>
(): EnvType<T> => {
// originally there was some Value.Check and Value.Decode here but they do not impact the issue
return null as any; // not relevant to the issue
};
No TS errors with 0.31.28.
With 0.32.5 I'm getting this error:
The inferred type of 'envLoaderFactory' cannot be named without a reference to '../../../node_modules/@sinclair/typebox/build/import/type/static/static.mjs'. This is likely not portable. A type annotation is necessary.ts(2742)
Typescript: 5.3.3
NodeJS: v20.10.0
package.json: "type": "module"
tsconfig.json:
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"declaration": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"skipLibCheck": true,
"strict": true,
"types": ["vitest/globals"]
}
}
After upgrading to
0.32.5from0.31.28I'm getting a new typescript error.Looking at the breaking changes in the release notes did not help me identify what could be the cause.
Consider this trimmed down version of my code:
No TS errors with
0.31.28.With
0.32.5I'm getting this error:Typescript:
5.3.3NodeJS:
v20.10.0package.json:
"type": "module"tsconfig.json:
{ "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { "target": "ESNext", "module": "NodeNext", "moduleResolution": "NodeNext", "declaration": true, "checkJs": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "noUncheckedIndexedAccess": true, "noUnusedLocals": true, "skipLibCheck": true, "strict": true, "types": ["vitest/globals"] } }