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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TypeScript 4.7 #12640

Closed
sosukesuzuki opened this issue Apr 10, 2022 · 14 comments
Closed

Support TypeScript 4.7 #12640

sosukesuzuki opened this issue Apr 10, 2022 · 14 comments
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) type:enhancement A potential new feature to be added, or an improvement to how we print something
Milestone

Comments

@sosukesuzuki
Copy link
Member

sosukesuzuki commented Apr 10, 2022

TypeScript 4.7 beta has been released 馃帀

https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-beta/

Instantiation Expressions

function foo<T>(value: T): T { return value };
const stringFoo = foo<string>;

extends Constraints on infer Type Variables

type FirstString<T> =
    T extends [infer S extends string, ...unknown[]]
        ? S
        : never;

Optional Variance Annotations for Type Parameters

type Getter<out T> = () => T;
type Setter<in T> = (value: T) => void;
@sosukesuzuki sosukesuzuki added type:enhancement A potential new feature to be added, or an improvement to how we print something lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) labels Apr 10, 2022
@sosukesuzuki
Copy link
Member Author

Anything else?

@Jack-Works
Copy link

both pr mentioned in this issue are merged 馃憖

@stepaniukm
Copy link

Is there still something left to be done?

@sosukesuzuki
Copy link
Member Author

Implementation of TS 4.7 support is almost complete. We are currently preparing for the release of 2.7.

@0x009922
Copy link

0x009922 commented Jun 1, 2022

@sosukesuzuki, I've tested this locally and found a critical bug.

My code:

image

It can be fixed by adding a semicolon:

image

But when Prettier formats my code, it removes the semicolon!

@sosukesuzuki sosukesuzuki added this to the 2.7 milestone Jun 2, 2022
@sosukesuzuki
Copy link
Member Author

sosukesuzuki commented Jun 2, 2022

@0x009922 Thank you! I'll investigate it.

@sosukesuzuki
Copy link
Member Author

Maybe this is a bug of TypeScript Compiler so I've reported to TS repo microsoft/TypeScript#49348

@ookamiiixd
Copy link

I encountered an errors when trying to format files containing TS 4.7 feature: Instantiation Expressions.

Here's my code producing the errors:

import { Button } from '@mantine/core'
import { Link, useTransition } from '@remix-run/react'
import type {  ComponentPropsWithRef} from 'react'
import { forwardRef } from 'react'

type SubmitButtonProps = {
  /** Show a loading indicator */
  showLoader?: boolean
} & ComponentPropsWithRef<typeof Button<'button'>>

Logs:

["ERROR" - 7:21:29 PM] Error formatting document.
["ERROR" - 7:21:29 PM] Unexpected token, expected "," (9:39)

However when i formats any other files that doesn't contain such code, it works just fine. Could you please investigate it @sosukesuzuki .

Thank you.

@stepaniukm
Copy link

@ookamiiixd You have just a syntax error. What does Button<'button'> is supposed to mean?

@ookamiiixd
Copy link

ookamiiixd commented Jul 28, 2022

@stepaniukm I just tried to pass a generic to my react component which accepts a generic. I believe it's not a syntax error since typechecking and the code is working just fine. I'm not good at explaining since i'm a beginner myself, could you please refer here?

@SimpleCreations
Copy link

@stepaniukm there are no syntax errors here. 'button' indicates a string literal type, i.e. the type of a string that exactly matches button, as in

declare const x: 'button';

@isc30
Copy link

isc30 commented Nov 23, 2022

Hey this still doesn't work properly on typeof cases like

function test<T>(i: T): T { return i }

type TestString = typeof test<string>

also, this comment isnt fixed yet
#12640 (comment)

@fisker
Copy link
Sponsor Member

fisker commented Nov 23, 2022

Can you open a new issue if problem still exists?

@prettier prettier locked as resolved and limited conversation to collaborators Nov 23, 2022
@fisker
Copy link
Sponsor Member

fisker commented Nov 23, 2022

Locked due to age.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) type:enhancement A potential new feature to be added, or an improvement to how we print something
Projects
None yet
Development

No branches or pull requests

8 participants