Skip to content

useAmp from Next.js breaks auto-imports for TypeScript #9436

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

Closed
sotnikov-link opened this issue Nov 16, 2019 · 5 comments · Fixed by #9450
Closed

useAmp from Next.js breaks auto-imports for TypeScript #9436

sotnikov-link opened this issue Nov 16, 2019 · 5 comments · Fixed by #9450
Labels
good first issue Easy to fix issues, good for newcomers

Comments

@sotnikov-link
Copy link

Bug report

Describe the bug

If use import { useAmp } from 'next/amp' then auto-imports for TypeScript not working.

To Reproduce

  1. Clone repository
  2. Install deps yarn
  3. Open pages/index.tsx
  4. Uncomment code for useAmp
  5. Try make auto-import for function memo
  6. See error to TypeScript Trace: typescript.log

Expected behavior

Auto-imports works.

Screencast

https://youtu.be/7Wbh7WgZNgg

System information

  • OS: macOS Catalina
  • Node: 13
  • TypeScript: 3.7.2, 3.6, 3.5, 3.4 (3.3 works!)
  • Next.js: 9.1.3

Additional context

Maybe linked: microsoft/TypeScript#29227

@timneutkens timneutkens added good first issue Easy to fix issues, good for newcomers help wanted labels Nov 16, 2019
@sotnikov-link
Copy link
Author

Workaround

Use import { useAmp } from 'next/dist/next-server/lib/amp' instead import { useAmp } from 'next/amp'.

@timneutkens
Copy link
Member

Do not import from the dist directory. This has a 100% guarantee on breaking with every release.

@bartlangelaan
Copy link
Contributor

Seems like this is the same issue as #8979. So, removing this line should fix it:
https://github.com/zeit/next.js/blob/0b18f854ba4397cdcbd6fd5b2a8df8e8f533033d/packages/next/amp.d.ts#L2

However, it seems that the same issue also applies for the following definition files:

  • data.d.ts
  • babel.d.ts

@timneutkens
Copy link
Member

@bartlangelaan feel free to open a PR to fix it!

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Easy to fix issues, good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants