dwp / govuk-casa

Framework for creating simple GOVUK Collect-And-Submit-Applications
ISC License
34 stars 24 forks source link

TypeScript: CasaTemplateLoader.d.ts getSource function has incompatible return type #56

Closed WorkingTheo closed 1 year ago

WorkingTheo commented 1 year ago

Summary When using latest version of CASA with TypeScript, I get a compilation error. CasaTemplateLoader``getSource function has incompatible return type.

FileSystemLoader defines getSource function as: getSource(name: string): LoaderSource;

CasaTemplateLoader extends FileSystemLoader However CasaTemplateLoader getSource function is defined as: getSource(name: string): string;

Which causes TypeScript compilation errors:

Screen Shot 2023-03-02 at 14 20 48

Steps to reproduce I created a GitHub repo with the bug: https://github.com/WorkingTheo/BugDemo

To reproduce the bug:

Current behaviour

Screen Shot 2023-03-02 at 14 33 46

When compiling TypeScript CASA (8.7.8) project, the above errors pop up Expected behaviour No errors should appear during compilation

Relevant logs and/or screenshots

Possible fixes Changing the return type of getSource to LoaderSource. Before:

Screen Shot 2023-03-02 at 14 37 46

After:

Screen Shot 2023-03-02 at 14 38 27
lhokktyn commented 1 year ago

Resolved in main