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

fix: support evaluating TypeScript files by default. fixes #27 #283

Merged
merged 1 commit into from Dec 19, 2018

Conversation

satya164
Copy link
Member

No description provided.

@callstack-bot
Copy link

callstack-bot commented Dec 15, 2018

Hey @satya164, thank you for your pull request 🤗.
The coverage report for this branch can be viewed here.

@satya164 satya164 force-pushed the @satya164/resolve-typescript branch 2 times, most recently from db661f7 to bf121b9 Compare December 16, 2018 00:17
@@ -58,10 +59,35 @@ class Module {
this.require.resolve = this.resolve.bind(this);
this.require.ensure = NOOP;
this.require.cache = cache;

// We support following extensions by default
this.extensions = ['.json', '.js', '.ts', '.tsx'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add .jsx as well? I'm cool with not adding that and forcing others to just use .js though :D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

death to .jsx

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should kill .tsx as well then XD

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thymikee I would if I could. But due to syntax ambiguity with deprecated typecast syntax, TypeScript relies on the .tsx extension to understand JSX!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a shame. Flow doesn't have these issues :D Hopefully they can get rid of deprecations soon 🙂

@@ -86,15 +112,16 @@ class Module {
// we would end up in infinite loop with cyclic dependencies
cache[filename] = m;

if (/\.(js|json)$/.test(filename)) {
// For JS/JSON files, we need to read the file first
if (/\.(json|js|tsx?)$/.test(filename)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safer to generate this regex based on this.extensions, but that's not gonna change too often, so feel free to ignore this advice

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

Successfully merging this pull request may close these issues.

None yet

4 participants