-
Notifications
You must be signed in to change notification settings - Fork 12.8k
generated output don't follow moduleSuffixes
option
#49586
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
Comments
Nothing in TS re-writes import paths. They only inform TS about existing path mappings. |
What makes you think that's the purpose of |
i read that from blog here , so i naively think that that's the purpose |
Sorry it wasn't more explicit - we won't do path rewriting. So if you have a bundler or resolver plugin that will try to look up |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
@DanielRosenwasser // react-native use-case: import './foo' -> search for foo.ios.ts, then foo.native.ts, and finally foo.ts
{
"compilerOptions": {
// empty string --> match without an extension
"moduleSuffixes": [".ios", ".native", ""]
}
} The original intend is above. |
It will resolve that way, but we won't rewrite the paths when we output JavaScript code. We expect that a loader of some sort will prefer If something isn't working for you, I'd guess it's probably because Node.js doesn't do that by default. You'll need to find some sort of loader hook for it. |
Sorry this isn't clear. This lets TypeScript build a matching file graph and run type-checking on it. For example, when building a React Native Android app, Metro will only bundle .android.ts files, it won't bundle .ios.ts files. So .ios.ts files should not be considered when type-checking Android builds. |
@afoxman @DanielRosenwasser But I do have the wrong logic of module load though. Maybe I should publish a new issue. |
I feel that documentation on https://www.typescriptlang.org/tsconfig#compilerOptions is very poor for paths and suffixes if this is the behaviour. It should clearly state that this will not change the output of TSC |
I found that here: https://www.typescriptlang.org/docs/handbook/module-resolution.html#additional-module-resolution-flags. |
Bug Report
typescript generated output don't follow
moduleSuffixes
option,🔎 Search Terms
searched terms:
moduleSuffixes
, result none🕗 Version & Regression Information
[email protected] and typescript@next(4.8.0-dev.20220616)
💻 Code
create 2 ts files
a.web.ts
a.node.ts
create index.ts
create tsconfig.json with
run
tsc -w
stackblitz link
🙁 Actual behavior
generated index.js directly imports
a
from './a'🙂 Expected behavior
generated index.js directly imports
a
from './a.node' according to moduleSuffixesThe text was updated successfully, but these errors were encountered: