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

feat: resolve declaration files (e.g. .d.ts) as a last resort [sc-23313] #1023

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/cli/src/services/check-parser/package-files/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ type CoreExtensionMapping = {
}

/**
* Unlike TypeScript's native lookup order, our lookup order prefers
* implementation files to declaration files.
*
* Why include declaration files at all? Some of our users use manually
* created declaration files as essentially shared header files without a
* corresponding implementation file, and the declaration is the only thing
* we'll be able to find. Otherwise we'd complain about a missing dependency.
*
* @see https://www.typescriptlang.org/docs/handbook/modules/reference.html#file-extension-substitution
*/
export const tsCoreExtensionLookupOrder: CoreExtensionMapping = {
'.js': ['.ts', '.tsx', '.js', '.jsx'],
'.mjs': ['.mts', '.mjs'],
'.cjs': ['.cts', '.cjs'],
'.js': ['.ts', '.tsx', '.js', '.jsx', '.d.ts'],
'.mjs': ['.mts', '.mjs', '.d.mts'],
'.cjs': ['.cts', '.cjs', '.d.cts'],
'.json': ['.json'],
}

Expand Down
Loading