-
Notifications
You must be signed in to change notification settings - Fork 69
Fix/mm2 1362: Typescript errors pt 4 #208
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
4e04c0e
fix: products type mismatches
sylwia-werner ed55166
refactor: remove unused order related modules
sylwia-werner 7e681e7
Merge branch 'test' into fix/mm2-1362/typescript-errors-pt-4
sylwia-werner bbc61f1
fix: order module type mismatches
sylwia-werner a1623aa
refactor: separate order timeline component for readability
sylwia-werner 5d9716e
refactor: remove rest of unused order module files
sylwia-werner b85094e
refactor: remove console log
sylwia-werner 97cf92a
refactor: remove console log
sylwia-werner 9719ac8
Merge branch 'fix/mm2-1280/typescript-errors-pt-2' into fix/mm2-1318/…
sylwia-werner 1f094fe
fix: minor ts mismatches
sylwia-werner a837146
fix: PR fixes
sylwia-werner cb3741e
fix: PR fixes
sylwia-werner a18176d
fix: PR fixes
sylwia-werner 65db38e
fix: PR fixes
sylwia-werner 93499c3
fix: PR fixes
sylwia-werner 540958d
Merge branch 'fix/mm2-1280/typescript-errors-pt-2' into fix/mm2-1318/…
sylwia-werner dea7923
fix: PR conflicts, move types from extended-product to products
sylwia-werner 06ba9cf
Merge branch 'test' into fix/mm2-1318/typescript-errors-pt-3
sylwia-werner 71ecb73
Merge branch 'fix/mm2-1318/typescript-errors-pt-3' into fix/mm2-1362/…
sylwia-werner 7da0d41
refactor: customer group tables, flatten the data
sylwia-werner b763e5f
fix: PR fixes, refactor
sylwia-werner c0f181d
fix: PR fixes, fix rest of ts issues
sylwia-werner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // scripts/ts-check.js | ||
| // Scans src/**/*.{ts,tsx} and uses tsconfig.json compilerOptions (so JSX settings are respected). | ||
|
|
||
| const ts = require("typescript") | ||
| const glob = require("glob") | ||
| const path = require("path") | ||
|
|
||
| // 1) Collect files under /src | ||
| const files = glob.sync("src/**/*.{ts,tsx}", { absolute: true }) | ||
|
|
||
| if (files.length === 0) { | ||
| console.log("No TypeScript files found under /src.") | ||
| process.exit(0) | ||
| } | ||
|
|
||
| // 2) Try to find and parse tsconfig.json to reuse compilerOptions (important for JSX) | ||
| let compilerOptions = {} | ||
| const configPath = ts.findConfigFile( | ||
| process.cwd(), | ||
| ts.sys.fileExists, | ||
| "tsconfig.json" | ||
| ) | ||
|
|
||
| if (configPath) { | ||
| const parsed = ts.getParsedCommandLineOfConfigFile(configPath, {}, ts.sys) | ||
| if (parsed && parsed.options) { | ||
| compilerOptions = parsed.options | ||
| } else { | ||
| console.warn( | ||
| "Warning: Couldn't fully parse tsconfig.json — falling back to defaults." | ||
| ) | ||
| } | ||
| } else { | ||
| console.warn("Warning: No tsconfig.json found. Using sensible defaults.") | ||
| } | ||
|
|
||
| // 3) Ensure we don't emit and skip noisy lib checks | ||
| compilerOptions = Object.assign({}, compilerOptions, { | ||
| noEmit: true, | ||
| skipLibCheck: true, | ||
| }) | ||
|
|
||
| // 4) Create program with the explicit file list (so we ignore tsconfig includes/excludes) | ||
| const program = ts.createProgram(files, compilerOptions) | ||
|
|
||
| // 5) Collect diagnostics | ||
| const diagnostics = ts.getPreEmitDiagnostics(program) | ||
|
|
||
| if (diagnostics.length === 0) { | ||
| console.log(`✅ No TypeScript errors found in ${files.length} files.`) | ||
| process.exit(0) | ||
| } | ||
|
|
||
| // 6) Print diagnostics in "file:line:col - error TS..." form and collect stats | ||
| let errorCount = 0 | ||
| const filesWithErrors = new Set() | ||
|
|
||
| diagnostics.forEach((diag) => { | ||
| if (diag.file) { | ||
| const { line, character } = diag.file.getLineAndCharacterOfPosition( | ||
| diag.start | ||
| ) | ||
| const message = ts.flattenDiagnosticMessageText(diag.messageText, "\n") | ||
| const relativeFile = path.relative(process.cwd(), diag.file.fileName) | ||
|
|
||
| console.log( | ||
| `${relativeFile}:${line + 1}:${character + 1} - error TS${diag.code}: ${message}` | ||
| ) | ||
|
|
||
| errorCount++ | ||
| filesWithErrors.add(relativeFile) | ||
| } else { | ||
| // global/unbound diagnostic | ||
| console.log( | ||
| `error TS${diag.code}: ${ts.flattenDiagnosticMessageText(diag.messageText, "\n")}` | ||
| ) | ||
| errorCount++ | ||
| } | ||
| }) | ||
|
|
||
| // 7) Summary | ||
| console.log("\n--- TypeScript Check Summary ---") | ||
| console.log(`Scanned files: ${files.length}`) | ||
| console.log(`Files with errors: ${filesWithErrors.size}`) | ||
| console.log(`Total errors: ${errorCount}`) | ||
|
|
||
| process.exit(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/components/table/table-cells/product/variant-cell/variant-cell.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
IMO those nevers should be removed
I tried something more strict but looks horrible
key: keyof TData | keyof TData[keyof TData][keyof TData[keyof TData]]or
type NestedKeys = keyof T | keyof T[keyof T][keyof T[keyof T]]
export type DataTableOrderByKey = {
key: keyof TData | NestedKeys
label: string
}
another proposed by (AI)an
type NestedKeys = {
[K in keyof T]: T[K] extends object
?
${string & K}.${string & keyof T[K]}: never
}[keyof T]
export type DataTableOrderByKey = {
key: keyof TData | NestedKeys
label: string
}
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.
My version kept autocomplete, will take a look at yours 👍
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.
I left it as it was:
key: keyof TDataI flattened the data before passing it to the table, problem solved