Unsupported: TypeScript 3.8 Syntax: import type
See original GitHub issueBug report
Describe the bug
Using the import type syntax from TypeScript 3.8 causes a build failure with next.js
To Reproduce
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 thewith-javascriptnext.js example)cd nextjs-typescript-3.8-syntaxyarn installyarn 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
System information
- OS: [e.g. macOS, Windows]
Darwin bevrymemacbook.local 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64 - Browser (if applies) [e.g. chrome, safari] n/a
- Version of Next.js: [e.g. 6.0.2] 9.3.5 - https://github.com/balupton/nextjs-typescript-3.8-syntax/blob/master/yarn.lock#L3413-L3414
- Version of Node.js: [e.g. 10.10.0] 13.12.0
Additional context
n/a
Issue Analytics
- State:
- Created 3 years ago
- Reactions:12
- Comments:11 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I still get this error with the latest version of nextjs (9.4.4)
I’m experiencing the same as @tamj0rd2 when using Next.js 9.4.4 and Typescript 3.9.6