Skip to content
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

Better TypeScript support #1378

Closed
mohsen1 opened this issue May 16, 2018 · 15 comments
Closed

Better TypeScript support #1378

mohsen1 opened this issue May 16, 2018 · 15 comments

Comments

@mohsen1
Copy link
Contributor

mohsen1 commented May 16, 2018

💬 RFC Better TypeScript support

TypeScript is working out of the box for the most part but there are a few pain points:

Pain points

Improvements

🔦 Context

TypeScript is pretty popular and having first class support for it in Parcel will attract a wider range of users.

💻 Examples

I tried cloning react-parcel-example and making repo states that demonstrate those pain points:

  1. JSX is not working in default mode (preserve):
  2. baseUrl config is not working
@fathyb
Copy link
Contributor

fathyb commented May 16, 2018

Duplicates :


parcel-plugin-typescript implements the TypeScript module resolution (baseUrl, paths). allowSyntheticDefaultImports is not part of the module resolution algorithm, it's used for the module symbol resolution by the type-checker. If you are using TypeScript 2.8+ you should be able to import synthetic defaults.

The plugin is originally a spin-off of a PR implementing type-checking, but the feature wasn't well received by the community, so I guess it's better to leave the choice to the end user.

The TypeScript plugin will probably be integrated as a core plugin once we settle on a plugin RFC though (aka 2.0). The long term goal would be to integrate TypeScript just like we do with Babel, and let developers use a pure TypeScript toolchain with or without Babel.

@DeMoorJasper
Copy link
Member

DeMoorJasper commented May 17, 2018

This will probably automatically happen once the new plugin system lands and we split up every plugin in a seperate package. Using parcel-plugin-ts as the default in that case. This will be part of the Parcel v2.0 update

@szagi3891
Copy link

@DeMoorJasper - When could this happen?

@DeMoorJasper
Copy link
Member

Please use the +1 button instead of adding comments saying +1

@parcel-bundler parcel-bundler deleted a comment from joseluisq Jun 19, 2018
@parcel-bundler parcel-bundler deleted a comment from uoziod Jun 19, 2018
@mihailik
Copy link

mihailik commented Jun 27, 2018

1627 Support <script src="tsconfig.json"></script> as asset type might be a way to solve many of those issues.

Rather than stretch parcel's file-based current TS handling, allow a way to fall back into TS standard way, using tsconfig.json directly.

That way all the resolution, errors, special modes will reside in TS compiler, and act in familiar TS manner.

@quantuminformation
Copy link

This best loaders use native typescript as much as possible.

SergeyZh pushed a commit to JetBrains/intellij-community that referenced this issue Feb 25, 2019
Remove compiled version of start-up-visualizer from source code in favour of externally hosted (for now - https://ij-perf.develar.org)
In general, nothing stops us to continue providing because still it is small text only js file, but not clear does it worth it or not.

Migrate from parcel to webpack because:

1. SRI support — https://github.com/waysact/webpack-subresource-integrity (parcel issue: parcel-bundler/parcel#2003)
2. Full typescript support (including type checking) — https://github.com/TypeStrong/ts-loader & https://github.com/Realytics/fork-ts-checker-webpack-plugin (parcel issue: parcel-bundler/parcel#1378)
3. Externals support — https://webpack.js.org/configuration/externals/ (parcel issue: parcel-bundler/parcel#144) There is workaround, but still because of lack type checking for typescript parcel is no-go.

So, parcel is good for very small projects during experimenting but not suitable for any production usage. Yeach, a lot of things in webpack can be simplified without sacrificing user-friendly (so funny bug that documented flag `optimize-minimize` doesn't work if `mode` also specified - and so on), but as no webpack alternatives at the moment, it is ok to write monstrous webpack.config.js
@inad9300
Copy link

inad9300 commented Jun 7, 2019

Wow, this seems to have been completely abandoned. Despite TypeScript's increase in popularity. Still no type checks.

@mischnic
Copy link
Member

mischnic commented Jun 7, 2019

We are working on this for Parcel 2.

@tgroutars
Copy link

@mischnic Awesome, is there an issue we can follow for updates on parcel 2?

@mihailik
Copy link

mihailik commented Jun 8, 2019

@tgroutars comment above refers to Parcel 2/TypeScript transformer:

Screenshot from 2019-06-08 21-21-24

Mind you, that PR is old and not handling type checks (yet?)

@mischnic
Copy link
Member

mischnic commented Jun 8, 2019

The current PR is #3083 (but doesn't have type checking either)

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Jun 9, 2019

Some initial work on typechecking: see #3142

@nexussays
Copy link

I posted a workaround for type errors in the console in a comment in #465 that others might find useful: #465 (comment)

I'm cross-posting because there are several issues on this topic and I'm not actually sure where I arrived from google; so this will hopefully save everyone else some time going through GitHub issues.

@mischnic mischnic added the Stale Ignore This issue is exempt from getting flagged as stale and autoremoved label Jan 17, 2020
@mohsen1 mohsen1 closed this as completed Jan 17, 2020
@mischnic mischnic reopened this Jan 17, 2020
@mischnic mischnic removed the Stale Ignore This issue is exempt from getting flagged as stale and autoremoved label Jan 17, 2020
@parcel-bundler parcel-bundler deleted a comment from stale bot Jan 17, 2020
@bbugh
Copy link

bbugh commented Jan 21, 2020

I created an issue for Parcel 2 about the incomplete TypeScript support, and the official response by @DeMoorJasper is that Parcel 2 will effectively behave the same as Parcel 1 by stripping out TypeScript and treating it as JavaScript with babel. TypeScript code will not be compiled, so there will be no type checking or compiler errors. If you have a desire for real TypeScript support in Parcel 2, please comment in the new RFC: #4022

@devongovett
Copy link
Member

Going to close this. Parcel 2 now does support loading setting from tsconfig.json and respects baseUrl, paths, etc. Type checking is not supported, but could be implemented in a third party plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests