-
-
Notifications
You must be signed in to change notification settings - Fork 66
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: Don't replace .d.ts paths #234
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
*/ | ||
|
||
/** */ | ||
import { isAbsolute, normalize, relative, resolve } from 'path'; | ||
import { isAbsolute, normalize, relative, resolve, parse, sep } from 'path'; | ||
import { findBasePathOfAlias, relativeOutPathToConfigDir } from '../helpers'; | ||
import { Alias, IProjectConfig, PathLike } from '../interfaces'; | ||
|
||
|
@@ -79,9 +79,21 @@ export class TrieNode<T> { | |
prefix: alias.replace(/\*$/, ''), | ||
// Normalize paths. | ||
paths: paths[alias].map((path) => { | ||
path = path | ||
.replace(/\*$/, '') | ||
.replace(/\.([mc])?ts(x)?$/, '.$1js$2'); | ||
path = path.replace(/\*$/, ''); | ||
|
||
const { dir, base } = parse(path); | ||
|
||
const dotIndex = base.indexOf('.'); | ||
const name = base.slice(0, dotIndex); | ||
const extension = base.slice(dotIndex); | ||
|
||
const normalizedExtension = extension.replace( | ||
/^\.([mc])?ts(x)?$/, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a Files to definitely exclude:
If you'd like me to look into a better way, I can. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided I may as well push a fix for |
||
'.$1js$2' | ||
); | ||
|
||
path = dir + sep + name + normalizedExtension; | ||
|
||
if (isAbsolute(path)) { | ||
path = relative( | ||
resolve(config.configDir, config.baseUrl), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might wonder why I did this instead of just using the extension already given to me by
parse
. This is because they considerxyz.d.ts
to have a name ofxyz.d
and an extension of.ts