Skip to content

Playground should run compiler as emitDeclarationOnly when in JS mode #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 tasks done
thw0rted opened this issue Nov 27, 2019 · 3 comments
Closed
5 tasks done
Labels
Playground Issues that affect the Playground

Comments

@thw0rted
Copy link

Search Terms

playground, allowJS, emitDeclarationOnly

Suggestion

Right now if you set the Playground "Lang" to JavaScript, the right side (output) pane just shows a comment about not needing to compile because the source is JS. Instead, it should default to running tsc --allowJS --emitDeclarationOnly so that we can see the .d.ts file that would be created for the source.

Use Cases

Now that the compiler can be used to create typings based on JSDoc comments in JS code, it would be helpful to have an online sandbox for illustrating how certain JSDoc directives work. For example, if I want to open an issue here about a JSDoc feature misbehaving or some syntax that I'd like to see supported, being able to just put the code up on Playground would make things much easier for everyone involved.

Examples

When I run tsc with the emitDeclarationOnly flag, I get a typings file that I can include when consuming the (JS) code from TS. Playground should generate and show that file.

If implemented we could have a helpful online example of e.g. microsoft/TypeScript#31410, microsoft/TypeScript#30624, etc

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.
@orta orta transferred this issue from microsoft/TypeScript Nov 27, 2019
@orta
Copy link
Contributor

orta commented Nov 27, 2019

A better explanation of #59

@orta orta added the Playground Issues that affect the Playground label Nov 27, 2019
@orta
Copy link
Contributor

orta commented Nov 27, 2019

Fixed by orta/typescript-play#35

@orta orta closed this as completed Nov 27, 2019
@orta
Copy link
Contributor

orta commented Nov 27, 2019

Thanks! I needed a fresh kick to think about that one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Playground Issues that affect the Playground
Projects
None yet
Development

No branches or pull requests

2 participants