ESLint requiring '.ts' when importing in CRA 2.1 Typescript
up vote
0
down vote
favorite
I just adopted TypeScript in the latest Create-react-app version, and seems that eslint
requires me to include .ts
when importing ts files:
import spacing from "../css/spacing"; // eslint complains can't resolved path
import spacing from "../css/spacing.ts"; // fine
Any way that I can make the .ts
optional in imports?
reactjs typescript create-react-app
add a comment |
up vote
0
down vote
favorite
I just adopted TypeScript in the latest Create-react-app version, and seems that eslint
requires me to include .ts
when importing ts files:
import spacing from "../css/spacing"; // eslint complains can't resolved path
import spacing from "../css/spacing.ts"; // fine
Any way that I can make the .ts
optional in imports?
reactjs typescript create-react-app
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I just adopted TypeScript in the latest Create-react-app version, and seems that eslint
requires me to include .ts
when importing ts files:
import spacing from "../css/spacing"; // eslint complains can't resolved path
import spacing from "../css/spacing.ts"; // fine
Any way that I can make the .ts
optional in imports?
reactjs typescript create-react-app
I just adopted TypeScript in the latest Create-react-app version, and seems that eslint
requires me to include .ts
when importing ts files:
import spacing from "../css/spacing"; // eslint complains can't resolved path
import spacing from "../css/spacing.ts"; // fine
Any way that I can make the .ts
optional in imports?
reactjs typescript create-react-app
reactjs typescript create-react-app
edited Nov 9 at 7:52
asked Nov 9 at 7:35
kyw
536923
536923
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
If you use .js
it should work at compile time, ESLint scan time, and when running.
The reason ESLint picks up on this is that some browsers require the file extension for their module loaders.
import spacing from "../css/spacing.js";
If you are using RequireJS or similar, it is optional - but given it works with the extension across module loaders it is probably a safe bet to use the .js
.
Thanks. Importing js files without.js
has always been fine. Issue is with ts files imports that eslint complains I should end with.ts
. But I think Im gonna have to ditch eslint for tslint unless they can work together somehow. Still finding that out..
– kyw
Nov 9 at 12:25
You might be able to supress the rule if it's a problem for you.
– Fenton
Nov 9 at 13:20
ECMAScript module specification does not say that file extension is necessary. Module resolution process is an implementation-defined abstract operation, the spec says nothing about file extensions there.
– artem
Nov 9 at 15:32
@artem - quite right. It's the browser implementation, not the spec. Thanks for the comment.
– Fenton
Nov 12 at 8:59
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
If you use .js
it should work at compile time, ESLint scan time, and when running.
The reason ESLint picks up on this is that some browsers require the file extension for their module loaders.
import spacing from "../css/spacing.js";
If you are using RequireJS or similar, it is optional - but given it works with the extension across module loaders it is probably a safe bet to use the .js
.
Thanks. Importing js files without.js
has always been fine. Issue is with ts files imports that eslint complains I should end with.ts
. But I think Im gonna have to ditch eslint for tslint unless they can work together somehow. Still finding that out..
– kyw
Nov 9 at 12:25
You might be able to supress the rule if it's a problem for you.
– Fenton
Nov 9 at 13:20
ECMAScript module specification does not say that file extension is necessary. Module resolution process is an implementation-defined abstract operation, the spec says nothing about file extensions there.
– artem
Nov 9 at 15:32
@artem - quite right. It's the browser implementation, not the spec. Thanks for the comment.
– Fenton
Nov 12 at 8:59
add a comment |
up vote
1
down vote
If you use .js
it should work at compile time, ESLint scan time, and when running.
The reason ESLint picks up on this is that some browsers require the file extension for their module loaders.
import spacing from "../css/spacing.js";
If you are using RequireJS or similar, it is optional - but given it works with the extension across module loaders it is probably a safe bet to use the .js
.
Thanks. Importing js files without.js
has always been fine. Issue is with ts files imports that eslint complains I should end with.ts
. But I think Im gonna have to ditch eslint for tslint unless they can work together somehow. Still finding that out..
– kyw
Nov 9 at 12:25
You might be able to supress the rule if it's a problem for you.
– Fenton
Nov 9 at 13:20
ECMAScript module specification does not say that file extension is necessary. Module resolution process is an implementation-defined abstract operation, the spec says nothing about file extensions there.
– artem
Nov 9 at 15:32
@artem - quite right. It's the browser implementation, not the spec. Thanks for the comment.
– Fenton
Nov 12 at 8:59
add a comment |
up vote
1
down vote
up vote
1
down vote
If you use .js
it should work at compile time, ESLint scan time, and when running.
The reason ESLint picks up on this is that some browsers require the file extension for their module loaders.
import spacing from "../css/spacing.js";
If you are using RequireJS or similar, it is optional - but given it works with the extension across module loaders it is probably a safe bet to use the .js
.
If you use .js
it should work at compile time, ESLint scan time, and when running.
The reason ESLint picks up on this is that some browsers require the file extension for their module loaders.
import spacing from "../css/spacing.js";
If you are using RequireJS or similar, it is optional - but given it works with the extension across module loaders it is probably a safe bet to use the .js
.
edited Nov 12 at 8:59
answered Nov 9 at 10:44
Fenton
148k42279306
148k42279306
Thanks. Importing js files without.js
has always been fine. Issue is with ts files imports that eslint complains I should end with.ts
. But I think Im gonna have to ditch eslint for tslint unless they can work together somehow. Still finding that out..
– kyw
Nov 9 at 12:25
You might be able to supress the rule if it's a problem for you.
– Fenton
Nov 9 at 13:20
ECMAScript module specification does not say that file extension is necessary. Module resolution process is an implementation-defined abstract operation, the spec says nothing about file extensions there.
– artem
Nov 9 at 15:32
@artem - quite right. It's the browser implementation, not the spec. Thanks for the comment.
– Fenton
Nov 12 at 8:59
add a comment |
Thanks. Importing js files without.js
has always been fine. Issue is with ts files imports that eslint complains I should end with.ts
. But I think Im gonna have to ditch eslint for tslint unless they can work together somehow. Still finding that out..
– kyw
Nov 9 at 12:25
You might be able to supress the rule if it's a problem for you.
– Fenton
Nov 9 at 13:20
ECMAScript module specification does not say that file extension is necessary. Module resolution process is an implementation-defined abstract operation, the spec says nothing about file extensions there.
– artem
Nov 9 at 15:32
@artem - quite right. It's the browser implementation, not the spec. Thanks for the comment.
– Fenton
Nov 12 at 8:59
Thanks. Importing js files without
.js
has always been fine. Issue is with ts files imports that eslint complains I should end with .ts
. But I think Im gonna have to ditch eslint for tslint unless they can work together somehow. Still finding that out..– kyw
Nov 9 at 12:25
Thanks. Importing js files without
.js
has always been fine. Issue is with ts files imports that eslint complains I should end with .ts
. But I think Im gonna have to ditch eslint for tslint unless they can work together somehow. Still finding that out..– kyw
Nov 9 at 12:25
You might be able to supress the rule if it's a problem for you.
– Fenton
Nov 9 at 13:20
You might be able to supress the rule if it's a problem for you.
– Fenton
Nov 9 at 13:20
ECMAScript module specification does not say that file extension is necessary. Module resolution process is an implementation-defined abstract operation, the spec says nothing about file extensions there.
– artem
Nov 9 at 15:32
ECMAScript module specification does not say that file extension is necessary. Module resolution process is an implementation-defined abstract operation, the spec says nothing about file extensions there.
– artem
Nov 9 at 15:32
@artem - quite right. It's the browser implementation, not the spec. Thanks for the comment.
– Fenton
Nov 12 at 8:59
@artem - quite right. It's the browser implementation, not the spec. Thanks for the comment.
– Fenton
Nov 12 at 8:59
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53221516%2feslint-requiring-ts-when-importing-in-cra-2-1-typescript%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown