sveltejs / sapper-template

Starter template for Sapper apps
703 stars 215 forks source link

Handle missing sapper root element #310

Open lovasoa opened 3 years ago

lovasoa commented 3 years ago

Before this change, upgrading this project to typescript and enabling strict null checks would throw the following error :

> @rollup/plugin-typescript TS2322: Type 'Element | null' is not assignable to type 'Node'.
  Type 'null' is not assignable to type 'Node'.

4   target: document.querySelector("#sapper"),
    ~~~~~~

  src/node_modules/@sapper/index.d.ts:20:32
    20  export function start(opts: { target: Node }): Promise<void>;
                                      ~~~~~~
    The expected type comes from property 'target' which is declared here on type '{ target: Node; }'