jsr icon indicating copy to clipboard operation
jsr copied to clipboard

Untagged template literals are incorrectly marked as slow types

Open lucacasonato opened this issue 1 year ago • 1 comments

// these should be fine
const x = `hello world`;
const x = `hello world` as const;
let x = `hello ${foobar} world`;

// these are not allowed
const x = tpl`hello world`;
const x = `hello ${foobar} world`; // if foobar is a specific string literal type, x will be a merger of these strings.
const x = `hello ${foobar} world` as const;

However right now all are disallowed.

Ref https://github.com/denoland/deno_graph/issues/457 and https://github.com/denoland/deno_graph/issues/458

lucacasonato avatar Apr 26 '24 18:04 lucacasonato

For anyone waiting for this fix, I've written a jscodeshift codemod to apply fixes to your code so its ready to publish to JSR – see https://github.com/paambaati/neon-js-sdk/blob/8c1ba1b8b4ad9f3f88f77f0dc783eb69db4e93ed/scripts/transformers/jsr-fixes.ts

Note that this might not work for every piece of code, but it should give you an idea of how to do this.

paambaati avatar Jul 23 '24 06:07 paambaati