question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected TS problem with q-table

See original GitHub issue

What happened?

Creating a project from scratch with the quasar CLI and adding:

    <q-table :columns="cols"> </q-table>
  </q-page>

    const cols = ref([
      { label: 'hello', name: '123', field: '123', align: 'left' },
    ]);

The problem emerges in VS Code when I add the “align” field to the column data object:


Type '{ label: string; name: string; field: string; align: string; }[]' is not assignable to type '{ name: string; label: string; field: string | ((row: any) => any); required?: boolean; align?: "left" | "right" | "center"; sortable?: boolean; sort?: (a: any, b: any, rowA: any, rowB: any) => number; ... 5 more ...; headerClasses?: string; }[]'.
  Type '{ label: string; name: string; field: string; align: string; }' is not assignable to type '{ name: string; label: string; field: string | ((row: any) => any); required?: boolean; align?: "left" | "right" | "center"; sortable?: boolean; sort?: (a: any, b: any, rowA: any, rowB: any) => number; ... 5 more ...; headerClasses?: string; }'.

This might be a Volar issue, I don’t know.

What did you expect to happen?

I expected no problems by adding the align field

Reproduction URL

n/a

How to reproduce?

create an app with vite and typescript usning the quasar cli. then add a q-table: <q-table :columns="cols"> </q-table> and create a variable with the align property like this: const cols = ref([ { label: ‘hello’, name: ‘123’, field: ‘123’, align: ‘left’ }, ]);

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-webpack | @quasar/app-vite)

Platforms/Browsers

No response

Quasar info output

No response

Relevant log output

No response

Additional context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
robfordwwcommented, Mar 20, 2022

solved it:

 const cols: QTableProps['columns'] = [
      { label: 'hello', name: '123', field: '123', align: 'left' },
    ];
1reaction
robfordwwcommented, Mar 20, 2022

@yusufkandemir Thanks for your answer, but I don’t think it addresses this problem:


const cols = [{ label: 'hello', name: '123', field: '123' }];  // is no errors in VS code
const cols = [{ label: 'hello', name: '123', field: '123', align: 'left' }];  // creates the following raw message in the 

[{
	"resource": "/C:/Users/___/dev/quasar-project/src/pages/IndexPage.vue",
	"owner": "_generated_diagnostic_collection_name_#1",
	"code": "2322",
	"severity": 8,
	"message": "Type '{ label: string; name: string; field: string; align: string; }[]' is not assignable to type '{ name: string; label: string; field: string | ((row: any) => any); required?: boolean; align?: \"left\" | \"right\" | \"center\"; sortable?: boolean; sort?: (a: any, b: any, rowA: any, rowB: any) => number; ... 5 more ...; headerClasses?: string; }[]'.\n  Type '{ label: string; name: string; field: string; align: string; }' is not assignable to type '{ name: string; label: string; field: string | ((row: any) => any); required?: boolean; align?: \"left\" | \"right\" | \"center\"; sortable?: boolean; sort?: (a: any, b: any, rowA: any, rowB: any) => number; ... 5 more ...; headerClasses?: string; }'.",
	"source": "ts",
...
...
			"message": "The expected type comes from property 'columns' which is declared here on type 'IntrinsicAttributes & VNodeProps & AllowedComponentProps & ComponentCustomProps & QTableProps'",
			"resource": "/c:/Users/___/dev/quasar-project/node_modules/quasar/dist/types/index.d.ts"
		}
	]
}]

But why. ‘align’ is perfectly fine according to documentattion, and even type def files as far as I can see.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fundamental issue with Typescript - "[ts] Unexpected token. A ...
I tried to search for a solution but I can't find one. Simple Problem. It also happens when i write this: functionOne(); var...
Read more >
When a QTable columns prop has the align set to 'left' or 'right ...
Explanation of the TS behavior. If you hover over columns in your definition, you will see that it shows align as string instead...
Read more >
Qt Programming [Archive] - Page 11 - Qt Centre Forum
Problem with a combobox · adding items in qtablewidget · Database access from Qt · config file class · need help for tree...
Read more >
Playing Pong Using Q-Learning
Before solving any decision problem using the MDP method, one must ... surprising result in Table 5 is TS 3 which uses the...
Read more >
Untitled
· Adding checkBox as vertical header in QtableView . ... The latest version of Qt is 6.3.0 released on 12 April 2022.. Also...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found