Could we have TypeScript with no build step? Could we have types in JavaScript? Maybe! We're exploring bringing optional type syntax into the JavaScript language! devblogs.microsoft.com/typescript/a-p…
The Types as Comments proposal means that browsers could run TypeScript-checked code directly, (even though they wouldn't do any type-checking). That means faster iteration with all the type-checking and editing experience you know and love today.
We're excited to hear what you think of this idea! We're hoping that this proposal can make coding easier for TypeScript and JavaScript users at every scale.
@typescript What about TS syntax that generate code? Would these language features be discouraged?
@typescript Why bother? Typescript is already broadly adopted and every major framework supports it (which is a great accomplishment!). The only use case I see is large legacy JS codebases but since you can already progressively adopt TS, that's largely covered....
@typescript I don't understand the motivation for this. The browser is a compilation target for most devs today, has been since uglify/Closure. Why do I need static analysis functionality there? Is this just an opportunity to redo TypeScript with a clean set of rules?
@typescript Quit bloating the ECMA262 spec and JS parser implementations with type-specific garbage We have the ability to define type annotations already w/ JSDoc
@typescript In principle this is a fine idea, but I think tools like ESBuild, SWC and Deno have already changed the development experience for TS to feel nearly transparent...
@typescript Concerned that it can limit the ability to improve Typescript going forward". Has to satisfy the keywords/syntax in the proposal. E.g if this proposal was accepted 2 years ago, we would not be able to introduce non-null assertion operator (!)
@typescript Awesome, if people are bothered about the size of the files, then they should start thinking about minifying their files anyway so this should not be an issue.
@typescript I would really love it if we could just fix the fundamental typing problem. > 0 == “0” // true > 0 == [] // true > “0” == [] // false Like the blog says, browsers are evergreen now. Why not support a comment or global function that that does “sane typing” instead?
@typescript Very cool - Glad to see mention of the developer experience. There are a whole bunch of TS compatible tools today focusing on making DX better (faster!) - How does the TS team think about the future of tsc’s performance?
@typescript Types aren't a feature that end-users can see or enjoy - the only thing they might experience is more wasted bandwidth if people actually begin to deploy types. This is a developer feature - just build this into DevTools, or build an extension that can do it. Why not?
@typescript It would be more amazing if we had optional types with runtime type checking. But if we go the path of optional types that have no runtime meaning, then adding runtime meaning becomes very difficult, requires alternative syntax, and leaves us with two whole separate syntaxes.
@typescript Wouldn’t this mean we’re shipping extra code to the browser that doesn’t actually do anything useful?
@typescript Compile target is still a thing.. It may help during development however