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 2.6.2 Auto Import and Tslint Formatting #42367

Closed
th-ko opened this issue Jan 29, 2018 · 9 comments
Closed

Better Typescript 2.6.2 Auto Import and Tslint Formatting #42367

th-ko opened this issue Jan 29, 2018 · 9 comments
Assignees
Labels
info-needed Issue requires more information from poster javascript JavaScript support issues

Comments

@th-ko
Copy link

th-ko commented Jan 29, 2018

  • VSCode Version: 1.19.3
  • OS Version: Win 10

Steps to Reproduce:

  1. Open a typescript-project
  2. Use the new auto import feature

Import should:
a) be minimal (not ending with /index)
b) respect tslints semicolon settings (as it does with quotemarks see: #21424

@vscodebot vscodebot bot added the javascript JavaScript support issues label Jan 29, 2018
@mjbvz
Copy link
Collaborator

mjbvz commented Jan 29, 2018

Are you using TS 2.2 in your workspace?

Also, please share information about your project: what is its structure? Do you have a tsconfig? What do the expected imports look like vs what the actual added imports look like?

@mjbvz mjbvz added the info-needed Issue requires more information from poster label Jan 29, 2018
@th-ko th-ko changed the title Better Typescript 2.2 Auto Import and Tslint Formatting Better Typescript 2.6.2 Auto Import and Tslint Formatting Jan 29, 2018
@th-ko
Copy link
Author

th-ko commented Jan 29, 2018

First of all, TS 2.2 was a typo. It should have been 2.6.2 (fixed the title by now).
I am having a tsconfig.json as well as a tslint.json (the project was created via create-react-app-ts).
The mentioned tslint-settings are:
"quotemark": [true, "single", "jsx-double"],
"semicolon": [true, "never"],

Assuming I am importing a constant api from the file /state/api/index.ts I would expect
import { api } from '../state/api'
instead I am getting:
import { api } from '../state/api/index';

@mjbvz
Copy link
Collaborator

mjbvz commented Jan 29, 2018

@th-ko Let's keep this issue focused on the auto-imports. Please open a separate issue for the tslint stuff.

Can you please share your tsconfig.json? I think you may need to set "module": "commonjs"

@mjbvz
Copy link
Collaborator

mjbvz commented Jan 29, 2018

Also, can you please try our the latest VS Code insiders builds. There have been a number of fixes to auto imports so this may already have been resolved

@th-ko
Copy link
Author

th-ko commented Jan 29, 2018

Using "module": "commonjs" might be a problem. Wouldn't that mean that web-packs tree-shaking wouldn't work any more?

tsconfig.json:

{
  "compilerOptions": {
    "outDir": "build/dist",
    "module": "esnext",
    "target": "es5",
    "lib": ["es6", "dom"],
    "sourceMap": true,
    "allowJs": true,
    "jsx": "react",
    "moduleResolution": "node",
    "rootDir": "src",

    "strict": true,
    "suppressImplicitAnyIndexErrors": true,
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": false,
    "noUnusedLocals": true
  },
  "exclude": [
    "node_modules",
    "build",
    "scripts",
    "acceptance-tests",
    "webpack",
    "jest",
    "src/setupTests.ts"
  ]
}

Regarding the tslint-settings: I would have assumed they are relevant as one point in this issue is the code-style of semicolons. (This one is still valid in the current insider-build)

The /index-part of the issue is resolved in the insiders-build.

BTW: Great work, loving VSCode and especially the autoimport.

@mjbvz
Copy link
Collaborator

mjbvz commented Jan 29, 2018

Semi colon part is already tracked by microsoft/TypeScript#19882 / microsoft/TypeScript#20161 I believe

I also see the correct stye imports on VS Code insiders when setting:

        "module": "esnext",
        "moduleResolution": "node",

Can you try out VS Code insiders?

@th-ko
Copy link
Author

th-ko commented Jan 30, 2018

I already have both of those set (see the posted tsconfig). However the semicolon is still appended. My version is the following:

Version 1.20.0-insider
Commit 757ff83
Datum 2018-01-29T05:13:39.772Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architektur x64

@mjbvz
Copy link
Collaborator

mjbvz commented Jan 30, 2018

@th-ko I'm only focusing on the import path issue. The semicolon issue is not fixed and tracked by the two bugs I linked

Does 1.20 fix the import path?

@th-ko
Copy link
Author

th-ko commented Jan 30, 2018

As stated above the import path issue is fixed. As the semicolon is tracked by the other bugs I will close the issue. Thanks.

@th-ko th-ko closed this as completed Jan 30, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster javascript JavaScript support issues
Projects
None yet
Development

No branches or pull requests

2 participants