When a QTable `columns` prop has the `align` set to `'left'` or `'right'` or `'center'` it throws a TypeScript error
See original GitHub issueWhat happened?
When a QTable columns
prop has the align
set to 'left'
or 'right'
or 'center'
it throws this TypeScript error:
Type '({ name: string; label: string; field: string; required: boolean; align: string; sortable: boolean; format?: undefined; } | { name: string; label: string; field: string; sortable: boolean; required?: undefined; align?: undefined; format?: undefined; } | { ...; })[]' is not assignable to type '{ name: string; label: string; field: string | ((row: any) => any); required?: boolean | undefined; align?: "left" | "right" | "center" | undefined; sortable?: boolean | undefined; sort?: ((a: any, b: any, rowA: any, rowB: any) => number) | undefined; ... 5 more ...; headerClasses?: string | undefined; }[]'.
Type '{ name: string; label: string; field: string; required: boolean; align: string; sortable: boolean; format?: undefined; } | { name: string; label: string; field: string; sortable: boolean; required?: undefined; align?: undefined; format?: undefined; } | { ...; }' is not assignable to type '{ name: string; label: string; field: string | ((row: any) => any); required?: boolean | undefined; align?: "left" | "right" | "center" | undefined; sortable?: boolean | undefined; sort?: ((a: any, b: any, rowA: any, rowB: any) => number) | undefined; ... 5 more ...; headerClasses?: string | undefined; }'.ts(2322)
[index.d.ts(10354, 3): ]()The expected type comes from property 'columns' which is declared here on type 'IntrinsicAttributes & VNodeProps & AllowedComponentProps & ComponentCustomProps & QTableProps'
The align
property of QTableProps.columns
is typed as align?: "left" | "right" | "center" | undefined;
which looks correct. So I have no idea why this is happening.
What did you expect to happen?
No TypeScript error should be showing.
Reproduction URL
n/a
How to reproduce?
- Create a new Quasar app using the Quasar CLI. Settings: TypeScript, Sass with SCSS Syntax, EsLint, Composition API, Prettier, NPM.
- Create a QTable
<q-table title="Tickets" row-key="id" :rows="rows" :columns="columns"></q-table>
- Set the
align
property on thecolumns
prop like so:
const columns = [
{
name: 'calories',
label: 'Calories',
field: 'calories',
align: 'center',
},
];
Now there will be a TypeScript error on :columns
.
Flavour
Quasar CLI with Webpack (@quasar/cli | @quasar/app-webpack)
Areas
TypeScript Support
Platforms/Browsers
Chrome
Quasar info output
Operating System - Darwin(21.4.0) - darwin/x64
NodeJs - 14.17.6
Global packages
NPM - 8.5.4
yarn - 1.22.11
@quasar/cli - 1.3.2
@quasar/icongenie - 2.4.2
cordova - Not installed
Important local packages
quasar - 2.6.1 -- Build high-performance VueJS user interfaces (SPA, PWA, SSR, Mobile and Desktop) in record time
@quasar/app-webpack - 3.4.3 -- Quasar Framework App CLI with Webpack
@quasar/extras - 1.13.3 -- Quasar Framework fonts, icons and animations
eslint-plugin-quasar - Not installed
vue - 3.2.31 -- The progressive JavaScript framework for building modern web UI.
vue-router - 4.0.13
pinia - 2.0.11 -- Intuitive, type safe and flexible Store for Vue
vuex - Not installed
electron - Not installed
electron-packager - Not installed
electron-builder - Not installed
@babel/core - 7.17.5 -- Babel compiler core.
webpack - 5.70.0 -- Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
webpack-dev-server - 4.7.4 -- Serves a webpack app. Updates the browser on changes.
workbox-webpack-plugin - Not installed
register-service-worker - 1.7.2 -- Script for registering service worker, with hooks
typescript - 4.5.5 -- TypeScript is a language for application scale JavaScript development
@capacitor/core - Not installed
@capacitor/cli - Not installed
@capacitor/android - Not installed
@capacitor/ios - Not installed
Quasar App Extensions
*None installed*
Networking
Host - MacBook-Pro.local
en0 - 192.168.20.11
Relevant log output
No response
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Inovua React Data Grid - can't set textAlign column property ...
type TextAlign = "end" | "left" | "center" | "right" | "start" | undefined;. And then in my columns, I just set the...
Read more >Word.Interfaces.TableCollectionLoadOptions interface - Office Add ...
For EACH ITEM in the collection: Gets or sets the alignment of the table against the page column. The value can be 'Left',...
Read more ><tr>: The Table Row element - HTML - MDN Web Docs - Mozilla
The HTML element defines a row of cells in a table. ... use the CSS text-align property to establish left , center ,...
Read more >Safari Technology Preview Release Notes - Apple Developer
If you already have Safari Technology Preview installed, you can update in the Software Update pane of System Preferences on macOS Monterey, or...
Read more >Documentation - Everyday Types - TypeScript
JavaScript has three very commonly used primitives: string , number , and boolean . Each has a corresponding type in TypeScript. As you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi thanks for the help.
Unfortunatley this did not work for me, it was showing the same error as before:
But this other solution did work, which was found in the comment you linked:
@BenJackGill Thank you! I spent hours to figure this out and finally I came here and saw your solution. I was about to create a new issue, but wanted to check if someone else has created it (to avoid issue duplicates)… Please, include this solution in documentation! 🙏