Skip to content

Using TypeScript for type checking, not for transpilation #4765

Closed
@johnnyreilly

Description

@johnnyreilly

Hi,

TypeScript doesn't provide transpilation for all ES6 constructs. I've been writing ES6 + JSX and working with Babel and React of late. I'm more than happy with the way Babel transpiles and brings in core js. It works really well.

But I still want TypeScript in the mix for static typing purposes. There's 2 ways to go about this; use TypeScript to emit ES5 and work out how to bring core-js into the mix. I'm not aware of clear guidance on how to make TypeScript play well with core js. I don't think it's out there - and to be fair I haven't tried it out.

The other way, and the way I currently favour, is just using TypeScript for static typing and handing off transpilation to a 3rd party tool such as Babel. This seems potentially possible at present through the use of these compiler options: "target": "ES6" and "jsx": "preserve"

I'm guessing this is something that will always work as long as you target the highest ES emit target (currently ES6 but as async / await etc start to drop then presumably ES7 will become the highest). Is this behaviour we can rely on? Is there any reason we should not?

Is there anything I've overlooked? Does the module import syntax cause any issues? Perhaps the caveat is: the user must be writing 100% ESLatest code + types. And TypeScript-only features (enums for example) will still be transpiled I guess (otherwise how would they work).

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions