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

Null assertion breaks only for ts loader #1518

Open
b3nb5n opened this issue Oct 17, 2022 · 0 comments
Open

Null assertion breaks only for ts loader #1518

b3nb5n opened this issue Oct 17, 2022 · 0 comments

Comments

@b3nb5n
Copy link

b3nb5n commented Oct 17, 2022

I'm trying to render a react app just like normal...

import React from 'react'
import { createRoot } from 'react-dom/client';
import App from './App';

const mountElement = document.getElementById('root')!;
const root = createRoot(mountElement);
root.render(<App />);

When I compile using tsc there arent any issues, but when I use webpack using ts-loader I get the error message "Argument of type 'HTMLElement | null' is not assignable to parameter of type 'Element | DocumentFragment'. Type 'null' is not assignable to type 'Element | DocumentFragment'."

Im using:
webpack: 4.41.0
typescript: 4.8.4
ts-loader: 8.4.0

My tsconfig:

{
  "compilerOptions": {
    "target": "es2015",
    "lib": ["esnext", "DOM", "DOM.Iterable"],
    "jsx": "preserve",
    "module": "commonjs",
    "rootDir": "src",
    "moduleResolution": "node",
    "incremental": true,
    "sourceMap": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "useUnknownInCatchVariables": true,
    "alwaysStrict": true,
    "noUncheckedIndexedAccess": true,
    "skipLibCheck": true
  }
}

ts loader config:

{
        test: /\.tsx?$/,
        exclude: /node_modules/,
        loader: 'ts-loader',
        options: {
          configFile: '../tsconfig.json'
        }
},
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