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

js tag function syntax highlighting is incorrect #1734

Open
Cat7373 opened this issue May 17, 2024 · 8 comments
Open

js tag function syntax highlighting is incorrect #1734

Cat7373 opened this issue May 17, 2024 · 8 comments
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. domain/schema Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc. kind/bug A reported bug. topic: syntax highlighting topic: TS integration Language-tools connecting with TypeScript files topic: vscode

Comments

@Cat7373
Copy link

Cat7373 commented May 17, 2024

Bug description

see: microsoft/vscode#212938

image

How to reproduce

It is difficult to make a minimal reproducible example, but when using the label function ($queryRaw), most of the time it will cause color errors in some of the following code.

Expected behavior

Correct highlighted code.

Prisma information

5.14.0

Environment & setup

  • OS: macOS
  • Editor: VS Code
  • Editor version: 1.89.1
  • Extension version: 5.14.0
@janpio
Copy link
Contributor

janpio commented May 17, 2024

Can you paste the code snippet from the screenshot please?
Is it possibly missing the closing backtick before the as Array ...?

@Cat7373
Copy link
Author

Cat7373 commented May 17, 2024

I made a small reproduction case:

import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

export function usePrisma(): typeof prisma {
  return prisma
}

class Demo {
  async test() {
    // aaa
    const x = '' as unknown as Array<{ a: number, b: number, c: number }>

    // bbb
    const a = await usePrisma().$queryRaw`
      SELECT
        taskId,
        COUNT(*) as \`count\`,
      FROM taskTarget
      WHERE typeId IN ['1', '2', '3']
      GROUP BY taskId
    ` as Array<{ taskId: number, count: number }>

    // ccc
    const y = '' as unknown as Array<{ a: number, b: number, c: number }>

    // ddd
  }
}
image

@Cat7373
Copy link
Author

Cat7373 commented May 17, 2024

Well, there is a small error in the sql. () should be used instead of [], but it does not affect the problem itself.

@Cat7373
Copy link
Author

Cat7373 commented May 20, 2024

It seems that there is no () after queryRaw. Just adding any function call can solve the problem:

@Cat7373
Copy link
Author

Cat7373 commented May 20, 2024

Comments are also ok

image

@Cat7373
Copy link
Author

Cat7373 commented May 20, 2024

You can also directly follow sql:

But in the middle, as can't solve the problem before, but it can solve the problem after as:

@Jolg42 Jolg42 added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. topic: vscode topic: syntax highlighting kind/bug A reported bug. domain/schema Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc. labels May 23, 2024
@Cat7373
Copy link
Author

Cat7373 commented Jul 1, 2024

Another magic fix: add a space:

image

@Cat7373
Copy link
Author

Cat7373 commented Jul 1, 2024

Another syntactically legal situation that will cause SQL highlighting to fail:

image

@Druue Druue added the topic: TS integration Language-tools connecting with TypeScript files label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. domain/schema Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc. kind/bug A reported bug. topic: syntax highlighting topic: TS integration Language-tools connecting with TypeScript files topic: vscode
Projects
None yet
Development

No branches or pull requests

4 participants