importing non JS files in Google Firebase Functions typescript project

I am working on a Cloud Functions project initialized with Firebase SDK. I chose typescript as a language. I would like to import a non js, non ts file as a string, using import syntax. For example:

import * as content from './templates/text.md'

But obviously, I get an error:

error TS2307: Cannot find module './templates/text.md'.

How should I configure my project (.d.ts files? tsconfig.json? something else), so that it compiles correctly.

For reference of how the project is initialized with Firebase SDK: https://firebase.google.com/docs/functions/get-started

Upvotes: 0

Views: 448

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317467

You can't import something that doesn't parse as JavaScript. Instead, if you want to get the contents of some other file, you should read it with something like readFile().

Upvotes: 1

Related Questions