Comments (2)
This is explicitly out of scope for TypeScript. Check the "Viability Checklist" again, specifically "emitting based on the type of expressions", "this isn't a runtime feature" and the Design Goals, goal 9 and non-goal 5. It's also been suggested and declined numerous times already.
While libraries like Zod allow type inference, it's not possible to infer TypeScript interfaces from schemas,
That doesn't seem to be accurate. You should be able to do this: type User = z.infer<typeof UserSchema>;
from typescript.
This is explicitly out of scope for TypeScript. Check the "Viability Checklist" again, specifically "emitting based on the type of expressions", "this isn't a runtime feature" and the Design Goals, goal 9 and non-goal 5. It's also been suggested and declined numerous times already.
Ok I didn't know about the design goals page , thank you for pointing it out. This feature would not keep typescript "fully erasable". I close this issue.
While libraries like Zod allow type inference, it's not possible to infer TypeScript interfaces from schemas,
That doesn't seem to be accurate. You should be able to do this: type User = z.infer;
You are correct I switched the words, I edited my first message to fix it.
from typescript.
Related Issues (20)
- TypeScript does not support bigint literals in type literal keys HOT 1
- Isolated declarations uses type information when emitting computed object keys HOT 6
- Error: Debug Failure when importing `AssertionError` from `node:assert/strict` HOT 4
- transpileDeclaration - Errors on unresolvable globals HOT 2
- duplicate comments on decorated fields
- Type narrowing with union types create impossible case with else statement HOT 6
- Error when using `import()` type within JSDoc tag `@implements`
- Narrowring a readonly class with instanceof of does not work on the else branch HOT 1
- Disposables disposed of, even though they are passed to a wrapper and still in use HOT 3
- It's the JSON validator that complains here. HOT 4
- Isolated declarations inconsistent about banning default assignment patterns for function parameters HOT 2
- Isolated declarations uses type information to emit return type for async function HOT 2
- Inconsistency with Rest Parameter in Function Type HOT 2
- Why is Promise<void> accepted as void HOT 3
- Hoisted vars in blocks at module scope generate in invalid `d.ts` files when referenced using `typeof` HOT 1
- Isolated declarations allows return types that reference local expr or type
- Use of intersection type leads to extremely slow typecheck times HOT 9
- Allow leading underscore for types to bypass noUnusedLocals warning
- Request to expose `getBigIntLiteralType` on the TS Type Checker
- [transpileDeclaration API][5.5] Type assertion is ignored HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript.