Skip to content

Instantly share code, notes, and snippets.

@mrclay
Created October 6, 2022 16:18
Show Gist options
  • Select an option

  • Save mrclay/b418e2ad2842dac6e76567921d211df3 to your computer and use it in GitHub Desktop.

Select an option

Save mrclay/b418e2ad2842dac6e76567921d211df3 to your computer and use it in GitHub Desktop.
Example d.ts file for a JSON file
// filename.json <-- the data
// filename.json.d.ts <-- type definition (this file)
// Just an example type
const value: Record<string, string>;
export default value;
@mrclay
Copy link
Copy Markdown
Author

mrclay commented May 1, 2023

This will also work for any data file webpack can import but typescript doesn't recognize (yet), like yaml or "json5".

@Waver-Velvet
Copy link
Copy Markdown

For those who came to this issue and found this gist doesn't work, you could try microsoft/TypeScript#48364 (comment) and it works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment