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.

Unsupported: TypeScript 3.8 Syntax: import type

See original GitHub issue

Bug report

Describe the bug

Using the import type syntax from TypeScript 3.8 causes a build failure with next.js

To Reproduce

  1. git clone https://github.com/balupton/nextjs-typescript-3.8-syntax (applies this changeset https://github.com/balupton/nextjs-typescript-3.8-syntax/commit/53a7fc6bffa8f030053cd3109ae11715d079f07c to the with-javascript next.js example)
  2. cd nextjs-typescript-3.8-syntax
  3. yarn install
  4. yarn build
yarn run v1.22.4
$ next build
Creating an optimized production build  

Failed to compile.

/Users/balupton/Projects/experiments/nextjs-typescript-3.8-syntax/my-app/pages/index.tsx
ERROR in /Users/balupton/Projects/experiments/nextjs-typescript-3.8-syntax/my-app/pages/index.tsx(3,13):
3:13 '=' expected.
    1 | import Link from "next/link";
    2 | import Layout from "../components/Layout";
  > 3 | import type { AllKeys } from "simplytyped";
      |             ^
    4 | 
    5 | const IndexPage = () => (
    6 |   <Layout title="Home | Next.js + TypeScript Example">


> Build error occurred
Error: > Build failed because of webpack errors
    at build (/Users/balupton/Projects/experiments/nextjs-typescript-3.8-syntax/my-app/node_modules/next/dist/build/index.js:13:900)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected behavior

It to work fine

Screenshots

Screen Shot 2020-04-15 at 6 54 10 pm

System information

Additional context

n/a

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:12
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
tamj0rd2commented, Jul 3, 2020

I still get this error with the latest version of nextjs (9.4.4) image

2reactions
aasili-shoprunnercommented, Jul 17, 2020

I’m experiencing the same as @tamj0rd2 when using Next.js 9.4.4 and Typescript 3.9.6

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - TypeScript 3.8
import type only imports declarations to be used for type annotations and declarations. It always gets fully erased, so there's no remnant of...
Read more >
Support TypeScript 3.8 type-only imports/exports in resolve ...
I saw the support for syntax, so I'm assuming this relates to the actual WebStorm import mechanism. I don't want to create a...
Read more >
TypeScript 3.8 adds type-only imports and exports - InfoWorld
The import type syntax only imports declarations to be used for type annotations and declarations and always gets fully erased. The export type...
Read more >
Announcing TypeScript 3.8 - Microsoft Developer Blogs
As a solution in TypeScript 3.8, we've added a new syntax for type-only imports and exports. import type { SomeThing } from "./some-module.js" ......
Read more >
Prettier 2.0 Supports Typescript 3.8, Improves CLI - InfoQ
Prettier now supports new syntax included in the TypeScript 3.8 release, covering type-only imports and exports, ECMAScript private fields, ...
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