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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using TypeScript appears to require target to be esnext #15

Open
egeriis opened this issue Jan 12, 2023 · 1 comment
Open

Using TypeScript appears to require target to be esnext #15

egeriis opened this issue Jan 12, 2023 · 1 comment

Comments

@egeriis
Copy link

egeriis commented Jan 12, 2023

With a freshly created Next.js app (using create-next-app) with TypeScript support, errors are occurring when running fastly compute serve as the transpilation step does not support certain features to be transpiled to es5. es5 is the default target for a new Next.js app with TypeScript support.

✘ [ERROR] Transforming const to the configured target environment ("es5") is not supported yet

    bin/index.js:2:1265012:
      2 │ ... n.default.Component{render(){const{statusCode:e,withDarkMode:t=...
        ╵                                  ~~~~~

  The target environment was set to "es5" here:

    ../tsconfig.json:3:14:
      3 │     "target": "es5",
        ╵               ~~~~~

Even with target set to es6, an error is occurring:

Error: Build failed with 1 error:
bin/index.js:2:1070811: ERROR: Transforming async generator functions to the configured target environment ("es6") is not supported yet

I was able to resolve this issue by configuring TypeScript to target esnext:

{
  "compilerOptions": {
    "target": "esnext",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules"]
}

It would be helpful to add a small note to the instruction about TypeScript support.

@zialh
Copy link

zialh commented Jan 24, 2023

ES2018 was the oldest possible version that works for me, apart from ESNext, you might want to opt to it to be as compatible as possible with older environments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants