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

Support for typescript path aliases #33

Closed
danielpza opened this issue Oct 1, 2021 · 2 comments
Closed

Support for typescript path aliases #33

danielpza opened this issue Oct 1, 2021 · 2 comments

Comments

@danielpza
Copy link

Hello, great plugin. I think this is more of a feature request than a bug, but when using typescript path aliases it organizes the global imports from inside the project first than the node_modules global imports.

Expected sorting

  • global node_modules imports
  • global project imports (defined by path aliases)
  • relative imports

But with path aliases (depending on the configuration), global project imports will appear first before the node_modules imports. Right now there's no distinction between global node_modules and global project imports.

tsconfig.json:

{
  "baseUrl": "./",
  "paths": { "@/*": ["./src/*"], },
}

file system:

.
├── src
│   ├── app.js
│   ├── components
│   │   ├── Button.js
│   │   └── Home.js
│   └── shared
│       ├── log.js
│       └── utils.js
└── tsconfig.json

Home.js expected order:

import React from 'react';
import { log } from '@/shared/log';
import Button from './Button';

Instead the result is:

import { log } from '@/shared/log';
import React from 'react';
import Button from './Button';

@/shared/log will be aliased after compilation to ../shared/log, so I expect it to be after react which is a node_module import

@danielpza
Copy link
Author

Actually I realize this is an issue upstream on typescript, microsoft/TypeScript#30456

@simonhaenisch
Copy link
Owner

Afaik TypeScript doesn't care at all where the import comes from, it just sorts them alphabetically? TBH I also really don't care about the order, I usually don't even look at the import statements anymore... so I couldn't care less how exactly they are sorted, as long as it's consistent (i. e. doesn't cause any merge conflicts/weird git diffs).

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

No branches or pull requests

2 participants