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

TypeScript Target Compiler Option is Silently Ignored #37271 #1

Open
1 task done
itsgurmannatsohal opened this issue Oct 22, 2022 · 0 comments
Open
1 task done

Comments

@itsgurmannatsohal
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Home
Binaries:
Node: 16.13.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 12.1.7-canary.19
react: 18.1.0
react-dom: 18.1.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

next export

Describe the Bug

Changing the tsconfig.json -> compilerOptions -> target setting has no effect on static export builds and no error or warning occurs to indicate this.

Expected Behavior

Changing the TypeScript build target should be respected by the build engine like other TypeScript configuration settings, or an error or warning should indicate that the TypeScript target must always be a certain value.

Link to reproduction

To Reproduce

Create a new project: npx create-next-app@canary --typescript
Modify the build script in package.json to be next build && next export
Remove the Image import and Image tag from index.tsx because it will prevent static build from succeeding
Modify pages/_app.tsx with a trivial piece of functionality which uses an ES2022 feature

import '../styles/globals.css'
import type { AppProps } from 'next/app'
import { useEffect, useState } from 'react';

class Test {
  #forMeOnly = true;
  
  doSomething(): void {
    console.log("FOR ME ONLY", this.#forMeOnly);
  }
}

function MyApp({ Component, pageProps }: AppProps) {
  const [test] = useState(new Test());
  useEffect(() => test.doSomething());
  return <Component {...pageProps} />
}

export default MyApp

Modify compilerOptions -> target in tsconfig.json to be ES2022
Execute npm run build
Note that in the chunk exported for _app-<cache-bust>.js in out/_next/static/chunks/pages that the private field #forMeOnly is enforced using WeakMap and not using the native JavaScript feature from ES2022
Expected to see #forMeOnly (or a minified version) and no WeakMap

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

1 participant